CS fixes, mostly around undefined variables

pull/7371/head
Aleksander Machniak 5 years ago
parent f0f6234a1a
commit 014659b600

@ -50,6 +50,8 @@ class rcmail extends rcube
public $action = '';
public $comm_path = './';
public $filename = '';
public $default_skin;
public $login_error;
private $address_books = array();
private $action_map = array();
@ -207,10 +209,12 @@ class rcmail extends rcube
{
$contacts = null;
$ldap_config = (array)$this->config->get('ldap_public');
$default = false;
// 'sql' is the alias for '0' used by autocomplete
if ($id == 'sql')
if ($id == 'sql') {
$id = '0';
}
else if ($id == -1) {
$id = $this->config->get('default_addressbook');
$default = true;
@ -559,17 +563,20 @@ class rcmail extends rcube
// parse $host URL
$a_host = parse_url($host);
if ($a_host['host']) {
$ssl = false;
if (!empty($a_host['host'])) {
$host = $a_host['host'];
$ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
if (!empty($a_host['port']))
if (!empty($a_host['port'])) {
$port = $a_host['port'];
else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143))
}
else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) {
$port = 993;
}
}
if (!$port) {
if (empty($port)) {
$port = $default_port;
}
@ -941,12 +948,13 @@ class rcmail extends rcube
if (function_exists('memory_get_usage')) {
$mem = round(memory_get_usage() / 1024 /1024, 1);
}
if (function_exists('memory_get_peak_usage')) {
$mem .= '/'. round(memory_get_peak_usage() / 1024 / 1024, 1);
if (function_exists('memory_get_peak_usage')) {
$mem .= '/'. round(memory_get_peak_usage() / 1024 / 1024, 1);
}
}
$log = $this->task . ($this->action ? '/'.$this->action : '') . ($mem ? " [$mem]" : '');
$log = $this->task . ($this->action ? '/'.$this->action : '') . (isset($mem) ? " [$mem]" : '');
if (defined('RCMAIL_START')) {
self::print_timer(RCMAIL_START, $log);
@ -1336,10 +1344,12 @@ class rcmail extends rcube
// strftime() format
if (preg_match('/%[a-z]+/i', $format)) {
$format = strftime($format, $timestamp);
if ($stz) {
if (isset($stz)) {
date_default_timezone_set($stz);
}
return $today ? ($this->gettext('today') . ' ' . $format) : $format;
return !empty($today) ? ($this->gettext('today') . ' ' . $format) : $format;
}
// parse format string manually in order to provide localized weekday and month names
@ -1378,7 +1388,7 @@ class rcmail extends rcube
}
}
if ($today) {
if (!empty($today)) {
$label = $this->gettext('today');
// replcae $ character with "Today" label (#1486120)
if (strpos($out, '$') !== false) {
@ -1389,7 +1399,7 @@ class rcmail extends rcube
}
}
if ($stz) {
if (isset($stz)) {
date_default_timezone_set($stz);
}
@ -1423,13 +1433,13 @@ class rcmail extends rcube
// get current folder
$storage = $this->get_storage();
$mbox_name = $storage->get_folder();
$delimiter = $storage->get_hierarchy_delimiter();
// build the folders tree
if (empty($a_mailboxes)) {
// get mailbox list
$a_folders = $storage->list_folders_subscribed(
'', $attrib['folder_name'], $attrib['folder_filter']);
$delimiter = $storage->get_hierarchy_delimiter();
$a_mailboxes = array();
foreach ($a_folders as $folder) {
@ -1461,6 +1471,7 @@ class rcmail extends rcube
$out = $select->show($attrib['default']);
}
else {
$out = '';
$js_mailboxlist = array();
$tree = $this->render_folder_tree_html($a_mailboxes, $mbox_name, $js_mailboxlist, $attrib);
@ -2028,7 +2039,7 @@ class rcmail extends rcube
$params['prefix'] = false;
}
if ($error) {
if (!empty($error)) {
if ($suffix && $this->text_exists($error . $suffix)) {
$error .= $suffix;
}
@ -2296,7 +2307,7 @@ class rcmail extends rcube
if ($imgtype = $image->resize($thumbnail_size, $cache_file, true)) {
$mimetype = 'image/' . $imgtype;
if ($orig_name) {
if (!empty($orig_name)) {
unlink($orig_name);
}
}

@ -31,6 +31,8 @@ class rcmail_install
public $is_post = false;
public $failures = 0;
public $config = array();
public $defaults = array();
public $comments = array();
public $configured = false;
public $legacy_config = false;
public $email_pattern = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9])';
@ -133,6 +135,9 @@ class rcmail_install
return;
}
$config = array();
$rcmail_config = array(); // deprecated var name
include $file;
// read comments from config file
@ -158,12 +163,7 @@ class rcmail_install
}
}
// deprecated name of config variable
if (is_array($rcmail_config)) {
return $rcmail_config;
}
return $config;
return array_merge(array(), (array) $rcmail_config, (array) $config);
}
/**
@ -507,9 +507,10 @@ class rcmail_install
*/
private function db_read_schema($schemafile, &$version = null)
{
$lines = file($schemafile);
$schema = array();
$keywords = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN');
$lines = file($schemafile);
$schema = array();
$keywords = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN');
$table_name = null;
foreach ($lines as $line) {
if (preg_match('/^\s*create table ([\S]+)/i', $line, $m)) {

@ -694,6 +694,7 @@ EOF;
{
$plugin = false;
$realname = $name;
$skin_dir = '';
$plugin_skin_paths = array();
$this->template_name = $realname;
@ -804,6 +805,7 @@ EOF;
{
$out = '';
$parent_commands = 0;
$parent_prefix = '';
$top_commands = array();
// these should be always on top,
@ -1439,7 +1441,7 @@ EOF;
$key = 'name';
$param = 'content';
}
else if ($object == 'links') {
else {
$source = 'link_tags';
$tag = 'link';
$key = 'rel';
@ -1719,6 +1721,8 @@ EOF;
}
$out = '';
$btn_content = null;
$link_attrib = array();
// generate image tag
if ($attrib['type'] == 'image') {
@ -1776,7 +1780,7 @@ EOF;
$out = html::tag($attrib['wrapper'], null, $out);
}
if ($menuitem) {
if (!empty($menuitem)) {
$class = $attrib['menuitem-class'] ? ' class="' . $attrib['menuitem-class'] . '"' : '';
$out = '<li role="menuitem"' . $class . '>' . $out . '</li>';
}
@ -1967,7 +1971,7 @@ EOF;
}
// add css files in head, before scripts, for speed up with parallel downloads
if (!empty($this->css_files) && !$is_empty
if (!empty($this->css_files) && empty($is_empty)
&& (($pos = stripos($output, '<script ')) || ($pos = stripos($output, '</head>')))
) {
$css = '';
@ -2043,6 +2047,8 @@ EOF;
*/
public function form_tag($attrib, $content = null)
{
$hidden = '';
if ($this->env['extwin']) {
$hiddenfield = new html_hiddenfield(array('name' => '_extwin', 'value' => '1'));
$hidden = $hiddenfield->show();
@ -2168,6 +2174,7 @@ EOF;
$input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'required' => 'required')
+ $attrib + $pass_attrib);
$input_host = null;
$hide_host = false;
if (is_array($default_host) && count($default_host) > 1) {
$input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
@ -2304,10 +2311,14 @@ EOF;
}
if (!empty($attrib['wrapper'])) {
$header = html::tag($attrib['ariatag'] ?: 'h2', array(
'id' => 'aria-label-' . $attrib['label'],
'class' => 'voice'
), rcube::Q($this->app->gettext('arialabel' . $attrib['label'], $attrib['label-domain'])));
$options_button = '';
$header_label = $this->app->gettext('arialabel' . $attrib['label'], $attrib['label-domain']);
$header_attrs = array(
'id' => 'aria-label-' . $attrib['label'],
'class' => 'voice'
);
$header = html::tag($attrib['ariatag'] ?: 'h2', $header_attrs, rcube::Q($header_label));
if ($attrib['options']) {
$options_button = $this->button(array(

@ -31,7 +31,8 @@ class rcmail_sendmail
public $options = array();
protected $parse_data = array();
protected $compose_form;
protected $message_form;
protected $rcmail;
// define constants for message compose mode
const MODE_REPLY = 'reply';
@ -121,6 +122,7 @@ class rcmail_sendmail
$from = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST, true, $charset);
$replyto = rcube_utils::get_input_value('_replyto', rcube_utils::INPUT_POST, true, $charset);
$followupto = rcube_utils::get_input_value('_followupto', rcube_utils::INPUT_POST, true, $charset);
$from_string = '';
// Get sender name and address from identity...
if (is_numeric($from)) {
@ -177,7 +179,7 @@ class rcmail_sendmail
'Bcc' => $mailbcc,
'Subject' => trim($subject),
'Reply-To' => $this->email_input_format($replyto),
'Mail-Reply-To' => $headers['Reply-To'],
'Mail-Reply-To' => $this->email_input_format($replyto),
'Mail-Followup-To' => $this->email_input_format($followupto),
'In-Reply-To' => $this->data['reply_msgid'],
'References' => $this->data['references'],
@ -370,7 +372,9 @@ class rcmail_sendmail
public function deliver_message($message, $disconnect = true)
{
// Handle Delivery Status Notification request
$smtp_opts = array('dsn' => $this->options['dsn_enabled']);
$smtp_opts = array('dsn' => $this->options['dsn_enabled']);
$smtp_error = null;
$mailbody_file = null;
$sent = $this->rcmail->deliver_message($message,
$this->options['from'],
@ -436,6 +440,10 @@ class rcmail_sendmail
*/
public function save_message($message)
{
$store_folder = false;
$store_target = null;
$saved = false;
// Determine which folder to save message
if ($this->options['savedraft']) {
$store_target = $this->rcmail->config->get('drafts_mbox');
@ -812,8 +820,12 @@ class rcmail_sendmail
{
list($form_start,) = $this->form_tags($attrib);
$out = '';
$part = strtolower($attrib['part']);
$out = '';
$part = strtolower($attrib['part']);
$fname = null;
$field_type = null;
$allow_attrib = array();
$param = $part;
switch ($part) {
case 'from':
@ -823,7 +835,6 @@ class rcmail_sendmail
case 'cc':
case 'bcc':
$fname = '_' . $part;
$header = $param = $part;
$allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'tabindex');
$field_type = 'html_textarea';
@ -833,14 +844,12 @@ class rcmail_sendmail
case 'reply-to':
$fname = '_replyto';
$param = 'replyto';
$header = 'reply-to';
case 'followupto':
case 'followup-to':
if (!$fname) {
$fname = '_followupto';
$param = 'followupto';
$header = 'mail-followup-to';
}
$allow_attrib = array('id', 'class', 'style', 'size', 'tabindex');

@ -61,9 +61,10 @@ class rcmail_utils
*/
public static function db_init($dir)
{
$db = self::db();
$db = self::db();
$error = null;
$file = $dir . '/' . $db->db_provider . '.initial.sql';
$file = $dir . '/' . $db->db_provider . '.initial.sql';
if (!file_exists($file)) {
rcube::raise_error("DDL file $file not found", false, true);
}
@ -116,7 +117,7 @@ class rcmail_utils
}
// DB version not found, but release version is specified
if (!$version && $ver) {
if (empty($version) && $ver) {
// Map old release version string to DB schema version
// Note: This is for backward compat. only, do not need to be updated
$map = array(

Loading…
Cancel
Save