PHP 8 fixes

Differential Revision: https://git.kolab.org/D3995
This commit is contained in:
Christian Mollekopf 2023-01-18 14:50:31 +01:00 committed by Aleksander Machniak
parent 5af7c61b20
commit d988dac141
33 changed files with 220 additions and 205 deletions

View file

@ -402,7 +402,7 @@ class kolab_calendar extends kolab_storage_folder_api
foreach ($event['attendees'] as $attendee) { foreach ($event['attendees'] as $attendee) {
if ( if (
in_array($attendee['email'], $user_emails) in_array($attendee['email'], $user_emails)
&& in_array($attendee['status'], $partstat_exclude) && in_array($attendee['status'] ?? null, $partstat_exclude)
) { ) {
return false; return false;
} }

View file

@ -180,7 +180,7 @@ class kolab_driver extends calendar_driver
$parents[] = $cal->id; $parents[] = $cal->id;
if ($cal->virtual) { if (property_exists($cal, "virtual") && $cal->virtual) {
$calendars[$cal->id] = [ $calendars[$cal->id] = [
'id' => $cal->id, 'id' => $cal->id,
'name' => $cal->get_name(), 'name' => $cal->get_name(),

View file

@ -125,23 +125,23 @@ class kolab_activesync_ui
} }
$devicetype = strtolower($this->device['TYPE']); $devicetype = strtolower($this->device['TYPE']);
$device_force_subscriptions = $this->force_subscriptions[$devicetype]; $device_force_subscriptions = $this->force_subscriptions[$devicetype] ?? null;
foreach ($this->plugin->list_folders() as $folder) { foreach ($this->plugin->list_folders() as $folder) {
if ($folder_types[$folder]) { if ($folder_types[$folder] ?? null) {
list($type, ) = explode('.', $folder_types[$folder]); list($type, ) = explode('.', $folder_types[$folder]);
} }
else { else {
$type = 'mail'; $type = 'mail';
} }
if (is_array($folder_groups[$type])) { if (is_array($folder_groups[$type] ?? null)) {
$folder_groups[$type][] = $folder; $folder_groups[$type][] = $folder;
if ($device_force_subscriptions && array_key_exists($folder, $device_force_subscriptions)) { if ($device_force_subscriptions && array_key_exists($folder, $device_force_subscriptions)) {
$subscribed[$folder] = intval($device_force_subscriptions[$folder]); $subscribed[$folder] = intval($device_force_subscriptions[$folder] ?? null);
} else if (!empty($folder_meta) && ($meta = $folder_meta[$folder]) } else if (!empty($folder_meta) && ($meta = ($folder_meta[$folder] ?? null))
&& $meta['FOLDER'] && $meta['FOLDER'][$imei]['S'] && ($meta['FOLDER'] ?? false) && $meta['FOLDER'][$imei]['S']
) { ) {
$subscribed[$folder] = intval($meta['FOLDER'][$imei]['S']); $subscribed[$folder] = intval($meta['FOLDER'][$imei]['S']);
} }
@ -149,6 +149,7 @@ class kolab_activesync_ui
} }
// build block for every folder type // build block for every folder type
$html = null;
foreach ($folder_groups as $type => $group) { foreach ($folder_groups as $type => $group) {
if (empty($group)) { if (empty($group)) {
continue; continue;
@ -181,7 +182,7 @@ class kolab_activesync_ui
'title' => $this->plugin->gettext('synchronize'), 'title' => $this->plugin->gettext('synchronize'),
'tabindex' => 0 'tabindex' => 0
), ),
$attrib['syncicon'] ? html::img(array('src' => $this->skin_path . $attrib['syncicon'])) : ($attrib['syncicon'] ?? false) ? html::img(array('src' => $this->skin_path . $attrib['syncicon'])) :
$this->plugin->gettext('synchronize') $this->plugin->gettext('synchronize')
); );
@ -191,7 +192,7 @@ class kolab_activesync_ui
'title' => $this->plugin->gettext('withalarms'), 'title' => $this->plugin->gettext('withalarms'),
'tabindex' => 0 'tabindex' => 0
), ),
$attrib['alarmicon'] ? html::img(array('src' => $this->skin_path . $attrib['alarmicon'])) : ($attrib['alarmicon'] ?? null) ? html::img(array('src' => $this->skin_path . $attrib['alarmicon'])) :
$this->plugin->gettext('withalarms') $this->plugin->gettext('withalarms')
); );
} }
@ -237,7 +238,7 @@ class kolab_activesync_ui
if ($alarms) { if ($alarms) {
$table->add('alarm checkbox-cell', $checkbox_alarm->show( $table->add('alarm checkbox-cell', $checkbox_alarm->show(
intval($subscribed[$folder]) > 1 ? $folder : null, intval($subscribed[$folder] ?? 0) > 1 ? $folder : null,
array('value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled))); array('value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled)));
} }

View file

@ -166,7 +166,7 @@ class kolab_contacts extends rcube_addressbook
// set localized labels for proprietary cols // set localized labels for proprietary cols
foreach ($this->coltypes as $col => $prop) { foreach ($this->coltypes as $col => $prop) {
if (is_string($prop['label'])) { if (is_string($prop['label'] ?? null)) {
$this->coltypes[$col]['label'] = $rcube->gettext($prop['label']); $this->coltypes[$col]['label'] = $rcube->gettext($prop['label']);
} }
} }
@ -1320,10 +1320,10 @@ class kolab_contacts extends rcube_addressbook
*/ */
private function _from_rcube_contact($contact, $old = array()) private function _from_rcube_contact($contact, $old = array())
{ {
if (!$contact['uid'] && $contact['ID']) { if (!($contact['uid'] ?? null) && ($contact['ID'] ?? null)) {
$contact['uid'] = $this->id2uid($contact['ID']); $contact['uid'] = $this->id2uid($contact['ID']);
} }
else if (!$contact['uid'] && $old['uid']) { else if (!($contact['uid'] ?? null) && ($old['uid'] ?? null)) {
$contact['uid'] = $old['uid']; $contact['uid'] = $old['uid'];
} }
@ -1368,7 +1368,7 @@ class kolab_contacts extends rcube_addressbook
$contact['address'] = $addresses; $contact['address'] = $addresses;
// categories are not supported in the web client but should be preserved (#2608) // categories are not supported in the web client but should be preserved (#2608)
$contact['categories'] = $old['categories']; $contact['categories'] = $old['categories'] ?? null;
// copy meta data (starting with _) from old object // copy meta data (starting with _) from old object
foreach ((array)$old as $key => $val) { foreach ((array)$old as $key => $val) {
@ -1380,7 +1380,7 @@ class kolab_contacts extends rcube_addressbook
// convert one-item-array elements into string element // convert one-item-array elements into string element
// this is needed e.g. to properly import birthday field // this is needed e.g. to properly import birthday field
foreach ($this->coltypes as $type => $col_def) { foreach ($this->coltypes as $type => $col_def) {
if ($col_def['limit'] == 1 && is_array($contact[$type])) { if (($col_def['limit'] ?? null) == 1 && is_array($contact[$type] ?? null)) {
$contact[$type] = array_shift(array_filter($contact[$type])); $contact[$type] = array_shift(array_filter($contact[$type]));
} }
} }

View file

@ -242,7 +242,7 @@ class kolab_contacts_driver
*/ */
public function abook_prop($id, $abook) public function abook_prop($id, $abook)
{ {
if ($abook->virtual) { if (property_exists($abook, 'virtual') && $abook->virtual) {
return [ return [
'id' => $id, 'id' => $id,
'name' => $abook->get_name(), 'name' => $abook->get_name(),

View file

@ -471,7 +471,7 @@ class kolab_addressbook extends rcube_plugin
public function contact_form($p) public function contact_form($p)
{ {
// none of our business // none of our business
if (!is_object($GLOBALS['CONTACTS']) || !is_a($GLOBALS['CONTACTS'], 'kolab_contacts')) { if (!is_object($GLOBALS['CONTACTS'] ?? null) || !is_a($GLOBALS['CONTACTS'], 'kolab_contacts')) {
return $p; return $p;
} }

View file

@ -61,7 +61,7 @@ class kolab_auth extends rcube_plugin
// Hook to modify logging directory // Hook to modify logging directory
$this->add_hook('write_log', array($this, 'write_log')); $this->add_hook('write_log', array($this, 'write_log'));
$this->username = $_SESSION['username']; $this->username = $_SESSION['username'] ?? null;
// Enable debug logs (per-user), when logged as another user // Enable debug logs (per-user), when logged as another user
if (!empty($_SESSION['kolab_auth_admin']) && $rcmail->config->get('kolab_auth_auditlog')) { if (!empty($_SESSION['kolab_auth_admin']) && $rcmail->config->get('kolab_auth_auditlog')) {
@ -666,7 +666,7 @@ class kolab_auth extends rcube_plugin
foreach ((array)$email_attr as $field) { foreach ((array)$email_attr as $field) {
$email = is_array($record[$field]) ? array_filter($record[$field]) : $record[$field]; $email = is_array($record[$field]) ? array_filter($record[$field]) : $record[$field];
if (!empty($email)) { if (!empty($email)) {
$this->data['user_email'] = array_merge((array)$this->data['user_email'], (array)$email); $this->data['user_email'] = array_merge((array)($this->data['user_email'] ?? null), (array)$email);
} }
} }
// Organization name for identity (first log in) // Organization name for identity (first log in)

View file

@ -31,6 +31,7 @@ class kolab_files_engine
private $timeout = 600; private $timeout = 600;
private $files_sort_cols = array('name', 'mtime', 'size'); private $files_sort_cols = array('name', 'mtime', 'size');
private $sessions_sort_cols = array('name'); private $sessions_sort_cols = array('name');
private $mimetypes = null;
const API_VERSION = 4; const API_VERSION = 4;
@ -55,6 +56,7 @@ class kolab_files_engine
$this->plugin->add_texts('localization/'); $this->plugin->add_texts('localization/');
$templates = array(); $templates = array();
$list_widget = false;
// set templates of Files UI and widgets // set templates of Files UI and widgets
if ($this->rc->task == 'mail') { if ($this->rc->task == 'mail') {
@ -140,7 +142,7 @@ class kolab_files_engine
$this->rc->output->set_env('files_url', $this->url . '/api/'); $this->rc->output->set_env('files_url', $this->url . '/api/');
$this->rc->output->set_env('files_token', $this->get_api_token()); $this->rc->output->set_env('files_token', $this->get_api_token());
$this->rc->output->set_env('files_caps', $caps); $this->rc->output->set_env('files_caps', $caps);
$this->rc->output->set_env('files_api_version', $caps['VERSION'] ?: 3); $this->rc->output->set_env('files_api_version', $caps['VERSION'] ?? 3);
$this->rc->output->set_env('files_user', $this->rc->get_user_name()); $this->rc->output->set_env('files_user', $this->rc->get_user_name());
if ($caps['DOCEDIT']) { if ($caps['DOCEDIT']) {
@ -921,7 +923,7 @@ class kolab_files_engine
*/ */
public function quota_display($attrib) public function quota_display($attrib)
{ {
if (!$attrib['id']) { if (!($attrib['id'] ?? false)) {
$attrib['id'] = 'rcmquotadisplay'; $attrib['id'] = 'rcmquotadisplay';
} }
@ -1076,7 +1078,7 @@ class kolab_files_engine
{ {
$url = $this->url_srv . '/api/'; $url = $this->url_srv . '/api/';
if (!$this->request) { if (!property_exists($this, "request") || !$this->request) {
$config = array( $config = array(
'store_body' => true, 'store_body' => true,
'follow_redirects' => true, 'follow_redirects' => true,
@ -1176,8 +1178,8 @@ class kolab_files_engine
$this->rc->output->set_env('file_mimetypes', $this->get_mimetypes()); $this->rc->output->set_env('file_mimetypes', $this->get_mimetypes());
$this->rc->output->set_env('files_quota', $caps['QUOTA']); $this->rc->output->set_env('files_quota', $caps['QUOTA']);
$this->rc->output->set_env('files_max_upload', $caps['MAX_UPLOAD']); $this->rc->output->set_env('files_max_upload', $caps['MAX_UPLOAD']);
$this->rc->output->set_env('files_progress_name', $caps['PROGRESS_NAME']); $this->rc->output->set_env('files_progress_name', $caps['PROGRESS_NAME'] ?? null);
$this->rc->output->set_env('files_progress_time', $caps['PROGRESS_TIME']); $this->rc->output->set_env('files_progress_time', $caps['PROGRESS_TIME'] ?? null);
$this->rc->output->send('kolab_files.files'); $this->rc->output->send('kolab_files.files');
} }

View file

@ -42,6 +42,7 @@ class kolab_folders extends rcube_plugin
private $rc; private $rc;
private static $instance; private static $instance;
private $expire_annotation = '/shared/vendor/cmu/cyrus-imapd/expire'; private $expire_annotation = '/shared/vendor/cmu/cyrus-imapd/expire';
private $is_processing = false;
/** /**
@ -158,7 +159,7 @@ class kolab_folders extends rcube_plugin
// Add type-based style for table rows // Add type-based style for table rows
// See kolab_folders::folder_class_name() // See kolab_folders::folder_class_name()
if ($table = $args['table']) { if ($table = ($args['table'] ?? null)) {
for ($i=1, $cnt=$table->size(); $i<=$cnt; $i++) { for ($i=1, $cnt=$table->size(); $i<=$cnt; $i++) {
$attrib = $table->get_row_attribs($i); $attrib = $table->get_row_attribs($i);
$folder = $attrib['foldername']; // UTF7-IMAP $folder = $attrib['foldername']; // UTF7-IMAP
@ -175,10 +176,10 @@ class kolab_folders extends rcube_plugin
} }
// Add type-based class for list items // Add type-based class for list items
if (is_array($args['list'])) { if (is_array($args['list'] ?? null)) {
foreach ((array)$args['list'] as $k => $item) { foreach ((array)$args['list'] as $k => $item) {
$folder = $item['folder_imap']; // UTF7-IMAP $folder = $item['folder_imap']; // UTF7-IMAP
$type = $folderdata[$folder]; $type = $folderdata[$folder] ?? null;
if (!$type) { if (!$type) {
$type = 'mail'; $type = 'mail';
@ -286,7 +287,7 @@ class kolab_folders extends rcube_plugin
$sub_types[$ftype] = array_combine($subtypes, array_map(array($this, 'gettext'), $subtypes)); $sub_types[$ftype] = array_combine($subtypes, array_map(array($this, 'gettext'), $subtypes));
// fill options for the current folder type // fill options for the current folder type
if ($ftype == $ctype || $ftype == $new_ctype) { if ($ftype == $ctype || (isset($new_ctype) && $ftype == $new_ctype)) {
$sub_select->add(array_values($sub_types[$ftype]), $subtypes); $sub_select->add(array_values($sub_types[$ftype]), $subtypes);
} }
} }
@ -596,7 +597,7 @@ class kolab_folders extends rcube_plugin
*/ */
static function folder_class_name($type) static function folder_class_name($type)
{ {
list($ctype, $subtype) = explode('.', $type); list($ctype, $subtype) = array_pad(explode('.', $type), 2, null);
$class[] = 'type-' . ($ctype ? $ctype : 'mail'); $class[] = 'type-' . ($ctype ? $ctype : 'mail');
@ -744,7 +745,7 @@ class kolab_folders extends rcube_plugin
$value = $storage->get_metadata($folder, $this->expire_annotation); $value = $storage->get_metadata($folder, $this->expire_annotation);
if (is_array($value)) { if (is_array($value)) {
return $value[$folder] ? intval($value[$folder][$this->expire_annotation]) : 0; return ($value[$folder] ?? false) ? intval($value[$folder][$this->expire_annotation]) : 0;
} }
return false; return false;

View file

@ -540,7 +540,7 @@ class kolab_notes extends rcube_plugin
// deliver from in-memory cache // deliver from in-memory cache
$key = $list_id . ':' . $uid; $key = $list_id . ':' . $uid;
if ($this->cache[$key]) { if ($this->cache[$key] ?? false) {
return $this->cache[$key]; return $this->cache[$key];
} }
@ -732,7 +732,7 @@ class kolab_notes extends rcube_plugin
return false; return false;
// moved from another folder // moved from another folder
if ($note['_fromlist'] && ($fromfolder = $this->get_folder($note['_fromlist']))) { if (($note['_fromlist'] ?? false) && ($fromfolder = $this->get_folder($note['_fromlist']))) {
if (!$fromfolder->move($note['uid'], $folder->name)) if (!$fromfolder->move($note['uid'], $folder->name))
return false; return false;
@ -740,6 +740,7 @@ class kolab_notes extends rcube_plugin
} }
// load previous version of this record to merge // load previous version of this record to merge
$old = null;
if ($note['uid']) { if ($note['uid']) {
$old = $folder->get_object($note['uid']); $old = $folder->get_object($note['uid']);
if (!$old || PEAR::isError($old)) if (!$old || PEAR::isError($old))
@ -754,8 +755,8 @@ class kolab_notes extends rcube_plugin
$object = $this->_write_preprocess($note, $old); $object = $this->_write_preprocess($note, $old);
// email links and tags are handled separately // email links and tags are handled separately
$links = $object['links']; $links = $object['links'] ?? null;
$tags = $object['tags']; $tags = $object['tags'] ?? null;
unset($object['links']); unset($object['links']);
unset($object['tags']); unset($object['tags']);
@ -1372,7 +1373,9 @@ class kolab_notes extends rcube_plugin
$object['links'] = array_map(function($link){ return is_array($link) ? $link['uri'] : strval($link); }, $note['links']); $object['links'] = array_map(function($link){ return is_array($link) ? $link['uri'] : strval($link); }, $note['links']);
} }
else { else {
$object['links'] = $old['links']; if ($old) {
$object['links'] = $old['links'] ?? null;
}
} }
// clean up HTML content // clean up HTML content
@ -1404,7 +1407,7 @@ class kolab_notes extends rcube_plugin
} }
// make list of categories unique // make list of categories unique
if (is_array($object['tags'])) { if (is_array($object['tags'] ?? null)) {
$object['tags'] = array_unique(array_filter($object['tags'])); $object['tags'] = array_unique(array_filter($object['tags']));
} }

View file

@ -77,12 +77,12 @@ class kolab_notes_ui
{ {
$attrib += array('id' => 'rcmkolabnotebooks'); $attrib += array('id' => 'rcmkolabnotebooks');
if ($attrib['type'] == 'select') { if (($attrib['type'] ?? null) == 'select') {
$attrib['is_escaped'] = true; $attrib['is_escaped'] = true;
$select = new html_select($attrib); $select = new html_select($attrib);
} }
$tree = $attrib['type'] != 'select' ? true : null; $tree = ($attrib['type'] ?? null) != 'select' ? true : null;
$lists = $this->plugin->get_lists($tree); $lists = $this->plugin->get_lists($tree);
$jsenv = array(); $jsenv = array();
@ -115,7 +115,7 @@ class kolab_notes_ui
$this->rc->output->set_env('kolab_notebooks', $jsenv); $this->rc->output->set_env('kolab_notebooks', $jsenv);
$this->rc->output->add_gui_object('notebooks', $attrib['id']); $this->rc->output->add_gui_object('notebooks', $attrib['id']);
return $attrib['type'] == 'select' ? $select->show() : html::tag('ul', $attrib, $html, html::$common_attrib); return ($attrib['type'] ?? null) == 'select' ? $select->show() : html::tag('ul', $attrib, $html, html::$common_attrib);
} }
/** /**
@ -139,7 +139,7 @@ class kolab_notes_ui
if (strlen($content)) { if (strlen($content)) {
$out .= html::tag('li', array( $out .= html::tag('li', array(
'id' => 'rcmliknb' . rcube_utils::html_identifier($id), 'id' => 'rcmliknb' . rcube_utils::html_identifier($id),
'class' => $prop['group'] . ($prop['virtual'] ? ' virtual' : ''), 'class' => $prop['group'] . (($prop['virtual'] ?? false) ? ' virtual' : ''),
), ),
$content); $content);
} }
@ -153,13 +153,13 @@ class kolab_notes_ui
*/ */
public function folder_list_item($id, $prop, &$jsenv, $checkbox = false) public function folder_list_item($id, $prop, &$jsenv, $checkbox = false)
{ {
if (!$prop['virtual']) { if (!($prop['virtual'] ?? false)) {
unset($prop['user_id']); unset($prop['user_id']);
$jsenv[$id] = $prop; $jsenv[$id] = $prop;
} }
$classes = array('folder'); $classes = array('folder');
if ($prop['virtual']) { if ($prop['virtual'] ?? false) {
$classes[] = 'virtual'; $classes[] = 'virtual';
} }
else if (!$prop['editable']) { else if (!$prop['editable']) {
@ -172,14 +172,14 @@ class kolab_notes_ui
$classes[] = $prop['class']; $classes[] = $prop['class'];
} }
$title = $prop['title'] ?: ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ? $title = $prop['title'] ?? ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ?
html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET) : ''); html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET) : '');
$label_id = 'nl:' . $id; $label_id = 'nl:' . $id;
$attr = $prop['virtual'] ? array('tabindex' => '0') : array('href' => $this->rc->url(array('_list' => $id))); $attr = ($prop['virtual'] ?? false) ? array('tabindex' => '0') : array('href' => $this->rc->url(array('_list' => $id)));
return html::div(join(' ', $classes), return html::div(join(' ', $classes),
html::a($attr + array('class' => 'listname', 'title' => $title, 'id' => $label_id), $prop['listname'] ?: $prop['name']) . html::a($attr + array('class' => 'listname', 'title' => $title, 'id' => $label_id), $prop['listname'] ?: $prop['name']) .
($prop['virtual'] ? '' : (($prop['virtual'] ?? false) ? '' :
($checkbox ? ($checkbox ?
html::tag('input', array('type' => 'checkbox', 'name' => '_list[]', 'value' => $id, 'checked' => $prop['active'], 'aria-labelledby' => $label_id)) : html::tag('input', array('type' => 'checkbox', 'name' => '_list[]', 'value' => $id, 'checked' => $prop['active'], 'aria-labelledby' => $label_id)) :
'' ''

View file

@ -484,7 +484,7 @@ class kolab_tags_engine
$result = array( $result = array(
'uid' => $tag['uid'], 'uid' => $tag['uid'],
'name' => $tag['name'], 'name' => $tag['name'],
'color' => $tag['color'], 'color' => $tag['color'] ?? null,
); );
if ($list) { if ($list) {

View file

@ -146,7 +146,7 @@ class libcalendaring extends rcube_plugin
); );
} }
if ($args['task'] == 'mail') { if (($args['task'] ?? null) == 'mail') {
if ($args['action'] == 'show' || $args['action'] == 'preview') { if ($args['action'] == 'show' || $args['action'] == 'preview') {
$this->add_hook('message_load', array($this, 'mail_message_load')); $this->add_hook('message_load', array($this, 'mail_message_load'));
} }

View file

@ -417,7 +417,7 @@ abstract class kolab_format
protected function update_uid() protected function update_uid()
{ {
// get generated UID // get generated UID
if (!$this->data['uid']) { if (!($this->data['uid'] ?? null)) {
if ($this->xmlobject) { if ($this->xmlobject) {
$this->data['uid'] = $this->xmlobject->getSerializedUID(); $this->data['uid'] = $this->xmlobject->getSerializedUID();
} }
@ -547,7 +547,7 @@ abstract class kolab_format
// set some automatic values if missing // set some automatic values if missing
if (method_exists($this->obj, 'setCreated')) { if (method_exists($this->obj, 'setCreated')) {
// Always set created date to workaround libkolabxml (>1.1.4) bug // Always set created date to workaround libkolabxml (>1.1.4) bug
$created = $object['created'] ?: new DateTime('now'); $created = $object['created'] ?? new DateTime('now');
$created->setTimezone(new DateTimeZone('UTC')); // must be UTC $created->setTimezone(new DateTimeZone('UTC')); // must be UTC
$this->obj->setCreated(self::get_datetime($created)); $this->obj->setCreated(self::get_datetime($created));
$object['created'] = $created; $object['created'] = $created;
@ -611,7 +611,7 @@ abstract class kolab_format
if ($data) { if ($data) {
foreach ($data as $idx => $value) { foreach ($data as $idx => $value) {
if (is_array($value)) { if (is_array($value)) {
$object[$idx] = array_merge((array)$object[$idx], $value); $object[$idx] = array_merge((array)($object[$idx] ?? []), $value);
} }
else { else {
$object[$idx] = $value; $object[$idx] = $value;
@ -698,7 +698,7 @@ abstract class kolab_format
{ {
// save attachments // save attachments
$vattach = new vectorattachment; $vattach = new vectorattachment;
foreach ((array) $object['_attachments'] as $cid => $attr) { foreach ((array)($object['_attachments'] ?? []) as $cid => $attr) {
if (empty($attr)) if (empty($attr))
continue; continue;
$attach = new Attachment; $attach = new Attachment;
@ -719,7 +719,7 @@ abstract class kolab_format
} }
} }
foreach ((array) $object['links'] as $link) { foreach ((array)($object['links'] ?? []) as $link) {
$attach = new Attachment; $attach = new Attachment;
$attach->setUri($link, 'unknown'); $attach->setUri($link, 'unknown');
$vattach->push($attach); $vattach->push($attach);

View file

@ -80,19 +80,19 @@ class kolab_format_configuration extends kolab_format
case 'relation': case 'relation':
$relation = new Relation(strval($object['name']), strval($object['category'])); $relation = new Relation(strval($object['name']), strval($object['category']));
if ($object['color']) { if ($object['color'] ?? false) {
$relation->setColor($object['color']); $relation->setColor($object['color']);
} }
if ($object['parent']) { if ($object['parent'] ?? false) {
$relation->setParent($object['parent']); $relation->setParent($object['parent']);
} }
if ($object['iconName']) { if ($object['iconName'] ?? false) {
$relation->setIconName($object['iconName']); $relation->setIconName($object['iconName']);
} }
if ($object['priority'] > 0) { if (($object['priority'] ?? 0) > 0) {
$relation->setPriority((int) $object['priority']); $relation->setPriority((int) $object['priority']);
} }
if (!empty($object['members'])) { if (!empty($object['members'] ?? null)) {
$relation->setMembers(self::array2vector($object['members'])); $relation->setMembers(self::array2vector($object['members']));
} }
@ -103,10 +103,10 @@ class kolab_format_configuration extends kolab_format
$collection = new SnippetCollection($object['name']); $collection = new SnippetCollection($object['name']);
$snippets = new vectorsnippets; $snippets = new vectorsnippets;
foreach ((array) $object['snippets'] as $item) { foreach ((array)($object['snippets'] ?? []) as $item) {
$snippet = new snippet($item['name'], $item['text']); $snippet = new snippet($item['name'], $item['text']);
$snippet->setTextType(strtolower($item['type']) == 'html' ? Snippet::HTML : Snippet::Plain); $snippet->setTextType(strtolower($item['type']) == 'html' ? Snippet::HTML : Snippet::Plain);
if ($item['shortcut']) { if ($item['shortcut'] ?? false) {
$snippet->setShortCut($item['shortcut']); $snippet->setShortCut($item['shortcut']);
} }

View file

@ -96,14 +96,14 @@ class kolab_format_contact extends kolab_format
// do the hard work of setting object values // do the hard work of setting object values
$nc = new NameComponents; $nc = new NameComponents;
$nc->setSurnames(self::array2vector($object['surname'])); $nc->setSurnames(self::array2vector($object['surname'] ?? null));
$nc->setGiven(self::array2vector($object['firstname'])); $nc->setGiven(self::array2vector($object['firstname'] ?? null));
$nc->setAdditional(self::array2vector($object['middlename'])); $nc->setAdditional(self::array2vector($object['middlename'] ?? null));
$nc->setPrefixes(self::array2vector($object['prefix'])); $nc->setPrefixes(self::array2vector($object['prefix'] ?? null));
$nc->setSuffixes(self::array2vector($object['suffix'])); $nc->setSuffixes(self::array2vector($object['suffix'] ?? null));
$this->obj->setNameComponents($nc); $this->obj->setNameComponents($nc);
$this->obj->setName($object['name']); $this->obj->setName($object['name'] ?? null);
$this->obj->setCategories(self::array2vector($object['categories'])); $this->obj->setCategories(self::array2vector($object['categories'] ?? null));
if (isset($object['nickname'])) if (isset($object['nickname']))
$this->obj->setNickNames(self::array2vector($object['nickname'])); $this->obj->setNickNames(self::array2vector($object['nickname']));
@ -113,16 +113,16 @@ class kolab_format_contact extends kolab_format
// organisation related properties (affiliation) // organisation related properties (affiliation)
$org = new Affiliation; $org = new Affiliation;
$offices = new vectoraddress; $offices = new vectoraddress;
if ($object['organization']) if ($object['organization'] ?? null)
$org->setOrganisation($object['organization']); $org->setOrganisation($object['organization']);
if ($object['department']) if ($object['department'] ?? null)
$org->setOrganisationalUnits(self::array2vector($object['department'])); $org->setOrganisationalUnits(self::array2vector($object['department']));
if ($object['profession']) if ($object['profession'] ?? null)
$org->setRoles(self::array2vector($object['profession'])); $org->setRoles(self::array2vector($object['profession']));
$rels = new vectorrelated; $rels = new vectorrelated;
foreach (array('manager','assistant') as $field) { foreach (array('manager','assistant') as $field) {
if (!empty($object[$field])) { if (!empty($object[$field] ?? null)) {
$reltype = $this->relatedmap[$field]; $reltype = $this->relatedmap[$field];
foreach ((array)$object[$field] as $value) { foreach ((array)$object[$field] as $value) {
$rels->push(new Related(Related::Text, $value, $reltype)); $rels->push(new Related(Related::Text, $value, $reltype));
@ -132,11 +132,11 @@ class kolab_format_contact extends kolab_format
$org->setRelateds($rels); $org->setRelateds($rels);
// im, email, url // im, email, url
$this->obj->setIMaddresses(self::array2vector($object['im'])); $this->obj->setIMaddresses(self::array2vector($object['im'] ?? null));
if (class_exists('vectoremail')) { if (class_exists('vectoremail')) {
$vemails = new vectoremail; $vemails = new vectoremail;
foreach ((array)$object['email'] as $email) { foreach ((array)($object['email'] ?? []) as $email) {
$type = $this->emailtypes[$email['type']]; $type = $this->emailtypes[$email['type']];
$vemails->push(new Email($email['address'], intval($type))); $vemails->push(new Email($email['address'], intval($type)));
} }
@ -147,7 +147,7 @@ class kolab_format_contact extends kolab_format
$this->obj->setEmailAddresses($vemails); $this->obj->setEmailAddresses($vemails);
$vurls = new vectorurl; $vurls = new vectorurl;
foreach ((array)$object['website'] as $url) { foreach ((array)($object['website'] ?? []) as $url) {
$type = $url['type'] == 'blog' ? Url::Blog : Url::NoType; $type = $url['type'] == 'blog' ? Url::Blog : Url::NoType;
$vurls->push(new Url($url['url'], $type)); $vurls->push(new Url($url['url'], $type));
} }
@ -155,25 +155,25 @@ class kolab_format_contact extends kolab_format
// addresses // addresses
$adrs = new vectoraddress; $adrs = new vectoraddress;
foreach ((array)$object['address'] as $address) { foreach ((array)($object['address'] ?? [])as $address) {
$adr = new Address; $adr = new Address;
$type = $this->addresstypes[$address['type']]; $type = $this->addresstypes[$address['type']];
if (isset($type)) if (isset($type))
$adr->setTypes($type); $adr->setTypes($type);
else if ($address['type']) else if ($address['type'] ?? null)
$adr->setLabel($address['type']); $adr->setLabel($address['type']);
if ($address['street']) if ($address['street'] ?? null)
$adr->setStreet($address['street']); $adr->setStreet($address['street']);
if ($address['locality']) if ($address['locality'] ?? null)
$adr->setLocality($address['locality']); $adr->setLocality($address['locality']);
if ($address['code']) if ($address['code'] ?? null)
$adr->setCode($address['code']); $adr->setCode($address['code']);
if ($address['region']) if ($address['region'] ?? null)
$adr->setRegion($address['region']); $adr->setRegion($address['region']);
if ($address['country']) if ($address['country'] ?? null)
$adr->setCountry($address['country']); $adr->setCountry($address['country']);
if ($address['type'] == 'office') if (($address['type'] ?? null) == 'office')
$offices->push($adr); $offices->push($adr);
else else
$adrs->push($adr); $adrs->push($adr);
@ -188,11 +188,11 @@ class kolab_format_contact extends kolab_format
// telephones // telephones
$tels = new vectortelephone; $tels = new vectortelephone;
foreach ((array)$object['phone'] as $phone) { foreach ((array)($object['phone'] ?? []) as $phone) {
$tel = new Telephone; $tel = new Telephone;
if (isset($this->phonetypes[$phone['type']])) if (isset($this->phonetypes[$phone['type'] ?? null]))
$tel->setTypes($this->phonetypes[$phone['type']]); $tel->setTypes($this->phonetypes[$phone['type']]);
$tel->setNumber($phone['number']); $tel->setNumber($phone['number'] ?? null);
$tels->push($tel); $tels->push($tel);
} }
$this->obj->setTelephones($tels); $this->obj->setTelephones($tels);
@ -210,7 +210,7 @@ class kolab_format_contact extends kolab_format
if (isset($object['anniversary'])) if (isset($object['anniversary']))
$this->obj->setAnniversary(self::get_datetime($object['anniversary'], false, true)); $this->obj->setAnniversary(self::get_datetime($object['anniversary'], false, true));
if (!empty($object['photo'])) { if (!empty($object['photo'] ?? null)) {
if ($type = rcube_mime::image_content_type($object['photo'])) if ($type = rcube_mime::image_content_type($object['photo']))
$this->obj->setPhoto($object['photo'], $type); $this->obj->setPhoto($object['photo'], $type);
} }
@ -230,7 +230,7 @@ class kolab_format_contact extends kolab_format
} }
} }
// add other relateds // add other relateds
if (is_array($object['related'])) { if (is_array($object['related'] ?? null)) {
foreach ($object['related'] as $value) { foreach ($object['related'] as $value) {
$rels->push(new Related(Related::Text, $value)); $rels->push(new Related(Related::Text, $value));
} }
@ -248,8 +248,8 @@ class kolab_format_contact extends kolab_format
$pkcs7_index = $i; $pkcs7_index = $i;
} }
$pgpkey = $object['pgppublickey'] ? new Key($object['pgppublickey'], Key::PGP) : new Key(); $pgpkey = ($object['pgppublickey'] ?? false) ? new Key($object['pgppublickey'], Key::PGP) : new Key();
$pkcs7key = $object['pkcs7publickey'] ? new Key($object['pkcs7publickey'], Key::PKCS7_MIME) : new Key(); $pkcs7key = ($object['pkcs7publickey'] ?? false) ? new Key($object['pkcs7publickey'], Key::PKCS7_MIME) : new Key();
if ($pgp_index >= 0) if ($pgp_index >= 0)
$keys->set($pgp_index, $pgpkey); $keys->set($pgp_index, $pgpkey);
@ -397,16 +397,16 @@ class kolab_format_contact extends kolab_format
{ {
$data = ''; $data = '';
foreach (self::$fulltext_cols as $colname) { foreach (self::$fulltext_cols as $colname) {
list($col, $field) = explode(':', $colname); list($col, $field) = array_pad(explode(':', $colname), 2, null);
if ($field) { if ($field) {
$a = array(); $a = array();
foreach ((array)$this->data[$col] as $attr) foreach ((array)($this->data[$col] ?? []) as $attr)
$a[] = $attr[$field]; $a[] = $attr[$field];
$val = join(' ', $a); $val = join(' ', $a);
} }
else { else {
$val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col]; $val = is_array($this->data[$col] ?? null) ? join(' ', $this->data[$col] ?? null) : ($this->data[$col] ?? null);
} }
if (strlen($val)) if (strlen($val))

View file

@ -67,18 +67,18 @@ class kolab_format_event extends kolab_format_xcal
$status = kolabformat::StatusUndefined; $status = kolabformat::StatusUndefined;
if ($object['free_busy'] == 'tentative') if ($object['free_busy'] == 'tentative')
$status = kolabformat::StatusTentative; $status = kolabformat::StatusTentative;
if ($object['cancelled']) if ($object['cancelled'] ?? false)
$status = kolabformat::StatusCancelled; $status = kolabformat::StatusCancelled;
else if ($object['status'] && array_key_exists($object['status'], $this->status_map)) else if ($object['status'] && array_key_exists($object['status'], $this->status_map))
$status = $this->status_map[$object['status']]; $status = $this->status_map[$object['status']];
$this->obj->setStatus($status); $this->obj->setStatus($status);
// save (recurrence) exceptions // save (recurrence) exceptions
if (is_array($object['recurrence']) && is_array($object['recurrence']['EXCEPTIONS']) && !isset($object['exceptions'])) { if (is_array($object['recurrence'] ?? null) && is_array($object['recurrence']['EXCEPTIONS'] ?? null) && !isset($object['exceptions'])) {
$object['exceptions'] = $object['recurrence']['EXCEPTIONS']; $object['exceptions'] = $object['recurrence']['EXCEPTIONS'];
} }
if (is_array($object['exceptions'])) { if (is_array($object['exceptions'] ?? null)) {
$recurrence_id_format = libkolab::recurrence_id_format($object); $recurrence_id_format = libkolab::recurrence_id_format($object);
$vexceptions = new vectorevent; $vexceptions = new vectorevent;
foreach ($object['exceptions'] as $i => $exception) { foreach ($object['exceptions'] as $i => $exception) {
@ -107,13 +107,13 @@ class kolab_format_event extends kolab_format_xcal
$this->obj->setExceptions($vexceptions); $this->obj->setExceptions($vexceptions);
// link with recurrence.EXCEPTIONS for compatibility // link with recurrence.EXCEPTIONS for compatibility
if (is_array($object['recurrence'])) { if (is_array($object['recurrence'] ?? null)) {
$object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; $object['recurrence']['EXCEPTIONS'] = &$object['exceptions'];
} }
} }
if ($object['recurrence_date'] && $object['recurrence_date'] instanceof DateTimeInterface) { if (($object['recurrence_date'] ?? false) && $object['recurrence_date'] instanceof DateTimeInterface) {
if ($object['recurrence']) { if ($object['recurrence'] ?? false) {
// unset recurrence_date for master events with rrule // unset recurrence_date for master events with rrule
$object['recurrence_date'] = null; $object['recurrence_date'] = null;
} }
@ -216,7 +216,7 @@ class kolab_format_event extends kolab_format_xcal
$object['exceptions'] = $recurrence_exceptions; $object['exceptions'] = $recurrence_exceptions;
// also link with recurrence.EXCEPTIONS for compatibility // also link with recurrence.EXCEPTIONS for compatibility
if (is_array($object['recurrence'])) { if (is_array($object['recurrence'] ?? null)) {
$object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; $object['recurrence']['EXCEPTIONS'] = &$object['exceptions'];
} }
} }

View file

@ -41,14 +41,14 @@ class kolab_format_file extends kolab_format
// set common object properties // set common object properties
parent::set($object); parent::set($object);
$this->obj->setCategories(self::array2vector($object['categories'])); $this->obj->setCategories(self::array2vector($object['categories'] ?? null));
if (isset($object['notes'])) { if (isset($object['notes'])) {
$this->obj->setNote($object['notes']); $this->obj->setNote($object['notes']);
} }
// Add file attachment // Add file attachment
if (!empty($object['_attachments'])) { if (!empty($object['_attachments'] ?? null)) {
$cid = key($object['_attachments']); $cid = key($object['_attachments']);
$attach_attr = $object['_attachments'][$cid]; $attach_attr = $object['_attachments'][$cid];
$attach = new Attachment; $attach = new Attachment;
@ -126,17 +126,17 @@ class kolab_format_file extends kolab_format
{ {
$tags = array(); $tags = array();
foreach ((array)$this->data['categories'] as $cat) { foreach ((array)($this->data['categories'] ?? null) as $cat) {
$tags[] = rcube_utils::normalize_string($cat); $tags[] = rcube_utils::normalize_string($cat);
} }
// Add file mimetype to tags // Add file mimetype to tags
if (!empty($this->data['_attachments'])) { if (!empty($this->data['_attachments'] ?? null)) {
reset($this->data['_attachments']); reset($this->data['_attachments']);
$key = key($this->data['_attachments']); $key = key($this->data['_attachments']);
$attachment = $this->data['_attachments'][$key]; $attachment = $this->data['_attachments'][$key];
if ($attachment['mimetype']) { if ($attachment['mimetype'] ?? false) {
$tags[] = $attachment['mimetype']; $tags[] = $attachment['mimetype'];
} }
} }

View file

@ -44,8 +44,8 @@ class kolab_format_note extends kolab_format
parent::set($object); parent::set($object);
$this->obj->setSummary($object['title']); $this->obj->setSummary($object['title']);
$this->obj->setDescription($object['description']); $this->obj->setDescription($object['description'] ?? null);
$this->obj->setCategories(self::array2vector($object['categories'])); $this->obj->setCategories(self::array2vector($object['categories'] ?? null));
$this->set_attachments($object); $this->set_attachments($object);
@ -99,12 +99,12 @@ class kolab_format_note extends kolab_format
{ {
$tags = array(); $tags = array();
foreach ((array)$this->data['categories'] as $cat) { foreach ((array)($this->data['categories'] ?? null) as $cat) {
$tags[] = rcube_utils::normalize_string($cat); $tags[] = rcube_utils::normalize_string($cat);
} }
// add tag for message references // add tag for message references
foreach ((array)$this->data['links'] as $link) { foreach ((array)($this->data['links'] ?? []) as $link) {
$url = parse_url($link); $url = parse_url($link);
if ($url['scheme'] == 'imap') { if ($url['scheme'] == 'imap') {
parse_str($url['query'], $param); parse_str($url['query'], $param);
@ -126,11 +126,11 @@ class kolab_format_note extends kolab_format
foreach (self::$fulltext_cols as $col) { foreach (self::$fulltext_cols as $col) {
// convert HTML content to plain text // convert HTML content to plain text
if ($col == 'description' && preg_match('/<(html|body)(\s[a-z]|>)/', $this->data[$col], $m) && strpos($this->data[$col], '</'.$m[1].'>')) { if ($col == 'description' && preg_match('/<(html|body)(\s[a-z]|>)/', $this->data[$col], $m) && strpos($this->data[$col], '</'.$m[1].'>')) {
$converter = new rcube_html2text($this->data[$col], false, false, 0); $converter = new rcube_html2text($this->data[$col] ?? null, false, false, 0);
$val = $converter->get_text(); $val = $converter->get_text();
} }
else { else {
$val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col]; $val = is_array($this->data[$col] ?? null) ? join(' ', $this->data[$col] ?? null) : ($this->data[$col] ?? null);
} }
if (strlen($val)) if (strlen($val))

View file

@ -62,8 +62,8 @@ class kolab_format_task extends kolab_format_xcal
$status = $this->status_map[$object['status']]; $status = $this->status_map[$object['status']];
$this->obj->setStatus($status); $this->obj->setStatus($status);
$this->obj->setStart(self::get_datetime($object['start'], null, $object['start']->_dateonly)); $this->obj->setStart(self::get_datetime($object['start'] ?? null, null, ($object['start'] ?? null) ? $object['start']->_dateonly : null));
$this->obj->setDue(self::get_datetime($object['due'], null, $object['due']->_dateonly)); $this->obj->setDue(self::get_datetime($object['due'] ?? null, null, ($object['due'] ?? null) ? $object['due']->_dateonly : null));
$related = new vectors; $related = new vectors;
if (!empty($object['parent_id'])) if (!empty($object['parent_id']))
@ -140,13 +140,13 @@ class kolab_format_task extends kolab_format_xcal
$tags = parent::get_tags($obj); $tags = parent::get_tags($obj);
$object = $obj ?: $this->data; $object = $obj ?: $this->data;
if ($object['status'] == 'COMPLETED' || ($object['complete'] == 100 && empty($object['status']))) if (($object['status'] ?? null) == 'COMPLETED' || (($object['complete'] ?? null) == 100 && empty($object['status'] ?? null)))
$tags[] = 'x-complete'; $tags[] = 'x-complete';
if ($object['priority'] == 1) if (($object['priority'] ?? 0) == 1)
$tags[] = 'x-flagged'; $tags[] = 'x-flagged';
if ($object['parent_id']) if ($object['parent_id'] ?? false)
$tags[] = 'x-parent:' . $object['parent_id']; $tags[] = 'x-parent:' . $object['parent_id'];
return array_unique($tags); return array_unique($tags);

View file

@ -117,7 +117,7 @@ abstract class kolab_format_xcal extends kolab_format
'location' => $this->obj->location(), 'location' => $this->obj->location(),
'description' => $this->obj->description(), 'description' => $this->obj->description(),
'url' => $this->obj->url(), 'url' => $this->obj->url(),
'status' => $status_map[$this->obj->status()], 'status' => $status_map[$this->obj->status()] ?? null,
'priority' => $this->obj->priority(), 'priority' => $this->obj->priority(),
'categories' => self::vector2array($this->obj->categories()), 'categories' => self::vector2array($this->obj->categories()),
'start' => self::php_datetime($this->obj->start()), 'start' => self::php_datetime($this->obj->start()),
@ -345,19 +345,19 @@ abstract class kolab_format_xcal extends kolab_format
} }
$this->obj->setSummary($object['title']); $this->obj->setSummary($object['title']);
$this->obj->setLocation($object['location']); $this->obj->setLocation($object['location'] ?? null);
$this->obj->setDescription($object['description']); $this->obj->setDescription($object['description']);
$this->obj->setPriority($object['priority']); $this->obj->setPriority($object['priority']);
$this->obj->setCategories(self::array2vector($object['categories'])); $this->obj->setCategories(self::array2vector($object['categories'] ?? null));
$this->obj->setUrl(strval($object['url'])); $this->obj->setUrl(strval($object['url'] ?? null));
if (method_exists($this->obj, 'setComment')) { if (method_exists($this->obj, 'setComment')) {
$this->obj->setComment($object['comment']); $this->obj->setComment($object['comment'] ?? null);
} }
// process event attendees // process event attendees
$attendees = new vectorattendee; $attendees = new vectorattendee;
foreach ((array)$object['attendees'] as $i => $attendee) { foreach ((array)($object['attendees'] ?? []) as $i => $attendee) {
if ($attendee['role'] == 'ORGANIZER') { if ($attendee['role'] == 'ORGANIZER') {
$object['organizer'] = $attendee; $object['organizer'] = $attendee;
} }
@ -412,7 +412,7 @@ abstract class kolab_format_xcal extends kolab_format
$this->obj->setOrganizer($organizer); $this->obj->setOrganizer($organizer);
} }
if ($object['start'] instanceof DateTimeInterface) { if (($object['start'] ?? null) instanceof DateTimeInterface) {
$start_tz = $object['start']->getTimezone(); $start_tz = $object['start']->getTimezone();
} }
@ -420,7 +420,7 @@ abstract class kolab_format_xcal extends kolab_format
$rr = new RecurrenceRule; $rr = new RecurrenceRule;
$rr->setFrequency(RecurrenceRule::FreqNone); $rr->setFrequency(RecurrenceRule::FreqNone);
if ($object['recurrence'] && !empty($object['recurrence']['FREQ'])) { if (($object['recurrence'] ?? null) && !empty($object['recurrence']['FREQ'])) {
$freq = $object['recurrence']['FREQ']; $freq = $object['recurrence']['FREQ'];
$bysetpos = explode(',', $object['recurrence']['BYSETPOS']); $bysetpos = explode(',', $object['recurrence']['BYSETPOS']);
@ -502,7 +502,7 @@ abstract class kolab_format_xcal extends kolab_format
// save alarm(s) // save alarm(s)
$valarms = new vectoralarm; $valarms = new vectoralarm;
$valarm_hashes = array(); $valarm_hashes = array();
if ($object['valarms']) { if ($object['valarms'] ?? null) {
foreach ($object['valarms'] as $valarm) { foreach ($object['valarms'] as $valarm) {
if (!array_key_exists($valarm['action'], $this->alarm_type_map)) { if (!array_key_exists($valarm['action'], $this->alarm_type_map)) {
continue; // skip unknown alarm types continue; // skip unknown alarm types
@ -577,7 +577,7 @@ abstract class kolab_format_xcal extends kolab_format
} }
} }
// legacy support // legacy support
else if ($object['alarms']) { else if ($object['alarms'] ?? null) {
list($offset, $type) = explode(":", $object['alarms']); list($offset, $type) = explode(":", $object['alarms']);
if ($type == 'EMAIL' && !empty($object['_owner'])) { // email alarms implicitly go to event owner if ($type == 'EMAIL' && !empty($object['_owner'])) { // email alarms implicitly go to event owner
@ -636,16 +636,16 @@ abstract class kolab_format_xcal extends kolab_format
$object = $obj ?: $this->data; $object = $obj ?: $this->data;
foreach (self::$fulltext_cols as $colname) { foreach (self::$fulltext_cols as $colname) {
list($col, $field) = explode(':', $colname); list($col, $field) = array_pad(explode(':', $colname), 2, null);
if ($field) { if ($field) {
$a = array(); $a = array();
foreach ((array)$object[$col] as $attr) foreach ((array)($object[$col] ?? []) as $attr)
$a[] = $attr[$field]; $a[] = $attr[$field];
$val = join(' ', $a); $val = join(' ', $a);
} }
else { else {
$val = is_array($object[$col]) ? join(' ', $object[$col]) : $object[$col]; $val = is_array($object[$col] ?? null) ? join(' ', $object[$col]) : $object[$col] ?? null;
} }
if (strlen($val)) if (strlen($val))
@ -655,7 +655,7 @@ abstract class kolab_format_xcal extends kolab_format
$words = rcube_utils::normalize_string($data, true); $words = rcube_utils::normalize_string($data, true);
// collect words from recurrence exceptions // collect words from recurrence exceptions
if (is_array($object['exceptions'])) { if (is_array($object['exceptions'] ?? null)) {
foreach ($object['exceptions'] as $exception) { foreach ($object['exceptions'] as $exception) {
$words = array_merge($words, $this->get_words($exception)); $words = array_merge($words, $this->get_words($exception));
} }
@ -674,12 +674,12 @@ abstract class kolab_format_xcal extends kolab_format
$tags = array(); $tags = array();
$object = $obj ?: $this->data; $object = $obj ?: $this->data;
if (!empty($object['valarms'])) { if (!empty($object['valarms'] ?? null)) {
$tags[] = 'x-has-alarms'; $tags[] = 'x-has-alarms';
} }
// create tags reflecting participant status // create tags reflecting participant status
if (is_array($object['attendees'])) { if (is_array($object['attendees'] ?? null)) {
foreach ($object['attendees'] as $attendee) { foreach ($object['attendees'] as $attendee) {
if (!empty($attendee['email']) && !empty($attendee['status'])) if (!empty($attendee['email']) && !empty($attendee['status']))
$tags[] = 'x-partstat:' . $attendee['email'] . ':' . strtolower($attendee['status']); $tags[] = 'x-partstat:' . $attendee['email'] . ':' . strtolower($attendee['status']);
@ -687,7 +687,7 @@ abstract class kolab_format_xcal extends kolab_format
} }
// collect tags from recurrence exceptions // collect tags from recurrence exceptions
if (is_array($object['exceptions'])) { if (is_array($object['exceptions'] ?? null)) {
foreach ($object['exceptions'] as $exception) { foreach ($object['exceptions'] as $exception) {
$tags = array_merge($tags, $this->get_tags($exception)); $tags = array_merge($tags, $this->get_tags($exception));
} }
@ -717,10 +717,10 @@ abstract class kolab_format_xcal extends kolab_format
} }
foreach ($this->_scheduling_properties ?: self::$scheduling_properties as $prop) { foreach ($this->_scheduling_properties ?: self::$scheduling_properties as $prop) {
$a = $old[$prop]; $a = $old[$prop] ?? null;
$b = $object[$prop]; $b = $object[$prop] ?? null;
if ($object['allday'] if (($object['allday'] ?? false)
&& ($prop == 'start' || $prop == 'end') && ($prop == 'start' || $prop == 'end')
&& $a instanceof DateTimeInterface && $a instanceof DateTimeInterface
&& $b instanceof DateTimeInterface && $b instanceof DateTimeInterface

View file

@ -70,8 +70,8 @@ class kolab_ldap extends rcube_ldap_generic
continue; continue;
} }
$bind_pass = $this->config['bind_pass']; $bind_pass = $this->config['bind_pass'] ?? null;
$bind_user = $this->config['bind_user']; $bind_user = $this->config['bind_user'] ?? null;
$bind_dn = $this->config['bind_dn']; $bind_dn = $this->config['bind_dn'];
$base_dn = $this->config['base_dn']; $base_dn = $this->config['base_dn'];
$groups_base_dn = $this->config['groups']['base_dn'] ?: $base_dn; $groups_base_dn = $this->config['groups']['base_dn'] ?: $base_dn;
@ -85,12 +85,13 @@ class kolab_ldap extends rcube_ldap_generic
$bind_pass = $rcube->get_user_password(); $bind_pass = $rcube->get_user_password();
} }
$u = null;
// Get the pieces needed for variable replacement. // Get the pieces needed for variable replacement.
if ($fu = ($rcube->get_user_email() ?: $this->config['username'])) { if ($fu = ($rcube->get_user_email() ?: ($this->config['username'] ?? null))) {
list($u, $d) = explode('@', $fu); list($u, $d) = explode('@', $fu);
} }
else { else {
$d = $this->config['mail_domain']; $d = $this->config['mail_domain'] ?? null;
} }
$dc = 'dc=' . strtr($d, array('.' => ',dc=')); // hierarchal domain string $dc = 'dc=' . strtr($d, array('.' => ',dc=')); // hierarchal domain string
@ -513,6 +514,7 @@ class kolab_ldap extends rcube_ldap_generic
$user = $_SESSION['username']; $user = $_SESSION['username'];
} }
$dc = null;
if (isset($this->icache[$user])) { if (isset($this->icache[$user])) {
list($user, $dc) = $this->icache[$user]; list($user, $dc) = $this->icache[$user];
} }

View file

@ -129,7 +129,7 @@ class kolab_storage
$config = self::$config->get($name); $config = self::$config->get($name);
} }
if (self::$ldap[$name]) { if (self::$ldap[$name] ?? false) {
return self::$ldap[$name]; return self::$ldap[$name];
} }

View file

@ -50,6 +50,7 @@ class kolab_storage_cache
protected $error = 0; protected $error = 0;
protected $server_timezone; protected $server_timezone;
protected $sync_start; protected $sync_start;
protected $cache_bypassed = 0;
/** /**
@ -380,7 +381,7 @@ class kolab_storage_cache
$mbox_data = $this->imap->folder_data($this->folder->name); $mbox_data = $this->imap->folder_data($this->folder->name);
// Removed vanished messages from the database // Removed vanished messages from the database
$vanished = (array) rcube_imap_generic::uncompressMessageSet($mbox_data['VANISHED']); $vanished = (array) rcube_imap_generic::uncompressMessageSet($mbox_data['VANISHED'] ?? null);
// Remove redundant entries from IMAP and DB // Remove redundant entries from IMAP and DB
$vanished = array_merge($removed, array_intersect($vanished, $existing)); $vanished = array_merge($removed, array_intersect($vanished, $existing));
@ -412,7 +413,7 @@ class kolab_storage_cache
// Deduplication: remove older objects with the same UID // Deduplication: remove older objects with the same UID
// Here we do not resolve conflicts, we just make sure // Here we do not resolve conflicts, we just make sure
// the most recent version of the object will be used // the most recent version of the object will be used
if ($old_msguid = $old_index[$object['uid']]) { if ($old_msguid = ($old_index[$object['uid']] ?? null)) {
if ($old_msguid < $msguid) { if ($old_msguid < $msguid) {
$del_index[] = $old_msguid; $del_index[] = $old_msguid;
} }
@ -1078,11 +1079,11 @@ class kolab_storage_cache
*/ */
protected function _unserialize($sql_arr) protected function _unserialize($sql_arr)
{ {
if ($sql_arr['fast-mode'] && !empty($sql_arr['data']) && ($object = json_decode($sql_arr['data'], true))) { if (($sql_arr['fast-mode'] ?? false) && !empty($sql_arr['data']) && ($object = json_decode($sql_arr['data'], true))) {
$object['uid'] = $sql_arr['uid']; $object['uid'] = $sql_arr['uid'];
foreach ($this->data_props as $prop) { foreach ($this->data_props as $prop) {
if (isset($object[$prop]) && is_array($object[$prop]) && $object[$prop]['cl'] == 'DateTime') { if (isset($object[$prop]) && is_array($object[$prop]) && isset($object[$prop]['cl']) && $object[$prop]['cl'] == 'DateTime') {
$object[$prop] = new DateTime($object[$prop]['dt'], new DateTimeZone($object[$prop]['tz'])); $object[$prop] = new DateTime($object[$prop]['dt'], new DateTimeZone($object[$prop]['tz']));
} }
else if (!isset($object[$prop]) && isset($sql_arr[$prop])) { else if (!isset($object[$prop]) && isset($sql_arr[$prop])) {
@ -1098,7 +1099,7 @@ class kolab_storage_cache
$object['changed'] = new DateTime($sql_arr['changed']); $object['changed'] = new DateTime($sql_arr['changed']);
} }
$object['_type'] = $sql_arr['type'] ?: $this->folder->type; $object['_type'] = $sql_arr['type'] ?? $this->folder->type;
$object['_msguid'] = $sql_arr['msguid']; $object['_msguid'] = $sql_arr['msguid'];
$object['_mailbox'] = $this->folder->name; $object['_mailbox'] = $this->folder->name;
} }

View file

@ -38,21 +38,21 @@ class kolab_storage_cache_contact extends kolab_storage_cache
$sql_data['type'] = $object['_type']; $sql_data['type'] = $object['_type'];
// columns for sorting // columns for sorting
$sql_data['name'] = rcube_charset::clean($object['name'] . $object['prefix']); $sql_data['name'] = rcube_charset::clean(($object['name'] ?? null) . ($object['prefix'] ?? null));
$sql_data['firstname'] = rcube_charset::clean($object['firstname'] . $object['middlename'] . $object['surname']); $sql_data['firstname'] = rcube_charset::clean(($object['firstname'] ?? null) . ($object['middlename'] ?? null) . ($object['surname'] ?? null));
$sql_data['surname'] = rcube_charset::clean($object['surname'] . $object['firstname'] . $object['middlename']); $sql_data['surname'] = rcube_charset::clean(($object['surname'] ?? null) . ($object['firstname'] ?? null) . ($object['middlename'] ?? null));
$sql_data['email'] = rcube_charset::clean(is_array($object['email']) ? $object['email'][0] : $object['email']); $sql_data['email'] = rcube_charset::clean(is_array($object['email'] ?? null) ? $object['email'][0] : ($object['email'] ?? null));
if (is_array($sql_data['email'])) { if (is_array($sql_data['email'] ?? null)) {
$sql_data['email'] = $sql_data['email']['address']; $sql_data['email'] = $sql_data['email']['address'];
} }
// avoid value being null // avoid value being null
if (empty($sql_data['email'])) { if (empty($sql_data['email'] ?? null)) {
$sql_data['email'] = ''; $sql_data['email'] = '';
} }
// use organization if name is empty // use organization if name is empty
if (empty($sql_data['name']) && !empty($object['organization'])) { if (empty($sql_data['name'] ?? null) && !empty($object['organization'] ?? null)) {
$sql_data['name'] = rcube_charset::clean($object['organization']); $sql_data['name'] = rcube_charset::clean($object['organization']);
} }

View file

@ -35,26 +35,26 @@ class kolab_storage_cache_event extends kolab_storage_cache
{ {
$sql_data = parent::_serialize($object); $sql_data = parent::_serialize($object);
$sql_data['dtstart'] = $this->_convert_datetime($object['start']); $sql_data['dtstart'] = $this->_convert_datetime($object['start'] ?? null);
$sql_data['dtend'] = $this->_convert_datetime($object['end']); $sql_data['dtend'] = $this->_convert_datetime($object['end'] ?? null);
// extend date range for recurring events // extend date range for recurring events
if ($object['recurrence']) { if ($object['recurrence'] ?? null) {
$recurrence = new kolab_date_recurrence($object['_formatobj']); $recurrence = new kolab_date_recurrence($object['_formatobj']);
$dtend = $recurrence->end() ?: new DateTime('now +100 years'); $dtend = $recurrence->end() ?: new DateTime('now +100 years');
$sql_data['dtend'] = $this->_convert_datetime($dtend); $sql_data['dtend'] = $this->_convert_datetime($dtend);
} }
// extend start/end dates to spawn all exceptions // extend start/end dates to spawn all exceptions
if (is_array($object['exceptions'])) { if (is_array($object['exceptions'] ?? null)) {
foreach ($object['exceptions'] as $exception) { foreach ($object['exceptions'] as $exception) {
if ($exception['start'] instanceof DateTimeInterface) { if (($exception['start'] ?? null) instanceof DateTimeInterface) {
$exstart = $this->_convert_datetime($exception['start']); $exstart = $this->_convert_datetime($exception['start']);
if ($exstart < $sql_data['dtstart']) { if ($exstart < $sql_data['dtstart']) {
$sql_data['dtstart'] = $exstart; $sql_data['dtstart'] = $exstart;
} }
} }
if ($exception['end'] instanceof DateTimeInterface) { if (($exception['end'] ?? null) instanceof DateTimeInterface) {
$exend = $this->_convert_datetime($exception['end']); $exend = $this->_convert_datetime($exception['end']);
if ($exend > $sql_data['dtend']) { if ($exend > $sql_data['dtend']) {
$sql_data['dtend'] = $exend; $sql_data['dtend'] = $exend;

View file

@ -35,8 +35,8 @@ class kolab_storage_cache_task extends kolab_storage_cache
{ {
$sql_data = parent::_serialize($object); $sql_data = parent::_serialize($object);
$sql_data['dtstart'] = $this->_convert_datetime($object['start']); $sql_data['dtstart'] = $this->_convert_datetime($object['start'] ?? null);
$sql_data['dtend'] = $this->_convert_datetime($object['due']); $sql_data['dtend'] = $this->_convert_datetime($object['due'] ?? null);
return $sql_data; return $sql_data;
} }

View file

@ -186,10 +186,10 @@ class kolab_storage_config
$object['type'] = $type; $object['type'] = $type;
} }
$status = $folder->save($object, self::FOLDER_TYPE . '.' . $object['type'], $object['uid']); $status = $folder->save($object, self::FOLDER_TYPE . '.' . ($object['type'] ?? null), $object['uid'] ?? null);
// on success, update cached tags list // on success, update cached tags list
if ($status && $object['category'] == 'tag' && is_array($this->tags)) { if ($status && ($object['category'] ?? null) == 'tag' && is_array($this->tags)) {
$found = false; $found = false;
unset($object['_formatobj']); // we don't need it anymore unset($object['_formatobj']); // we don't need it anymore
@ -256,7 +256,7 @@ class kolab_storage_config
} }
// find folder object // find folder object
if ($object['_mailbox']) { if ($object['_mailbox'] ?? false) {
foreach ($this->folders as $folder) { foreach ($this->folders as $folder) {
if ($folder->name == $object['_mailbox']) { if ($folder->name == $object['_mailbox']) {
break; break;
@ -676,7 +676,7 @@ class kolab_storage_config
// assign links to objects // assign links to objects
foreach ((array) $relation['members'] as $member) { foreach ((array) $relation['members'] as $member) {
if (($id = $ids[$member]) !== null) { if (($id = ($ids[$member] ?? null)) !== null) {
foreach ($id as $i) { foreach ($id as $i) {
$records[$i]['links'] = array_unique(array_merge($records[$i]['links'], $members)); $records[$i]['links'] = array_unique(array_merge($records[$i]['links'], $members));
} }

View file

@ -155,7 +155,7 @@ class kolab_storage_dataset implements Iterator, ArrayAccess, Countable
return $this->data[$offset]; return $this->data[$offset];
} }
if ($uid = $this->index[$offset]) { if ($uid = ($this->index[$offset] ?? null)) {
return $this->cache->get($uid); return $this->cache->get($uid);
} }

View file

@ -158,7 +158,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
if ($metadata !== null) { if ($metadata !== null) {
foreach ($metakeys as $key) { foreach ($metakeys as $key) {
if ($uid = $metadata[$key]) { if ($uid = ($metadata[$key] ?? null)) {
return $uid; return $uid;
} }
} }
@ -197,7 +197,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
{ {
$fdata = $this->get_imap_data(); $fdata = $this->get_imap_data();
$this->check_error(); $this->check_error();
return sprintf('%d-%d-%d', $fdata['UIDVALIDITY'], $fdata['HIGHESTMODSEQ'], $fdata['UIDNEXT']); return sprintf('%d-%d-%d', $fdata['UIDVALIDITY'] ?? null, $fdata['HIGHESTMODSEQ'] ?? null, $fdata['UIDNEXT'] ?? null);
} }
/** /**
@ -500,6 +500,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
$attachments = array(); $attachments = array();
// get XML part // get XML part
$xml = null;
foreach ((array)$message->attachments as $part) { foreach ((array)$message->attachments as $part) {
if (!$xml && ($part->mimetype == $content_type || preg_match('!application/([a-z.]+\+)?xml!i', $part->mimetype))) { if (!$xml && ($part->mimetype == $content_type || preg_match('!application/([a-z.]+\+)?xml!i', $part->mimetype))) {
$xml = $message->get_part_body($part->mime_id, true); $xml = $message->get_part_body($part->mime_id, true);
@ -607,7 +608,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
$type = $this->type; $type = $this->type;
// copy attachments from old message // copy attachments from old message
$copyfrom = $object['_copyfrom'] ?: $object['_msguid']; $copyfrom = $object['_copyfrom'] ?? ($object['_msguid'] ?? null);
if (!empty($copyfrom) && ($old = $this->cache->get($copyfrom, $type, $object['_mailbox']))) { if (!empty($copyfrom) && ($old = $this->cache->get($copyfrom, $type, $object['_mailbox']))) {
foreach ((array)$old['_attachments'] as $key => $att) { foreach ((array)$old['_attachments'] as $key => $att) {
if (!isset($object['_attachments'][$key])) { if (!isset($object['_attachments'][$key])) {
@ -636,7 +637,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
} }
// process attachments // process attachments
if (is_array($object['_attachments'])) { if (is_array($object['_attachments'] ?? null)) {
$numatt = count($object['_attachments']); $numatt = count($object['_attachments']);
foreach ($object['_attachments'] as $key => $attachment) { foreach ($object['_attachments'] as $key => $attachment) {
// FIXME: kolab_storage and Roundcube attachment hooks use different fields! // FIXME: kolab_storage and Roundcube attachment hooks use different fields!
@ -701,7 +702,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
// update cache with new UID // update cache with new UID
if ($result) { if ($result) {
$old_uid = $object['_msguid']; $old_uid = $object['_msguid'] ?? null;
$object['_msguid'] = $result; $object['_msguid'] = $result;
$object['_mailbox'] = $this->name; $object['_mailbox'] = $this->name;
@ -918,10 +919,11 @@ class kolab_storage_folder extends kolab_storage_folder_api
private function build_message(&$object, $type, $binary, &$body_file) private function build_message(&$object, $type, $binary, &$body_file)
{ {
// load old object to preserve data we don't understand/process // load old object to preserve data we don't understand/process
if (is_object($object['_formatobj'])) $format = null;
if (is_object($object['_formatobj'] ?? null))
$format = $object['_formatobj']; $format = $object['_formatobj'];
else if ($object['_msguid'] && ($old = $this->cache->get($object['_msguid'], $type, $object['_mailbox']))) else if ($object['_msguid'] ?? null && ($old = $this->cache->get($object['_msguid'], $type, $object['_mailbox'] ?? null)))
$format = $old['_formatobj']; $format = $old['_formatobj'] ?? null;
// create new kolab_format instance // create new kolab_format instance
if (!$format) if (!$format)
@ -995,8 +997,10 @@ class kolab_storage_folder extends kolab_storage_folder_api
); );
$part_id++; $part_id++;
$is_file = false;
// save object attachments as separate parts // save object attachments as separate parts
foreach ((array)$object['_attachments'] as $key => $att) { foreach ((array)($object['_attachments'] ?? []) as $key => $att) {
if (empty($att['content']) && !empty($att['id'])) { if (empty($att['content']) && !empty($att['id'])) {
// @TODO: use IMAP CATENATE to skip attachment fetch+push operation // @TODO: use IMAP CATENATE to skip attachment fetch+push operation
$msguid = $object['_copyfrom'] ?: ($object['_msguid'] ?: $object['uid']); $msguid = $object['_copyfrom'] ?: ($object['_msguid'] ?: $object['uid']);

View file

@ -67,7 +67,7 @@ class libkolab extends rcube_plugin
} }
// embed scripts and templates for email message audit trail // embed scripts and templates for email message audit trail
if ($rcmail->task == 'mail' && self::get_bonnie_api()) { if (property_exists($rcmail, 'task') && $rcmail->task == 'mail' && self::get_bonnie_api()) {
if ($rcmail->output->type == 'html') { if ($rcmail->output->type == 'html') {
$this->add_hook('render_page', array($this, 'bonnie_render_page')); $this->add_hook('render_page', array($this, 'bonnie_render_page'));
$this->include_script('libkolab.js'); $this->include_script('libkolab.js');

View file

@ -653,11 +653,11 @@ class tasklist_kolab_driver extends tasklist_driver
} }
} }
if ($filter['since']) { if ($filter['since'] ?? false) {
$query[] = array('changed', '>=', $filter['since']); $query[] = array('changed', '>=', $filter['since']);
} }
if ($filter['uid']) { if ($filter['uid'] ?? false) {
$query[] = array('uid', '=', (array) $filter['uid']); $query[] = array('uid', '=', (array) $filter['uid']);
} }
@ -709,7 +709,7 @@ class tasklist_kolab_driver extends tasklist_driver
$folder = $this->folders[$list_id]; $folder = $this->folders[$list_id];
if (is_numeric($list_id) || !$folder) if (is_numeric($list_id) || !$folder)
continue; continue;
if (!$this->tasks[$id] && ($object = $folder->get_object($id))) { if (!($this->tasks[$id] ?? false) && ($object = $folder->get_object($id))) {
$this->load_tags($object); $this->load_tags($object);
$this->tasks[$id] = $this->_to_rcube_task($object, $list_id); $this->tasks[$id] = $this->_to_rcube_task($object, $list_id);
break; break;
@ -1258,20 +1258,20 @@ class tasklist_kolab_driver extends tasklist_driver
$task = array( $task = array(
'id' => $id_prefix . $record['uid'], 'id' => $id_prefix . $record['uid'],
'uid' => $record['uid'], 'uid' => $record['uid'],
'title' => $record['title'], 'title' => $record['title'] ?? null,
// 'location' => $record['location'], // 'location' => $record['location'],
'description' => $record['description'], 'description' => $record['description'] ?? null,
'flagged' => $record['priority'] == 1, 'flagged' => ($record['priority'] ?? null) == 1,
'complete' => floatval($record['complete'] / 100), 'complete' => floatval(($record['complete'] ?? null) / 100),
'status' => $record['status'], 'status' => $record['status'] ?? null,
'parent_id' => $record['parent_id'] ? $id_prefix . $record['parent_id'] : null, 'parent_id' => ($record['parent_id'] ?? null) ? $id_prefix . $record['parent_id'] : null,
'recurrence' => $record['recurrence'], 'recurrence' => $record['recurrence'] ?? null,
'attendees' => $record['attendees'], 'attendees' => $record['attendees'] ?? null,
'organizer' => $record['organizer'], 'organizer' => $record['organizer'] ?? null,
'sequence' => $record['sequence'], 'sequence' => $record['sequence'] ?? null,
'tags' => $record['tags'], 'tags' => $record['tags'] ?? null,
'list' => $list_id, 'list' => $list_id,
'links' => $record['links'], 'links' => $record['links'] ?? null,
); );
// we can sometimes skip this expensive operation // we can sometimes skip this expensive operation
@ -1280,7 +1280,7 @@ class tasklist_kolab_driver extends tasklist_driver
} }
// convert from DateTime to internal date format // convert from DateTime to internal date format
if ($record['due'] instanceof DateTimeInterface) { if (($record['due'] ?? null) instanceof DateTimeInterface) {
$due = $this->plugin->lib->adjust_timezone($record['due']); $due = $this->plugin->lib->adjust_timezone($record['due']);
$task['date'] = $due->format('Y-m-d'); $task['date'] = $due->format('Y-m-d');
if (empty($record['due']->_dateonly)) { if (empty($record['due']->_dateonly)) {
@ -1288,24 +1288,24 @@ class tasklist_kolab_driver extends tasklist_driver
} }
} }
// convert from DateTime to internal date format // convert from DateTime to internal date format
if ($record['start'] instanceof DateTimeInterface) { if (($record['start'] ?? null) instanceof DateTimeInterface) {
$start = $this->plugin->lib->adjust_timezone($record['start']); $start = $this->plugin->lib->adjust_timezone($record['start']);
$task['startdate'] = $start->format('Y-m-d'); $task['startdate'] = $start->format('Y-m-d');
if (empty($record['start']->_dateonly)) { if (empty($record['start']->_dateonly)) {
$task['starttime'] = $start->format('H:i'); $task['starttime'] = $start->format('H:i');
} }
} }
if ($record['changed'] instanceof DateTimeInterface) { if (($record['changed'] ?? null) instanceof DateTimeInterface) {
$task['changed'] = $record['changed']; $task['changed'] = $record['changed'];
} }
if ($record['created'] instanceof DateTimeInterface) { if (($record['created'] ?? null) instanceof DateTimeInterface) {
$task['created'] = $record['created']; $task['created'] = $record['created'];
} }
if ($record['valarms']) { if ($record['valarms'] ?? false) {
$task['valarms'] = $record['valarms']; $task['valarms'] = $record['valarms'];
} }
else if ($record['alarms']) { else if ($record['alarms'] ?? false) {
$task['alarms'] = $record['alarms']; $task['alarms'] = $record['alarms'];
} }
@ -1320,7 +1320,7 @@ class tasklist_kolab_driver extends tasklist_driver
} }
} }
if (!empty($record['_attachments'])) { if (!empty($record['_attachments'] ?? [])) {
foreach ($record['_attachments'] as $key => $attachment) { foreach ($record['_attachments'] as $key => $attachment) {
if ($attachment !== false) { if ($attachment !== false) {
if (empty($attachment['name'])) { if (empty($attachment['name'])) {
@ -1381,10 +1381,10 @@ class tasklist_kolab_driver extends tasklist_driver
if ($task['complete'] == 1.0 && empty($task['complete'])) if ($task['complete'] == 1.0 && empty($task['complete']))
$object['status'] = 'COMPLETED'; $object['status'] = 'COMPLETED';
if ($task['flagged']) if ($task['flagged'] ?? false)
$object['priority'] = 1; $object['priority'] = 1;
else else
$object['priority'] = $old['priority'] > 1 ? $old['priority'] : 0; $object['priority'] = ($old['priority'] ?? 0) > 1 ? $old['priority'] : 0;
// remove list: prefix from parent_id // remove list: prefix from parent_id
if (!empty($task['parent_id']) && strpos($task['parent_id'], $id_prefix) === 0) { if (!empty($task['parent_id']) && strpos($task['parent_id'], $id_prefix) === 0) {
@ -1448,12 +1448,12 @@ class tasklist_kolab_driver extends tasklist_driver
} }
// email links and tags are stored separately // email links and tags are stored separately
$links = $task['links']; $links = $task['links'] ?? null;
$tags = $task['tags']; $tags = $task['tags'] ?? null;
unset($task['tags'], $task['links']); unset($task['tags'], $task['links']);
// moved from another folder // moved from another folder
if ($task['_fromlist'] && ($fromfolder = $this->get_folder($task['_fromlist']))) { if (($task['_fromlist'] ?? false) && ($fromfolder = $this->get_folder($task['_fromlist']))) {
if (!$fromfolder->move($task['uid'], $folder)) if (!$fromfolder->move($task['uid'], $folder))
return false; return false;
@ -1461,7 +1461,8 @@ class tasklist_kolab_driver extends tasklist_driver
} }
// load previous version of this task to merge // load previous version of this task to merge
if ($task['id']) { $old = null;
if ($task['id'] ?? null) {
$old = $folder->get_object($task['uid']); $old = $folder->get_object($task['uid']);
if (!$old || PEAR::isError($old)) if (!$old || PEAR::isError($old))
return false; return false;

View file

@ -218,7 +218,7 @@ class tasklist_ui
$prop = $data[$id]; $prop = $data[$id];
$is_collapsed = false; // TODO: determine this somehow? $is_collapsed = false; // TODO: determine this somehow?
$content = $this->tasklist_list_item($id, $prop, $jsenv, $attrib['activeonly']); $content = $this->tasklist_list_item($id, $prop, $jsenv, $attrib['activeonly'] ?? null);
if (!empty($folder->children)) { if (!empty($folder->children)) {
$content .= html::tag('ul', array('style' => ($is_collapsed ? "display:none;" : null)), $content .= html::tag('ul', array('style' => ($is_collapsed ? "display:none;" : null)),
@ -294,7 +294,7 @@ class tasklist_ui
} }
$actions .= html::a(['href' => '#', 'class' => 'quickview', 'title' => $this->plugin->gettext('focusview'), 'role' => 'checkbox', 'aria-checked' => 'false'], ' '); $actions .= html::a(['href' => '#', 'class' => 'quickview', 'title' => $this->plugin->gettext('focusview'), 'role' => 'checkbox', 'aria-checked' => 'false'], ' ');
if (isset($prop['subscribed'])) { if (isset($prop['subscribed'])) {
$action .= html::a(['href' => '#', 'class' => 'subscribed', 'title' => $this->plugin->gettext('tasklistsubscribe'), 'role' => 'checkbox', 'aria-checked' => $prop['subscribed'] ? 'true' : 'false'], ' '); $actions .= html::a(['href' => '#', 'class' => 'subscribed', 'title' => $this->plugin->gettext('tasklistsubscribe'), 'role' => 'checkbox', 'aria-checked' => $prop['subscribed'] ? 'true' : 'false'], ' ');
} }
return html::div(join(' ', $classes), return html::div(join(' ', $classes),