diff --git a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php --- a/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php +++ b/plugins/kolab_addressbook/drivers/kolab/kolab_contacts.php @@ -385,7 +385,7 @@ $this->sortindex = array_merge($this->sortindex, $local_sortindex); } } - else if (is_array($this->filter['ids'])) { + else if ($this->filter && is_array($this->filter['ids'])) { $ids = $this->filter['ids']; if (count($ids)) { $uids = array_map(array($this, 'id2uid'), $this->filter['ids']); @@ -1134,13 +1134,13 @@ switch ($this->sort_col) { case 'name': - $str = $rec['name'] . $rec['prefix']; + $str = ($rec['name'] ?? null) . ($rec['prefix'] ?? null); case 'firstname': - $str .= $rec['firstname'] . $rec['middlename'] . $rec['surname']; + $str .= ($rec['firstname'] ?? null) . ($rec['middlename'] ?? null) . ($rec['surname'] ?? null); break; case 'surname': - $str = $rec['surname'] . $rec['firstname'] . $rec['middlename']; + $str = ($rec['surname'] ?? null) . ($rec['firstname'] ?? null) . ($rec['middlename'] ?? null); break; default: @@ -1148,7 +1148,9 @@ break; } - $str .= is_array($rec['email']) ? $rec['email'][0] : $rec['email']; + if ($rec['email'] ?? null) { + $str .= is_array($rec['email']) ? $rec['email'][0] : $rec['email']; + } return mb_strtolower($str); } @@ -1262,7 +1264,7 @@ // convert email, website, phone values foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) { - if (is_array($record[$col])) { + if (is_array($record[$col] ?? null)) { $values = $record[$col]; unset($record[$col]); foreach ((array)$values as $i => $val) { @@ -1272,7 +1274,7 @@ } } - if (is_array($record['address'])) { + if (is_array($record['address'] ?? null)) { $addresses = $record['address']; unset($record['address']); foreach ($addresses as $i => $adr) { @@ -1288,7 +1290,7 @@ } // photo is stored as separate attachment - if ($record['photo'] && strlen($record['photo']) < 255 && !empty($record['_attachments'][$record['photo']])) { + if (($record['photo'] ?? null) && strlen($record['photo']) < 255 && !empty($record['_attachments'][$record['photo']])) { $att = $record['_attachments'][$record['photo']]; // only fetch photo content if requested if ($this->action == 'photo') { diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -240,7 +240,7 @@ $source = $data[$id]; $is_collapsed = strpos($this->rc->config->get('collapsed_abooks',''), '&'.rawurlencode($id).'&') !== false; - if ($folder->virtual) { + if (!empty($folder->virtual)) { $source = $this->driver->abook_prop($folder->id, $folder); } else if (empty($source)) { diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php --- a/plugins/kolab_auth/kolab_auth.php +++ b/plugins/kolab_auth/kolab_auth.php @@ -656,7 +656,7 @@ // User name for identity (first log in) foreach ((array)$name_attr as $field) { - $name = is_array($record[$field]) ? $record[$field][0] : $record[$field]; + $name = is_array($record[$field] ?? null) ? $record[$field][0] : ($record[$field] ?? null); if (!empty($name)) { $this->data['user_name'] = $name; break; diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php --- a/plugins/kolab_files/lib/kolab_files_engine.php +++ b/plugins/kolab_files/lib/kolab_files_engine.php @@ -28,6 +28,7 @@ private $rc; private $url; private $url_srv; + private $filetypes_style; private $timeout = 600; private $files_sort_cols = array('name', 'mtime', 'size'); private $sessions_sort_cols = array('name'); @@ -145,7 +146,7 @@ $this->rc->output->set_env('files_api_version', $caps['VERSION'] ?? 3); $this->rc->output->set_env('files_user', $this->rc->get_user_name()); - if ($caps['DOCEDIT']) { + if ($caps['DOCEDIT'] ?? false) { $this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice', 'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice', 'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment', @@ -729,7 +730,7 @@ { $prefix = 'kolab_' . $type . '_'; $c_prefix = 'kolab_files_' . ($type != 'files' ? $type : '') . '_'; - $skin_path = $_SESSION['skin_path']; + $skin_path = $_SESSION['skin_path'] ?? null; // check to see if we have some settings for sorting $sort_col = $_SESSION[$prefix . 'sort_col']; @@ -789,7 +790,7 @@ 'title' => $this->plugin->gettext('sortby') ), $col_name); } - else if ($col_name[0] != '<') { + else if (empty($col_name) || $col_name[0] != '<') { $col_name = '<span class="' . $col .'">' . $col_name . '</span>'; } @@ -870,7 +871,7 @@ $attrib['id'] = 'filepreviewframe'; } - if ($frame = $this->file_data['viewer']['frame']) { + if ($frame = ($this->file_data['viewer']['frame'] ?? null)) { return $frame; } @@ -895,6 +896,7 @@ $attrib['src'] = $href; $attrib['onload'] = 'kolab_files_frame_load(this)'; + $form = null; // editor requires additional arguments via POST if (!empty($this->file_data['viewer']['post'])) { $attrib['src'] = 'program/resources/blank.gif'; @@ -966,8 +968,8 @@ */ public function get_api_token($configure = true) { - $token = $_SESSION['kolab_files_token']; - $time = $_SESSION['kolab_files_time']; + $token = $_SESSION['kolab_files_token'] ?? null; + $time = $_SESSION['kolab_files_time'] ?? null; if ($token && time() - $this->timeout < $time) { if (time() - $time <= $this->timeout / 2) { @@ -1059,7 +1061,7 @@ } } - if ($_SESSION['kolab_files_caps']['MANTICORE'] || $_SESSION['kolab_files_caps']['WOPI']) { + if (($_SESSION['kolab_files_caps']['MANTICORE'] ?? false) || ($_SESSION['kolab_files_caps']['WOPI'] ?? false)) { $_SESSION['kolab_files_caps']['DOCEDIT'] = true; $_SESSION['kolab_files_caps']['DOCTYPE'] = $_SESSION['kolab_files_caps']['MANTICORE'] ? 'manticore' : 'wopi'; } @@ -1135,8 +1137,8 @@ // Configure session $query = array( 'method' => 'configure', - 'timezone' => $prefs['timezone'] ?: $this->rc->config->get('timezone'), - 'date_format' => $prefs['date_long'] ?: $this->rc->config->get('date_long', 'Y-m-d H:i'), + 'timezone' => $prefs['timezone'] ?? $this->rc->config->get('timezone'), + 'date_format' => $prefs['date_long'] ?? $this->rc->config->get('date_long', 'Y-m-d H:i'), ); $request = $this->get_request($query, $token); @@ -1643,11 +1645,13 @@ $placeholder = $this->rc->output->asset_url('program/resources/blank.gif'); - if ($this->file_data['viewer']['wopi']) { + $editor_type = null; + $got_editor = null; + if ($this->file_data['viewer']['wopi'] ?? false) { $editor_type = 'wopi'; $got_editor = ($viewer & 4); } - else if ($this->file_data['viewer']['manticore']) { + else if ($this->file_data['viewer']['manticore'] ?? false) { $editor_type = 'manticore'; $got_editor = ($viewer & 4); } diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php --- a/plugins/kolab_folders/kolab_folders.php +++ b/plugins/kolab_folders/kolab_folders.php @@ -324,7 +324,7 @@ $ctype = trim(rcube_utils::get_input_value('_ctype', rcube_utils::INPUT_POST)); $subtype = trim(rcube_utils::get_input_value('_subtype', rcube_utils::INPUT_POST)); $mbox = $args['record']['name']; - $old_mbox = $args['record']['oldname']; + $old_mbox = $args['record']['oldname'] ?? null; $subscribe = $args['record']['subscribe']; if (empty($ctype)) { diff --git a/plugins/kolab_notes/kolab_notes.php b/plugins/kolab_notes/kolab_notes.php --- a/plugins/kolab_notes/kolab_notes.php +++ b/plugins/kolab_notes/kolab_notes.php @@ -95,7 +95,7 @@ } // add 'Append note' item to message menu - if ($this->api->output->type == 'html' && $_REQUEST['_rel'] != 'note') { + if ($this->api->output->type == 'html' && ($_REQUEST['_rel'] ?? null) != 'note') { $this->api->add_content(html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array( 'command' => 'append-kolab-note', @@ -112,7 +112,7 @@ } } - if (!$this->rc->output->ajax_call && !$this->rc->output->env['framed']) { + if (!$this->rc->output->ajax_call && !($this->rc->output->env['framed'] ?? null)) { $this->load_ui(); } @@ -243,7 +243,7 @@ 'parent' => $parent_id, ); } - else if ($folder->virtual) { + else if (!empty($folder->virtual)) { $lists[$list_id] = array( 'id' => $list_id, 'name' => $fullname, diff --git a/plugins/libkolab/lib/kolab_ldap.php b/plugins/libkolab/lib/kolab_ldap.php --- a/plugins/libkolab/lib/kolab_ldap.php +++ b/plugins/libkolab/lib/kolab_ldap.php @@ -457,7 +457,7 @@ $entry['displayname'] = rcube_addressbook::compose_search_name( $entry, $entry['email'], - $entry['name'], + $entry['name'] ?? null, $this->conf['kolab_auth_user_displayname'] ); } diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php --- a/plugins/libkolab/lib/kolab_storage.php +++ b/plugins/libkolab/lib/kolab_storage.php @@ -624,7 +624,7 @@ } } - if ($data = $metadata[$folder]) { + if ($data = $metadata[$folder] ?? null) { if (($name = $data[self::NAME_KEY_PRIVATE]) || ($name = $data[self::NAME_KEY_SHARED])) { return $name; } @@ -649,6 +649,7 @@ $found = false; $namespace = self::$imap->get_namespace(); + $prefix = null; if (!empty($namespace['shared'])) { foreach ($namespace['shared'] as $ns) { @@ -910,7 +911,7 @@ // Filter folders list foreach ($folders as $idx => $folder) { - $type = $folderdata[$folder]; + $type = $folderdata[$folder] ?? null; if ($filter == 'mail' && empty($type)) { continue; @@ -964,7 +965,7 @@ $folders = self::$imap->list_folders_subscribed($root, $mbox); // add temporarily subscribed folders - if ($filter != 'mail' && self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'])) { + if ($filter != 'mail' && self::$with_tempsubs && is_array($_SESSION['kolab_subscribed_folders'] ?? null)) { $folders = array_unique(array_merge($folders, $_SESSION['kolab_subscribed_folders'])); } @@ -1695,7 +1696,7 @@ } $token = $folder_id; - if ($domain && strpos($find, '@') === false) { + if ($domain && strpos($token, '@') === false) { $token .= '@' . $domain; } diff --git a/plugins/libkolab/lib/kolab_storage_dav_folder.php b/plugins/libkolab/lib/kolab_storage_dav_folder.php --- a/plugins/libkolab/lib/kolab_storage_dav_folder.php +++ b/plugins/libkolab/lib/kolab_storage_dav_folder.php @@ -440,7 +440,7 @@ if (!is_array($objects)) { rcube::raise_error([ 'code' => 900, - 'message' => "Failed to fetch {$href}" + 'message' => "Failed to fetch {$this->href}" ], true); return false; } diff --git a/plugins/libkolab/lib/kolab_storage_folder_api.php b/plugins/libkolab/lib/kolab_storage_folder_api.php --- a/plugins/libkolab/lib/kolab_storage_folder_api.php +++ b/plugins/libkolab/lib/kolab_storage_folder_api.php @@ -225,7 +225,7 @@ { // color is defined in folder METADATA $metadata = $this->get_metadata(); - if (($color = $metadata[kolab_storage::COLOR_KEY_PRIVATE]) || ($color = $metadata[kolab_storage::COLOR_KEY_SHARED])) { + if (($color = $metadata[kolab_storage::COLOR_KEY_PRIVATE] ?? null) || ($color = $metadata[kolab_storage::COLOR_KEY_SHARED] ?? null)) { return $color; } diff --git a/plugins/libkolab/lib/kolab_storage_folder_virtual.php b/plugins/libkolab/lib/kolab_storage_folder_virtual.php --- a/plugins/libkolab/lib/kolab_storage_folder_virtual.php +++ b/plugins/libkolab/lib/kolab_storage_folder_virtual.php @@ -23,8 +23,6 @@ */ class kolab_storage_folder_virtual extends kolab_storage_folder_api { - public $virtual = true; - protected $displayname; public function __construct($name, $dispname, $ns, $parent = '') @@ -34,6 +32,7 @@ $this->namespace = $ns; $this->parent = $parent; $this->displayname = $dispname; + $this->virtual = true; } /** diff --git a/plugins/libkolab/libkolab.php b/plugins/libkolab/libkolab.php --- a/plugins/libkolab/libkolab.php +++ b/plugins/libkolab/libkolab.php @@ -379,7 +379,7 @@ 'reset-command' => 'non-existing-command', ); - if ($attrib['label-domain'] && !strpos($attrib['buttontitle'], '.')) { + if (($attrib['label-domain'] ?? null) && !strpos($attrib['buttontitle'], '.')) { $attrib['buttontitle'] = $attrib['label-domain'] . '.' . $attrib['buttontitle']; } diff --git a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php --- a/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php +++ b/plugins/tasklist/drivers/kolab/tasklist_kolab_driver.php @@ -150,7 +150,7 @@ 'owner' => $folder->get_owner(), 'parentfolder' => $folder->get_parent(), 'default' => $folder->default, - 'virtual' => $folder->virtual, + 'virtual' => !empty($folder->virtual), 'children' => true, // TODO: determine if that folder indeed has child folders 'subscribed' => (bool)$folder->is_subscribed(), 'removable' => !$folder->default, @@ -224,7 +224,7 @@ 'parent' => $parent_id, ); } - else if ($folder->virtual) { + else if (!empty($folder->virtual)) { $lists[$list_id] = array( 'id' => $list_id, 'name' => $fullname,