diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php index ac5d3086..64b3afb1 100644 --- a/plugins/calendar/drivers/kolab/kolab_calendar.php +++ b/plugins/calendar/drivers/kolab/kolab_calendar.php @@ -401,8 +401,8 @@ class kolab_calendar extends kolab_storage_folder_api if (count($partstat_exclude) && !empty($event['attendees'])) { foreach ($event['attendees'] as $attendee) { if ( - in_array($attendee['email'], $user_emails) - && in_array($attendee['status'] ?? null, $partstat_exclude) + !empty($attendee['email']) && in_array($attendee['email'], $user_emails) + && !empty($attendee['status']) && in_array($attendee['status'], $partstat_exclude) ) { return false; } diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php index 10d301d1..e8aaf1c0 100644 --- a/plugins/calendar/drivers/kolab/kolab_driver.php +++ b/plugins/calendar/drivers/kolab/kolab_driver.php @@ -180,7 +180,7 @@ class kolab_driver extends calendar_driver $parents[] = $cal->id; - if (property_exists($cal, "virtual") && $cal->virtual) { + if (!empty($cal->virtual)) { $calendars[$cal->id] = [ 'id' => $cal->id, 'name' => $cal->get_name(), diff --git a/plugins/kolab_activesync/kolab_activesync_ui.php b/plugins/kolab_activesync/kolab_activesync_ui.php index 45122b04..2ef1448a 100644 --- a/plugins/kolab_activesync/kolab_activesync_ui.php +++ b/plugins/kolab_activesync/kolab_activesync_ui.php @@ -27,8 +27,8 @@ class kolab_activesync_ui { private $rc; private $plugin; - private $force_subscriptions = array(); - public $device = array(); + private $force_subscriptions = []; + public $device = []; const SETUP_URL = 'https://kb.kolabenterprise.com/documentation/setting-up-an-activesync-client'; @@ -41,21 +41,21 @@ class kolab_activesync_ui $this->skin_path = 'plugins/kolab_activesync/' . $skin_path; $this->plugin->load_config(); - $this->force_subscriptions = $this->rc->config->get('activesync_force_subscriptions', array()); + $this->force_subscriptions = $this->rc->config->get('activesync_force_subscriptions', []); $this->plugin->include_stylesheet($skin_path . 'config.css'); } - public function device_list($attrib = array()) + public function device_list($attrib = []) { - $attrib += array('id' => 'devices-list'); + $attrib += ['id' => 'devices-list']; $devices = $this->plugin->list_devices(); $table = new html_table(); foreach ($devices as $id => $device) { $name = $device['ALIAS'] ? $device['ALIAS'] : $id; - $table->add_row(array('id' => 'rcmrow' . $id)); + $table->add_row(['id' => 'rcmrow' . $id]); $table->add(null, html::span('devicealias', rcube::Q($name)) . ' ' . html::span('devicetype secondary', rcube::Q($device['TYPE']))); } @@ -69,12 +69,12 @@ class kolab_activesync_ui } - public function device_config_form($attrib = array()) + public function device_config_form($attrib = []) { - $table = new html_table(array('cols' => 2)); + $table = new html_table(['cols' => 2]); $field_id = 'config-device-alias'; - $input = new html_inputfield(array('name' => 'devicealias', 'id' => $field_id, 'size' => 40)); + $input = new html_inputfield(['name' => 'devicealias', 'id' => $field_id, 'size' => 40]); $table->add('title', html::label($field_id, $this->plugin->gettext('devicealias'))); $table->add(null, $input->show($this->device['ALIAS'] ? $this->device['ALIAS'] : $this->device['_id'])); @@ -107,43 +107,41 @@ class kolab_activesync_ui return false; } - public function folder_subscriptions($attrib = array()) + public function folder_subscriptions($attrib = []) { if (!$attrib['id']) { $attrib['id'] = 'foldersubscriptions'; } // group folders by type (show only known types) - $folder_groups = array('mail' => array(), 'contact' => array(), 'event' => array(), 'task' => array(), 'note' => array()); + $folder_groups = ['mail' => [], 'contact' => [], 'event' => [], 'task' => [], 'note' => []]; $folder_types = kolab_storage::folders_typedata(); $use_fieldsets = rcube_utils::get_boolean($attrib['use-fieldsets']); $imei = $this->device['_id']; - $subscribed = array(); + $subscribed = []; if ($imei) { $folder_meta = $this->plugin->folder_meta(); } $devicetype = strtolower($this->device['TYPE']); - $device_force_subscriptions = $this->force_subscriptions[$devicetype] ?? null; + $device_force_subscriptions = $this->force_subscriptions[$devicetype] ?? []; foreach ($this->plugin->list_folders() as $folder) { - if ($folder_types[$folder] ?? null) { + if (!empty($folder_types[$folder])) { list($type, ) = explode('.', $folder_types[$folder]); } else { $type = 'mail'; } - if (is_array($folder_groups[$type] ?? null)) { + if (!empty($folder_groups[$type])) { $folder_groups[$type][] = $folder; if ($device_force_subscriptions && array_key_exists($folder, $device_force_subscriptions)) { - $subscribed[$folder] = intval($device_force_subscriptions[$folder] ?? null); - } else if (!empty($folder_meta) && ($meta = ($folder_meta[$folder] ?? null)) - && ($meta['FOLDER'] ?? false) && $meta['FOLDER'][$imei]['S'] - ) { - $subscribed[$folder] = intval($meta['FOLDER'][$imei]['S']); + $subscribed[$folder] = intval($device_force_subscriptions[$folder]); + } else if (!empty($folder_meta[$folder]['FOLDER'][$imei]['S'])) { + $subscribed[$folder] = intval($folder_meta[$folder]['FOLDER'][$imei]['S']); } } } @@ -176,33 +174,31 @@ class kolab_activesync_ui { $alarms = ($attrib['type'] == 'event' || $attrib['type'] == 'task'); - $table = new html_table(array('cellspacing' => 0, 'class' => 'table-striped')); - $table->add_header(array( + $table = new html_table(['cellspacing' => 0, 'class' => 'table-striped']); + $table->add_header([ 'class' => 'subscription checkbox-cell', 'title' => $this->plugin->gettext('synchronize'), 'tabindex' => 0 - ), - ($attrib['syncicon'] ?? false) ? html::img(array('src' => $this->skin_path . $attrib['syncicon'])) : - $this->plugin->gettext('synchronize') + ], + !empty($attrib['syncicon']) ? html::img(['src' => $this->skin_path . $attrib['syncicon']]) : $this->plugin->gettext('synchronize') ); if ($alarms) { - $table->add_header(array( + $table->add_header([ 'class' => 'alarm checkbox-cell', 'title' => $this->plugin->gettext('withalarms'), 'tabindex' => 0 - ), - ($attrib['alarmicon'] ?? null) ? html::img(array('src' => $this->skin_path . $attrib['alarmicon'])) : - $this->plugin->gettext('withalarms') + ], + !empty($attrib['alarmicon']) ? html::img(['src' => $this->skin_path . $attrib['alarmicon']]) : $this->plugin->gettext('withalarms') ); } $table->add_header('foldername', $this->plugin->gettext('folder')); - $checkbox_sync = new html_checkbox(array('name' => 'subscribed[]', 'class' => 'subscription')); - $checkbox_alarm = new html_checkbox(array('name' => 'alarm[]', 'class' => 'alarm')); + $checkbox_sync = new html_checkbox(['name' => 'subscribed[]', 'class' => 'subscription']); + $checkbox_alarm = new html_checkbox(['name' => 'alarm[]', 'class' => 'alarm']); - $names = array(); + $names = []; foreach ($a_folders as $folder) { $foldername = $origname = kolab_storage::object_prettyname($folder); @@ -219,7 +215,7 @@ class kolab_activesync_ui $folder_id = 'rcmf' . rcube_utils::html_identifier($folder); $names[] = $origname; - $classes = array('mailbox'); + $classes = ['mailbox']; if ($folder_class = $this->rc->folder_classname($folder)) { if ($this->rc->text_exists($folder_class)) { @@ -234,12 +230,12 @@ class kolab_activesync_ui $table->add('subscription checkbox-cell', $checkbox_sync->show( !empty($subscribed[$folder]) ? $folder : null, - array('value' => $folder, 'id' => $folder_id, 'disabled' => $disabled))); + ['value' => $folder, 'id' => $folder_id, 'disabled' => $disabled])); if ($alarms) { $table->add('alarm checkbox-cell', $checkbox_alarm->show( intval($subscribed[$folder] ?? 0) > 1 ? $folder : null, - array('value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled))); + ['value' => $folder, 'id' => $folder_id.'_alarm', 'disabled' => $disabled])); } $table->add(join(' ', $classes), html::label($folder_id, $foldername)); diff --git a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php index 53147f5c..1b02733c 100644 --- a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php +++ b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php @@ -166,7 +166,7 @@ class kolab_contacts extends rcube_addressbook // set localized labels for proprietary cols foreach ($this->coltypes as $col => $prop) { - if (is_string($prop['label'] ?? null)) { + if (!empty($prop['label']) && is_string($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()) { - if (!($contact['uid'] ?? null) && ($contact['ID'] ?? null)) { + if (empty($contact['uid']) && !empty($contact['ID'])) { $contact['uid'] = $this->id2uid($contact['ID']); } - else if (!($contact['uid'] ?? null) && ($old['uid'] ?? null)) { + else if (empty($contact['uid']) && !empty($old['uid'])) { $contact['uid'] = $old['uid']; } @@ -1380,7 +1380,7 @@ class kolab_contacts extends rcube_addressbook // convert one-item-array elements into string element // this is needed e.g. to properly import birthday field foreach ($this->coltypes as $type => $col_def) { - if (($col_def['limit'] ?? null) == 1 && is_array($contact[$type] ?? null)) { + if (($col_def['limit'] ?? 0) == 1 && !empty($contact[$type]) && is_array($contact[$type])) { $contact[$type] = array_shift(array_filter($contact[$type])); } } diff --git a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php index 2f4635fc..0ecedf81 100644 --- a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php +++ b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts_driver.php @@ -242,7 +242,7 @@ class kolab_contacts_driver */ public function abook_prop($id, $abook) { - if (property_exists($abook, 'virtual') && $abook->virtual) { + if (!empty($abook->virtual)) { return [ 'id' => $id, 'name' => $abook->get_name(), diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index 2c239979..6e34b973 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -471,7 +471,7 @@ class kolab_addressbook extends rcube_plugin public function contact_form($p) { // none of our business - if (!is_object($GLOBALS['CONTACTS'] ?? null) || !is_a($GLOBALS['CONTACTS'], 'kolab_contacts')) { + if (empty($GLOBALS['CONTACTS']) || !($GLOBALS['CONTACTS'] instanceof kolab_contacts)) { return $p; } diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php index 7c8e9c0d..311a8695 100644 --- a/plugins/kolab_files/lib/kolab_files_engine.php +++ b/plugins/kolab_files/lib/kolab_files_engine.php @@ -923,7 +923,7 @@ class kolab_files_engine */ public function quota_display($attrib) { - if (!($attrib['id'] ?? false)) { + if (empty($attrib['id'])) { $attrib['id'] = 'rcmquotadisplay'; } @@ -1078,7 +1078,7 @@ class kolab_files_engine { $url = $this->url_srv . '/api/'; - if (!property_exists($this, "request") || !$this->request) { + if (empty($this->request)) { $config = array( 'store_body' => true, 'follow_redirects' => true, diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php index b9b9f914..e68c436a 100644 --- a/plugins/kolab_folders/kolab_folders.php +++ b/plugins/kolab_folders/kolab_folders.php @@ -159,7 +159,9 @@ class kolab_folders extends rcube_plugin // Add type-based style for table rows // See kolab_folders::folder_class_name() - if ($table = ($args['table'] ?? null)) { + if (!empty($args['table'])) { + $table = $args['table']; + for ($i=1, $cnt=$table->size(); $i<=$cnt; $i++) { $attrib = $table->get_row_attribs($i); $folder = $attrib['foldername']; // UTF7-IMAP @@ -176,8 +178,8 @@ class kolab_folders extends rcube_plugin } // Add type-based class for list items - if (is_array($args['list'] ?? null)) { - foreach ((array)$args['list'] as $k => $item) { + if (!empty($args['list']) && is_array($args['list'])) { + foreach ($args['list'] as $k => $item) { $folder = $item['folder_imap']; // UTF7-IMAP $type = $folderdata[$folder] ?? null; @@ -597,14 +599,13 @@ class kolab_folders extends rcube_plugin */ static function folder_class_name($type) { - list($ctype, $subtype) = array_pad(explode('.', $type), 2, null); + if ($type && strpos($type, '.')) { + list($ctype, $subtype) = explode('.', $type); - $class[] = 'type-' . ($ctype ? $ctype : 'mail'); + return 'type-' . $ctype . ' subtype-' . $subtype; + } - if ($subtype) - $class[] = 'subtype-' . $subtype; - - return implode(' ', $class); + return 'type-' . ($type ? $type : 'mail'); } /** @@ -745,7 +746,7 @@ class kolab_folders extends rcube_plugin $value = $storage->get_metadata($folder, $this->expire_annotation); if (is_array($value)) { - return ($value[$folder] ?? false) ? intval($value[$folder][$this->expire_annotation]) : 0; + return !empty($value[$folder]) ? intval($value[$folder][$this->expire_annotation] ?? 0) : 0; } return false; diff --git a/plugins/kolab_notes/kolab_notes.php b/plugins/kolab_notes/kolab_notes.php index a73d17a4..b0674f86 100644 --- a/plugins/kolab_notes/kolab_notes.php +++ b/plugins/kolab_notes/kolab_notes.php @@ -540,7 +540,7 @@ class kolab_notes extends rcube_plugin // deliver from in-memory cache $key = $list_id . ':' . $uid; - if ($this->cache[$key] ?? false) { + if (!empty($this->cache[$key])) { return $this->cache[$key]; } @@ -732,7 +732,7 @@ class kolab_notes extends rcube_plugin return false; // moved from another folder - if (($note['_fromlist'] ?? false) && ($fromfolder = $this->get_folder($note['_fromlist']))) { + if (!empty($note['_fromlist']) && ($fromfolder = $this->get_folder($note['_fromlist']))) { if (!$fromfolder->move($note['uid'], $folder->name)) return false; @@ -741,7 +741,7 @@ class kolab_notes extends rcube_plugin // load previous version of this record to merge $old = null; - if ($note['uid']) { + if (!empty($note['uid'])) { $old = $folder->get_object($note['uid']); if (!$old || PEAR::isError($old)) return false; @@ -1407,7 +1407,7 @@ class kolab_notes extends rcube_plugin } // make list of categories unique - if (is_array($object['tags'] ?? null)) { + if (!empty($object['tags'])) { $object['tags'] = array_unique(array_filter($object['tags'])); } diff --git a/plugins/kolab_notes/kolab_notes_ui.php b/plugins/kolab_notes/kolab_notes_ui.php index 2d3ad12d..855f3352 100644 --- a/plugins/kolab_notes/kolab_notes_ui.php +++ b/plugins/kolab_notes/kolab_notes_ui.php @@ -76,13 +76,14 @@ class kolab_notes_ui public function folders($attrib) { $attrib += array('id' => 'rcmkolabnotebooks'); + $is_select = ($attrib['type'] ?? null) == 'select'; - if (($attrib['type'] ?? null) == 'select') { + if ($is_select) { $attrib['is_escaped'] = true; $select = new html_select($attrib); } - $tree = ($attrib['type'] ?? null) != 'select' ? true : null; + $tree = $is_select ? true : null; $lists = $this->plugin->get_lists($tree); $jsenv = array(); @@ -94,12 +95,12 @@ class kolab_notes_ui foreach ($lists as $prop) { $id = $prop['id']; - if (!$prop['virtual']) { + if (empty($prop['virtual'])) { unset($prop['user_id']); $jsenv[$id] = $prop; } - if ($attrib['type'] == 'select') { + if ($is_select) { if ($prop['editable'] || strpos($prop['rights'], 'i') !== false) { $select->add($prop['name'], $prop['id']); } @@ -115,7 +116,7 @@ class kolab_notes_ui $this->rc->output->set_env('kolab_notebooks', $jsenv); $this->rc->output->add_gui_object('notebooks', $attrib['id']); - return ($attrib['type'] ?? null) == 'select' ? $select->show() : html::tag('ul', $attrib, $html, html::$common_attrib); + return $is_select ? $select->show() : html::tag('ul', $attrib, $html, html::$common_attrib); } /** @@ -139,7 +140,7 @@ class kolab_notes_ui if (strlen($content)) { $out .= html::tag('li', array( 'id' => 'rcmliknb' . rcube_utils::html_identifier($id), - 'class' => $prop['group'] . (($prop['virtual'] ?? false) ? ' virtual' : ''), + 'class' => $prop['group'] . (!empty($prop['virtual']) ? ' virtual' : ''), ), $content); } @@ -153,13 +154,13 @@ class kolab_notes_ui */ public function folder_list_item($id, $prop, &$jsenv, $checkbox = false) { - if (!($prop['virtual'] ?? false)) { + if (empty($prop['virtual'])) { unset($prop['user_id']); $jsenv[$id] = $prop; } $classes = array('folder'); - if ($prop['virtual'] ?? false) { + if (!empty($prop['virtual'])) { $classes[] = 'virtual'; } else if (!$prop['editable']) { @@ -172,21 +173,21 @@ class kolab_notes_ui $classes[] = $prop['class']; } - $title = $prop['title'] ?? ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ? + $title = !empty($prop['title']) ? $prop['title'] : ($prop['name'] != $prop['listname'] || strlen($prop['name']) > 25 ? html_entity_decode($prop['name'], ENT_COMPAT, RCUBE_CHARSET) : ''); $label_id = 'nl:' . $id; - $attr = ($prop['virtual'] ?? false) ? array('tabindex' => '0') : array('href' => $this->rc->url(array('_list' => $id))); + $attr = !empty($prop['virtual']) ? array('tabindex' => '0') : array('href' => $this->rc->url(array('_list' => $id))); return html::div(join(' ', $classes), html::a($attr + array('class' => 'listname', 'title' => $title, 'id' => $label_id), $prop['listname'] ?: $prop['name']) . - (($prop['virtual'] ?? false) ? '' : + (!empty($prop['virtual']) ? '' : ($checkbox ? html::tag('input', array('type' => 'checkbox', 'name' => '_list[]', 'value' => $id, 'checked' => $prop['active'], 'aria-labelledby' => $label_id)) : '' ) . html::span('handle', '') . html::span('actions', - (!$prop['default'] ? + (empty($prop['default']) ? html::a(array('href' => '#', 'class' => 'remove', 'title' => $this->plugin->gettext('removelist')), ' ') : '' ) . diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php index 8e8194c0..efd7a7be 100644 --- a/plugins/libkolab/lib/kolab_format.php +++ b/plugins/libkolab/lib/kolab_format.php @@ -417,7 +417,7 @@ abstract class kolab_format protected function update_uid() { // get generated UID - if (!($this->data['uid'] ?? null)) { + if (empty($this->data['uid'])) { if ($this->xmlobject) { $this->data['uid'] = $this->xmlobject->getSerializedUID(); } @@ -541,13 +541,14 @@ abstract class kolab_format { $this->init(); - if (!empty($object['uid'])) + if (!empty($object['uid'])) { $this->obj->setUid($object['uid']); + } // set some automatic values if missing if (method_exists($this->obj, 'setCreated')) { // Always set created date to workaround libkolabxml (>1.1.4) bug - $created = $object['created'] ?? new DateTime('now'); + $created = !empty($object['created']) ? $object['created'] : new DateTime('now'); $created->setTimezone(new DateTimeZone('UTC')); // must be UTC $this->obj->setCreated(self::get_datetime($created)); $object['created'] = $created; diff --git a/plugins/libkolab/lib/kolab_format_configuration.php b/plugins/libkolab/lib/kolab_format_configuration.php index 7d7bba4a..c0979c25 100644 --- a/plugins/libkolab/lib/kolab_format_configuration.php +++ b/plugins/libkolab/lib/kolab_format_configuration.php @@ -80,19 +80,19 @@ class kolab_format_configuration extends kolab_format case 'relation': $relation = new Relation(strval($object['name']), strval($object['category'])); - if ($object['color'] ?? false) { + if (!empty($object['color'])) { $relation->setColor($object['color']); } - if ($object['parent'] ?? false) { + if (!empty($object['parent'])) { $relation->setParent($object['parent']); } - if ($object['iconName'] ?? false) { + if (!empty($object['iconName'])) { $relation->setIconName($object['iconName']); } - if (($object['priority'] ?? 0) > 0) { + if (!empty($object['priority'])) { $relation->setPriority((int) $object['priority']); } - if (!empty($object['members'] ?? null)) { + if (!empty($object['members'])) { $relation->setMembers(self::array2vector($object['members'])); } @@ -106,7 +106,7 @@ class kolab_format_configuration extends kolab_format foreach ((array)($object['snippets'] ?? []) as $item) { $snippet = new snippet($item['name'], $item['text']); $snippet->setTextType(strtolower($item['type']) == 'html' ? Snippet::HTML : Snippet::Plain); - if ($item['shortcut'] ?? false) { + if (!empty($item['shortcut'])) { $snippet->setShortCut($item['shortcut']); } diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php index ac5be839..bf82aa03 100644 --- a/plugins/libkolab/lib/kolab_format_contact.php +++ b/plugins/libkolab/lib/kolab_format_contact.php @@ -113,16 +113,16 @@ class kolab_format_contact extends kolab_format // organisation related properties (affiliation) $org = new Affiliation; $offices = new vectoraddress; - if ($object['organization'] ?? null) + if (!empty($object['organization'])) $org->setOrganisation($object['organization']); - if ($object['department'] ?? null) + if (!empty($object['department'])) $org->setOrganisationalUnits(self::array2vector($object['department'])); - if ($object['profession'] ?? null) + if (!empty($object['profession'])) $org->setRoles(self::array2vector($object['profession'])); $rels = new vectorrelated; foreach (array('manager','assistant') as $field) { - if (!empty($object[$field] ?? null)) { + if (!empty($object[$field])) { $reltype = $this->relatedmap[$field]; foreach ((array)$object[$field] as $value) { $rels->push(new Related(Related::Text, $value, $reltype)); @@ -160,17 +160,17 @@ class kolab_format_contact extends kolab_format $type = $this->addresstypes[$address['type']]; if (isset($type)) $adr->setTypes($type); - else if ($address['type'] ?? null) + else if (!empty($address['type'])) $adr->setLabel($address['type']); - if ($address['street'] ?? null) + if (!empty($address['street'])) $adr->setStreet($address['street']); - if ($address['locality'] ?? null) + if (!empty($address['locality'])) $adr->setLocality($address['locality']); - if ($address['code'] ?? null) + if (!empty($address['code'])) $adr->setCode($address['code']); - if ($address['region'] ?? null) + if (!empty($address['region'])) $adr->setRegion($address['region']); - if ($address['country'] ?? null) + if (!empty($address['country'])) $adr->setCountry($address['country']); if (($address['type'] ?? null) == 'office') @@ -210,7 +210,7 @@ class kolab_format_contact extends kolab_format if (isset($object['anniversary'])) $this->obj->setAnniversary(self::get_datetime($object['anniversary'], false, true)); - if (!empty($object['photo'] ?? null)) { + if (!empty($object['photo'])) { if ($type = rcube_mime::image_content_type($object['photo'])) $this->obj->setPhoto($object['photo'], $type); } @@ -230,7 +230,7 @@ class kolab_format_contact extends kolab_format } } // add other relateds - if (is_array($object['related'] ?? null)) { + if (!empty($object['related']) && is_array($object['related'])) { foreach ($object['related'] as $value) { $rels->push(new Related(Related::Text, $value)); } @@ -248,8 +248,8 @@ class kolab_format_contact extends kolab_format $pkcs7_index = $i; } - $pgpkey = ($object['pgppublickey'] ?? false) ? new Key($object['pgppublickey'], Key::PGP) : new Key(); - $pkcs7key = ($object['pkcs7publickey'] ?? false) ? new Key($object['pkcs7publickey'], Key::PKCS7_MIME) : new Key(); + $pgpkey = !empty($object['pgppublickey']) ? new Key($object['pgppublickey'], Key::PGP) : new Key(); + $pkcs7key = !empty($object['pkcs7publickey']) ? new Key($object['pkcs7publickey'], Key::PKCS7_MIME) : new Key(); if ($pgp_index >= 0) $keys->set($pgp_index, $pgpkey); diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php index ad5e8b71..d9d4127f 100644 --- a/plugins/libkolab/lib/kolab_format_event.php +++ b/plugins/libkolab/lib/kolab_format_event.php @@ -67,18 +67,18 @@ class kolab_format_event extends kolab_format_xcal $status = kolabformat::StatusUndefined; if ($object['free_busy'] == 'tentative') $status = kolabformat::StatusTentative; - if ($object['cancelled'] ?? false) + if (!empty($object['cancelled'])) $status = kolabformat::StatusCancelled; - else if ($object['status'] && array_key_exists($object['status'], $this->status_map)) + else if (!empty($object['status']) && array_key_exists($object['status'], $this->status_map)) $status = $this->status_map[$object['status']]; $this->obj->setStatus($status); // save (recurrence) exceptions - if (is_array($object['recurrence'] ?? null) && is_array($object['recurrence']['EXCEPTIONS'] ?? null) && !isset($object['exceptions'])) { + if (!empty($object['recurrence']['EXCEPTIONS']) && !isset($object['exceptions'])) { $object['exceptions'] = $object['recurrence']['EXCEPTIONS']; } - if (is_array($object['exceptions'] ?? null)) { + if (!empty($object['exceptions'])) { $recurrence_id_format = libkolab::recurrence_id_format($object); $vexceptions = new vectorevent; foreach ($object['exceptions'] as $i => $exception) { @@ -112,12 +112,13 @@ class kolab_format_event extends kolab_format_xcal } } - if (($object['recurrence_date'] ?? false) && $object['recurrence_date'] instanceof DateTimeInterface) { - if ($object['recurrence'] ?? false) { + if (!empty($object['recurrence_date']) && $object['recurrence_date'] instanceof DateTimeInterface) { + if (!empty($object['recurrence'])) { // unset recurrence_date for master events with rrule $object['recurrence_date'] = null; } - $this->obj->setRecurrenceID(self::get_datetime($object['recurrence_date'], null, $object['allday']), (bool)$object['thisandfuture']); + $recid = self::get_datetime($object['recurrence_date'], null, !empty($object['allday'])); + $this->obj->setRecurrenceID($recid, !empty($object['thisandfuture'])); } // cache this data @@ -216,7 +217,7 @@ class kolab_format_event extends kolab_format_xcal $object['exceptions'] = $recurrence_exceptions; // also link with recurrence.EXCEPTIONS for compatibility - if (is_array($object['recurrence'] ?? null)) { + if (!empty($object['recurrence']) && isset($object['exceptions'])) { $object['recurrence']['EXCEPTIONS'] = &$object['exceptions']; } } diff --git a/plugins/libkolab/lib/kolab_format_file.php b/plugins/libkolab/lib/kolab_format_file.php index ba182d3c..b4739b61 100644 --- a/plugins/libkolab/lib/kolab_format_file.php +++ b/plugins/libkolab/lib/kolab_format_file.php @@ -48,7 +48,7 @@ class kolab_format_file extends kolab_format } // Add file attachment - if (!empty($object['_attachments'] ?? null)) { + if (!empty($object['_attachments'])) { $cid = key($object['_attachments']); $attach_attr = $object['_attachments'][$cid]; $attach = new Attachment; @@ -98,7 +98,7 @@ class kolab_format_file extends kolab_format * * @return array Config object data as hash array */ - public function to_array($data = array()) + public function to_array($data = []) { // return cached result if (!empty($this->data)) { @@ -109,10 +109,10 @@ class kolab_format_file extends kolab_format $object = parent::to_array($data); // read object properties - $object += array( + $object += [ 'categories' => self::vector2array($this->obj->categories()), 'notes' => $this->obj->note(), - ); + ]; return $this->data = $object; } @@ -124,19 +124,17 @@ class kolab_format_file extends kolab_format */ public function get_tags() { - $tags = array(); + $tags = []; - foreach ((array)($this->data['categories'] ?? null) as $cat) { + foreach ((array)($this->data['categories'] ?? []) as $cat) { $tags[] = rcube_utils::normalize_string($cat); } // Add file mimetype to tags - if (!empty($this->data['_attachments'] ?? null)) { - reset($this->data['_attachments']); - $key = key($this->data['_attachments']); - $attachment = $this->data['_attachments'][$key]; + if (!empty($this->data['_attachments'])) { + $attachment = $this->data['_attachments'][array_key_first($this->data['_attachments'])]; - if ($attachment['mimetype'] ?? false) { + if (!empty($attachment['mimetype'])) { $tags[] = $attachment['mimetype']; } } diff --git a/plugins/libkolab/lib/kolab_format_note.php b/plugins/libkolab/lib/kolab_format_note.php index b279eb23..e1ba16fa 100644 --- a/plugins/libkolab/lib/kolab_format_note.php +++ b/plugins/libkolab/lib/kolab_format_note.php @@ -124,20 +124,24 @@ class kolab_format_note extends kolab_format { $data = ''; foreach (self::$fulltext_cols as $col) { + if (empty($this->data[$col])) { + continue; + } + // convert HTML content to plain text if ($col == 'description' && preg_match('/<(html|body)(\s[a-z]|>)/', $this->data[$col], $m) && strpos($this->data[$col], '')) { - $converter = new rcube_html2text($this->data[$col] ?? null, false, false, 0); + $converter = new rcube_html2text($this->data[$col], false, false, 0); $val = $converter->get_text(); } else { - $val = is_array($this->data[$col] ?? null) ? join(' ', $this->data[$col] ?? null) : ($this->data[$col] ?? null); + $val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col]; } - if (strlen($val)) + if (strlen($val)) { $data .= $val . ' '; + } } return array_filter(array_unique(rcube_utils::normalize_string($data, true))); } - } diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php index 25fc6ace..398c8da4 100644 --- a/plugins/libkolab/lib/kolab_format_task.php +++ b/plugins/libkolab/lib/kolab_format_task.php @@ -58,12 +58,16 @@ class kolab_format_task extends kolab_format_xcal $status = kolabformat::StatusUndefined; if ($object['complete'] == 100 && !array_key_exists('status', $object)) $status = kolabformat::StatusCompleted; - else if ($object['status'] && array_key_exists($object['status'], $this->status_map)) + else if (!empty($object['status']) && array_key_exists($object['status'], $this->status_map)) $status = $this->status_map[$object['status']]; $this->obj->setStatus($status); - $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, null, ($object['due'] ?? null) ? $object['due']->_dateonly : null)); + if (!empty($object['start'])) { + $this->obj->setStart(self::get_datetime($object['start'], null, !empty($object['start']->_dateonly))); + } + if (!empty($object['due'])) { + $this->obj->setDue(self::get_datetime($object['due'], null, !empty($object['due']->_dateonly))); + } $related = new vectors; if (!empty($object['parent_id'])) @@ -76,7 +80,7 @@ class kolab_format_task extends kolab_format_xcal } /** - * + * Check if the object is valid */ public function is_valid() { @@ -123,7 +127,7 @@ class kolab_format_task extends kolab_format_xcal */ public function get_reference_date() { - if ($this->data['due'] && $this->data['due'] instanceof DateTimeInterface) { + if (!empty($this->data['due']) && $this->data['due'] instanceof DateTimeInterface) { return $this->data['due']; } @@ -143,10 +147,10 @@ class kolab_format_task extends kolab_format_xcal if (($object['status'] ?? null) == 'COMPLETED' || (($object['complete'] ?? null) == 100 && empty($object['status'] ?? null))) $tags[] = 'x-complete'; - if (($object['priority'] ?? 0) == 1) + if (!empty($object['priority'])) $tags[] = 'x-flagged'; - if ($object['parent_id'] ?? false) + if (!empty($object['parent_id'])) $tags[] = 'x-parent:' . $object['parent_id']; return array_unique($tags); diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php index b8b4513f..2ddeff63 100644 --- a/plugins/libkolab/lib/kolab_format_xcal.php +++ b/plugins/libkolab/lib/kolab_format_xcal.php @@ -420,7 +420,7 @@ abstract class kolab_format_xcal extends kolab_format $rr = new RecurrenceRule; $rr->setFrequency(RecurrenceRule::FreqNone); - if (($object['recurrence'] ?? null) && !empty($object['recurrence']['FREQ'])) { + if (!empty($object['recurrence']['FREQ'])) { $freq = $object['recurrence']['FREQ']; $bysetpos = explode(',', $object['recurrence']['BYSETPOS']); @@ -502,7 +502,7 @@ abstract class kolab_format_xcal extends kolab_format // save alarm(s) $valarms = new vectoralarm; $valarm_hashes = array(); - if ($object['valarms'] ?? null) { + if (!empty($object['valarms'])) { foreach ($object['valarms'] as $valarm) { if (!array_key_exists($valarm['action'], $this->alarm_type_map)) { continue; // skip unknown alarm types @@ -577,7 +577,7 @@ abstract class kolab_format_xcal extends kolab_format } } // legacy support - else if ($object['alarms'] ?? null) { + else if (!empty($object['alarms'])) { list($offset, $type) = explode(":", $object['alarms']); if ($type == 'EMAIL' && !empty($object['_owner'])) { // email alarms implicitly go to event owner @@ -638,14 +638,18 @@ abstract class kolab_format_xcal extends kolab_format foreach (self::$fulltext_cols as $colname) { list($col, $field) = array_pad(explode(':', $colname), 2, null); + if (empty($object[$col])) { + continue; + } + if ($field) { $a = array(); - foreach ((array)($object[$col] ?? []) as $attr) + foreach ((array) $object[$col] as $attr) $a[] = $attr[$field]; $val = join(' ', $a); } else { - $val = is_array($object[$col] ?? null) ? join(' ', $object[$col]) : $object[$col] ?? null; + $val = is_array($object[$col]) ? join(' ', $object[$col]) : $object[$col]; } if (strlen($val)) @@ -655,7 +659,7 @@ abstract class kolab_format_xcal extends kolab_format $words = rcube_utils::normalize_string($data, true); // collect words from recurrence exceptions - if (is_array($object['exceptions'] ?? null)) { + if (!empty($object['exceptions'])) { foreach ($object['exceptions'] as $exception) { $words = array_merge($words, $this->get_words($exception)); } @@ -674,12 +678,12 @@ abstract class kolab_format_xcal extends kolab_format $tags = array(); $object = $obj ?: $this->data; - if (!empty($object['valarms'] ?? null)) { + if (!empty($object['valarms'])) { $tags[] = 'x-has-alarms'; } // create tags reflecting participant status - if (is_array($object['attendees'] ?? null)) { + if (!empty($object['attendees'])) { foreach ($object['attendees'] as $attendee) { if (!empty($attendee['email']) && !empty($attendee['status'])) $tags[] = 'x-partstat:' . $attendee['email'] . ':' . strtolower($attendee['status']); @@ -687,14 +691,14 @@ abstract class kolab_format_xcal extends kolab_format } // collect tags from recurrence exceptions - if (is_array($object['exceptions'] ?? null)) { + if (!empty($object['exceptions'])) { foreach ($object['exceptions'] as $exception) { $tags = array_merge($tags, $this->get_tags($exception)); } } if (!empty($object['status'])) { - $tags[] = 'x-status:' . strtolower($object['status']); + $tags[] = 'x-status:' . strtolower($object['status']); } return array_unique($tags); @@ -713,14 +717,14 @@ abstract class kolab_format_xcal extends kolab_format $reschedule = false; if (!is_array($old)) { - $old = $this->data['uid'] ? $this->data : $this->to_array(); + $old = !empty($this->data['uid']) ? $this->data : $this->to_array(); } foreach ($this->_scheduling_properties ?: self::$scheduling_properties as $prop) { $a = $old[$prop] ?? null; $b = $object[$prop] ?? null; - if (($object['allday'] ?? false) + if (!empty($object['allday']) && ($prop == 'start' || $prop == 'end') && $a instanceof DateTimeInterface && $b instanceof DateTimeInterface diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php index 13db9b5b..1ef2138e 100644 --- a/plugins/libkolab/lib/kolab_storage.php +++ b/plugins/libkolab/lib/kolab_storage.php @@ -129,7 +129,7 @@ class kolab_storage $config = self::$config->get($name); } - if (self::$ldap[$name] ?? false) { + if (!empty(self::$ldap[$name])) { return self::$ldap[$name]; } diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php index 22e9140c..a559d7cf 100644 --- a/plugins/libkolab/lib/kolab_storage_cache.php +++ b/plugins/libkolab/lib/kolab_storage_cache.php @@ -1079,11 +1079,11 @@ class kolab_storage_cache */ protected function _unserialize($sql_arr) { - if (($sql_arr['fast-mode'] ?? false) && !empty($sql_arr['data']) && ($object = json_decode($sql_arr['data'], true))) { + if (!empty($sql_arr['fast-mode']) && !empty($sql_arr['data']) && ($object = json_decode($sql_arr['data'], true))) { $object['uid'] = $sql_arr['uid']; foreach ($this->data_props as $prop) { - if (isset($object[$prop]) && is_array($object[$prop]) && isset($object[$prop]['cl']) && $object[$prop]['cl'] == 'DateTime') { + if (!empty($object[$prop]['cl']) && $object[$prop]['cl'] == 'DateTime') { $object[$prop] = new DateTime($object[$prop]['dt'], new DateTimeZone($object[$prop]['tz'])); } else if (!isset($object[$prop]) && isset($sql_arr[$prop])) { @@ -1099,9 +1099,9 @@ class kolab_storage_cache $object['changed'] = new DateTime($sql_arr['changed']); } - $object['_type'] = $sql_arr['type'] ?? $this->folder->type; - $object['_msguid'] = $sql_arr['msguid']; - $object['_mailbox'] = $this->folder->name; + $object['_type'] = !empty($sql_arr['type']) ? $sql_arr['type'] : $this->folder->type; + $object['_msguid'] = $sql_arr['msguid']; + $object['_mailbox'] = $this->folder->name; } // Fetch object xml else { diff --git a/plugins/libkolab/lib/kolab_storage_cache_contact.php b/plugins/libkolab/lib/kolab_storage_cache_contact.php index ab39ef7f..754bdd3e 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_contact.php +++ b/plugins/libkolab/lib/kolab_storage_cache_contact.php @@ -37,22 +37,26 @@ class kolab_storage_cache_contact extends kolab_storage_cache $sql_data = parent::_serialize($object); $sql_data['type'] = $object['_type']; - // columns for sorting - $sql_data['name'] = rcube_charset::clean(($object['name'] ?? null) . ($object['prefix'] ?? null)); - $sql_data['firstname'] = rcube_charset::clean(($object['firstname'] ?? null) . ($object['middlename'] ?? null) . ($object['surname'] ?? null)); - $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'] ?? null) ? $object['email'][0] : ($object['email'] ?? null)); + $email = is_array($object['email'] ?? null) ? $object['email'][0] : ($object['email'] ?? ''); - if (is_array($sql_data['email'] ?? null)) { - $sql_data['email'] = $sql_data['email']['address']; + // columns for sorting + $sql_data['name'] = rcube_charset::clean(($object['name'] ?? '') . ($object['prefix'] ?? '')); + $sql_data['firstname'] = rcube_charset::clean(($object['firstname'] ?? '') . ($object['middlename'] ?? '') . ($object['surname'] ?? '')); + $sql_data['surname'] = rcube_charset::clean(($object['surname'] ?? '') . ($object['firstname'] ?? '') . ($object['middlename'] ?? '')); + + if (is_array($email)) { + $sql_data['email'] = $email['address'] ?? ''; + } + else { + $sql_data['email'] = rcube_charset::clean($email); } // avoid value being null - if (empty($sql_data['email'] ?? null)) { + if (empty($sql_data['email'])) { $sql_data['email'] = ''; } // use organization if name is empty - if (empty($sql_data['name'] ?? null) && !empty($object['organization'] ?? null)) { + if (empty($sql_data['name']) && !empty($object['organization'])) { $sql_data['name'] = rcube_charset::clean($object['organization']); } diff --git a/plugins/libkolab/lib/kolab_storage_cache_event.php b/plugins/libkolab/lib/kolab_storage_cache_event.php index 625b10fe..94b81f17 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_event.php +++ b/plugins/libkolab/lib/kolab_storage_cache_event.php @@ -39,14 +39,14 @@ class kolab_storage_cache_event extends kolab_storage_cache $sql_data['dtend'] = $this->_convert_datetime($object['end'] ?? null); // extend date range for recurring events - if ($object['recurrence'] ?? null) { + if (!empty($object['recurrence'])) { $recurrence = new kolab_date_recurrence($object['_formatobj']); $dtend = $recurrence->end() ?: new DateTime('now +100 years'); $sql_data['dtend'] = $this->_convert_datetime($dtend); } // extend start/end dates to spawn all exceptions - if (is_array($object['exceptions'] ?? null)) { + if (!empty($object['exceptions'])) { foreach ($object['exceptions'] as $exception) { if (($exception['start'] ?? null) instanceof DateTimeInterface) { $exstart = $this->_convert_datetime($exception['start']); diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php index 64d305ab..76ffaf30 100644 --- a/plugins/libkolab/lib/kolab_storage_config.php +++ b/plugins/libkolab/lib/kolab_storage_config.php @@ -256,7 +256,7 @@ class kolab_storage_config } // find folder object - if ($object['_mailbox'] ?? false) { + if (!empty($object['_mailbox'])) { foreach ($this->folders as $folder) { if ($folder->name == $object['_mailbox']) { break; @@ -676,9 +676,9 @@ class kolab_storage_config // assign links to objects foreach ((array) $relation['members'] as $member) { - if (($id = ($ids[$member] ?? null)) !== null) { - foreach ($id as $i) { - $records[$i]['links'] = array_unique(array_merge($records[$i]['links'], $members)); + if (!empty($ids[$member])) { + foreach ($ids[$member] as $i) { + $records[$i]['links'] = array_unique(array_merge($records[$i]['links'] ?? [], $members)); } } } diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php index 6cf7d1b8..56abbf21 100644 --- a/plugins/libkolab/lib/kolab_storage_folder.php +++ b/plugins/libkolab/lib/kolab_storage_folder.php @@ -197,7 +197,7 @@ class kolab_storage_folder extends kolab_storage_folder_api { $fdata = $this->get_imap_data(); $this->check_error(); - return sprintf('%d-%d-%d', $fdata['UIDVALIDITY'] ?? null, $fdata['HIGHESTMODSEQ'] ?? null, $fdata['UIDNEXT'] ?? null); + return sprintf('%d-%d-%d', $fdata['UIDVALIDITY'] ?? 0, $fdata['HIGHESTMODSEQ'] ?? 0, $fdata['UIDNEXT'] ?? 0); } /** @@ -637,7 +637,7 @@ class kolab_storage_folder extends kolab_storage_folder_api } // process attachments - if (is_array($object['_attachments'] ?? null)) { + if (!empty($object['_attachments'])) { $numatt = count($object['_attachments']); foreach ($object['_attachments'] as $key => $attachment) { // FIXME: kolab_storage and Roundcube attachment hooks use different fields! @@ -922,7 +922,7 @@ class kolab_storage_folder extends kolab_storage_folder_api $format = null; if (is_object($object['_formatobj'] ?? null)) $format = $object['_formatobj']; - else if ($object['_msguid'] ?? null && ($old = $this->cache->get($object['_msguid'], $type, $object['_mailbox'] ?? null))) + else if (!empty($object['_msguid']) && ($old = $this->cache->get($object['_msguid'], $type, $object['_mailbox'] ?? null))) $format = $old['_formatobj'] ?? null; // create new kolab_format instance diff --git a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php index b1eea3e0..8f65ffdc 100644 --- a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php +++ b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php @@ -653,11 +653,11 @@ class tasklist_kolab_driver extends tasklist_driver } } - if ($filter['since'] ?? false) { + if (!empty($filter['since'])) { $query[] = array('changed', '>=', $filter['since']); } - if ($filter['uid'] ?? false) { + if (!empty($filter['uid'])) { $query[] = array('uid', '=', (array) $filter['uid']); } @@ -709,7 +709,7 @@ class tasklist_kolab_driver extends tasklist_driver $folder = $this->folders[$list_id]; if (is_numeric($list_id) || !$folder) continue; - if (!($this->tasks[$id] ?? false) && ($object = $folder->get_object($id))) { + if (empty($this->tasks[$id]) && ($object = $folder->get_object($id))) { $this->load_tags($object); $this->tasks[$id] = $this->_to_rcube_task($object, $list_id); break; @@ -1302,10 +1302,10 @@ class tasklist_kolab_driver extends tasklist_driver $task['created'] = $record['created']; } - if ($record['valarms'] ?? false) { + if (!empty($record['valarms'])) { $task['valarms'] = $record['valarms']; } - else if ($record['alarms'] ?? false) { + else if (!empty($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) { if ($attachment !== false) { if (empty($attachment['name'])) { @@ -1381,7 +1381,7 @@ class tasklist_kolab_driver extends tasklist_driver if ($task['complete'] == 1.0 && empty($task['complete'])) $object['status'] = 'COMPLETED'; - if ($task['flagged'] ?? false) + if (!empty($task['flagged'])) $object['priority'] = 1; else $object['priority'] = ($old['priority'] ?? 0) > 1 ? $old['priority'] : 0; @@ -1462,7 +1462,7 @@ class tasklist_kolab_driver extends tasklist_driver // load previous version of this task to merge $old = null; - if ($task['id'] ?? null) { + if (!empty($task['id'])) { $old = $folder->get_object($task['uid']); if (!$old || PEAR::isError($old)) return false; diff --git a/plugins/tasklist/tasklist_ui.php b/plugins/tasklist/tasklist_ui.php index 6d36149c..24d388ba 100644 --- a/plugins/tasklist/tasklist_ui.php +++ b/plugins/tasklist/tasklist_ui.php @@ -45,14 +45,14 @@ class tasklist_ui } // add taskbar button - $this->plugin->add_button(array( + $this->plugin->add_button([ 'command' => 'tasks', 'class' => 'button-tasklist', 'classsel' => 'button-tasklist button-selected', 'innerclass' => 'button-inner', 'label' => 'tasklist.navtitle', 'type' => 'link' - ), 'taskbar'); + ], 'taskbar'); $this->plugin->include_stylesheet($this->plugin->local_skin_path() . '/tasklist.css'); @@ -92,11 +92,11 @@ class tasklist_ui } $identity['emails'][] = $this->rc->user->get_username(); - $settings['identity'] = array( + $settings['identity'] = [ 'name' => $identity['name'], 'email' => strtolower($identity['email']), 'emails' => ';' . strtolower(join(';', $identity['emails'])) - ); + ]; if ($list = rcube_utils::get_input_value('_list', rcube_utils::INPUT_GPC)) { $settings['selected_list'] = $list; @@ -218,18 +218,18 @@ class tasklist_ui $prop = $data[$id]; $is_collapsed = false; // TODO: determine this somehow? - $content = $this->tasklist_list_item($id, $prop, $jsenv, $attrib['activeonly'] ?? null); + $content = $this->tasklist_list_item($id, $prop, $jsenv, !empty($attrib['activeonly'])); if (!empty($folder->children)) { - $content .= html::tag('ul', array('style' => ($is_collapsed ? "display:none;" : null)), + $content .= html::tag('ul', ['style' => ($is_collapsed ? "display:none;" : null)], $this->list_tree_html($folder, $data, $jsenv, $attrib)); } if (strlen($content)) { - $out .= html::tag('li', array( + $out .= html::tag('li', [ 'id' => 'rcmlitasklist' . rcube_utils::html_identifier($id), 'class' => $prop['group'] . ($prop['virtual'] ? ' virtual' : ''), - ), + ], $content); } } @@ -277,13 +277,13 @@ class tasklist_ui $classes[] = $prop['class']; } - if (!$activeonly || $prop['active']) { + if (!$activeonly || !empty($prop['active'])) { $label_id = 'tl:' . $id; $chbox = html::tag('input', array( 'type' => 'checkbox', 'name' => '_list[]', 'value' => $id, - 'checked' => $prop['active'], + 'checked' => !empty($prop['active']), 'title' => $this->plugin->gettext('activate'), 'aria-labelledby' => $label_id )); @@ -514,16 +514,16 @@ class tasklist_ui /** * */ - function edit_attendees_notify($attrib = array()) + function edit_attendees_notify($attrib = []) { - $checkbox = new html_checkbox(array('name' => '_notify', 'id' => 'edit-attendees-donotify', 'value' => 1, 'class' => 'pretty-checkbox')); + $checkbox = new html_checkbox(['name' => '_notify', 'id' => 'edit-attendees-donotify', 'value' => 1, 'class' => 'pretty-checkbox']); return html::div($attrib, html::label(null, $checkbox->show(1) . ' ' . $this->plugin->gettext('sendnotifications'))); } /** * Form for uploading and importing tasks */ - function tasks_import_form($attrib = array()) + function tasks_import_form($attrib = []) { if (empty($attrib['id'])) { $attrib['id'] = 'rcmImportForm'; @@ -572,33 +572,33 @@ class tasklist_ui /** * Form to select options for exporting tasks */ - function tasks_export_form($attrib = array()) + function tasks_export_form($attrib = []) { if (empty($attrib['id'])) { $attrib['id'] = 'rcmTaskExportForm'; } $html = html::div('form-section form-group row', - html::label(array('for' => 'task-export-list', 'class' => 'col-sm-4 col-form-label'), $this->plugin->gettext('list')) - . html::div('col-sm-8', $this->tasklist_select(array( + html::label(['for' => 'task-export-list', 'class' => 'col-sm-4 col-form-label'], $this->plugin->gettext('list')) + . html::div('col-sm-8', $this->tasklist_select([ 'name' => 'source', 'id' => 'task-export-list', - 'extra' => array('' => '- ' . $this->plugin->gettext('currentview') . ' -'), - ))) + 'extra' => ['' => '- ' . $this->plugin->gettext('currentview') . ' -'], + ])) ); - $checkbox = new html_checkbox(array('name' => 'attachments', 'id' => 'task-export-attachments', 'value' => 1, 'class' => 'form-check-input pretty-checkbox')); + $checkbox = new html_checkbox(['name' => 'attachments', 'id' => 'task-export-attachments', 'value' => 1, 'class' => 'form-check-input pretty-checkbox']); $html .= html::div('form-section row form-check', - html::label(array('for' => 'task-export-attachments', 'class' => 'col-sm-4 col-form-label'), $this->plugin->gettext('exportattachments')) + html::label(['for' => 'task-export-attachments', 'class' => 'col-sm-4 col-form-label'], $this->plugin->gettext('exportattachments')) . html::div('col-sm-8', $checkbox->show(1)) ); $this->register_gui_object('exportform', $attrib['id']); - return html::tag('form', array( - 'action' => $this->rc->url(array('task' => 'tasklist', 'action' => 'export')), + return html::tag('form', [ + 'action' => $this->rc->url(['task' => 'tasklist', 'action' => 'export']), 'method' => 'post', 'id' => $attrib['id'] - ), + ], $html ); }