Fix PHP8 warnings
This commit is contained in:
parent
2b29e447ba
commit
609336d71f
14 changed files with 79 additions and 58 deletions
|
@ -812,7 +812,7 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
|
||||
// Modify invitation status class name, when invitation calendars are disabled
|
||||
// we'll use opacity only for declined/needs-action events
|
||||
$record['className'] = str_replace('-invitation', '', $record['className']);
|
||||
$record['className'] = str_replace('-invitation', '', $record['className'] ?? '');
|
||||
}
|
||||
|
||||
// add instance identifier to first occurrence (master event)
|
||||
|
|
|
@ -778,14 +778,17 @@ class kolab_contacts extends rcube_addressbook
|
|||
}
|
||||
else {
|
||||
// remove from distribution lists
|
||||
foreach ((array) $this->groupmembers[$id] as $gid) {
|
||||
if (!$is_mailto || $gid == $this->gid) {
|
||||
$this->remove_from_group($gid, $id);
|
||||
if (!empty($this->groupmembers[$id])) {
|
||||
foreach ((array) $this->groupmembers[$id] as $gid) {
|
||||
if (!$is_mailto || $gid == $this->gid) {
|
||||
$this->remove_from_group($gid, $id);
|
||||
}
|
||||
}
|
||||
|
||||
// clear internal cache
|
||||
unset($this->groupmembers[$id]);
|
||||
}
|
||||
|
||||
// clear internal cache
|
||||
unset($this->groupmembers[$id]);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
@ -1398,7 +1401,7 @@ class kolab_contacts extends rcube_addressbook
|
|||
'birthday' => '',
|
||||
'anniversary' => '',
|
||||
'freebusyurl' => '',
|
||||
'photo' => $contact['photo']
|
||||
'photo' => $contact['photo'] ?? null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ class kolab_delegation extends rcube_plugin
|
|||
$delegate = $engine->delegate_get($id);
|
||||
}
|
||||
|
||||
if ($delegate) {
|
||||
if (!empty($delegate)) {
|
||||
$input = new html_hiddenfield(array('name' => $field_id, 'id' => $field_id, 'size' => 40));
|
||||
$input = rcube::Q($delegate['name']) . $input->show($id);
|
||||
|
||||
|
@ -511,7 +511,7 @@ class kolab_delegation extends rcube_plugin
|
|||
$delegate = $engine->delegate_get($id);
|
||||
}
|
||||
|
||||
$folder_data = $engine->list_folders($delegate['uid']);
|
||||
$folder_data = $engine->list_folders(!empty($delegate) ? $delegate['uid'] : null);
|
||||
$use_fieldsets = rcube_utils::get_boolean($attrib['use-fieldsets']);
|
||||
$rights = array();
|
||||
$folder_groups = array();
|
||||
|
@ -521,6 +521,8 @@ class kolab_delegation extends rcube_plugin
|
|||
$rights[$folder_name] = $folder['rights'];
|
||||
}
|
||||
|
||||
$html = '';
|
||||
|
||||
// build block for every folder type
|
||||
foreach ($folder_groups as $type => $group) {
|
||||
if (empty($group)) {
|
||||
|
@ -550,8 +552,8 @@ class kolab_delegation extends rcube_plugin
|
|||
private function delegate_folders_block($a_folders, $attrib, $rights)
|
||||
{
|
||||
$path = 'plugins/kolab_delegation/' . $this->skin_path . '/';
|
||||
$read_ico = $attrib['readicon'] ? html::img(array('src' => $path . $attrib['readicon'], 'title' => $this->gettext('read'))) : '';
|
||||
$write_ico = $attrib['writeicon'] ? html::img(array('src' => $path . $attrib['writeicon'], 'title' => $this->gettext('write'))) : '';
|
||||
$read_ico = !empty($attrib['readicon']) ? html::img(array('src' => $path . $attrib['readicon'], 'title' => $this->gettext('read'))) : '';
|
||||
$write_ico = !empty($attrib['writeicon']) ? html::img(array('src' => $path . $attrib['writeicon'], 'title' => $this->gettext('write'))) : '';
|
||||
|
||||
$table = new html_table(array('cellspacing' => 0, 'class' => 'table-striped'));
|
||||
$table->add_header(array('class' => 'read checkbox-cell', 'title' => $this->gettext('read'), 'tabindex' => 0), $read_ico);
|
||||
|
|
|
@ -38,6 +38,7 @@ class kolab_delegation_engine
|
|||
private $ldap_dn;
|
||||
private $cache = array();
|
||||
private $folder_types = array('mail', 'event', 'task');
|
||||
private $supported;
|
||||
|
||||
const ACL_READ = 1;
|
||||
const ACL_WRITE = 2;
|
||||
|
@ -378,7 +379,7 @@ class kolab_delegation_engine
|
|||
// Definition of read and write ACL
|
||||
$right_types = $this->right_types();
|
||||
|
||||
$delegate_lc = strtolower($delegate);
|
||||
$delegate_lc = strtolower((string) $delegate);
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
// get only folders in personal namespace
|
||||
|
@ -387,8 +388,8 @@ class kolab_delegation_engine
|
|||
}
|
||||
|
||||
$rights = null;
|
||||
$type = $metadata[$folder] ?: 'mail';
|
||||
list($class, $subclass) = explode('.', $type);
|
||||
$type = !empty($metadata[$folder]) ? $metadata[$folder] : 'mail';
|
||||
list($class, $subclass) = strpos($type, '.') ? explode('.', $type) : [$type, ''];
|
||||
|
||||
if (!in_array($class, $this->folder_types)) {
|
||||
continue;
|
||||
|
@ -398,7 +399,7 @@ class kolab_delegation_engine
|
|||
if ($delegate) {
|
||||
// @TODO: cache ACL
|
||||
$imap_acl = $storage->get_acl($folder);
|
||||
if (!empty($imap_acl) && (($acl = $imap_acl[$delegate]) || ($acl = $imap_acl[$delegate_lc]))) {
|
||||
if (!empty($imap_acl) && (($acl = ($imap_acl[$delegate] ?? null)) || ($acl = ($imap_acl[$delegate_lc] ?? null)))) {
|
||||
if ($this->acl_compare($acl, $right_types[self::ACL_WRITE])) {
|
||||
$rights = self::ACL_WRITE;
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@ class kolab_folders extends rcube_plugin
|
|||
/**
|
||||
* Checks if IMAP server supports any of METADATA, ANNOTATEMORE, ANNOTATEMORE2
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
function metadata_support()
|
||||
{
|
||||
|
@ -552,7 +552,13 @@ class kolab_folders extends rcube_plugin
|
|||
*/
|
||||
function get_folder_type($folder)
|
||||
{
|
||||
return explode('.', (string)kolab_storage::folder_type($folder));
|
||||
$type = explode('.', (string)kolab_storage::folder_type($folder));
|
||||
|
||||
if (!isset($type[1])) {
|
||||
$type[1] = null;
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -561,7 +567,7 @@ class kolab_folders extends rcube_plugin
|
|||
* @param string $folder Folder name
|
||||
* @param string $type Content type
|
||||
*
|
||||
* @return boolean True on success
|
||||
* @return bool True on success
|
||||
*/
|
||||
function set_folder_type($folder, $type = 'mail')
|
||||
{
|
||||
|
|
|
@ -484,10 +484,9 @@ class kolab_notes extends rcube_plugin
|
|||
// post-filter search results
|
||||
if (strlen($search)) {
|
||||
$matches = 0;
|
||||
$contents = mb_strtolower(
|
||||
$record['title'] .
|
||||
($this->is_html($record) ? strip_tags($record['description']) : $record['description'])
|
||||
);
|
||||
$desc = $this->is_html($record) ? strip_tags($record['description']) : ($record['description'] ?? '');
|
||||
$contents = mb_strtolower($record['title'] . $desc);
|
||||
|
||||
foreach ($words as $word) {
|
||||
if (mb_strpos($contents, $word) !== false) {
|
||||
$matches++;
|
||||
|
@ -615,7 +614,7 @@ class kolab_notes extends rcube_plugin
|
|||
$action = rcube_utils::get_input_value('_do', rcube_utils::INPUT_POST);
|
||||
$note = rcube_utils::get_input_value('_data', rcube_utils::INPUT_POST, true);
|
||||
|
||||
$success = $silent = false;
|
||||
$success = $silent = $refresh = false;
|
||||
switch ($action) {
|
||||
case 'new':
|
||||
case 'edit':
|
||||
|
@ -1266,7 +1265,9 @@ class kolab_notes extends rcube_plugin
|
|||
private function is_html($note)
|
||||
{
|
||||
// check for opening and closing <html> or <body> tags
|
||||
return (preg_match('/<(html|body)(\s+[a-z]|>)/', $note['description'], $m) && strpos($note['description'], '</'.$m[1].'>') > 0);
|
||||
return !empty($note['description'])
|
||||
&& preg_match('/<(html|body)(\s+[a-z]|>)/', $note['description'], $m)
|
||||
&& strpos($note['description'], '</' . $m[1] . '>') > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -445,7 +445,7 @@ class kolab_tags_engine
|
|||
$class = 'rcube_result_' . ($args['threading'] ? 'thread' : 'index');
|
||||
$result = $args['threading'] ? '* THREAD' : '* SORT';
|
||||
|
||||
$args['result'] = new $class($folder, $result);
|
||||
$args['result'] = new $class($args['folder'] ?? 'INBOX', $result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class kolab_format_configuration extends kolab_format
|
|||
case 'file_driver':
|
||||
$driver = new FileDriver($object['driver'], $object['title']);
|
||||
|
||||
$driver->setEnabled((bool) $object['enabled']);
|
||||
$driver->setEnabled(!empty($object['enabled']));
|
||||
|
||||
foreach ($this->driver_settings_fields as $field) {
|
||||
$value = $object[$field];
|
||||
|
@ -78,7 +78,7 @@ class kolab_format_configuration extends kolab_format
|
|||
break;
|
||||
|
||||
case 'relation':
|
||||
$relation = new Relation(strval($object['name']), strval($object['category']));
|
||||
$relation = new Relation(strval($object['name'] ?? ''), strval($object['category'] ?? ''));
|
||||
|
||||
if (!empty($object['color'])) {
|
||||
$relation->setColor($object['color']);
|
||||
|
|
|
@ -60,8 +60,9 @@ class kolab_format_distributionlist extends kolab_format
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!$seen[$key]++) {
|
||||
if (empty($seen[$key])) {
|
||||
$members->push($m);
|
||||
$seen[$key] = true;
|
||||
}
|
||||
else {
|
||||
// remove dupes for caching
|
||||
|
|
|
@ -239,13 +239,13 @@ class kolab_format_event extends kolab_format_xcal
|
|||
$recurrence_id_format = libkolab::recurrence_id_format($object);
|
||||
$instance_id = $recurrence_id instanceof DateTimeInterface ? $recurrence_id->format($recurrence_id_format) : strval($recurrence_id);
|
||||
|
||||
if ($object['recurrence_date'] instanceof DateTimeInterface) {
|
||||
if (!empty($object['recurrence_date']) && $object['recurrence_date'] instanceof DateTimeInterface) {
|
||||
if ($object['recurrence_date']->format($recurrence_id_format) == $instance_id) {
|
||||
$result = $object;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$result && is_array($object['exceptions'])) {
|
||||
if (!$result && !empty($object['exceptions']) && is_array($object['exceptions'])) {
|
||||
foreach ($object['exceptions'] as $exception) {
|
||||
if ($exception['_instance'] == $instance_id) {
|
||||
$result = $exception;
|
||||
|
|
|
@ -423,14 +423,14 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
|
||||
if (!empty($object['recurrence']['FREQ'])) {
|
||||
$freq = $object['recurrence']['FREQ'];
|
||||
$bysetpos = explode(',', $object['recurrence']['BYSETPOS']);
|
||||
$bysetpos = isset($object['recurrence']['BYSETPOS']) ? explode(',', $object['recurrence']['BYSETPOS']) : [];
|
||||
|
||||
$rr->setFrequency($this->rrule_type_map[$freq]);
|
||||
|
||||
if ($object['recurrence']['INTERVAL'])
|
||||
$rr->setInterval(intval($object['recurrence']['INTERVAL']));
|
||||
|
||||
if ($object['recurrence']['BYDAY']) {
|
||||
if (!empty($object['recurrence']['BYDAY'])) {
|
||||
$byday = new vectordaypos;
|
||||
foreach (explode(',', $object['recurrence']['BYDAY']) as $day) {
|
||||
$occurrence = 0;
|
||||
|
@ -455,31 +455,37 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
$rr->setByday($byday);
|
||||
}
|
||||
|
||||
if ($object['recurrence']['BYMONTHDAY']) {
|
||||
if (!empty($object['recurrence']['BYMONTHDAY'])) {
|
||||
$bymday = new vectori;
|
||||
foreach (explode(',', $object['recurrence']['BYMONTHDAY']) as $day)
|
||||
foreach (explode(',', $object['recurrence']['BYMONTHDAY']) as $day) {
|
||||
$bymday->push(intval($day));
|
||||
}
|
||||
$rr->setBymonthday($bymday);
|
||||
}
|
||||
|
||||
if ($object['recurrence']['BYMONTH']) {
|
||||
if (!empty($object['recurrence']['BYMONTH'])) {
|
||||
$bymonth = new vectori;
|
||||
foreach (explode(',', $object['recurrence']['BYMONTH']) as $month)
|
||||
$bymonth->push(intval($month));
|
||||
$rr->setBymonth($bymonth);
|
||||
}
|
||||
|
||||
if ($object['recurrence']['COUNT'])
|
||||
if (!empty($object['recurrence']['COUNT'])) {
|
||||
$rr->setCount(intval($object['recurrence']['COUNT']));
|
||||
else if ($object['recurrence']['UNTIL'])
|
||||
}
|
||||
else if (!empty($object['recurrence']['UNTIL'])) {
|
||||
$rr->setEnd(self::get_datetime($object['recurrence']['UNTIL'], null, true, $start_tz));
|
||||
}
|
||||
|
||||
if ($rr->isValid()) {
|
||||
// add exception dates (only if recurrence rule is valid)
|
||||
$exdates = new vectordatetime;
|
||||
foreach ((array)$object['recurrence']['EXDATE'] as $exdate)
|
||||
$exdates->push(self::get_datetime($exdate, null, true, $start_tz));
|
||||
$this->obj->setExceptionDates($exdates);
|
||||
if (!empty($object['recurrence']['EXDATE'])) {
|
||||
$exdates = new vectordatetime;
|
||||
foreach ((array)$object['recurrence']['EXDATE'] as $exdate) {
|
||||
$exdates->push(self::get_datetime($exdate, null, true, $start_tz));
|
||||
}
|
||||
$this->obj->setExceptionDates($exdates);
|
||||
}
|
||||
}
|
||||
else {
|
||||
rcube::raise_error(array(
|
||||
|
@ -495,8 +501,9 @@ abstract class kolab_format_xcal extends kolab_format
|
|||
// save recurrence dates (aka RDATE)
|
||||
if (!empty($object['recurrence']['RDATE'])) {
|
||||
$rdates = new vectordatetime;
|
||||
foreach ((array)$object['recurrence']['RDATE'] as $rdate)
|
||||
foreach ((array)$object['recurrence']['RDATE'] as $rdate) {
|
||||
$rdates->push(self::get_datetime($rdate, null, true, $start_tz));
|
||||
}
|
||||
$this->obj->setRecurrenceDates($rdates);
|
||||
}
|
||||
|
||||
|
|
|
@ -1273,7 +1273,7 @@ class kolab_storage
|
|||
if (self::folder_is_subscribed($folder)) {
|
||||
return true;
|
||||
}
|
||||
else if (!is_array($_SESSION['kolab_subscribed_folders']) || !in_array($folder, $_SESSION['kolab_subscribed_folders'])) {
|
||||
else if (empty($_SESSION['kolab_subscribed_folders']) || !in_array($folder, $_SESSION['kolab_subscribed_folders'])) {
|
||||
$_SESSION['kolab_subscribed_folders'][] = $folder;
|
||||
return true;
|
||||
}
|
||||
|
@ -1300,7 +1300,7 @@ class kolab_storage
|
|||
|
||||
// temporary/session subscription
|
||||
if ($temp) {
|
||||
if (is_array($_SESSION['kolab_subscribed_folders']) && ($i = array_search($folder, $_SESSION['kolab_subscribed_folders'])) !== false) {
|
||||
if (!empty($_SESSION['kolab_subscribed_folders']) && ($i = array_search($folder, $_SESSION['kolab_subscribed_folders'])) !== false) {
|
||||
unset($_SESSION['kolab_subscribed_folders'][$i]);
|
||||
}
|
||||
return true;
|
||||
|
@ -1608,7 +1608,7 @@ class kolab_storage
|
|||
$other_ns = rtrim(self::namespace_root('other'), $delimiter);
|
||||
$path_len = count(explode($delimiter, $other_ns));
|
||||
|
||||
foreach ((array)self::list_folders($other_ns . $delimiter, '*', '', $subscribed) as $foldername) {
|
||||
foreach ((array) self::list_folders($other_ns . $delimiter, '*', '', $subscribed) as $foldername) {
|
||||
if ($foldername == 'INBOX') // skip INBOX which is added by default
|
||||
continue;
|
||||
|
||||
|
@ -1622,16 +1622,16 @@ class kolab_storage
|
|||
// truncate folder path to top-level folders of the 'other' namespace
|
||||
$foldername = join($delimiter, array_slice($path, 0, $path_len + 1));
|
||||
|
||||
if (!$folders[$foldername]) {
|
||||
if (empty($folders[$foldername])) {
|
||||
$folders[$foldername] = new kolab_storage_folder_user($foldername, $other_ns);
|
||||
}
|
||||
}
|
||||
|
||||
// for every (subscribed) user folder, list all (unsubscribed) subfolders
|
||||
foreach ($folders as $userfolder) {
|
||||
foreach ((array)self::list_folders($userfolder->name . $delimiter, '*', $type, false, $folderdata) as $foldername) {
|
||||
if (!$folders[$foldername]) {
|
||||
$folders[$foldername] = new kolab_storage_folder($foldername, $type, $folderdata[$foldername]);
|
||||
foreach ((array) self::list_folders($userfolder->name . $delimiter, '*', $type, false, $folderdata) as $foldername) {
|
||||
if (empty($folders[$foldername])) {
|
||||
$folders[$foldername] = new kolab_storage_folder($foldername, $type, $folderdata[$foldername] ?? null);
|
||||
$userfolder->children[] = $folders[$foldername];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -609,7 +609,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
|||
|
||||
// copy attachments from old message
|
||||
$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'])) && !empty($old['_attachments'])) {
|
||||
foreach ((array)$old['_attachments'] as $key => $att) {
|
||||
if (!isset($object['_attachments'][$key])) {
|
||||
$object['_attachments'][$key] = $old['_attachments'][$key];
|
||||
|
@ -1003,7 +1003,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
|||
foreach ((array)($object['_attachments'] ?? []) as $key => $att) {
|
||||
if (empty($att['content']) && !empty($att['id'])) {
|
||||
// @TODO: use IMAP CATENATE to skip attachment fetch+push operation
|
||||
$msguid = $object['_copyfrom'] ?: ($object['_msguid'] ?: $object['uid']);
|
||||
$msguid = !empty($object['_copyfrom']) ? $object['_copyfrom'] : (!empty($object['_msguid']) ? $object['_msguid'] : $object['uid']);
|
||||
if ($is_file) {
|
||||
$att['path'] = tempnam($temp_dir, 'rcmAttmnt');
|
||||
if (($fp = fopen($att['path'], 'w')) && $this->get_attachment($msguid, $att['id'], $object['_mailbox'], false, $fp, true)) {
|
||||
|
|
|
@ -335,15 +335,15 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
$this->_read_lists();
|
||||
|
||||
// create list and folder instance if necesary
|
||||
if (!$this->lists[$id]) {
|
||||
if (empty($this->lists[$id])) {
|
||||
$folder = kolab_storage::get_folder(kolab_storage::id_decode($id));
|
||||
if ($folder->type) {
|
||||
if ($folder && $folder->type) {
|
||||
$this->folders[$id] = $folder;
|
||||
$this->lists[$id] = $this->folder_props($folder, $this->rc->config->get('kolab_tasklists', array()));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->folders[$id];
|
||||
return $this->folders[$id] ?? null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -455,8 +455,8 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
$ret |= $folder->activate(intval($prop['active']));
|
||||
|
||||
// apply to child folders, too
|
||||
if ($prop['recursive']) {
|
||||
foreach ((array)kolab_storage::list_folders($folder->name, '*', 'task') as $subfolder) {
|
||||
if (!empty($prop['recursive'])) {
|
||||
foreach ((array) kolab_storage::list_folders($folder->name, '*', 'task') as $subfolder) {
|
||||
if (isset($prop['permanent']))
|
||||
($prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder));
|
||||
if (isset($prop['active']))
|
||||
|
@ -640,13 +640,13 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
|
||||
// query Kolab storage
|
||||
$query = array();
|
||||
if ($filter['mask'] & tasklist::FILTER_MASK_COMPLETE)
|
||||
if (!empty($filter['mask']) && $filter['mask'] & tasklist::FILTER_MASK_COMPLETE)
|
||||
$query[] = array('tags','~','x-complete');
|
||||
else if (empty($filter['since']))
|
||||
$query[] = array('tags','!~','x-complete');
|
||||
|
||||
// full text search (only works with cache enabled)
|
||||
if ($filter['search']) {
|
||||
if (!empty($filter['search'])) {
|
||||
$search = mb_strtolower($filter['search']);
|
||||
foreach (rcube_utils::normalize_string($search, true) as $word) {
|
||||
$query[] = array('words', '~', $word);
|
||||
|
|
Loading…
Add table
Reference in a new issue