From 9f1f754daf4b57a0d0d3aea95d2321716d218cf5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 22 Nov 2015 09:41:53 +0100 Subject: [PATCH] CS fixes --- plugins/acl/acl.php | 2 +- .../attachment_reminder.js | 0 .../attachment_reminder.php | 0 .../database_attachments.php | 2 +- plugins/debug_logger/debug_logger.php | 2 +- plugins/debug_logger/runlog/runlog.php | 2 +- plugins/enigma/lib/enigma_error.php | 7 +- plugins/enigma/lib/enigma_mime_message.php | 2 +- plugins/help/help.php | 5 +- plugins/hide_blockquote/hide_blockquote.php | 4 +- .../http_authentication.php | 2 +- .../managesieve/lib/Roundcube/rcube_sieve.php | 2 +- .../lib/Roundcube/rcube_sieve_engine.php | 8 +- .../lib/Roundcube/rcube_sieve_vacation.php | 6 +- plugins/managesieve/managesieve.php | 2 +- plugins/markasjunk/markasjunk.php | 97 ++++++++++--------- .../redundant_attachments.php | 2 +- .../subscriptions_option.php | 2 +- plugins/userinfo/userinfo.php | 89 +++++++++-------- plugins/zipdownload/zipdownload.php | 4 +- 20 files changed, 119 insertions(+), 121 deletions(-) mode change 100755 => 100644 plugins/attachment_reminder/attachment_reminder.js mode change 100755 => 100644 plugins/attachment_reminder/attachment_reminder.php diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 252668391..8058656f6 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -123,7 +123,7 @@ class acl extends rcube_plugin $group_id = is_array($record[$group_field]) ? $record[$group_field][0] : $record[$group_field]; if ($group) { - $users[] = array('name' => ($prefix ? $prefix : '') . $group_id, 'display' => $group, 'type' => 'group'); + $users[] = array('name' => ($prefix ?: '') . $group_id, 'display' => $group, 'type' => 'group'); $keys[] = $group; } } diff --git a/plugins/attachment_reminder/attachment_reminder.js b/plugins/attachment_reminder/attachment_reminder.js old mode 100755 new mode 100644 diff --git a/plugins/attachment_reminder/attachment_reminder.php b/plugins/attachment_reminder/attachment_reminder.php old mode 100755 new mode 100644 diff --git a/plugins/database_attachments/database_attachments.php b/plugins/database_attachments/database_attachments.php index f3804f3c5..aacafae4e 100644 --- a/plugins/database_attachments/database_attachments.php +++ b/plugins/database_attachments/database_attachments.php @@ -155,7 +155,7 @@ class database_attachments extends filesystem_attachments */ protected function _key($args) { - $uname = $args['path'] ? $args['path'] : $args['name']; + $uname = $args['path'] ?: $args['name']; return $args['group'] . md5(time() . $uname . $_SESSION['user_id']); } diff --git a/plugins/debug_logger/debug_logger.php b/plugins/debug_logger/debug_logger.php index 07190e5a1..c66b8b6ac 100644 --- a/plugins/debug_logger/debug_logger.php +++ b/plugins/debug_logger/debug_logger.php @@ -18,7 +18,7 @@ * @version @package_version@ * @author Ziba Scott * @website http://roundcube.net - * + * * Example: * * config.inc.php: diff --git a/plugins/debug_logger/runlog/runlog.php b/plugins/debug_logger/runlog/runlog.php index 0f43df83b..ae352bd58 100644 --- a/plugins/debug_logger/runlog/runlog.php +++ b/plugins/debug_logger/runlog/runlog.php @@ -130,7 +130,7 @@ class runlog { $this->debug_messages[] = $msg; $this->run_log[] = array( 'type' => 'note', - 'tag' => $tag ? $tag:"text", + 'tag' => $tag ?: 'text', 'value' => htmlentities($msg), 'time' => microtime(true), 'parents' => $this->parent_stack, diff --git a/plugins/enigma/lib/enigma_error.php b/plugins/enigma/lib/enigma_error.php index d5638547d..d5f190b2f 100644 --- a/plugins/enigma/lib/enigma_error.php +++ b/plugins/enigma/lib/enigma_error.php @@ -51,11 +51,6 @@ class enigma_error function getData($name) { - if ($name) { - return $this->data[$name]; - } - else { - return $this->data; - } + return $name ? $this->data[$name] : $this->data; } } diff --git a/plugins/enigma/lib/enigma_mime_message.php b/plugins/enigma/lib/enigma_mime_message.php index 395de8f2b..07afef5bd 100644 --- a/plugins/enigma/lib/enigma_mime_message.php +++ b/plugins/enigma/lib/enigma_mime_message.php @@ -264,7 +264,7 @@ class enigma_mime_message extends Mail_mime { $this->checkParams(); - $eol = !empty($this->build_params['eol']) ? $this->build_params['eol'] : "\r\n"; + $eol = $this->build_params['eol'] ?: "\r\n"; // multipart message: and boundary if (!empty($this->build_params['boundary'])) { diff --git a/plugins/help/help.php b/plugins/help/help.php index 5387c9f35..029ab97cf 100644 --- a/plugins/help/help.php +++ b/plugins/help/help.php @@ -155,9 +155,10 @@ class help extends rcube_plugin private function resolve_language($path) { // resolve language placeholder - $rcmail = rcmail::get_instance(); + $rcmail = rcmail::get_instance(); $langmap = $rcmail->config->get('help_language_map', array('*' => 'en_US')); - $lang = !empty($langmap[$_SESSION['language']]) ? $langmap[$_SESSION['language']] : $langmap['*']; + $lang = $langmap[$_SESSION['language']] ?: $langmap['*']; + return str_replace('%l', $lang, $path); } } diff --git a/plugins/hide_blockquote/hide_blockquote.php b/plugins/hide_blockquote/hide_blockquote.php index 2ad5dd8ac..cf999be67 100644 --- a/plugins/hide_blockquote/hide_blockquote.php +++ b/plugins/hide_blockquote/hide_blockquote.php @@ -59,8 +59,8 @@ class hide_blockquote extends rcube_plugin $input = new html_inputfield(array('name' => '_'.$field_id, 'id' => $field_id, 'size' => 5)); $args['blocks']['main']['options']['hide_blockquote_limit'] = array( - 'title' => $this->gettext('quotelimit'), - 'content' => $input->show($limit ? $limit : '') + 'title' => $this->gettext('quotelimit'), + 'content' => $input->show($limit ?: '') ); return $args; diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php index 39d70153a..d3be5b7f5 100644 --- a/plugins/http_authentication/http_authentication.php +++ b/plugins/http_authentication/http_authentication.php @@ -93,7 +93,7 @@ class http_authentication extends rcube_plugin // We'll set it back on startup (#1486553) rcmail::get_instance()->session->remove('password'); } - + function login($args) { // Redirect to the previous QUERY_STRING diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve.php b/plugins/managesieve/lib/Roundcube/rcube_sieve.php index 898f694a3..2d000fed2 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve.php @@ -111,7 +111,7 @@ class rcube_sieve */ public function error() { - return $this->error ? $this->error : false; + return $this->error ?: false; } /** diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 2e267ebb2..987c63910 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -633,8 +633,8 @@ class rcube_sieve_engine foreach ($sizeitems as $item) $items[] = $item; - $this->form['disabled'] = $_POST['_disabled'] ? true : false; - $this->form['join'] = $join=='allof' ? true : false; + $this->form['disabled'] = !empty($_POST['_disabled']); + $this->form['join'] = $join == 'allof'; $this->form['name'] = $name; $this->form['tests'] = array(); $this->form['actions'] = array(); @@ -1685,7 +1685,7 @@ class rcube_sieve_engine $test = $rule['type']; } else if (in_array($rule['test'], $set)) { - $test = ($rule['not'] ? 'not' : '') . ($rule['type'] ? $rule['type'] : 'is'); + $test = ($rule['not'] ? 'not' : '') . ($rule['type'] ?: 'is'); } else { $test = ($rule['not'] ? 'not' : '') . $rule['test']; @@ -2358,7 +2358,7 @@ class rcube_sieve_engine if (empty($filter['actions'])) { continue; } - $fname = $filter['name'] ? $filter['name'] : "#$i"; + $fname = $filter['name'] ?: "#$i"; $result[] = array( 'id' => $idx, 'name' => $fname, diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php index 13082cd82..932aaaafe 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php @@ -312,7 +312,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine } } - $this->rc->output->show_message($error ? $error : 'managesieve.saveerror', 'error'); + $this->rc->output->show_message($error ?: 'managesieve.saveerror', 'error'); $this->rc->output->send(); } @@ -327,7 +327,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine $seconds_extension = in_array('vacation-seconds', $this->exts); // build FORM tag - $form_id = !empty($attrib['id']) ? $attrib['id'] : 'form'; + $form_id = $attrib['id'] ?: 'form'; $out = $this->rc->output->request_form(array( 'id' => $form_id, 'name' => $form_id, @@ -597,7 +597,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine } } - return $interval ? $interval : ''; + return $interval ?: ''; } /** diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 6643847e7..68d56a1ab 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -239,7 +239,7 @@ class managesieve extends rcube_plugin $include_path .= ini_get('include_path'); set_include_path($include_path); - $class_name = 'rcube_sieve_' . ($type ? $type : 'engine'); + $class_name = 'rcube_sieve_' . ($type ?: 'engine'); $this->engine = new $class_name($this); } diff --git a/plugins/markasjunk/markasjunk.php b/plugins/markasjunk/markasjunk.php index d07b494f8..1f92390e5 100644 --- a/plugins/markasjunk/markasjunk.php +++ b/plugins/markasjunk/markasjunk.php @@ -12,64 +12,67 @@ */ class markasjunk extends rcube_plugin { - public $task = 'mail'; + public $task = 'mail'; - function init() - { - $rcmail = rcmail::get_instance(); + function init() + { + $rcmail = rcmail::get_instance(); - $this->register_action('plugin.markasjunk', array($this, 'request_action')); - $this->add_hook('storage_init', array($this, 'storage_init')); + $this->register_action('plugin.markasjunk', array($this, 'request_action')); + $this->add_hook('storage_init', array($this, 'storage_init')); - if ($rcmail->action == '' || $rcmail->action == 'show') { - $skin_path = $this->local_skin_path(); - $this->include_script('markasjunk.js'); - if (is_file($this->home . "/$skin_path/markasjunk.css")) - $this->include_stylesheet("$skin_path/markasjunk.css"); - $this->add_texts('localization', true); + if ($rcmail->action == '' || $rcmail->action == 'show') { + $skin_path = $this->local_skin_path(); - $this->add_button(array( - 'type' => 'link', - 'label' => 'buttontext', - 'command' => 'plugin.markasjunk', - 'class' => 'button buttonPas junk disabled', - 'classact' => 'button junk', - 'title' => 'buttontitle', - 'domain' => 'markasjunk'), 'toolbar'); - } - } - - function storage_init($args) - { - $flags = array( - 'JUNK' => 'Junk', - 'NONJUNK' => 'NonJunk', - ); + $this->add_texts('localization', true); + $this->include_script('markasjunk.js'); - // register message flags - $args['message_flags'] = array_merge((array)$args['message_flags'], $flags); + if (is_file($this->home . "/$skin_path/markasjunk.css")) { + $this->include_stylesheet("$skin_path/markasjunk.css"); + } - return $args; - } + $this->add_button(array( + 'type' => 'link', + 'label' => 'buttontext', + 'command' => 'plugin.markasjunk', + 'class' => 'button buttonPas junk disabled', + 'classact' => 'button junk', + 'title' => 'buttontitle', + 'domain' => 'markasjunk' + ),'toolbar'); + } + } - function request_action() - { - $this->add_texts('localization'); + function storage_init($args) + { + $flags = array( + 'JUNK' => 'Junk', + 'NONJUNK' => 'NonJunk', + ); - $rcmail = rcmail::get_instance(); - $storage = $rcmail->get_storage(); + // register message flags + $args['message_flags'] = array_merge((array)$args['message_flags'], $flags); - foreach (rcmail::get_uids() as $mbox => $uids) { - $storage->unset_flag($uids, 'NONJUNK', $mbox); - $storage->set_flag($uids, 'JUNK', $mbox); + return $args; } - if (($junk_mbox = $rcmail->config->get('junk_mbox'))) { - $rcmail->output->command('move_messages', $junk_mbox); - } + function request_action() + { + $this->add_texts('localization'); - $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation'); - $rcmail->output->send(); - } + $rcmail = rcmail::get_instance(); + $storage = $rcmail->get_storage(); + foreach (rcmail::get_uids() as $mbox => $uids) { + $storage->unset_flag($uids, 'NONJUNK', $mbox); + $storage->set_flag($uids, 'JUNK', $mbox); + } + + if (($junk_mbox = $rcmail->config->get('junk_mbox'))) { + $rcmail->output->command('move_messages', $junk_mbox); + } + + $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation'); + $rcmail->output->send(); + } } diff --git a/plugins/redundant_attachments/redundant_attachments.php b/plugins/redundant_attachments/redundant_attachments.php index 55ec3befc..52a7ea3be 100644 --- a/plugins/redundant_attachments/redundant_attachments.php +++ b/plugins/redundant_attachments/redundant_attachments.php @@ -90,7 +90,7 @@ class redundant_attachments extends filesystem_attachments */ private function _key($args) { - $uname = $args['path'] ? $args['path'] : $args['name']; + $uname = $args['path'] ?: $args['name']; return $args['group'] . md5(time() . $uname . $_SESSION['user_id']); } diff --git a/plugins/subscriptions_option/subscriptions_option.php b/plugins/subscriptions_option/subscriptions_option.php index 5b926f2af..fa4063135 100644 --- a/plugins/subscriptions_option/subscriptions_option.php +++ b/plugins/subscriptions_option/subscriptions_option.php @@ -61,7 +61,7 @@ class subscriptions_option extends rcube_plugin $rcmail = rcmail::get_instance(); $use_subscriptions = $rcmail->config->get('use_subscriptions'); - $args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']) ? true : false; + $args['prefs']['use_subscriptions'] = isset($_POST['_use_subscriptions']); // if the use_subscriptions preference changes, flush the folder cache if (($use_subscriptions && !isset($_POST['_use_subscriptions'])) || diff --git a/plugins/userinfo/userinfo.php b/plugins/userinfo/userinfo.php index a175563ef..74c099f0d 100644 --- a/plugins/userinfo/userinfo.php +++ b/plugins/userinfo/userinfo.php @@ -6,50 +6,49 @@ */ class userinfo extends rcube_plugin { - public $task = 'settings'; - public $noajax = true; - public $noframe = true; - - function init() - { - $this->add_texts('localization/', array('userinfo')); - $this->register_action('plugin.userinfo', array($this, 'infostep')); - $this->include_script('userinfo.js'); - } - - function infostep() - { - $this->register_handler('plugin.body', array($this, 'infohtml')); - rcmail::get_instance()->output->send('plugin'); - } - - function infohtml() - { - $rcmail = rcmail::get_instance(); - $user = $rcmail->user; - - $table = new html_table(array('cols' => 2, 'cellpadding' => 3)); - - $table->add('title', 'ID'); - $table->add('', rcube::Q($user->ID)); - - $table->add('title', rcube::Q($this->gettext('username'))); - $table->add('', rcube::Q($user->data['username'])); - - $table->add('title', rcube::Q($this->gettext('server'))); - $table->add('', rcube::Q($user->data['mail_host'])); - - $table->add('title', rcube::Q($this->gettext('created'))); - $table->add('', rcube::Q($user->data['created'])); - - $table->add('title', rcube::Q($this->gettext('lastlogin'))); - $table->add('', rcube::Q($user->data['last_login'])); - - $identity = $user->get_identity(); - $table->add('title', rcube::Q($this->gettext('defaultidentity'))); - $table->add('', rcube::Q($identity['name'] . ' <' . $identity['email'] . '>')); - - return html::tag('h4', null, rcube::Q('Infos for ' . $user->get_username())) . $table->show(); - } + public $task = 'settings'; + public $noajax = true; + public $noframe = true; + function init() + { + $this->add_texts('localization/', array('userinfo')); + $this->register_action('plugin.userinfo', array($this, 'infostep')); + $this->include_script('userinfo.js'); + } + + function infostep() + { + $this->register_handler('plugin.body', array($this, 'infohtml')); + rcmail::get_instance()->output->send('plugin'); + } + + function infohtml() + { + $rcmail = rcmail::get_instance(); + $user = $rcmail->user; + $identity = $user->get_identity(); + + $table = new html_table(array('cols' => 2, 'cellpadding' => 3)); + + $table->add('title', 'ID'); + $table->add('', rcube::Q($user->ID)); + + $table->add('title', rcube::Q($this->gettext('username'))); + $table->add('', rcube::Q($user->data['username'])); + + $table->add('title', rcube::Q($this->gettext('server'))); + $table->add('', rcube::Q($user->data['mail_host'])); + + $table->add('title', rcube::Q($this->gettext('created'))); + $table->add('', rcube::Q($user->data['created'])); + + $table->add('title', rcube::Q($this->gettext('lastlogin'))); + $table->add('', rcube::Q($user->data['last_login'])); + + $table->add('title', rcube::Q($this->gettext('defaultidentity'))); + $table->add('', rcube::Q($identity['name'] . ' <' . $identity['email'] . '>')); + + return html::tag('h4', null, rcube::Q('Infos for ' . $user->get_username())) . $table->show(); + } } diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index 983db1227..2928f4978 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -156,7 +156,7 @@ class zipdownload extends rcube_plugin $zip->close(); - $filename = ($message->subject ? $message->subject : 'roundcube') . '.zip'; + $filename = ($message->subject ?: 'roundcube') . '.zip'; $this->_deliver_zipfile($tmpfname, $filename); // delete temporary files from disk @@ -247,7 +247,7 @@ class zipdownload extends rcube_plugin $subject = $this->_convert_filename($subject); $subject = substr($subject, 0, 16); - $disp_name = ($subject ? $subject : 'message_rfc822') . ".eml"; + $disp_name = ($subject ?: 'message_rfc822') . ".eml"; $disp_name = $path . $uid . "_" . $disp_name; $tmpfn = tempnam($temp_dir, 'zipmessage');