From 27e57c73352e1966918cdfe567c32c5a4844be82 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 7 May 2013 12:16:11 +0200 Subject: Fix undefined or unused variable errors caught in static code analysis --- plugins/kolab_activesync/kolab_activesync.php | 4 ++-- plugins/kolab_activesync/kolab_activesync_ui.php | 6 ++---- plugins/kolab_addressbook/kolab_addressbook.php | 13 +++++++------ plugins/kolab_addressbook/lib/kolab_addressbook_ui.php | 9 +++++---- plugins/kolab_addressbook/lib/rcube_kolab_contacts.php | 7 ++++--- plugins/kolab_auth/kolab_auth.php | 2 +- plugins/kolab_config/kolab_config.php | 2 +- plugins/kolab_delegation/kolab_delegation.php | 8 ++------ plugins/kolab_delegation/kolab_delegation_engine.php | 9 ++++----- plugins/kolab_folders/kolab_folders.php | 1 - plugins/kolab_zpush/kolab_zpush_ui.php | 6 ++---- plugins/libcalendaring/libcalendaring.php | 8 ++++---- plugins/logon_page/logon_page.php | 2 +- plugins/odfviewer/odfviewer.php | 2 -- plugins/pdfviewer/pdfviewer.php | 2 +- plugins/tinymce_config/tinymce_config.php | 3 ++- 16 files changed, 38 insertions(+), 46 deletions(-) diff --git a/plugins/kolab_activesync/kolab_activesync.php b/plugins/kolab_activesync/kolab_activesync.php index 19604af..78f36c8 100644 --- a/plugins/kolab_activesync/kolab_activesync.php +++ b/plugins/kolab_activesync/kolab_activesync.php @@ -82,9 +82,9 @@ class kolab_activesync extends rcube_plugin if (!$err) { // iterate over folders list and update metadata if necessary // old subscriptions - foreach ($this->folder_meta() as $folder => $meta) { + foreach (array_keys($this->folder_meta()) as $folder) { $err |= !$this->folder_set($folder, $imei, intval($subscriptions[$folder])); - unset($subsciptions[$folder]); + unset($subscriptions[$folder]); } // new subscription foreach ($subscriptions as $folder => $flag) { diff --git a/plugins/kolab_activesync/kolab_activesync_ui.php b/plugins/kolab_activesync/kolab_activesync_ui.php index 6e796cc..b723668 100644 --- a/plugins/kolab_activesync/kolab_activesync_ui.php +++ b/plugins/kolab_activesync/kolab_activesync_ui.php @@ -179,6 +179,7 @@ class kolab_activesync_ui } } + $folder_id = 'rcmf' . html_identifier($folder); $names[] = $origname; $classes = array('mailbox'); @@ -187,9 +188,6 @@ class kolab_activesync_ui $classes[] = $folder_class; } - $folder_id = 'rcmf' . html_identifier($folder); - $padding = str_repeat('    ', $level); - $table->add_row(); $table->add('subscription', $checkbox_sync->show( !empty($subscribed[$folder]) ? $folder : null, @@ -201,7 +199,7 @@ class kolab_activesync_ui array('value' => $folder, 'id' => $folder_id.'_alarm'))); } - $table->add(join(' ', $classes), html::label($folder_id, $padding . $foldername)); + $table->add(join(' ', $classes), html::label($folder_id, $foldername)); } return $table->show(); diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index a85965e..818a47a 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -173,7 +173,7 @@ class kolab_addressbook extends rcube_plugin } $kolab_sources = array(); - foreach ($this->_list_sources() as $abook_id => $abook) { + foreach (array_keys($this->_list_sources()) as $abook_id) { if (!in_array($abook_id, $sources)) $kolab_sources[] = $abook_id; } @@ -250,7 +250,7 @@ class kolab_addressbook extends rcube_plugin asort($names, SORT_LOCALE_STRING); - foreach ($names as $utf7name => $name) { + foreach (array_keys($names) as $utf7name) { // create instance of rcube_contacts $abook_id = kolab_storage::folder_id($utf7name); $abook = new rcube_kolab_contacts($utf7name); @@ -305,9 +305,10 @@ class kolab_addressbook extends rcube_plugin private function _sort_form_fields($contents) { - $block = array(); + $block = array(); $contacts = reset($this->sources); - foreach ($contacts->coltypes as $col => $prop) { + + foreach (array_keys($contacts->coltypes) as $col) { if (isset($contents[$col])) $block[$col] = $contents[$col]; } @@ -441,10 +442,10 @@ class kolab_addressbook extends rcube_plugin // create display name for the folder (see self::address_sources()) if (strpos($folder, $delimiter)) { $names = array(); - foreach ($this->_list_sources() as $abook_id => $abook) { + foreach ($this->_list_sources() as $abook) { $realname = $abook->get_realname(); // The list can be not updated yet, handle old folder name - if ($type == 'update' && $realname == $oldfolder) { + if ($type == 'update' && $realname == $prop['oldname']) { $abook = $kolab_folder; $realname = $folder; } diff --git a/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php b/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php index a1504fb..7546046 100644 --- a/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php +++ b/plugins/kolab_addressbook/lib/kolab_addressbook_ui.php @@ -116,8 +116,9 @@ class kolab_addressbook_ui $hidden_fields[] = array('name' => '_source', 'value' => $folder); - $folder = rcube_charset::convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); - $delim = $_SESSION['imap_delimiter']; + $folder = rcube_charset::convert($folder, RCMAIL_CHARSET, 'UTF7-IMAP'); + $storage = $this->rc->get_storage(); + $delim = $storage->get_hierarchy_delimiter(); if ($this->rc->action == 'plugin.book-save') { // save error @@ -144,7 +145,7 @@ class kolab_addressbook_ui if (strlen($folder)) { $hidden_fields[] = array('name' => '_oldname', 'value' => $folder); - $options = $this->rc->get_storage()->folder_info($folder); + $options = $storage->folder_info($folder); } $form = array(); @@ -155,7 +156,7 @@ class kolab_addressbook_ui ); if (!empty($options) && ($options['norename'] || $options['protected'])) { - $foldername = Q(str_replace($delimiter, ' » ', kolab_storage::object_name($folder))); + $foldername = Q(str_replace($delim, ' » ', kolab_storage::object_name($folder))); } else { $foldername = new html_inputfield(array('name' => '_name', 'id' => '_name', 'size' => 30)); diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 48b89be..35312d9 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -245,11 +245,11 @@ class rcube_kolab_contacts extends rcube_addressbook /** * List the current set of contact records * - * @param array List of cols to show * @param int Only return this number of records, use negative values for tail + * * @return array Indexed list of contact records, each a hash array */ - public function list_records($cols=null, $subset=0) + public function list_records($subset = 0) { $this->result = new rcube_result_set(0, ($this->list_page-1) * $this->page_size);; @@ -808,8 +808,9 @@ class rcube_kolab_contacts extends rcube_addressbook $this->_fetch_groups(true); $list = $this->distlists[$gid]; - foreach ((array)$list['member'] as $i => $member) + foreach ((array)$list['member'] as $member) { $exists[] = $member['ID']; + } // substract existing assignments from list $ids = array_diff($ids, $exists); diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php index 719df98..f511949 100644 --- a/plugins/kolab_auth/kolab_auth.php +++ b/plugins/kolab_auth/kolab_auth.php @@ -337,7 +337,7 @@ class kolab_auth extends rcube_plugin // check group if (!$isadmin && !empty($group)) { $groups = $ldap->get_record_groups($record['ID']); - foreach ($groups as $g => $prop) { + foreach (array_keys($groups) as $g) { if ($group == rcube_ldap::dn_decode($g)) { $isadmin = true; break; diff --git a/plugins/kolab_config/kolab_config.php b/plugins/kolab_config/kolab_config.php index 23188cf..e5f07ad 100644 --- a/plugins/kolab_config/kolab_config.php +++ b/plugins/kolab_config/kolab_config.php @@ -68,7 +68,7 @@ class kolab_config extends rcube_plugin $this->require_plugin('libkolab'); $this->folders = kolab_storage::get_folders('configuration'); - foreach ($this->folders as $i => $folder) { + foreach ($this->folders as $folder) { if ($folder->default) { $this->default = $folder; break; diff --git a/plugins/kolab_delegation/kolab_delegation.php b/plugins/kolab_delegation/kolab_delegation.php index 8ec1f8b..156e81f 100644 --- a/plugins/kolab_delegation/kolab_delegation.php +++ b/plugins/kolab_delegation/kolab_delegation.php @@ -350,7 +350,6 @@ class kolab_delegation extends rcube_plugin asort($list, SORT_LOCALE_STRING); foreach ($list as $id => $delegate) { - $name = $id; $table->add_row(array('id' => 'rcmrow' . $id)); $table->add(null, Q($delegate)); } @@ -415,7 +414,6 @@ class kolab_delegation extends rcube_plugin $folder_data = $engine->list_folders($delegate['uid']); $rights = array(); - $folders = array(); $folder_groups = array(); foreach ($folder_data as $folder_name => $folder) { @@ -471,6 +469,7 @@ class kolab_delegation extends rcube_plugin } } + $folder_id = 'rcmf' . html_identifier($folder); $names[] = $origname; $classes = array('mailbox'); @@ -479,9 +478,6 @@ class kolab_delegation extends rcube_plugin $classes[] = $folder_class; } - $folder_id = 'rcmf' . html_identifier($folder); - $padding = str_repeat('    ', $level); - $table->add_row(); $table->add('read', $checkbox_read->show( $rights[$folder] >= kolab_delegation_engine::ACL_READ ? $folder : null, @@ -490,7 +486,7 @@ class kolab_delegation extends rcube_plugin $rights[$folder] >= kolab_delegation_engine::ACL_WRITE ? $folder : null, array('value' => $folder, 'id' => $folder_id))); - $table->add(join(' ', $classes), html::label($folder_id, $padding . $foldername)); + $table->add(join(' ', $classes), html::label($folder_id, $foldername)); } return $table->show(); diff --git a/plugins/kolab_delegation/kolab_delegation_engine.php b/plugins/kolab_delegation/kolab_delegation_engine.php index 7b35f41..26f6b38 100644 --- a/plugins/kolab_delegation/kolab_delegation_engine.php +++ b/plugins/kolab_delegation/kolab_delegation_engine.php @@ -60,10 +60,10 @@ class kolab_delegation_engine if (!is_array($delegate)) { $delegate = $this->delegate_get($delegate); } - $dn = $delegate['ID']; - $list = $this->list_delegates(); - $user = $this->user(); - $ldap = $this->ldap(); + + $dn = $delegate['ID']; + $list = $this->list_delegates(); + $user = $this->user(); if (empty($delegate) || empty($dn)) { return false; @@ -133,7 +133,6 @@ class kolab_delegation_engine $delegate = $this->delegate_get($dn); $list = $this->list_delegates(); $user = $this->user(); - $ldap = $this->ldap(); if (empty($delegate) || !isset($list[$dn])) { return false; diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php index cf2bb77..12c0423 100644 --- a/plugins/kolab_folders/kolab_folders.php +++ b/plugins/kolab_folders/kolab_folders.php @@ -486,7 +486,6 @@ class kolab_folders extends rcube_plugin $storage = $this->rc->get_storage(); $namespace = $storage->get_namespace(); $defaults = array(); - $need_update = false; $prefix = ''; // Find personal namespace prefix diff --git a/plugins/kolab_zpush/kolab_zpush_ui.php b/plugins/kolab_zpush/kolab_zpush_ui.php index 3d2fbcc..0e8e6e9 100644 --- a/plugins/kolab_zpush/kolab_zpush_ui.php +++ b/plugins/kolab_zpush/kolab_zpush_ui.php @@ -143,7 +143,6 @@ class kolab_zpush_ui } $names[] = $origname; - $classes = array('mailbox'); if ($folder_class = $this->rc->folder_classname($folder)) { @@ -152,9 +151,8 @@ class kolab_zpush_ui } $folder_id = 'rcmf' . html_identifier($folder); - $padding = str_repeat('    ', $level); - $table->add_row(array('class' => (($level+1) * $idx++) % 2 == 0 ? 'even' : 'odd')); + $table->add_row(); $table->add('subscription', $checkbox_sync->show('', array('value' => $folder, 'id' => $folder_id))); if ($alarms) @@ -162,7 +160,7 @@ class kolab_zpush_ui else $table->add('alarm', ''); - $table->add(join(' ', $classes), html::label($folder_id, $padding . Q($foldername))); + $table->add(join(' ', $classes), html::label($folder_id, Q($foldername))); } return $table->show(); diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 138c506..eb72e70 100644 --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -106,7 +106,7 @@ class libcalendaring extends rcube_plugin public function adjust_timezone($dt) { if (is_numeric($dt)) - $dt = new DateTime('@'.$td); + $dt = new DateTime('@'.$dt); else if (is_string($dt)) $dt = new DateTime($dt); @@ -391,10 +391,10 @@ class libcalendaring extends rcube_plugin // collect pending alarms from all providers (e.g. calendar, tasks) $plugin = $this->rc->plugins->exec_hook('pending_alarms', array( 'time' => time(), - 'alarms' => $alarms, + 'alarms' => array(), )); - if (!$plugin['abort'] && $plugin['alarms']) { + if (!$plugin['abort'] && !empty($plugin['alarms'])) { // make sure texts and env vars are available on client $this->add_texts('localization/', true); $this->rc->output->set_env('snooze_select', $this->snooze_select()); @@ -407,7 +407,7 @@ class libcalendaring extends rcube_plugin */ public function alarms_action() { - $action = get_input_value('action', RCUBE_INPUT_GPC); +// $action = get_input_value('action', RCUBE_INPUT_GPC); $data = get_input_value('data', RCUBE_INPUT_POST, true); $data['ids'] = explode(',', $data['id']); diff --git a/plugins/logon_page/logon_page.php b/plugins/logon_page/logon_page.php index 4c69099..8dee962 100644 --- a/plugins/logon_page/logon_page.php +++ b/plugins/logon_page/logon_page.php @@ -63,6 +63,6 @@ class logon_page extends rcube_plugin $rcmail->output->add_footer($html); } - return $arg; + return $args; } } diff --git a/plugins/odfviewer/odfviewer.php b/plugins/odfviewer/odfviewer.php index 950b2dd..39d88de 100644 --- a/plugins/odfviewer/odfviewer.php +++ b/plugins/odfviewer/odfviewer.php @@ -136,8 +136,6 @@ class odfviewer extends rcube_plugin */ function gc_cleanup() { - $rcmail = rcube::get_instance(); - $tmp = unslashify($this->tempdir); $expire = mktime() - 172800; // expire in 48 hours diff --git a/plugins/pdfviewer/pdfviewer.php b/plugins/pdfviewer/pdfviewer.php index b6da2d2..93369da 100644 --- a/plugins/pdfviewer/pdfviewer.php +++ b/plugins/pdfviewer/pdfviewer.php @@ -83,7 +83,7 @@ class pdfviewer extends rcube_plugin public function part_structure($args) { if (!empty($args['structure']->parts)) { - foreach ($args['structure']->parts as $i => $part) { + foreach (array_keys($args['structure']->parts) as $i) { $this->fix_mime_part($args['structure']->parts[$i], $args['object']); } } diff --git a/plugins/tinymce_config/tinymce_config.php b/plugins/tinymce_config/tinymce_config.php index e6e5828..07b14e6 100644 --- a/plugins/tinymce_config/tinymce_config.php +++ b/plugins/tinymce_config/tinymce_config.php @@ -42,6 +42,7 @@ class tinymce_config extends rcube_plugin $script = sprintf('$.extend(window.rcmail_editor_settings, %s);', json_encode($config)); $rcmail->output->add_script($script, 'foot'); + + return $args; } } - -- cgit v0.12