CS improvements

This commit is contained in:
Aleksander Machniak 2023-01-25 15:13:27 +01:00
parent bac56c4cd1
commit 5cca91ab6c
6 changed files with 30 additions and 24 deletions

View file

@ -575,7 +575,7 @@ class kolab_contacts extends rcube_addressbook
$this->_fetch_groups();
$count = count($this->distlists[$this->gid]['member']);
}
else if (is_array($this->filter['ids'])) {
else if (isset($this->filter['ids']) && is_array($this->filter['ids'])) {
$count = count($this->filter['ids']);
}
else {
@ -1134,13 +1134,13 @@ class kolab_contacts extends rcube_addressbook
switch ($this->sort_col) {
case 'name':
$str = ($rec['name'] ?? null) . ($rec['prefix'] ?? null);
$str = ($rec['name'] ?? '') . ($rec['prefix'] ?? '');
case 'firstname':
$str .= ($rec['firstname'] ?? null) . ($rec['middlename'] ?? null) . ($rec['surname'] ?? null);
$str .= ($rec['firstname'] ?? '') . ($rec['middlename'] ?? '') . ($rec['surname'] ?? '');
break;
case 'surname':
$str = ($rec['surname'] ?? null) . ($rec['firstname'] ?? null) . ($rec['middlename'] ?? null);
$str = ($rec['surname'] ?? '') . ($rec['firstname'] ?? '') . ($rec['middlename'] ?? '');
break;
default:
@ -1148,9 +1148,10 @@ class kolab_contacts extends rcube_addressbook
break;
}
if ($rec['email'] ?? null) {
if (!empty($rec['email'])) {
$str .= is_array($rec['email']) ? $rec['email'][0] : $rec['email'];
}
return mb_strtolower($str);
}
@ -1264,7 +1265,7 @@ class kolab_contacts extends rcube_addressbook
// convert email, website, phone values
foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) {
if (is_array($record[$col] ?? null)) {
if (isset($record[$col]) && is_array($record[$col])) {
$values = $record[$col];
unset($record[$col]);
foreach ((array)$values as $i => $val) {
@ -1274,7 +1275,7 @@ class kolab_contacts extends rcube_addressbook
}
}
if (is_array($record['address'] ?? null)) {
if (isset($record['address']) && is_array($record['address'])) {
$addresses = $record['address'];
unset($record['address']);
foreach ($addresses as $i => $adr) {
@ -1290,7 +1291,7 @@ class kolab_contacts extends rcube_addressbook
}
// photo is stored as separate attachment
if (($record['photo'] ?? null) && strlen($record['photo']) < 255 && !empty($record['_attachments'][$record['photo']])) {
if (!empty($record['photo']) && strlen($record['photo']) < 255 && !empty($record['_attachments'][$record['photo']])) {
$att = $record['_attachments'][$record['photo']];
// only fetch photo content if requested
if ($this->action == 'photo') {

View file

@ -664,14 +664,14 @@ class kolab_auth extends rcube_plugin
}
// User email(s) for identity (first log in)
foreach ((array)$email_attr as $field) {
$email = is_array($record[$field]) ? array_filter($record[$field]) : $record[$field];
$email = is_array($record[$field] ?? null) ? array_filter($record[$field]) : ($record[$field] ?? null);
if (!empty($email)) {
$this->data['user_email'] = array_merge((array)($this->data['user_email'] ?? null), (array)$email);
}
}
// Organization name for identity (first log in)
foreach ((array)$org_attr as $field) {
$organization = is_array($record[$field]) ? $record[$field][0] : $record[$field];
$organization = is_array($record[$field] ?? null) ? $record[$field][0] : ($record[$field] ?? null);
if (!empty($organization)) {
$this->data['user_organization'] = $organization;
break;

View file

@ -146,7 +146,7 @@ class kolab_files_engine
$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'] ?? false) {
if (!empty($caps['DOCEDIT'])) {
$this->plugin->add_label('declinednotice', 'invitednotice', 'acceptedownernotice',
'declinedownernotice', 'requestednotice', 'acceptednotice', 'declinednotice',
'more', 'accept', 'decline', 'join', 'status', 'when', 'file', 'comment',
@ -896,7 +896,8 @@ class kolab_files_engine
$attrib['src'] = $href;
$attrib['onload'] = 'kolab_files_frame_load(this)';
$form = null;
$form = '';
// editor requires additional arguments via POST
if (!empty($this->file_data['viewer']['post'])) {
$attrib['src'] = 'program/resources/blank.gif';
@ -1061,9 +1062,9 @@ class kolab_files_engine
}
}
if (($_SESSION['kolab_files_caps']['MANTICORE'] ?? false) || ($_SESSION['kolab_files_caps']['WOPI'] ?? false)) {
if (!empty($_SESSION['kolab_files_caps']['MANTICORE']) || !empty($_SESSION['kolab_files_caps']['WOPI'])) {
$_SESSION['kolab_files_caps']['DOCEDIT'] = true;
$_SESSION['kolab_files_caps']['DOCTYPE'] = $_SESSION['kolab_files_caps']['MANTICORE'] ? 'manticore' : 'wopi';
$_SESSION['kolab_files_caps']['DOCTYPE'] = !empty($_SESSION['kolab_files_caps']['WOPI']) ? 'wopi' : 'manticore';
}
if (!empty($_SESSION['kolab_files_caps']) && !isset($_SESSION['kolab_files_caps']['MOUNTPOINTS'])) {
@ -1647,11 +1648,11 @@ class kolab_files_engine
$editor_type = null;
$got_editor = null;
if ($this->file_data['viewer']['wopi'] ?? false) {
if (!empty($this->file_data['viewer']['wopi'])) {
$editor_type = 'wopi';
$got_editor = ($viewer & 4);
}
else if ($this->file_data['viewer']['manticore'] ?? false) {
else if (!empty($this->file_data['viewer']['manticore'])) {
$editor_type = 'manticore';
$got_editor = ($viewer & 4);
}

View file

@ -112,7 +112,7 @@ class kolab_notes extends rcube_plugin
}
}
if (!$this->rc->output->ajax_call && !($this->rc->output->env['framed'] ?? null)) {
if (!$this->rc->output->ajax_call && empty($this->rc->output->env['framed'])) {
$this->load_ui();
}

View file

@ -616,7 +616,7 @@ class kolab_storage
}
else {
// For performance reasons ask for all folders, it will be cached as one cache entry
$metadata = self::$imap->get_metadata("*", array(self::NAME_KEY_PRIVATE, self::NAME_KEY_SHARED));
$metadata = self::$imap->get_metadata("*", [self::NAME_KEY_PRIVATE, self::NAME_KEY_SHARED]);
// If cache is disabled store result in memory
if (!self::$config->get('imap_cache')) {
@ -643,13 +643,13 @@ class kolab_storage
*
* @return string Name of the folder-object
*/
public static function object_prettyname($folder, &$folder_ns=null)
public static function object_prettyname($folder, &$folder_ns = null)
{
self::setup();
$found = false;
$namespace = self::$imap->get_namespace();
$prefix = null;
$prefix = null;
if (!empty($namespace['shared'])) {
foreach ($namespace['shared'] as $ns) {
@ -701,18 +701,21 @@ class kolab_storage
}
}
if (empty($delim))
if (empty($delim)) {
$delim = self::$imap->get_hierarchy_delimiter();
}
$folder = rcube_charset::convert($folder, 'UTF7-IMAP');
$folder = html::quote($folder);
$folder = str_replace(html::quote($delim), ' &raquo; ', $folder);
if ($prefix)
if ($prefix) {
$folder = html::quote($prefix) . ($folder !== '' ? ' ' . $folder : '');
}
if (!$folder_ns)
if (empty($folder_ns)) {
$folder_ns = 'personal';
}
return $folder;
}
@ -916,6 +919,7 @@ class kolab_storage
if ($filter == 'mail' && empty($type)) {
continue;
}
if (empty($type) || !preg_match($regexp, $type)) {
unset($folders[$idx]);
}

View file

@ -440,7 +440,7 @@ class kolab_storage_dav_folder extends kolab_storage_folder
if (!is_array($objects)) {
rcube::raise_error([
'code' => 900,
'message' => "Failed to fetch {$this->href}"
'message' => "Failed to fetch objects from {$this->href}"
], true);
return false;
}