CS fixes, mostly around undefined variables

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

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

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

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

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

@ -61,9 +61,10 @@ class rcmail_utils
*/ */
public static function db_init($dir) 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)) { if (!file_exists($file)) {
rcube::raise_error("DDL file $file not found", false, true); 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 // 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 // Map old release version string to DB schema version
// Note: This is for backward compat. only, do not need to be updated // Note: This is for backward compat. only, do not need to be updated
$map = array( $map = array(

Loading…
Cancel
Save