next big chunk of fixed PHP 8.0 Warnings

This commit is contained in:
Ralf Becker 2021-10-05 14:11:11 +02:00
parent 12f6dca2bb
commit 56f60c691f
16 changed files with 93 additions and 91 deletions

View File

@ -204,7 +204,7 @@ class admin_ui
$item['id'] = substr($item['extradata'], 11); $item['id'] = substr($item['extradata'], 11);
unset($item['extradata']); unset($item['extradata']);
$matches = null; $matches = null;
if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches)) if (!empty($item['options']) && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches))
{ {
$item['popup'] = $matches[2].'x'.$matches[3]; $item['popup'] = $matches[2].'x'.$matches[3];
if (isset($matches[5])) $item['tooltip'] = $matches[5]; if (isset($matches[5])) $item['tooltip'] = $matches[5];
@ -213,7 +213,7 @@ class admin_ui
} }
if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
if (empty($item['group'])) $item['group'] = $group; if (empty($item['group'])) $item['group'] = $group;
if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ? if (empty($item['onExecute'])) $item['onExecute'] = !empty($item['popup']) ?
'javaScript:nm_action' : 'javaScript:app.admin.iframe_location'; 'javaScript:nm_action' : 'javaScript:app.admin.iframe_location';
if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
@ -297,7 +297,7 @@ class admin_ui
$item['id'] = substr($item['extradata'], 11); $item['id'] = substr($item['extradata'], 11);
unset($item['extradata']); unset($item['extradata']);
$matches = null; $matches = null;
if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches)) if (!empty($item['options']) && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches))
{ {
$item['popup'] = $matches[2].'x'.$matches[3]; $item['popup'] = $matches[2].'x'.$matches[3];
$item['onExecute'] = 'javaScript:nm_action'; $item['onExecute'] = 'javaScript:nm_action';
@ -326,7 +326,7 @@ class admin_ui
public static function get_users(array $query, array &$rows=null) public static function get_users(array $query, array &$rows=null)
{ {
$params = array( $params = array(
'type' => (int)$query['filter'] ? (int)$query['filter'] : 'accounts', 'type' => (int)($query['filter'] ?? 0) ?: 'accounts',
'start' => $query['start'], 'start' => $query['start'],
'offset' => $query['num_rows'], 'offset' => $query['num_rows'],
'order' => $query['order'], 'order' => $query['order'],
@ -334,7 +334,7 @@ class admin_ui
'active' => !empty($query['active']) ? $query['active'] : false, 'active' => !empty($query['active']) ? $query['active'] : false,
); );
// Make sure active filter give status what it needs // Make sure active filter give status what it needs
switch($query['filter2']) switch($query['filter2'] ?? '')
{ {
case 'disabled': case 'disabled':
case 'expired': case 'expired':
@ -356,12 +356,12 @@ class admin_ui
break; break;
} }
if ($query['searchletter']) if (!empty($query['searchletter']))
{ {
$params['query'] = $query['searchletter']; $params['query'] = $query['searchletter'];
$params['query_type'] = 'start'; $params['query_type'] = 'start';
} }
elseif($query['search']) elseif(!empty($query['search']))
{ {
$params['query'] = $query['search']; $params['query'] = $query['search'];
$params['query_type'] = 'all'; $params['query_type'] = 'all';
@ -377,7 +377,7 @@ class admin_ui
foreach($rows as $key => &$row) foreach($rows as $key => &$row)
{ {
// Filter by status // Filter by status
if ($need_status_filter && !static::filter_status($need_status_filter, $row)) if (!empty($need_status_filter) && !static::filter_status($need_status_filter, $row))
{ {
unset($rows[$key]); unset($rows[$key]);
$total--; $total--;
@ -391,8 +391,8 @@ class admin_ui
if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive';
} }
// finally limit query, if status filter was used // finally, limit query, if status filter was used
if ($need_status_filter) if (!empty($need_status_filter))
{ {
$rows = array_values(array_slice($rows, (int)$query['start'], $query['num_rows'] ?: count($rows))); $rows = array_values(array_slice($rows, (int)$query['start'], $query['num_rows'] ?: count($rows)));
} }
@ -436,9 +436,9 @@ class admin_ui
{ {
$groups = $GLOBALS['egw']->accounts->search(array( $groups = $GLOBALS['egw']->accounts->search(array(
'type' => 'groups', 'type' => 'groups',
'query' => $query['search'], 'query' => $query['search'] ?? null,
'order' => $query['order'], 'order' => $query['order'] ?? null,
'sort' => $query['sort'], 'sort' => $query['sort'] ?? null,
'start' => (int)$query['start'], 'start' => (int)$query['start'],
'offset' => (int)$query['num_rows'] 'offset' => (int)$query['num_rows']
)); ));
@ -463,7 +463,7 @@ class admin_ui
$run_rights = $GLOBALS['egw']->acl->get_user_applications($group['account_id'], false, false); $run_rights = $GLOBALS['egw']->acl->get_user_applications($group['account_id'], false, false);
foreach($apps as $app) foreach($apps as $app)
{ {
if((boolean)$run_rights[$app]) if(!empty($run_rights[$app]))
{ {
$group['apps'][] = $app; $group['apps'][] = $app;
} }
@ -537,7 +537,7 @@ class admin_ui
if (!empty($data['icon'])) if (!empty($data['icon']))
{ {
$icon = Etemplate\Widget\Tree::imagePath($data['icon']); $icon = Etemplate\Widget\Tree::imagePath($data['icon']);
if ($data['child'] || $data[Tree::CHILDREN]) if (!empty($data['child']) || !empty($data[Tree::CHILDREN]))
{ {
$data[Tree::IMAGE_FOLDER_OPEN] = $data[Tree::IMAGE_FOLDER_CLOSED] = $icon; $data[Tree::IMAGE_FOLDER_OPEN] = $data[Tree::IMAGE_FOLDER_CLOSED] = $icon;
} }

View File

@ -223,7 +223,7 @@ class Accounts
if (!empty($param['offset']) && !isset($param['start'])) $param['start'] = 0; if (!empty($param['offset']) && !isset($param['start'])) $param['start'] = 0;
// Check for lang(Group) in search - if there, we search all groups // Check for lang(Group) in search - if there, we search all groups
$group_index = array_search(strtolower(lang('Group')), array_map('strtolower', $query = explode(' ',$param['query']))); $group_index = array_search(strtolower(lang('Group')), array_map('strtolower', $query = explode(' ',$param['query'] ?? '')));
if($group_index !== FALSE && !( if($group_index !== FALSE && !(
in_array($param['type'], array('accounts', 'groupmembers')) || is_int($param['type']) in_array($param['type'], array('accounts', 'groupmembers')) || is_int($param['type'])
)) ))
@ -595,12 +595,12 @@ class Accounts
/** /**
* Return formatted username for a given account_id * Return formatted username for a given account_id
* *
* @param string $account_id =null account id * @param int $account_id account id
* @return string full name of user or "#$accountid" if user not found * @return string full name of user or "#$account_id" if user not found
*/ */
static function username($account_id=null) static function username(int $account_id)
{ {
if ($account_id && !($account = self::cache_read((int)$account_id))) if (!($account = self::cache_read($account_id)))
{ {
return '#'.$account_id; return '#'.$account_id;
} }

View File

@ -50,12 +50,12 @@ class Box extends Etemplate\Widget
$old_expand = $params[1]; $old_expand = $params[1];
if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]); if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]);
if ($expand['cname'] !== $cname && trim($cname) != '') if (!empty($expand['cname']) && $expand['cname'] !== $cname && trim($cname))
{ {
$expand['cont'] =& self::get_array(self::$request->content, $cname); $expand['cont'] =& self::get_array(self::$request->content, $cname);
$expand['cname'] = $cname; $expand['cname'] = $cname;
} }
if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand))) if ($respect_disabled && isset($this->attrs['disabled']) && self::check_disabled($this->attrs['disabled'], $expand))
{ {
//error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running"); //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running");
return; return;
@ -73,7 +73,7 @@ class Box extends Etemplate\Widget
// Expand children // Expand children
$columns_disabled = null; $columns_disabled = null;
if($this->id && $this->children[0] && strpos($this->children[0]->id, '$') !== false) if($this->id && isset($this->children[0]) && strpos($this->children[0]->id, '$') !== false)
{ {
// Need to set this so the first child can repeat // Need to set this so the first child can repeat
$expand['row'] = 0; $expand['row'] = 0;

View File

@ -111,7 +111,7 @@ class Date extends Transformer
{ {
$date = Api\DateTime::server2user($value); $date = Api\DateTime::server2user($value);
} }
elseif ($this->attrs['data_format'] && $this->attrs['data_format'] !== 'object') elseif (!empty($this->attrs['data_format']) && $this->attrs['data_format'] !== 'object')
{ {
$date = Api\DateTime::createFromFormat($this->attrs['data_format'], $value, Api\DateTime::$user_timezone); $date = Api\DateTime::createFromFormat($this->attrs['data_format'], $value, Api\DateTime::$user_timezone);
} }

View File

@ -80,7 +80,7 @@ class Grid extends Box
$columns_disabled = array(); $columns_disabled = array();
} }
if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand))) if ($respect_disabled && isset($this->attrs['disabled']) && self::check_disabled($this->attrs['disabled'], $expand))
{ {
//error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running"); //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running");
$params[0] = $old_cname; $params[0] = $old_cname;
@ -89,7 +89,7 @@ class Grid extends Box
} }
if ($this->id && $this->type !== 'row') $cname = self::form_name($cname, $this->id, $expand); if ($this->id && $this->type !== 'row') $cname = self::form_name($cname, $this->id, $expand);
if ($expand['cname'] !== $cname && $cname) if (!empty($expand['cname']) && $expand['cname'] !== $cname && $cname)
{ {
$expand['cont'] =& self::get_array(self::$request->content, $cname); $expand['cont'] =& self::get_array(self::$request->content, $cname);
$expand['cname'] = $cname; $expand['cname'] = $cname;

View File

@ -495,17 +495,10 @@ abstract class Framework extends Framework\Extra
{ {
$lang_code = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; $lang_code = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
} }
// IE specific fixes
if (Header\UserAgent::type() == 'msie')
{
// tell IE to use it's own mode, not old compatibility modes (set eg. via group policy for all intranet sites)
// has to be before any other header tags, but meta and title!!!
$pngfix = '<meta http-equiv="X-UA-Compatible" content="IE=edge" />'."\n";
}
$app = $GLOBALS['egw_info']['flags']['currentapp']; $app = $GLOBALS['egw_info']['flags']['currentapp'];
$app_title = isset($GLOBALS['egw_info']['apps'][$app]) ? $GLOBALS['egw_info']['apps'][$app]['title'] : lang($app); $app_title = isset($GLOBALS['egw_info']['apps'][$app]) ? $GLOBALS['egw_info']['apps'][$app]['title'] : lang($app);
$app_header = $GLOBALS['egw_info']['flags']['app_header'] ? $GLOBALS['egw_info']['flags']['app_header'] : $app_title; $app_header = $GLOBALS['egw_info']['flags']['app_header'] ?? $app_title;
$site_title = strip_tags($GLOBALS['egw_info']['server']['site_title'].' ['.($app_header ? $app_header : $app_title).']'); $site_title = strip_tags($GLOBALS['egw_info']['server']['site_title'].' ['.($app_header ? $app_header : $app_title).']');
// send appheader to clientside // send appheader to clientside
@ -515,7 +508,7 @@ abstract class Framework extends Framework\Extra
$var['favicon_file'] = self::get_login_logo_or_bg_url('favicon_file', 'favicon.ico'); $var['favicon_file'] = self::get_login_logo_or_bg_url('favicon_file', 'favicon.ico');
if ($GLOBALS['egw_info']['flags']['include_wz_tooltip'] && if (!empty($GLOBALS['egw_info']['flags']['include_wz_tooltip']) &&
file_exists(EGW_SERVER_ROOT.($wz_tooltip = '/phpgwapi/js/wz_tooltip/wz_tooltip.js'))) file_exists(EGW_SERVER_ROOT.($wz_tooltip = '/phpgwapi/js/wz_tooltip/wz_tooltip.js')))
{ {
$include_wz_tooltip = '<script src="'.$GLOBALS['egw_info']['server']['webserver_url']. $include_wz_tooltip = '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].
@ -524,7 +517,6 @@ abstract class Framework extends Framework\Extra
return $this->_get_css()+array( return $this->_get_css()+array(
'img_icon' => $var['favicon_file'], 'img_icon' => $var['favicon_file'],
'img_shortcut' => $var['favicon_file'], 'img_shortcut' => $var['favicon_file'],
'pngfix' => $pngfix,
'lang_code' => $lang_code, 'lang_code' => $lang_code,
'charset' => Translation::charset(), 'charset' => Translation::charset(),
'website_title' => $site_title, 'website_title' => $site_title,
@ -532,7 +524,7 @@ abstract class Framework extends Framework\Extra
'java_script' => self::_get_js($extra), 'java_script' => self::_get_js($extra),
'meta_robots' => $robots, 'meta_robots' => $robots,
'dir_code' => lang('language_direction_rtl') != 'rtl' ? '' : ' dir="rtl"', 'dir_code' => lang('language_direction_rtl') != 'rtl' ? '' : ' dir="rtl"',
'include_wz_tooltip'=> $include_wz_tooltip, 'include_wz_tooltip'=> $include_wz_tooltip ?? '',
'webserver_url' => $GLOBALS['egw_info']['server']['webserver_url'], 'webserver_url' => $GLOBALS['egw_info']['server']['webserver_url'],
'darkmode' => !empty(Cache::getSession('api','darkmode')) ?? $GLOBALS['egw_info']['user']['preferences']['common']['darkmode'] 'darkmode' => !empty(Cache::getSession('api','darkmode')) ?? $GLOBALS['egw_info']['user']['preferences']['common']['darkmode']
); );
@ -601,12 +593,12 @@ abstract class Framework extends Framework\Extra
*/ */
static function get_login_logo_or_bg_url ($type, $find_type) static function get_login_logo_or_bg_url ($type, $find_type)
{ {
$url = is_array($GLOBALS['egw_info']['server'][$type]) ? $url = !empty($GLOBALS['egw_info']['server'][$type]) && is_array($GLOBALS['egw_info']['server'][$type]) ?
$GLOBALS['egw_info']['server'][$type][0] : $GLOBALS['egw_info']['server'][$type][0] :
$GLOBALS['egw_info']['server'][$type]; $GLOBALS['egw_info']['server'][$type] ?? null;
if (substr($url, 0, 4) == 'http' || if (substr($url, 0, 4) === 'http' ||
$url[0] == '/') !empty($url) && $url[0] === '/')
{ {
return $url; return $url;
} }
@ -800,7 +792,7 @@ abstract class Framework extends Framework\Extra
$index = '/index.php?menuaction='.$data['index']; $index = '/index.php?menuaction='.$data['index'];
} }
} }
return self::link($index,$GLOBALS['egw_info']['flags']['params'][$app]); return self::link($index, $GLOBALS['egw_info']['flags']['params'][$app] ?? '');
} }
/** /**
@ -981,7 +973,7 @@ abstract class Framework extends Framework\Extra
{ {
if (file_exists(EGW_SERVER_ROOT.$theme_css)) break; if (file_exists(EGW_SERVER_ROOT.$theme_css)) break;
} }
$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True'; $debug_minify = !empty($GLOBALS['egw_info']['server']['debug_minify']) && $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
if (!$debug_minify && file_exists(EGW_SERVER_ROOT.($theme_min_css = str_replace('.css', '.min.css', $theme_css)))) if (!$debug_minify && file_exists(EGW_SERVER_ROOT.($theme_min_css = str_replace('.css', '.min.css', $theme_css))))
{ {
//error_log(__METHOD__."() Framework\CssIncludes::get()=".array2string(Framework\CssIncludes::get())); //error_log(__METHOD__."() Framework\CssIncludes::get()=".array2string(Framework\CssIncludes::get()));
@ -1095,8 +1087,7 @@ abstract class Framework extends Framework\Extra
if(@isset($_GET['menuaction'])) if(@isset($_GET['menuaction']))
{ {
list(, $class) = explode('.',$_GET['menuaction']); list(, $class) = explode('.',$_GET['menuaction']);
if(is_array($GLOBALS[$class]->public_functions) && if (!empty($GLOBALS[$class]->public_functions['java_script']))
$GLOBALS[$class]->public_functions['java_script'])
{ {
$java_script .= $GLOBALS[$class]->java_script(); $java_script .= $GLOBALS[$class]->java_script();
} }
@ -1524,8 +1515,8 @@ abstract class Framework extends Framework\Extra
foreach(Framework\CssIncludes::get() as $path) foreach(Framework\CssIncludes::get() as $path)
{ {
unset($query); unset($query);
list($path,$query) = explode('?',$path,2); list($path,$query) = explode('?', $path,2)+[null,null];
$path .= '?'. ($query ? $query : filemtime(EGW_SERVER_ROOT.$path)); $path .= '?'. ($query ?? filemtime(EGW_SERVER_ROOT.$path));
$response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path); $response->includeCSS($GLOBALS['egw_info']['server']['webserver_url'].$path);
} }

View File

@ -63,8 +63,8 @@ class Hooks
$location = is_array($args) ? (isset($args['hook_location']) ? $args['hook_location'] : $args['location']) : $args; $location = is_array($args) ? (isset($args['hook_location']) ? $args['hook_location'] : $args['location']) : $args;
if (!isset(self::$locations)) self::read(); if (!isset(self::$locations)) self::read();
if (empty(self::$locations[$location])) return []; // not a single app implements that hook
$hooks = self::$locations[$location]; $hooks = self::$locations[$location];
if (!isset($hooks) || empty($hooks)) return array(); // not a single app implements that hook
$apps = array_keys($hooks); $apps = array_keys($hooks);
if (!$no_permission_check) if (!$no_permission_check)
@ -115,7 +115,7 @@ class Hooks
} }
$ret = array(); $ret = array();
foreach((array)self::$locations[$location][$appname] as $hook) foreach(self::$locations[$location][$appname] ?? [] as $hook)
{ {
try { try {
// old style file hook // old style file hook
@ -130,7 +130,7 @@ class Hooks
return true; return true;
} }
list($class, $method) = explode('::', $hook); list($class, $method) = explode('::', $hook)+[null,null];
// static method of an autoloadable class // static method of an autoloadable class
if (isset($method) && class_exists($class)) if (isset($method) && class_exists($class))

View File

@ -762,7 +762,7 @@ class Link extends Link\Storage
if ($must_support && !isset($reg[$must_support])) continue; if ($must_support && !isset($reg[$must_support])) continue;
list($app) = explode('-', $type); list($app) = explode('-', $type);
if ($GLOBALS['egw_info']['user']['apps'][$app]) if (!empty($GLOBALS['egw_info']['user']['apps'][$app]))
{ {
$apps[$type] = lang(self::get_registry($type, 'name')); $apps[$type] = lang(self::get_registry($type, 'name'));
} }
@ -1132,7 +1132,7 @@ class Link extends Link\Storage
*/ */
static function get_registry($app, $name, $url_id=false) static function get_registry($app, $name, $url_id=false)
{ {
$reg = self::$app_register[$app]; $reg = self::$app_register[$app] ?? null;
if (!isset($reg)) return false; if (!isset($reg)) return false;
@ -1181,7 +1181,7 @@ class Link extends Link\Storage
return $str; return $str;
} }
return isset($reg) ? $reg[$name] : false; return $reg[$name] ?? false;
} }
/** /**

View File

@ -2950,7 +2950,7 @@ class Mail
// Trigger examination of namespace to retrieve // Trigger examination of namespace to retrieve
// folders located in other and shared; needed only for some servers // folders located in other and shared; needed only for some servers
if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail');
if (self::$mailConfig['examineNamespace']) if (!empty(self::$mailConfig['examineNamespace']))
{ {
$prefixes=array(); $prefixes=array();
if (is_array($nameSpace)) if (is_array($nameSpace))
@ -3014,7 +3014,7 @@ class Mail
$subFolders = $this->icServer->getMailboxes($node['MAILBOX'].$node['delimiter'], $_search, true); $subFolders = $this->icServer->getMailboxes($node['MAILBOX'].$node['delimiter'], $_search, true);
} }
if (is_array($mainFolder['INBOX'])) if (isset($mainFolder['INBOX']) && is_array($mainFolder['INBOX']))
{ {
// Array container of auto folders // Array container of auto folders
$aFolders = array(); $aFolders = array();
@ -3180,7 +3180,7 @@ class Mail
{ {
foreach(array('others','shared') as $type) foreach(array('others','shared') as $type)
{ {
if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) if (!empty($nameSpace[$type]['prefix_present']) && !empty($nameSpace[$type]['prefix']))
{ {
if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']||
substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) {
@ -3211,7 +3211,7 @@ class Mail
} }
//error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects));
if (!$isGoogleMail) { if (!$isGoogleMail) {
$folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'] ?? [],(array)$typeFolderObject['shared'] ?? []);
} else { } else {
// avoid calling sortByAutoFolder as it is not regarding subfolders // avoid calling sortByAutoFolder as it is not regarding subfolders
$gAutoFolderObjectsTmp = $googleAutoFolderObjects; $gAutoFolderObjectsTmp = $googleAutoFolderObjects;
@ -3910,7 +3910,7 @@ class Mail
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod);
$oldMailbox = ''; $oldMailbox = '';
if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; if (empty($_folder) && !empty($this->sessionData['mailbox'])) $_folder = $this->sessionData['mailbox'];
if (empty($_messageUID)) if (empty($_messageUID))
{ {
if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));

View File

@ -313,7 +313,7 @@ class Account implements \ArrayAccess
try { try {
if ($this->acc_imap_type != __NAMESPACE__.'\\Imap' && if ($this->acc_imap_type != __NAMESPACE__.'\\Imap' &&
// do NOT query IMAP server, if we are in forward-only delivery-mode, imap will NOT answer, as switched off for that account! // do NOT query IMAP server, if we are in forward-only delivery-mode, imap will NOT answer, as switched off for that account!
$this->params['deliveryMode'] != Smtp::FORWARD_ONLY && $need_quota && ($this->params['deliveryMode'] ?? null) != Smtp::FORWARD_ONLY && $need_quota &&
$this->imapServer($this->user) && is_a($this->imapServer, __NAMESPACE__.'\\Imap') && $this->imapServer($this->user) && is_a($this->imapServer, __NAMESPACE__.'\\Imap') &&
($data = $this->imapServer->getUserData($GLOBALS['egw']->accounts->id2name($this->user)))) ($data = $this->imapServer->getUserData($GLOBALS['egw']->accounts->id2name($this->user))))
{ {
@ -335,7 +335,7 @@ class Account implements \ArrayAccess
} }
$this->params += array_fill_keys(self::$user_data, null); // make sure all keys exist now $this->params += array_fill_keys(self::$user_data, null); // make sure all keys exist now
return (array)$data + (array)$smtp_data; return ($data ?? []) + ($smtp_data ?? []);
} }
/** /**
@ -454,10 +454,10 @@ class Account implements \ArrayAccess
$this->smtpServer->host = 'tls://'.$this->smtpServer->host; $this->smtpServer->host = 'tls://'.$this->smtpServer->host;
} }
$this->smtpServer->smtpAuth = !empty($this->params['acc_smtp_username']); $this->smtpServer->smtpAuth = !empty($this->params['acc_smtp_username']);
$this->smtpServer->username = $this->params['acc_smtp_username']; $this->smtpServer->username = $this->params['acc_smtp_username'] ?? null;
$this->smtpServer->password = $this->params['acc_smtp_password']; $this->smtpServer->password = $this->params['acc_smtp_password'] ?? null;
$this->smtpServer->defaultDomain = $this->params['acc_domain']; $this->smtpServer->defaultDomain = $this->params['acc_domain'];
$this->smtpServer->loginType = $this->params['acc_imap_login_type']; $this->smtpServer->loginType = $this->params['acc_imap_login_type'] ?? null;
} }
return $this->smtpServer; return $this->smtpServer;
} }
@ -676,7 +676,7 @@ class Account implements \ArrayAccess
$to_replace = array(); $to_replace = array();
foreach($fields as $name) foreach($fields as $name)
{ {
if (strpos($identity[$name], '{{') !== false || strpos($identity[$name], '$$') !== false) if (!empty($identity[$name]) && (strpos($identity[$name], '{{') !== false || strpos($identity[$name], '$$') !== false))
{ {
$to_replace[$name] = $identity[$name]; $to_replace[$name] = $identity[$name];
} }
@ -837,7 +837,7 @@ class Account implements \ArrayAccess
// let getUserData "know" if we are interested in quota (requiring IMAP login) or not // let getUserData "know" if we are interested in quota (requiring IMAP login) or not
$this->getUserData(substr($name, 0, 5) === 'quota'); $this->getUserData(substr($name, 0, 5) === 'quota');
} }
return $this->params[$name]; return $this->params[$name] ?? null;
} }
/** /**
@ -1578,7 +1578,7 @@ class Account implements \ArrayAccess
'ident_realname' => $account['ident_realname'], 'ident_realname' => $account['ident_realname'],
'ident_org' => $account['ident_org'], 'ident_org' => $account['ident_org'],
'ident_email' => $account['ident_email'], 'ident_email' => $account['ident_email'],
'acc_name' => $account['acc_name'], 'acc_name' => $account['acc_name'] ?? null,
'acc_imap_username' => $account['acc_imap_username'], 'acc_imap_username' => $account['acc_imap_username'],
'acc_imap_logintype' => $account['acc_imap_logintype'], 'acc_imap_logintype' => $account['acc_imap_logintype'],
'acc_domain' => $account['acc_domain'], 'acc_domain' => $account['acc_domain'],
@ -1605,7 +1605,7 @@ class Account implements \ArrayAccess
} }
} }
// fill an empty ident_realname or ident_email of current user with data from user account // fill an empty ident_realname or ident_email of current user with data from user account
if ($replace_placeholders && (!isset($account_id) || $account_id == $GLOBALS['egw_info']['user']['acount_id'])) if ($replace_placeholders && (!isset($account_id) || $account_id == $GLOBALS['egw_info']['user']['account_id']))
{ {
if (empty($account['ident_realname'])) $account['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname']; if (empty($account['ident_realname'])) $account['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname'];
if (empty($account['ident_email'])) $account['ident_email'] = $GLOBALS['egw_info']['user']['account_email']; if (empty($account['ident_email'])) $account['ident_email'] = $GLOBALS['egw_info']['user']['account_email'];

View File

@ -87,7 +87,7 @@ class Notifications
$account_specific = $account_id; $account_specific = $account_id;
} }
} }
$folders = (array)self::$cache[$acc_id][$account_specific]; $folders = self::$cache[$acc_id][$account_specific] ?? [];
if (!$return_empty_marker && $folders == array(null)) $folders = array(); if (!$return_empty_marker && $folders == array(null)) $folders = array();
$result = array( $result = array(
'notify_folders' => $folders, 'notify_folders' => $folders,

View File

@ -1538,19 +1538,19 @@ class Session
} }
// check if the url already contains a query and ensure that vars is an array and all strings are in extravars // check if the url already contains a query and ensure that vars is an array and all strings are in extravars
if (strpos($ret_url=$url, '?') !== false) list($ret_url,$othervars) = explode('?', $url, 2); if (strpos($ret_url=$url, '?') !== false) list($ret_url,$othervars) = explode('?', $url, 2)+[null,null];
if ($extravars && is_array($extravars)) if ($extravars && is_array($extravars))
{ {
$vars += $extravars; $vars += $extravars;
$extravars = $othervars; $extravars = $othervars;
} }
else elseif (!empty($othervars))
{ {
if ($othervars) $extravars .= ($extravars?'&':'').$othervars; $extravars .= ($extravars ? '&' : '') . $othervars;
} }
// parse extravars string into the vars array // parse extravars string into the vars array
if ($extravars) if (!empty($extravars))
{ {
foreach(explode('&', $extravars) as $expr) foreach(explode('&', $extravars) as $expr)
{ {

View File

@ -48,7 +48,12 @@ abstract class Merge
/** /**
* Fields that are to be treated as datetimes, when merged into spreadsheets * Fields that are to be treated as datetimes, when merged into spreadsheets
*/ */
var $date_fields = array(); var $date_fields = [];
/**
* Fields that are numeric, for special numeric handling
*/
protected $numeric_fields = [];
/** /**
* Mimetype of document processed by merge * Mimetype of document processed by merge
@ -77,10 +82,10 @@ abstract class Merge
*/ */
public $export_limit; public $export_limit;
public $public_functions = array( public $public_functions = array(
"merge_entries" => true "merge_entries" => true
); );
/** /**
* Configuration for HTML Tidy to clean up any HTML content that is kept * Configuration for HTML Tidy to clean up any HTML content that is kept
*/ */
@ -237,7 +242,7 @@ abstract class Merge
$replacements = array(); $replacements = array();
foreach(array_keys($this->contacts->contact_fields) as $name) foreach(array_keys($this->contacts->contact_fields) as $name)
{ {
$value = $contact[$name]; $value = $contact[$name] ?? null;
switch($name) switch($name)
{ {
case 'created': case 'modified': case 'created': case 'modified':
@ -333,7 +338,9 @@ abstract class Merge
$cats[$cat_id] = array(); $cats[$cat_id] = array();
} }
} }
foreach($cats as $main => $cat) { $replacements['$$'.($prefix ? $prefix.'/':'').'categories$$'] = '';
foreach($cats as $main => $cat)
{
$replacements['$$'.($prefix ? $prefix.'/':'').'categories$$'] .= $GLOBALS['egw']->categories->id2name($main,'name') $replacements['$$'.($prefix ? $prefix.'/':'').'categories$$'] .= $GLOBALS['egw']->categories->id2name($main,'name')
. (count($cat) > 0 ? ': ' : '') . implode(', ', $cats[$main]) . "\n"; . (count($cat) > 0 ? ': ' : '') . implode(', ', $cats[$main]) . "\n";
} }
@ -818,7 +825,7 @@ abstract class Merge
$content = preg_replace(array_keys($fix),array_values($fix),$content); $content = preg_replace(array_keys($fix),array_values($fix),$content);
//die("<pre>".htmlspecialchars($content)."</pre>\n"); //die("<pre>".htmlspecialchars($content)."</pre>\n");
} }
list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY)+[null,null,null]; //get differt parts of document, seperatet by Pagerepeat
if ($mimetype == 'text/plain' && $ids && count($ids) > 1) if ($mimetype == 'text/plain' && $ids && count($ids) > 1)
{ {
// textdocuments are simple, they do not hold start and end, but they may have content before and after the $$pagerepeat$$ tag // textdocuments are simple, they do not hold start and end, but they may have content before and after the $$pagerepeat$$ tag
@ -862,11 +869,11 @@ abstract class Merge
$contentstart .= '<w:body>'; $contentstart .= '<w:body>';
$contentend = '</w:body></w:document>'; $contentend = '</w:body></w:document>';
} }
list($Labelstart,$Labelrepeat,$Labeltend) = preg_split('/\$\$label\$\$/',$contentrepeat,-1, PREG_SPLIT_NO_EMPTY); //get the Lable content list($Labelstart,$Labelrepeat,$Labeltend) = preg_split('/\$\$label\$\$/',$contentrepeat,-1, PREG_SPLIT_NO_EMPTY)+[null,null,null]; //get the label content
preg_match_all('/\$\$labelplacement\$\$/',$contentrepeat,$countlables, PREG_SPLIT_NO_EMPTY); preg_match_all('/\$\$labelplacement\$\$/',$contentrepeat,$countlables, PREG_SPLIT_NO_EMPTY);
$countlables = count($countlables[0]); $countlables = count($countlables[0]);
preg_replace('/\$\$labelplacement\$\$/','',$Labelrepeat,1); preg_replace('/\$\$labelplacement\$\$/','',$Labelrepeat,1);
if ($countlables > 1) $lableprint = true; $lableprint = $countlables > 1;
if (count($ids) > 1 && !$contentrepeat) if (count($ids) > 1 && !$contentrepeat)
{ {
$err = lang('for more than one contact in a document use the tag pagerepeat!'); $err = lang('for more than one contact in a document use the tag pagerepeat!');
@ -1111,7 +1118,7 @@ abstract class Merge
{ {
foreach($this->date_fields as $field) foreach($this->date_fields as $field)
{ {
if(($value = $replacements['$$'.$field.'$$'])) if(($value = $replacements['$$'.$field.'$$'] ?? null))
{ {
$time = Api\DateTime::createFromFormat('+'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat.'*', $value); $time = Api\DateTime::createFromFormat('+'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat.'*', $value);
$replacements['$$'.$field.'/date$$'] = $time ? $time->format(Api\DateTime::$user_dateformat) : ''; $replacements['$$'.$field.'/date$$'] = $time ? $time->format(Api\DateTime::$user_dateformat) : '';
@ -1234,7 +1241,8 @@ abstract class Merge
// Look for numbers, set their value if needed // Look for numbers, set their value if needed
if(property_exists($this,'numeric_fields') || count($names)) if(property_exists($this,'numeric_fields') || count($names))
{ {
foreach((array)$this->numeric_fields as $fieldname) { foreach($this->numeric_fields as $fieldname)
{
$names[] = preg_quote($fieldname,'/'); $names[] = preg_quote($fieldname,'/');
} }
$this->format_spreadsheet_numbers($content, $names, $mimetype.$mso_application_progid); $this->format_spreadsheet_numbers($content, $names, $mimetype.$mso_application_progid);
@ -1327,7 +1335,8 @@ abstract class Merge
*/ */
protected function format_spreadsheet_numbers(&$content, $names, $mimetype) protected function format_spreadsheet_numbers(&$content, $names, $mimetype)
{ {
foreach((array)$this->numeric_fields as $fieldname) { foreach($this->numeric_fields as $fieldname)
{
$names[] = preg_quote($fieldname,'/'); $names[] = preg_quote($fieldname,'/');
} }
switch($mimetype) switch($mimetype)
@ -1351,7 +1360,7 @@ abstract class Merge
break; break;
} }
if($format && $names) if (!empty($format) && $names)
{ {
// Dealing with backtrack limit per AmigoJack 10-Jul-2010 comment on php.net preg-replace docs // Dealing with backtrack limit per AmigoJack 10-Jul-2010 comment on php.net preg-replace docs
do { do {

View File

@ -1255,7 +1255,7 @@ class Vfs extends Vfs\Base
array_push($parts,''); // scheme://host is wrong (no path), has to be scheme://host/ array_push($parts,''); // scheme://host is wrong (no path), has to be scheme://host/
} }
//error_log(__METHOD__."($url)=".implode('/',$parts).($query ? '?'.$query : '')); //error_log(__METHOD__."($url)=".implode('/',$parts).($query ? '?'.$query : ''));
return implode('/',$parts).($query ? '?'.$query : ''); return implode('/',$parts).(!empty($query) ? '?'.$query : '');
} }
/** /**

View File

@ -901,7 +901,7 @@ END:VALARM';
{ {
Api\Translation::add_app('calendar'); Api\Translation::add_app('calendar');
// do not set actions for alarm type // do not set actions for alarm type
if ($params['data']['type'] == 6) if (isset($params['data']['type']) && $params['data']['type'] == 6)
{ {
if (!empty($params['data']['videoconference']) if (!empty($params['data']['videoconference'])
&& !self::isVideoconferenceDisabled()) && !self::isVideoconferenceDisabled())
@ -917,6 +917,8 @@ END:VALARM';
} }
return array(); return array();
} }
if (!isset($params['data']['event_id'])) $params['data']['event_id'] = '';
if (!isset($params['data']['user_id'])) $params['data']['user_id'] = '';
return array( return array(
array( array(
'id' => 'A', 'id' => 'A',

View File

@ -145,7 +145,7 @@ class mail_tree
*/ */
private static function isAccountNode ($_node) private static function isAccountNode ($_node)
{ {
list(,$leaf) = explode(self::DELIMITER, $_node); list(,$leaf) = explode(self::DELIMITER, $_node)+[null,null];
if ($leaf || $_node == null) return false; if ($leaf || $_node == null) return false;
return true; return true;
} }
@ -404,7 +404,7 @@ class mail_tree
} }
$parents[] = $component; $parents[] = $component;
} }
if ($data['folderarray']['delimiter'] && $data['folderarray']['MAILBOX']) if (!empty($data['folderarray']['delimiter']) && !empty($data['folderarray']['MAILBOX']))
{ {
$path = explode($data['folderarray']['delimiter'], $data['folderarray']['MAILBOX']); $path = explode($data['folderarray']['delimiter'], $data['folderarray']['MAILBOX']);
$folderName = array_pop($path); $folderName = array_pop($path);
@ -428,7 +428,7 @@ class mail_tree
$data[Tree::IMAGE_FOLDER_OPEN] = $data[Tree::IMAGE_FOLDER_OPEN] =
$data [Tree::IMAGE_FOLDER_CLOSED] = basename(Api\Image::find('mail', 'dhtmlxtree/'."MailFolder".$key)); $data [Tree::IMAGE_FOLDER_CLOSED] = basename(Api\Image::find('mail', 'dhtmlxtree/'."MailFolder".$key));
} }
elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false) elseif(!empty($data['folderarray']['attributes']) && stripos(array2string($data['folderarray']['attributes']),'\noselect') !== false)
{ {
$data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed']; $data[Tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed'];
$data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen']; $data[Tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen'];
@ -444,7 +444,7 @@ class mail_tree
} }
// Contains unseen mails for the folder // Contains unseen mails for the folder
$unseen = $data['folderarray']['counter']['UNSEEN']; $unseen = $data['folderarray']['counter']['UNSEEN'] ?? 0;
// if there's unseen mails then change the label and style // if there's unseen mails then change the label and style
// accordingly to indicate useen mails // accordingly to indicate useen mails
@ -477,7 +477,7 @@ class mail_tree
foreach(Mail\Account::search(true, false) as $acc_id => $accObj) foreach(Mail\Account::search(true, false) as $acc_id => $accObj)
{ {
if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue; if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue;
$identity = self::getIdentityName(Mail\Account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id'], true)); $identity = self::getIdentityName(Mail\Account::identity_name($accObj,true, $GLOBALS['egw_info']['user']['account_id'], true));
// Open top level folders for active account // Open top level folders for active account
$openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0; $openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0;