diff --git a/api/src/Accounts/Sql.php b/api/src/Accounts/Sql.php index a8dc7166f4..703aaedb7a 100644 --- a/api/src/Accounts/Sql.php +++ b/api/src/Accounts/Sql.php @@ -660,7 +660,7 @@ class Sql //error_log(__METHOD__."('$name', '$which', ".array2string($account_type).") db->select('$table', '$cols', ".array2string($where).") returned ".array2string($rs).' '.function_backtrace()); return false; } - return ($row['account_type'] == 'g' ? -1 : 1) * $row['account_id']; + return (($row['account_type']??null) === 'g' ? -1 : 1) * $row['account_id']; } /** diff --git a/api/src/Auth/Sql.php b/api/src/Auth/Sql.php index 0d50b78c29..ad55f0c385 100644 --- a/api/src/Auth/Sql.php +++ b/api/src/Auth/Sql.php @@ -60,7 +60,7 @@ class Sql implements Backend 'account_type' => 'u', 'account_status' => 'A' ); - if (!$GLOBALS['egw_info']['server']['case_sensitive_username']) // = is case sensitiv eg. on postgres, but not on mysql! + if (empty($GLOBALS['egw_info']['server']['case_sensitive_username'])) // = is case-sensitive e.g. on postgres, but not on mysql! { $where[] = 'account_lid '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote($username); unset($where['account_lid']); @@ -69,7 +69,7 @@ class Sql implements Backend { if (!($row = $this->db->select($this->table,'account_lid,account_pwd,account_lastlogin,account_id',$where,__LINE__,__FILE__)->fetch()) || empty($row['account_pwd']) || - $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username) + !empty($GLOBALS['egw_info']['server']['case_sensitive_username']) && $row['account_lid'] != $username) { return false; } @@ -265,4 +265,4 @@ class Sql implements Backend } return true; } -} +} \ No newline at end of file diff --git a/api/src/Categories.php b/api/src/Categories.php index 39c98ada67..53adc8a654 100644 --- a/api/src/Categories.php +++ b/api/src/Categories.php @@ -237,7 +237,7 @@ class Categories } } // check if certain parent required - if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) continue; + if ($parent_id && !in_array($cat['parent']??null, (array)$parent_id)) continue; // return global categories just if $globals is set if (!$globals && !empty($cat['appname']) && $cat['appname'] === self::GLOBAL_APPNAME) diff --git a/api/src/Db.php b/api/src/Db.php index 003d841789..d7252fc16a 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -855,7 +855,10 @@ class Db "\n$this->Error ($this->Errno)". ($inputarr ? "\nParameters: '".implode("','",$inputarr)."'":''), $this->Errno); } - elseif(!$rs->sql) $rs->sql = $Query_String; + elseif(empty($rs->sql)) + { + $rs->sql = $Query_String; + } return $rs; } diff --git a/api/src/Hooks.php b/api/src/Hooks.php index 5ac92161cd..6b0bca8a99 100644 --- a/api/src/Hooks.php +++ b/api/src/Hooks.php @@ -261,7 +261,7 @@ class Hooks // some apps have setup_info for more then themselfs (eg. api for groupdav) foreach($setup_info as $appname => $data) { - foreach((array)$data['hooks'] as $location => $methods) + foreach((array)($data['hooks'] ?? []) as $location => $methods) { if (is_int($location)) { diff --git a/api/src/Link.php b/api/src/Link.php index 20eb657b15..e1b1343794 100644 --- a/api/src/Link.php +++ b/api/src/Link.php @@ -235,7 +235,7 @@ class Link extends Link\Storage // for performance reasons, we do it only once / cache it in the session if ($clear_all || !($search_link_hooks = Cache::getSession(__CLASS__, 'search_link_hooks'))) { - $search_link_hooks = Hooks::process('search_link',array(), $clear_all || (bool)$GLOBALS['egw_info']['flags']['async-service']); + $search_link_hooks = Hooks::process('search_link',array(), $clear_all || !empty($GLOBALS['egw_info']['flags']['async-service'])); Cache::setSession(__CLASS__, 'search_link_hooks', $search_link_hooks); } if (is_array($search_link_hooks)) diff --git a/api/src/Mail.php b/api/src/Mail.php index b7ef9b2018..73cae99da4 100644 --- a/api/src/Mail.php +++ b/api/src/Mail.php @@ -4644,7 +4644,7 @@ class Mail ); break; } - return $bodyPart; + return $bodyPart ?? null; } /** @@ -5057,7 +5057,7 @@ class Mail { $body2return = $_bodyParts; } - return $body2return; + return $body2return ?? null; } /** diff --git a/api/src/Session.php b/api/src/Session.php index e865fee6a7..a47e07d833 100644 --- a/api/src/Session.php +++ b/api/src/Session.php @@ -643,7 +643,7 @@ class Session $this->sessionid_access_log = $this->log_access($this->sessionid,$login,$user_ip,$this->account_id); // We do NOT log anonymous sessions to not block website and also to cope with // high rate anon endpoints might be called creating a bottleneck in the egw_accounts table. - Cache::setSession('phpgwapi', 'account_previous_login', $GLOBALS['egw']->auth->previous_login); + Cache::setSession('phpgwapi', 'account_previous_login', $GLOBALS['egw']->auth->previous_login ?? null); $GLOBALS['egw']->accounts->update_lastlogin($this->account_id,$user_ip); } $GLOBALS['egw']->db->transaction_commit(); @@ -664,7 +664,7 @@ class Session // set new remember me token/cookie, if requested and necessary $expiration = null; - if (($token = $this->checkSetRememberMeToken($remember_me, $_COOKIE[self::REMEMBER_ME_COOKIE], $expiration))) + if (($token = $this->checkSetRememberMeToken($remember_me, $_COOKIE[self::REMEMBER_ME_COOKIE] ?? null, $expiration))) { self::egw_setcookie(self::REMEMBER_ME_COOKIE, $token, $expiration); } @@ -684,7 +684,7 @@ class Session 'account_domain' => $this->account_domain, 'user_ip' => $user_ip, 'session_type' => Session\Type::get($_SERVER['REQUEST_URI'], - $GLOBALS['egw_info']['flags']['current_app'], + $GLOBALS['egw_info']['flags']['current_app'] ?? null, true), // true return WebGUI instead of login, as we are logged in now ),'',true); @@ -957,7 +957,7 @@ class Session // restore session vars set before session was started if (is_array($this->required_files)) { - $_SESSION[self::EGW_REQUIRED_FILES] = !is_array($_SESSION[self::EGW_REQUIRED_FILES]) ? $this->required_files : + $_SESSION[self::EGW_REQUIRED_FILES] = !is_array($_SESSION[self::EGW_REQUIRED_FILES] ?? null) ? $this->required_files : array_unique(array_merge($_SESSION[self::EGW_REQUIRED_FILES],$this->required_files)); unset($this->required_files); } @@ -969,7 +969,7 @@ class Session 'session_dla' => $now, 'session_action' => $_SERVER['PHP_SELF'], 'session_flags' => $session_flags, - // we need the install-id to differ between serveral installs shareing one tmp-dir + // we need the install-id to differ between several installations sharing one tmp-dir 'session_install_id' => $GLOBALS['egw_info']['server']['install_id'] ); } @@ -1065,7 +1065,7 @@ class Session } } //error_log(__METHOD__."('$sessionid', '$login', '$user_ip', $account_id) returning ".array2string($ret)); - return $ret; + return $ret ?? null; } /** @@ -1251,7 +1251,7 @@ class Session { if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace()); - $fill_egw_info_and_repositories = !$GLOBALS['egw_info']['flags']['restored_from_session']; + $fill_egw_info_and_repositories = empty($GLOBALS['egw_info']['flags']['restored_from_session']); if(!$sessionid) { @@ -1298,9 +1298,9 @@ class Session return false; } - $this->session_flags = $session['session_flags']; + $this->session_flags = $session['session_flags'] ?? null; - $this->split_login_domain($session['session_lid'],$this->account_lid,$this->account_domain); + $this->split_login_domain($session['session_lid'] ?? null,$this->account_lid,$this->account_domain); // This is to ensure that we authenticate to the correct domain (might not be default) if($GLOBALS['egw_info']['user']['domain'] && $this->account_domain != $GLOBALS['egw_info']['user']['domain']) @@ -1441,7 +1441,7 @@ class Session ),'',true); // true = run hooks from all apps, not just the ones the current user has perms to run // Only do the following, if where working with the current user - if (!$GLOBALS['egw_info']['user']['sessionid'] || $sessionid == $GLOBALS['egw_info']['user']['sessionid']) + if (empty($GLOBALS['egw_info']['user']['sessionid']) || $sessionid == $GLOBALS['egw_info']['user']['sessionid']) { // eg. SAML logout will fail, if there is no more session --> remove everything else $auth = new Auth(); @@ -1988,7 +1988,7 @@ class Session } } - if (!$got_login) + if (empty($got_login)) { $domain = $GLOBALS['egw_info']['server']['default_domain']; $account_lid = $login; diff --git a/api/src/Storage/Customfields.php b/api/src/Storage/Customfields.php index 83942a547b..4e3435d6cc 100644 --- a/api/src/Storage/Customfields.php +++ b/api/src/Storage/Customfields.php @@ -603,7 +603,7 @@ class Customfields implements \IteratorAggregate if(!$customfields) { static $_customfields = array(); - if(!$_customfields[$app]) + if(empty($_customfields[$app])) { $_customfields[$app] = Api\Storage\Customfields::get($app); } diff --git a/api/src/Storage/Tracking.php b/api/src/Storage/Tracking.php index 21c04f5655..61c8659ea0 100644 --- a/api/src/Storage/Tracking.php +++ b/api/src/Storage/Tracking.php @@ -369,8 +369,8 @@ abstract class Tracking { //error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (new):'.array2string($data[$name])); //error_log(__METHOD__.__LINE__.' Field:'.$name. ' Value (old):'.array2string($old[$name])); - if (is_array($data[$name]) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id']; - if (is_array($old[$name]) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id']; + if (is_array($data[$name] ?? null) && array_key_exists('id',$data[$name])) $data[$name] = $data[$name]['id']; + if (is_array($old[$name] ?? null) && array_key_exists('id',$old[$name])) $old[$name] = $old[$name]['id']; //error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (new):'.array2string($data[$name])); //error_log(__METHOD__.__LINE__.'(After processing) Field:'.$name. ' Value (old):'.array2string($old[$name])); } @@ -1361,4 +1361,4 @@ abstract class Tracking } return $message; } -} +} \ No newline at end of file diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 08d2a8b616..917942c708 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -602,8 +602,8 @@ class calendar_bo } // resolve users to add memberships for users and members for groups // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries - $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); - if($params['private_allowed']) + $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'] ?? null, empty($params['query'])); + if(!empty($params['private_allowed'])) { $params['private_allowed'] = $this->resolve_users($params['private_allowed'],$params['filter'] == 'no-enum-groups',$params['ignore_acl'], empty($params['query'])); } @@ -667,7 +667,7 @@ class calendar_bo //echo "

remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."

\n"; foreach($events as $id => $event) { - if ($params['enum_groups'] && $this->enum_groups($event)) + if (!empty($params['enum_groups']) && $this->enum_groups($event)) { $events[$id] = $event; } @@ -680,9 +680,9 @@ class calendar_bo { $is_private = !$this->check_perms(Acl::READ,$event); } - if (!$params['ignore_acl'] && ($is_private || (!$event['public'] && $filter == 'hideprivate'))) + if (empty($params['ignore_acl']) && ($is_private || (!$event['public'] && $filter == 'hideprivate'))) { - $this->clear_private_infos($events[$id],$params['private_allowed'] ? $params['private_allowed'] : $users); + $this->clear_private_infos($events[$id],$params['private_allowed'] ?: $users); } } @@ -1344,7 +1344,7 @@ class calendar_bo } if (!is_array($event)) { - if ($this->xmlrpc) + if (!empty($this->xmlrpc)) { $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']); } @@ -1698,7 +1698,7 @@ class calendar_bo $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email'); } } - return $id2lid[$id].(($append_email || $id[0] == 'e') && !empty($id2email[$id]) ? ' <'.$id2email[$id].'>' : ''); + return $id2lid[$id].(($append_email || is_string($id) && $id[0] == 'e') && !empty($id2email[$id]) ? ' <'.$id2email[$id].'>' : ''); } /** @@ -2187,7 +2187,7 @@ class calendar_bo { if (!is_array($entry)) { - list($id,$recur_date) = explode(':',$entry); + list($id,$recur_date) = explode(':',$entry)+[null,null]; $entry = $this->read($id, $recur_date, true, 'server'); } $etag = $schedule_tag = $entry['id'].':'.$entry['etag']; diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 0c943ab724..36beb9df07 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -133,8 +133,8 @@ class calendar_boupdate extends calendar_bo // check some minimum requirements: // - new events need start, end and title // - updated events cant set start, end or title to empty - if (!$event['id'] && (!$event['start'] || !$event['end'] || !$event['title']) || - $event['id'] && (isset($event['start']) && !$event['start'] || isset($event['end']) && !$event['end'] || + if (empty($event['id']) && (!$event['start'] || !$event['end'] || !$event['title']) || + !empty($event['id']) && (isset($event['start']) && !$event['start'] || isset($event['end']) && !$event['end'] || isset($event['title']) && !$event['title'])) { $messages[] = lang('Required information (start, end, title, ...) missing!'); @@ -143,7 +143,7 @@ class calendar_boupdate extends calendar_bo $status_reset_to_unknown = false; - if (($new_event = !$event['id'])) // some defaults for new entries + if (($new_event = empty($event['id']))) // some defaults for new entries { // if no owner given, set user to owner if (!$event['owner']) $event['owner'] = $this->user; @@ -185,7 +185,7 @@ class calendar_boupdate extends calendar_bo ': '.implode(', ',$removed); } // check category based ACL - if ($event['category']) + if (!empty($event['category'])) { if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); if (!$old_event || !isset($old_event['category'])) @@ -236,7 +236,7 @@ class calendar_boupdate extends calendar_bo } // generate a video-room-url, if we need one and not already have one - if ($event['videoconference'] && empty($event['##videoconference']) && !calendar_hooks::isVideoconferenceDisabled()) + if (!empty($event['videoconference']) && empty($event['##videoconference']) && !calendar_hooks::isVideoconferenceDisabled()) { $event['##videoconference'] = EGroupware\Status\Videoconference\Call::genUniqueRoomID(); } @@ -245,7 +245,7 @@ class calendar_boupdate extends calendar_bo $event['##videoconference'] = ''; } // update videoconference resource amounts based on number of participants - if ($event['videoconference'] && !empty($event['##videoconference']) && !calendar_hooks::isVideoconferenceDisabled() + if (!empty($event['videoconference']) && !empty($event['##videoconference']) && !calendar_hooks::isVideoconferenceDisabled() && ($videoconferenceResId = \EGroupware\Status\Hooks::getVideoconferenceResourceId())) { $participant_total = 0; @@ -291,13 +291,13 @@ class calendar_boupdate extends calendar_bo $event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null); //error_log("new $cal_id=". array2string($event)); - if($old_event['deleted'] && $event['deleted'] == null) + if(!empty($old_event['deleted']) && !isset($event['deleted'])) { // Restored, bring back links Link::restore('calendar', $cal_id); $update_type = 'add'; } - if ($this->log_file) + if (!empty($this->log_file)) { $this->log2file($event2save,$event,$old_event); } @@ -875,7 +875,7 @@ class calendar_boupdate extends calendar_bo { $to_notify = array(); } - $notify_externals = $new_event ? $new_event['##notify_externals'] : $old_event['##notify_externals']; + $notify_externals = $new_event ? ($new_event['##notify_externals']??null) : ($old_event['##notify_externals']??null); $disinvited = $msg_type == MSG_DISINVITE ? array_keys($to_notify) : array(); $owner = $old_event ? $old_event['owner'] : $new_event['owner']; @@ -942,9 +942,9 @@ class calendar_boupdate extends calendar_bo } } } - // unless we notfiy externals about everything aka 'responses' + // unless we notify externals about everything aka 'responses' // we will notify only an external chair, if only one exists - if (($notify_externals ?: $GLOBALS['egw_info']['user']['calendar']['notify_externals']) !== 'responses') + if (($notify_externals ?: $GLOBALS['egw_info']['user']['calendar']['notify_externals'] ?? null) !== 'responses') { // check if we have *only* an external chair $chair = null; @@ -1165,7 +1165,7 @@ class calendar_boupdate extends calendar_bo // we need to pass $event[id] so iCal class reads event again, // as event is in user TZ, but iCal class expects server TZ! $ics = $calendar_ical->exportVCal([$cleared_event], - '2.0', $method, $cleared_event['recur_date'], + '2.0', $method, $cleared_event['recur_date'] ?? null, '', 'utf-8', $method == 'REPLY' ? $user : 0 ); unset($calendar_ical); @@ -1371,14 +1371,14 @@ class calendar_boupdate extends calendar_bo //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); // check if user has the permission to update / create the event - if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) || - !$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) && + if (!$ignore_acl && (!empty($event['id']) && !$this->check_perms(Acl::EDIT,$event['id']) || + empty($event['id']) && !$this->check_perms(Acl::EDIT,0,$event['owner']) && !$this->check_perms(Acl::ADD,0,$event['owner']))) { return false; } - if ($event['id']) + if (!empty($event['id'])) { // invalidate the read-cache if it contains the event we store now if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); @@ -1499,16 +1499,16 @@ class calendar_boupdate extends calendar_bo $this->enum_groups($expanded); foreach($event['alarm'] as $id => &$alarm) { - if($alarm['time']) + if(!empty($alarm['time'])) { $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time } // remove alarms belonging to not longer existing or rejected participants - if ($alarm['owner'] && isset($expanded['participants'])) + if (!empty($alarm['owner']) && isset($expanded['participants'])) { // Don't auto-delete alarm if for all users - if($alarm['all']) continue; + if(!empty($alarm['all'])) continue; $status = $expanded['participants'][$alarm['owner']]; if (!isset($status) || calendar_so::split_status($status) === 'R') @@ -1518,7 +1518,7 @@ class calendar_boupdate extends calendar_bo //error_log(__LINE__.': '.__METHOD__."(".array2string($event).") deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); } } - else if (!$alarm['owner']) + else if (empty($alarm['owner'])) { $alarm['owner'] = $event['owner']; } @@ -1562,7 +1562,7 @@ class calendar_boupdate extends calendar_bo $event['created'] = $save_event['created'] = $this->now; $event['creator'] = $save_event['creator'] = $this->user; } - $set_recurrences = $old_event ? abs(Api\DateTime::to($event['recur_enddate'], 'utc') - Api\DateTime::to($old_event['recur_enddate'], 'utc')) > 1 : false; + $set_recurrences = $old_event ? abs(Api\DateTime::to($event['recur_enddate']??null, 'utc') - Api\DateTime::to($old_event['recur_enddate']??null, 'utc')) > 1 : false; $set_recurrences_start = 0; if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) { @@ -1573,7 +1573,7 @@ class calendar_boupdate extends calendar_bo } // create links for new participants from addressbook, if configured - if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) + if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && !empty($event['participants'])) { foreach($event['participants'] as $uid => $status) { @@ -1602,7 +1602,7 @@ class calendar_boupdate extends calendar_bo } foreach(['start', 'end', 'recur_enddate'] as $ts) { - if(is_object($save_event[$ts])) + if(isset($save_event[$ts]) && is_object($save_event[$ts])) { $save_event[$ts] = $save_event[$ts]->format('ts'); } @@ -3119,7 +3119,7 @@ class calendar_boupdate extends calendar_bo { foreach($event['alarm'] as $id => $alarm) { - $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); + $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time'] ?? null); } } } diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index 1286f39740..59838312ed 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -87,7 +87,7 @@ class calendar_hooks $send_keys = ['id', 'owner', 'participants', 'start', 'end']; if($event['recur_type']) { - // If it's a recurring event, we're only sending the first instance, which may be outside of the current + // If it's a recurring event, we're only sending the first instance, which may be outside the current // view and therefore would be ignored by the client. Include range for additional check. $send_keys[] = 'range_start'; $send_keys[] = 'range_end'; @@ -95,7 +95,7 @@ class calendar_hooks $event = array_intersect_key($event, array_flip($send_keys)); foreach($event['participants'] as $uid => $status) { - if($uid[0] === 'e') + if(is_string($uid) && $uid[0] === 'e') { unset($event['participants'][$uid]); } @@ -1009,4 +1009,4 @@ function calendar_purge_old($config) $GLOBALS['config_error'] = 'Unable to schedule purge'; } } -} +} \ No newline at end of file diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index a7ae2c13c9..ae8d4ea05c 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -939,7 +939,7 @@ class calendar_ical extends calendar_boupdate if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue; // skip alarms not being set for all users and alarms owned by other users - if ($alarmData['all'] != true && $alarmData['owner'] != $this->user) + if (empty($alarmData['all']) && $alarmData['owner'] != $this->user) { continue; } @@ -1041,13 +1041,13 @@ class calendar_ical extends calendar_boupdate foreach ($attributes as $key => $value) { - foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) + foreach (is_array($value) && ($parameters[$key]['VALUE']??null) != 'DATE' ? $value : array($value) as $valueID => $valueData) { $valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset); $paramData = (array) Api\Translation::convert(is_array($value) ? - $parameters[$key][$valueID] : $parameters[$key], + ($parameters[$key][$valueID]??null) : ($parameters[$key]??null), Api\Translation::charset(),$charset); - $valuesData = (array) Api\Translation::convert($values[$key], + $valuesData = (array) Api\Translation::convert($values[$key] ?? null, Api\Translation::charset(),$charset); $content = $valueData . implode(';', $valuesData); @@ -3068,7 +3068,7 @@ class calendar_ical extends calendar_boupdate } break; case 'CREATED': // will be written direct to the event - if ($event['modified']) break; + if (!empty($event['modified'])) break; // fall through case 'LAST-MODIFIED': // will be written direct to the event $event['modified'] = $attributes['value']; @@ -3192,7 +3192,7 @@ class calendar_ical extends calendar_boupdate break; } } - if ($event['recur_enddate']) + if (!empty($event['recur_enddate'])) { // reset recure_enddate to 00:00:00 on the last day $rriter = calendar_rrule::event2rrule($event, false); @@ -3211,7 +3211,7 @@ class calendar_ical extends calendar_boupdate $event['recur_enddate'] = Api\DateTime::to($last, 'server'); } // translate COUNT into an enddate, as we only store enddates - elseif($event['recur_count']) + elseif(!empty($event['recur_count'])) { $rriter = calendar_rrule::event2rrule($event, false); $last = $rriter->count2date($event['recur_count']); diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 42e35565d4..349bb4b9aa 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -353,6 +353,7 @@ class calendar_so )); unset($where['cal_id']); } + $group_by = ''; if ((int) $recur_date && !$read_recurrence) { $where[] = 'cal_start >= '.(int)$recur_date; @@ -901,7 +902,10 @@ class calendar_so $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; } } - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection + if (empty($params['order']) || !preg_match('/^[a-z_ ,c]+$/i', $params['order'])) + { + $params['order'] = 'cal_start'; // gard against SQL injection + } // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! if (!$params['enum_recuring']) @@ -987,7 +991,7 @@ class calendar_so 'cols' => $cols, 'where' => $where, 'app' => 'calendar', - 'append'=> $params['append'], + 'append'=> $params['append'] ?? null, 'table_def' => $cal_table_def, ); $selects = array(); @@ -1032,7 +1036,7 @@ class calendar_so $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; } } - if (is_numeric($offset) && !$params['no_total']) // get the total too + if (is_numeric($offset) && empty($params['no_total'])) // get the total too { $save_selects = $selects; // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) @@ -1045,14 +1049,14 @@ class calendar_so array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); } } - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); + if (!isset($params['cols']) && empty($params['no_integration'])) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); // restore original cols / selects $selects = $save_selects; unset($save_selects); } - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); + if (!isset($params['cols']) && empty($params['no_integration'])) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); } @@ -1120,7 +1124,7 @@ class calendar_so $row['recur_exception'] = $row['alarm'] = array(); // compile a list of recurrences per cal_id - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; + if (!isset($recur_ids[$row['cal_id']]) || !in_array($id, $recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; $events[$id] = Api\Db::strip_array_keys($row,'cal_'); } @@ -1184,7 +1188,7 @@ class calendar_so } } //custom fields are not shown in the regular views, so we only query them, if explicitly required - if (!is_null($params['cfs'])) + if (isset($params['cfs'])) { $where = array('cal_id' => $ids); if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; @@ -1439,7 +1443,7 @@ ORDER BY cal_user_type, cal_usre_id //error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace()); - $cal_id = (int) $event['id']; + $cal_id = (int)($event['id'] ?? 0); unset($event['id']); $set_recurrences = $set_recurrences || !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE; @@ -1465,15 +1469,15 @@ ORDER BY cal_user_type, cal_usre_id $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null); } - // ensure that we find mathing entries later on - if (!is_array($event['cal_category'])) + // ensure that we find matching entries later on + if (isset($event['cal_category']) && !is_array($event['cal_category'])) { $categories = array_unique(explode(',',$event['cal_category'])); sort($categories); } else { - $categories = array_unique($event['cal_category']); + $categories = array_unique($event['cal_category'] ?? []); } sort($categories, SORT_NUMERIC); @@ -1515,7 +1519,7 @@ ORDER BY cal_user_type, cal_usre_id // new event if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! + if (empty($event['cal_id']) && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! $event['cal_etag'] = $etag = 0; $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); @@ -1556,7 +1560,7 @@ ORDER BY cal_user_type, cal_usre_id __LINE__,__FILE__,'calendar'); // add exception marker to master, so participants added to exceptions *only* get found - if ($event['cal_reference']) + if (!empty($event['cal_reference'])) { $master_participants = array(); foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( @@ -1725,7 +1729,7 @@ ORDER BY cal_user_type, cal_usre_id foreach($event as $name => $value) { - if ($name[0] == '#') + if (is_string($name) && $name[0] === '#') { if (is_array($value) && array_key_exists('id',$value)) { @@ -1756,7 +1760,7 @@ ORDER BY cal_user_type, cal_usre_id { foreach ($event['alarm'] as $id => $alarm) { - if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0) + if (!empty($alarm['id']) && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0) { unset($alarm['id']); // unset the temporary id to add the alarm } @@ -1782,7 +1786,7 @@ ORDER BY cal_user_type, cal_usre_id } // if event is an exception: update modified of master, to force etag, ctag and sync-token change - if ($event['cal_reference']) + if (!empty($event['cal_reference'])) { $this->updateModified($event['cal_reference']); } @@ -2071,7 +2075,7 @@ ORDER BY cal_user_type, cal_usre_id // we do not touch unchanged (!) existing ones foreach($participants as $uid => $status) { - if ($old_participants[$uid] === $status) + if (isset($old_participants[$uid]) && $old_participants[$uid] === $status) { unset($participants[$uid]); } @@ -2387,13 +2391,13 @@ ORDER BY cal_user_type, cal_usre_id } if (!is_array($cal_id)) { - $alarms = (array)self::$alarm_cache[$cal_id]; + $alarms = self::$alarm_cache[$cal_id] ?? []; } else { foreach($cal_id as $id) { - $alarms[$id] = (array)self::$alarm_cache[$id]; + $alarms[$id] = self::$alarm_cache[$id] ?? []; } } //error_log(__METHOD__."(".array2string($cal_id).", ".array2string($update_cache).") returning from cache ".array2string($alarms)); @@ -2416,7 +2420,7 @@ ORDER BY cal_user_type, cal_usre_id } } //error_log(__METHOD__."(".array2string($cal_id).") returning ".array2string($alarms)); - return $alarms ? $alarms : array(); + return $alarms ?? []; } /** @@ -2452,7 +2456,7 @@ ORDER BY cal_user_type, cal_usre_id function save_alarm($cal_id, $alarm, $update_modified=true) { //error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace()); - if (!($id = $alarm['id'])) + if (!($id = $alarm['id'] ?? null)) { $alarms = $this->read_alarms($cal_id); // find a free alarm# $n = count($alarms); diff --git a/calendar/inc/class.calendar_timezones.inc.php b/calendar/inc/class.calendar_timezones.inc.php index 4f2014e199..6f298b7147 100644 --- a/calendar/inc/class.calendar_timezones.inc.php +++ b/calendar/inc/class.calendar_timezones.inc.php @@ -148,7 +148,7 @@ class calendar_timezones } } // if not tzid queried, resolve aliases automatically - if ($data && $data['alias'] && $what != 'tzid' && $what != 'alias') + if ($data && !empty($data['alias']) && $what != 'tzid' && $what != 'alias') { $data = self::id2tz($data['alias'],null); } @@ -489,4 +489,4 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_ } } else*/ -calendar_timezones::init_static(); +calendar_timezones::init_static(); \ No newline at end of file diff --git a/calendar/inc/class.calendar_tracking.inc.php b/calendar/inc/class.calendar_tracking.inc.php index 6d6b0c2add..ecab598a28 100644 --- a/calendar/inc/class.calendar_tracking.inc.php +++ b/calendar/inc/class.calendar_tracking.inc.php @@ -148,7 +148,7 @@ class calendar_tracking extends Api\Storage\Tracking { unset($old['participants']); } - if(is_array($old['participants'])) + if(isset($old['participants']) && is_array($old['participants'])) { $participants = $old['participants']; $old['participants'] = array(); @@ -221,9 +221,9 @@ class calendar_tracking extends Api\Storage\Tracking 'status' => $status, 'quantity' => $quantity, 'role' => $role, - 'recur' => $data['recur_date'] ? $data['recur_date'] : 0, + 'recur' => $data['recur_date'] ?? 0, ); } return $data; } -} +} \ No newline at end of file diff --git a/calendar/inc/class.calendar_zpush.inc.php b/calendar/inc/class.calendar_zpush.inc.php index 8a97c83e15..b143bdc4b2 100644 --- a/calendar/inc/class.calendar_zpush.inc.php +++ b/calendar/inc/class.calendar_zpush.inc.php @@ -389,7 +389,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti $message->sensitivity = !isset($event['public']) || $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential // busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1 - $message->busystatus = $event['non_blocking'] ? 0 : 2; + $message->busystatus = !empty($event['non_blocking']) ? 0 : 2; // ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ... $message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception @@ -467,7 +467,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti // convert to user-time, as that is what calendar_boupdate expects $this->calendar->server2usertime($event); - if ($event['id'] && isset($event['participants'][$uid])) + if (!empty($event['id']) && isset($event['participants'][$uid])) { $ret = $this->calendar->set_status($event, $uid, $status) ? $event['id'] : false; $msg = $ret ? "status '$status' set for event #$ret" : "could NOT set status '$status' for event #$event[id]"; @@ -557,7 +557,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $_id, ".array2string($message).") type='$type', account=$account"); - list($id,$recur_date) = explode(':', $_id); + list($id,$recur_date) = explode(':', $_id)+[null,null]; if ($type != 'calendar' || $id && !($old_event = $this->calendar->read($id, $recur_date, false, 'server'))) { @@ -698,7 +698,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti $participants = array(); foreach((array)$message->attendees as $attendee) { - if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later + if (isset($attendee->type) && $attendee->type == 3) continue; // we can not identify resources and re-add them anyway later $matches = null; if (preg_match('/^noreply-(.*)-uid@egroupware.org$/',$attendee->email,$matches)) @@ -736,7 +736,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti $status = $event['participants'][$uid]; $quantity = $role = null; calendar_so::split_status($status, $quantity, $role); - //ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantitiy, role=$role"); + //ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantity, role=$role"); } // check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) || @@ -744,14 +744,14 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti { $status = $event['participants'][$u]; calendar_so::split_status($status, $quantity, $role); - //ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid as $u is status=$status, quantity=$quantitiy, role=$role"); + //ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid as $u is status=$status, quantity=$quantity, role=$role"); } else // set some defaults { $status = 'U'; - $quantitiy = 1; + $quantity = 1; $role = 'REQ-PARTICIPANT'; - //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role"); + //ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantity, role=$role"); } if ($role == 'CHAIR') $chair_set = true; // by role from existing participant @@ -771,8 +771,8 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti { $role = $r; } - //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)"); - $participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role); + //ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantity, role=$role ($r)"); + $participants[$uid] = calendar_so::combine_status($status,$quantity,$role); } // if organizer is not already participant, add him as chair if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid])) @@ -867,7 +867,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti { foreach((array)$event['alarm'] as $alarm) { - if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder) + if ((!empty($alarm['all']) || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder) { $alarm = true; // alarm already exists --> do nothing break; @@ -1041,7 +1041,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti } else { - list($id,$recur_date) = explode(':',$id); + list($id,$recur_date) = explode(':',$id)+[null,null]; if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account))) { error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false"); @@ -1263,11 +1263,11 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($id) message->exceptions=".array2string($message->exceptions)); } // only return alarms if in own calendar - if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm']) + if ($account == $GLOBALS['egw_info']['user']['account_id'] && !empty($event['alarm'])) { foreach($event['alarm'] as $alarm) { - if ($alarm['all'] || $alarm['owner'] == $account) + if (!empty($alarm['all']) || $alarm['owner'] == $account) { $message->reminder = $alarm['offset']/60; // is in minutes, not seconds as in EGw break; // AS supports only one alarm! (we use the next/earliest one) diff --git a/mail/inc/class.mail_zpush.inc.php b/mail/inc/class.mail_zpush.inc.php index a8ab002e30..f262527639 100644 --- a/mail/inc/class.mail_zpush.inc.php +++ b/mail/inc/class.mail_zpush.inc.php @@ -84,7 +84,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, */ public function __construct(activesync_backend $backend) { - if ($GLOBALS['egw_setup']) return; + if (isset($GLOBALS['egw_setup'])) return; //$this->debugLevel=2; $this->backend = $backend; @@ -1069,18 +1069,18 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, $output->read = $headers["flags"]; $output->flag = new SyncMailFlags(); - if ($headers['flagged'] == 1) + if (isset($headers['flagged']) && $headers['flagged'] == 1) { $output->flag->flagstatus = 2; //$output->flag->flagtype = "Flag for Follow up"; } else { $output->flag->flagstatus = 0; } - if ($headers['answered']) + if (!empty($headers['answered'])) { $output->lastverexecuted = AS_REPLYTOSENDER; } - elseif ($headers['forwarded']) + elseif (!empty($headers['forwarded'])) { $output->lastverexecuted = AS_FORWARD; } @@ -1492,7 +1492,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, // 'seen' aka 'read' is the only flag we want to know about $mess["flags"] = 0; // outlook supports additional flags, set them to 0 - if($vars["seen"]) $mess["flags"] = 1; + if(!empty($vars["seen"])) $mess["flags"] = 1; if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.array2string($mess)); $messagelist[$vars['uid']] = $mess; unset($mess); @@ -1518,9 +1518,9 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail, static function doFlagsMod($headerFlags) { $flags = 'nnn'; - if ($headerFlags['flagged']) $flags[0] = 'f'; - if ($headerFlags['answered']) $flags[1] = 'a'; - if ($headerFlags['forwarded']) $flags[2] = 'f'; + if (!empty($headerFlags['flagged'])) $flags[0] = 'f'; + if (!empty($headerFlags['answered'])) $flags[1] = 'a'; + if (!empty($headerFlags['forwarded'])) $flags[2] = 'f'; //ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($headerFlags).') returning '.array2string($flags)); return $flags; }