next chunk of fixed PHP Warning: Undefined array key or variable in main repo

This commit is contained in:
ralf 2022-04-26 21:04:16 +02:00
parent 2d0de5f287
commit a74bd82dde
11 changed files with 40 additions and 40 deletions

View File

@ -419,11 +419,11 @@ class addressbook_hooks
{
unset($location); // not used, but required by function signature
return $GLOBALS['egw_info']['server']['contact_export_limit'];
return $GLOBALS['egw_info']['server']['contact_export_limit'] ?? null;
}
/**
* Register contacts as calendar resources (items which can be sheduled by the calendar)
* Register contacts as calendar resources (items which can be scheduled by the calendar)
*
* @param array $args hook-params (not used)
* @return array
@ -433,7 +433,7 @@ class addressbook_hooks
unset($args); // not used, but required by function signature
return array(
'type' => 'c',// one char type-identifiy for this resources
'type' => 'c',// one char type-identifier for this resource
'info' => 'api.EGroupware\\Api\\Contacts.calendar_info',// info method, returns array with id, type & name for a given id
);
}
@ -633,4 +633,4 @@ class addressbook_hooks
]
];
}
}
}

View File

@ -129,7 +129,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se
if (!isset($abs) || !$return_all_in_one)
{
if ($return_all_in_one && $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'])
if ($return_all_in_one && ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] ?? null))
{
$abs = array(
$GLOBALS['egw_info']['user']['account_id'] => lang('All'),
@ -141,7 +141,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se
if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
$pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'];
$pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'] ?? [];
if (!is_array($pref_abs))
{
$pref_abs = $pref_abs ? explode(',',$pref_abs) : [];
@ -917,4 +917,4 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se
);
return $settings;
}
}
}

View File

@ -262,7 +262,7 @@ class calendar_bo
//error_log(__METHOD__ . " registered resources=". array2string($this->resources));
$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'] ?? null;
$this->categories = new Api\Categories($this->user,'calendar');
@ -1686,7 +1686,7 @@ class calendar_bo
$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
}
}
return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
return $id2lid[$id].(($append_email || $id[0] == 'e') && !empty($id2email[$id]) ? ' <'.$id2email[$id].'>' : '');
}
/**
@ -2291,4 +2291,4 @@ class calendar_bo
}
return $set;
}
}
}

View File

@ -833,7 +833,7 @@ class calendar_boupdate extends calendar_bo
$msg = $prefs['notifyAdded']; // use a default
}
//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
return $method;
return $method ?? null;
}
/**
@ -994,7 +994,7 @@ class calendar_boupdate extends calendar_bo
//$cleared_event = $this->read($event['id'], null, true, 'server');
$this->clear_private_infos($cleared_event, array($userid));
}
$userid = $res_info['responsible'];
$userid = $res_info['responsible'] ?? null;
if (empty($userid)) // no resource responsible: $userid===0
{
@ -1247,7 +1247,7 @@ class calendar_boupdate extends calendar_bo
$notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n");
$notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar')));
if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
if(!empty($attachment)) { $notification->set_attachments(array($attachment)); }
$notification->send();
$errors = notifications::errors(true);
}
@ -1289,7 +1289,7 @@ class calendar_boupdate extends calendar_bo
Api\Translation::init();
}
// restore timezone, in case we had to reset it to server-timezone
if ($restore_tz) date_default_timezone_set($restore_tz);
if (!empty($restore_tz)) date_default_timezone_set($restore_tz);
return true;
}
@ -2131,7 +2131,7 @@ class calendar_boupdate extends calendar_bo
$var['updated'] = Array(
'field' => lang('Updated'),
'data' => $this->format_date($event['modtime']).', '.Api\Accounts::username($event['modifier'])
'data' => $this->format_date($event['modtime'] ?? null).', '.Api\Accounts::username($event['modifier'])
);
$var['access'] = Array(

View File

@ -50,9 +50,9 @@ define('TENTATIVE',2);
define('ACCEPTED',3);
define('DELEGATED',4);
define('HOUR_s',60*60);
define('DAY_s',24*HOUR_s);
define('WEEK_s',7*DAY_s);
if (!defined('HOUR_s')) define('HOUR_s',60*60);
if (!defined('DAY_s')) define('DAY_s',24*HOUR_s);
if (!defined('WEEK_s')) define('WEEK_s',7*DAY_s);
/**
* Class to store all calendar data (storage object)
@ -3087,4 +3087,4 @@ ORDER BY cal_user_type, cal_usre_id
}
}
}
}
}

View File

@ -84,7 +84,7 @@ class calendar_zpush implements activesync_plugin_write, activesync_plugin_meeti
{
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'] ?? null;
$cals = $cals_pref ? explode(',',$cals_pref) : array('P'); // implicit default of 'P'
$folderlist = array();
@ -1751,4 +1751,4 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME'])
}
echo "</tbody></table>\n";
echo "</body></html>\n";
}
}

View File

@ -249,7 +249,7 @@ class importexport_export_csv implements importexport_iface_export_record
break;
case 'date':
case 'date-time':
if ($c_field['values']['format'])
if (!empty($c_field['values']['format']))
{
// Date has custom format. Convert so it's standard, don't do normal processing
$type = $c_field['type'];
@ -312,7 +312,7 @@ class importexport_export_csv implements importexport_iface_export_record
{
if($appname)
{
if(!self::$cf_parse_cache[$appname])
if(empty(self::$cf_parse_cache[$appname]))
{
$c_fields = self::convert_parse_custom_fields($record, $appname, $selects, $links, $methods);
self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
@ -343,7 +343,7 @@ class importexport_export_csv implements importexport_iface_export_record
}
foreach($fields['select'] ?? [] as $name)
{
if($record->$name != null && is_array($selects) && $selects[$name])
if($record->$name != null && is_array($selects) && !empty($selects[$name]))
{
$record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name;
if(is_array($record->$name))
@ -368,7 +368,7 @@ class importexport_export_csv implements importexport_iface_export_record
}
foreach($fields['links'] ?? [] as $name) {
if($record->$name) {
if(is_numeric($record->$name) && !$links[$name]) {
if(is_numeric($record->$name) && empty($links[$name])) {
$link = Link::get_link($record->$name);
$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
@ -428,13 +428,13 @@ class importexport_export_csv implements importexport_iface_export_record
{
$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
if (empty($dec_separator)) $dec_separator = '.';
$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1] ?? '';
}
if($record->$name && (string)$record->$name != '')
{
if(!is_numeric($record->$name))
{
$record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name)));
$record->$name = (float)(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator, '/').']/', '', $record->$name)));
}
$record->$name = number_format(str_replace(' ','',$record->$name), 2,
$dec_separator,$thousands_separator
@ -514,4 +514,4 @@ class importexport_export_csv implements importexport_iface_export_record
}
} // end export_csv_record
?>
?>

View File

@ -798,7 +798,7 @@ class infolog_so
// query children independent of action
if (empty($query['col_filter']['info_id_parent']))
{
$action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : ($query['action'] ?? null);
$action = isset($action2app[$query['action']??null]) ? $action2app[$query['action']] : ($query['action'] ?? null);
if ($action)
{
$links = Link\Storage::get_links($action=='sp'?'infolog':$action,
@ -947,7 +947,7 @@ class infolog_so
$pid = 'AND ' . $this->db->expression($this->info_table,array('info_id_parent' => ($action == 'sp' ?$query['action_id'] : 0)));
if ($GLOBALS['egw_info']['user']['preferences']['infolog']['listNoSubs'] != '1' && $action != 'sp' ||
(string)$query['col_filter']['info_id_parent'] !== '' ||
($query['col_filter']['info_id_parent']??'') !== '' ||
isset($query['subs']) && $query['subs'] || $action != 'sp' && !empty($query['search']))
{
$pid = '';
@ -1096,4 +1096,4 @@ class infolog_so
}
return $users;
}
}
}

View File

@ -502,7 +502,7 @@ class notifications {
$backend_errors = array();
try {
// system or non-system user
if($receiver->account_id && is_numeric($receiver->account_id)) {
if(!empty($receiver->account_id) && is_numeric($receiver->account_id)) {
// system user, collect data and check for Status and expire state, skip notification if expired or not active
$userData = $GLOBALS['egw']->accounts->read($receiver->account_id);
//error_log(__METHOD__.__LINE__." fetched data for User:".array2string($userData['account_lid']).'#'.$userData['account_type'].'#'.$userData['account_status'].'#'.$GLOBALS['egw']->accounts->is_expired($userData).'#');
@ -560,7 +560,7 @@ class notifications {
if(!file_exists(EGW_INCLUDE_ROOT.'/'. self::_appname.'/inc/class.'. $notification_backend. '.inc.php')) {
throw new Exception('file for '.$notification_backend. ' does not exist');
}
$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences );
$obj = new $notification_backend( $this->sender, $receiver, $this->config, $preferences??null );
if ( !($obj instanceof notifications_iface) ) {
unset ( $obj );
throw new Exception($notification_backend. ' is no implementation of notifications_iface');
@ -575,7 +575,7 @@ class notifications {
} elseif ($backend == 'email') {
if (!empty($this->reply_to)) $popup_data = array( 'reply_to' => $this->reply_to );
}
$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments, $popup_data);
$obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments, $popup_data??null);
// This is to make popup_or_email option sensfull since
// we save popup notifications in database anyway, email
@ -730,7 +730,7 @@ class notifications {
break;
default:
$param = $backend.'_enable';
$enabled_backends[$backend] = $this->config->{$param} == true ? true : false;
$enabled_backends[$backend] = !empty($this->config->{$param});
break;
}
}
@ -867,4 +867,4 @@ class notifications {
return $result;
}
}
}

View File

@ -254,7 +254,7 @@ class notifications_ajax {
private function get_egwpopup($browserNotify = false)
{
$entries = notifications_popup::read($this->recipient->account_id);
$this->response->apply('app.notifications.append', array($entries['rows'], $browserNotify, $entries['total']));
$this->response->apply('app.notifications.append', array($entries['rows']??[], $browserNotify, $entries['total']??0));
return true;
}
@ -283,4 +283,4 @@ class notifications_ajax {
Api\Cache::setSession(self::_appname, 'session_data', $this->session_data);
return true;
}
}
}

View File

@ -97,8 +97,8 @@ class notifications_email implements notifications_iface {
*/
public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false, $_data = false)
{
$body_plain = $_messages['plain'].$this->render_links($_links, false, $this->preferences->external_mailclient);
$body_html = "<html><body>\n".$_messages['html'].$this->render_links($_links, true, $this->preferences->external_mailclient)."</body>\n</html>\n";
$body_plain = $_messages['plain'].$this->render_links($_links, false, $this->preferences->external_mailclient??false);
$body_html = "<html><body>\n".$_messages['html'].$this->render_links($_links, true, $this->preferences->external_mailclient??false)."</body>\n</html>\n";
$this->mail->ClearAddresses();
$this->mail->ClearAttachments();