4 commits - plugins/calendar plugins/kolab_activesync plugins/kolab_addressbook plugins/kolab_auth plugins/kolab_config plugins/kolab_delegation plugins/kolab_folders plugins/kolab_zpush plugins/libcalendaring plugins/logon_page plugins/odfviewer plugins/pdfviewer plugins/tasklist plugins/tinymce_config

Aleksander Machniak machniak at kolabsys.com
Tue May 7 12:17:01 CEST 2013


 plugins/calendar/calendar.php                                  |   25 +++-------
 plugins/calendar/drivers/calendar_driver.php                   |   13 ++++-
 plugins/calendar/drivers/database/database_driver.php          |   17 ++----
 plugins/calendar/drivers/kolab/kolab_calendar.php              |    2 
 plugins/calendar/drivers/kolab/kolab_driver.php                |   14 ++---
 plugins/calendar/lib/calendar_ui.php                           |   11 ++--
 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/tasklist/drivers/database/tasklist_database_driver.php |    8 ---
 plugins/tinymce_config/tinymce_config.php                      |    3 -
 23 files changed, 77 insertions(+), 97 deletions(-)

New commits:
commit 27e57c73352e1966918cdfe567c32c5a4844be82
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue May 7 12:16:11 2013 +0200

    Fix undefined or unused variable errors caught in static code analysis

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;
   }
 }
-


commit 828b868d973748c2e45f284fb7cf15e33a59b02e
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue May 7 11:34:45 2013 +0200

    Fix so insert_id() argument is a table name, not sequence - drop sequence settings

diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php
index 3b949ad..44f6bd6 100644
--- a/plugins/calendar/drivers/database/database_driver.php
+++ b/plugins/calendar/drivers/database/database_driver.php
@@ -47,9 +47,6 @@ class database_driver extends calendar_driver
   private $db_events = 'events';
   private $db_calendars = 'calendars';
   private $db_attachments = 'attachments';
-  private $sequence_events = 'event_ids';
-  private $sequence_calendars = 'calendar_ids';
-  private $sequence_attachments = 'attachment_ids';
 
 
   /**
@@ -68,9 +65,6 @@ class database_driver extends calendar_driver
     $this->db_events = $this->rc->config->get('db_table_events', $this->db_events);
     $this->db_calendars = $this->rc->config->get('db_table_calendars', $this->db_calendars);
     $this->db_attachments = $this->rc->config->get('db_table_attachments', $this->db_attachments);
-    $this->sequence_events = $this->rc->config->get('db_sequence_events', $this->sequence_events);
-    $this->sequence_calendars = $this->rc->config->get('db_sequence_calendars', $this->sequence_calendars);
-    $this->sequence_attachments = $this->rc->config->get('db_sequence_attachments', $this->sequence_attachments);
     
     $this->_read_calendars();
   }
@@ -154,7 +148,7 @@ class database_driver extends calendar_driver
     );
     
     if ($result)
-      return $this->rc->db->insert_id($this->sequence_calendars);
+      return $this->rc->db->insert_id($this->db_calendars);
     
     return false;
   }
@@ -266,7 +260,7 @@ class database_driver extends calendar_driver
         $event['notifyat']
       );
 
-      $event_id = $this->rc->db->insert_id($this->sequence_events);
+      $event_id = $this->rc->db->insert_id($this->db_events);
 
       if ($event_id) {
         $event['id'] = $event_id;
diff --git a/plugins/tasklist/drivers/database/tasklist_database_driver.php b/plugins/tasklist/drivers/database/tasklist_database_driver.php
index ae2b5e2..93734ca 100644
--- a/plugins/tasklist/drivers/database/tasklist_database_driver.php
+++ b/plugins/tasklist/drivers/database/tasklist_database_driver.php
@@ -36,8 +36,6 @@ class tasklist_database_driver extends tasklist_driver
 
     private $db_tasks = 'tasks';
     private $db_lists = 'tasklists';
-    private $sequence_tasks = 'task_ids';
-    private $sequence_lists = 'tasklist_ids';
 
 
     /**
@@ -51,8 +49,6 @@ class tasklist_database_driver extends tasklist_driver
         // read database config
         $this->db_lists = $this->rc->config->get('db_table_lists', $this->db_lists);
         $this->db_tasks = $this->rc->config->get('db_table_tasks', $this->db_tasks);
-        $this->sequence_lists = $this->rc->config->get('db_sequence_lists', $this->sequence_lists);
-        $this->sequence_tasks = $this->rc->config->get('db_sequence_tasks', $this->sequence_tasks);
 
         $this->_read_lists();
     }
@@ -119,7 +115,7 @@ class tasklist_database_driver extends tasklist_driver
         );
 
         if ($result)
-            return $this->rc->db->insert_id($this->sequence_lists);
+            return $this->rc->db->insert_id($this->db_lists);
 
         return false;
     }
@@ -528,7 +524,7 @@ class tasklist_database_driver extends tasklist_driver
         );
 
         if ($result)
-            return $this->rc->db->insert_id($this->sequence_tasks);
+            return $this->rc->db->insert_id($this->db_tasks);
 
         return false;
     }


commit de71de2fdae07d72f0e5d176c124cb03ac8775c5
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue May 7 11:31:30 2013 +0200

    Fix code bugs caught in static code analysis

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 1517306..f8451a1 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -843,7 +843,7 @@ class calendar extends rcube_plugin
   {
     $this->load_driver();
     if ($alarms = $this->driver->pending_alarms($p['time'] ?: time())) {
-      foreach ($alarms as $i => $alarm) {
+      foreach ($alarms as $alarm) {
         $alarm['id'] = 'cal:' . $alarm['id'];  // prefix ID with cal:
         $p['alarms'][] = $alarm;
       }
@@ -886,7 +886,6 @@ class calendar extends rcube_plugin
     }
 
     $calendar = get_input_value('calendar', RCUBE_INPUT_GPC);
-    $uploadid = get_input_value('_uploadid', RCUBE_INPUT_GPC);
 
     // process uploaded file if there is no error
     $err = $_FILES['_data']['error'];
@@ -903,7 +902,7 @@ class calendar extends rcube_plugin
           continue;
 
         $event['calendar'] = $calendar;
-        if ($success = $this->driver->new_event($event)) {
+        if ($this->driver->new_event($event)) {
           $count++;
         }
         else
@@ -1161,9 +1160,10 @@ class calendar extends rcube_plugin
    */
   public function generate_randomdata()
   {
-    $num = $_REQUEST['_num'] ? intval($_REQUEST['_num']) : 100;
-    $cats = array_keys($this->driver->list_categories());
-    $cals = $this->driver->list_calendars(true);
+    $num   = $_REQUEST['_num'] ? intval($_REQUEST['_num']) : 100;
+    $cats  = array_keys($this->driver->list_categories());
+    $cals  = $this->driver->list_calendars(true);
+    $count = 0;
 
     while ($count++ < $num) {
       $start = round((time() + rand(-2600, 2600) * 1000) / 300) * 300;
@@ -1183,7 +1183,7 @@ class calendar extends rcube_plugin
       $title = '';
       $len = rand(2, 12);
       $words = explode(" ", "The Hough transform is named after Paul Hough who patented the method in 1962. It is a technique which can be used to isolate features of a particular shape within an image. Because it requires that the desired features be specified in some parametric form, the classical Hough transform is most commonly used for the de- tection of regular curves such as lines, circles, ellipses, etc. A generalized Hough transform can be employed in applications where a simple analytic description of a feature(s) is not possible. Due to the computational complexity of the generalized Hough algorithm, we restrict the main focus of this discussion to the classical Hough transform. Despite its domain restrictions, the classical Hough transform (hereafter referred to without the classical prefix ) retains many applications, as most manufac- tured parts (and many anatomical parts investigated in medical imagery) contain feature boundaries which can be described by regu
 lar curves. The main advantage of the Hough transform technique is that it is tolerant of gaps in feature boundary descriptions and is relatively unaffected by image noise.");
-      $chars = "!# abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890";
+//      $chars = "!# abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890";
       for ($i = 0; $i < $len; $i++)
         $title .= $words[rand(0,count($words)-1)] . " ";
       
@@ -1670,7 +1670,7 @@ class calendar extends rcube_plugin
     $itip_part = null;
 
     // check all message parts for .ics files
-    foreach ((array)$this->message->mime_parts as $idx => $part) {
+    foreach ((array)$this->message->mime_parts as $part) {
       if ($this->is_vcalendar($part)) {
         if ($part->ctype_parameters['method'])
           $itip_part = $part->mime_id;
@@ -1739,7 +1739,7 @@ class calendar extends rcube_plugin
           
           // check my status
           $status = 'unknown';
-          foreach ($event['attendees'] as $i => $attendee) {
+          foreach ($event['attendees'] as $attendee) {
             if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
               $status = strtoupper($attendee['status']);
               break;
diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php
index 43e1345..a9402e1 100644
--- a/plugins/calendar/drivers/calendar_driver.php
+++ b/plugins/calendar/drivers/calendar_driver.php
@@ -379,12 +379,12 @@ abstract class calendar_driver
   public function calendar_form($action, $calendar, $formfields)
   {
     $html = '';
-    foreach ($formfields as $prop => $field) {
+    foreach ($formfields as $field) {
       $html .= html::div('form-section',
         html::label($field['id'], $field['label']) .
         $field['value']);
     }
-    
+
     return $html;
   }
 
diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php
index 7669350..3b949ad 100644
--- a/plugins/calendar/drivers/database/database_driver.php
+++ b/plugins/calendar/drivers/database/database_driver.php
@@ -236,9 +236,10 @@ class database_driver extends calendar_driver
         return false;
       if (!$event['calendar'])
         $event['calendar'] = reset(array_keys($this->calendars));
-      
+
       $event = $this->_save_preprocess($event);
-      $query = $this->rc->db->query(sprintf(
+
+      $this->rc->db->query(sprintf(
         "INSERT INTO " . $this->db_events . "
          (calendar_id, created, changed, uid, %s, %s, all_day, recurrence, title, description, location, categories, free_busy, priority, sensitivity, attendees, alarms, notifyat)
          VALUES (?, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
@@ -560,6 +561,7 @@ class database_driver extends calendar_driver
           break;
         
         // stop adding events for inifinite recurrence after 20 years
+        $count = 0;
         if (++$count > 999 || (!$recurrence->recurEnd && !$recurrence->recurCount && $next->year > date('Y') + 20))
           break;
       }
@@ -923,7 +925,6 @@ class database_driver extends calendar_driver
   public function list_attachments($event)
   {
     $attachments = array();
-    $event_id = $event['recurrence_id'] ? $event['recurrence_id'] : $event['event_id'];
 
     if (!empty($this->calendar_ids)) {
       $result = $this->rc->db->query(
diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index b9a6231..0f564ae 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -583,7 +583,7 @@ class kolab_calendar
     // in kolab_storage attachments are indexed by content-id
     $event['_attachments'] = array();
     if (is_array($event['attachments'])) {
-      foreach ($event['attachments'] as $idx => $attachment) {
+      foreach ($event['attachments'] as $attachment) {
         $key = null;
         // Roundcube ID has nothing to do with the storage ID, remove it
         if ($attachment['content']) {
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 081f2b0..f5b32d9 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -83,7 +83,7 @@ class kolab_driver extends calendar_driver
 
     asort($names, SORT_LOCALE_STRING);
 
-    foreach ($names as $utf7name => $name) {
+    foreach (array_keys($names) as $utf7name) {
       $calendar = new kolab_calendar($utf7name, $this->cal);
       $this->calendars[$calendar->id] = $calendar;
       if (!$calendar->readonly)
@@ -689,7 +689,7 @@ class kolab_driver extends calendar_driver
       $calendars = explode(',', $calendars);
 
     $events = $categories = array();
-    foreach ($this->calendars as $cid => $calendar) {
+    foreach (array_keys($this->calendars) as $cid) {
       if ($calendars && !in_array($cid, $calendars))
         continue;
 
@@ -1040,7 +1040,7 @@ class kolab_driver extends calendar_driver
     // Disable folder name input
     if (!empty($options) && ($options['norename'] || $options['protected'])) {
       $input_name = new html_hiddenfield(array('name' => 'name', 'id' => 'calendar-name'));
-      $formfields['name']['value'] = Q(str_replace($delimiter, ' » ', kolab_storage::object_name($folder)))
+      $formfields['name']['value'] = Q(str_replace($delim, ' » ', kolab_storage::object_name($folder)))
         . $input_name->show($folder);
     }
 
@@ -1178,8 +1178,6 @@ class kolab_driver extends calendar_driver
       $color  = '';
     }
 
-    $hidden_fields[] = array('name' => 'oldname', 'value' => $folder);
-
     $storage = $this->rc->get_storage();
     $delim   = $storage->get_hierarchy_delimiter();
     $form   = array();
@@ -1190,7 +1188,7 @@ class kolab_driver extends calendar_driver
       $path_imap = implode($path_imap, $delim);
 
       $options = $storage->folder_info($folder);
-    
+
       // Allow plugins to modify the form content (e.g. with ACL form)
       $plugin = $this->rc->plugins->exec_hook('calendar_form_kolab',
         array('form' => $form, 'options' => $options, 'name' => $folder));
diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php
index f06084c..61803e7 100644
--- a/plugins/calendar/lib/calendar_ui.php
+++ b/plugins/calendar/lib/calendar_ui.php
@@ -270,7 +270,7 @@ class calendar_ui
     $select         = new html_select($attrib);
     $identities     = $this->rc->user->list_identities();
 
-    foreach ($identities as $id => $ident) {
+    foreach ($identities as $ident) {
         $select->add(format_email_recipient($ident['email'], $ident['name']), $ident['identity_id']);
     }
 
@@ -285,7 +285,7 @@ class calendar_ui
     $attrib['name'] = 'categories';
     $select = new html_select($attrib);
     $select->add('---', '');
-    foreach ((array)$this->cal->driver->list_categories() as $cat => $color) {
+    foreach (array_keys((array)$this->cal->driver->list_categories()) as $cat) {
       $select->add($cat, $cat);
     }
 
@@ -530,7 +530,6 @@ class calendar_ui
     // Get max filesize, enable upload progress bar
     $max_filesize = rcube_upload_init();
 
-    $button = new html_inputfield(array('type' => 'button'));
     $input = new html_inputfield(array(
       'type' => 'file', 'name' => '_data', 'size' => $attrib['uploadfieldsize']));
 
@@ -543,12 +542,12 @@ class calendar_ui
         $this->cal->gettext('all'),
       ),
       array('1','2','6','12',0));
-    
+
     $html .= html::div('form-section',
       html::div(null, $input->show()) .
       html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))))
     );
-    
+
     $html .= html::div('form-section',
       html::label('event-import-calendar', $this->cal->gettext('calendar')) .
       $this->calendar_select(array('name' => 'calendar', 'id' => 'event-import-calendar'))
@@ -641,7 +640,7 @@ class calendar_ui
     $formfields = array(
       'name' => array(
         'label' => $this->cal->gettext('name'),
-        'value' => $input_name->show($name),
+        'value' => $input_name->show($calendar['name']),
         'id' => 'calendar-name',
       ),
       'color' => array(


commit aae87c8954a10288b8cffdbcf937269b465486e5
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue May 7 10:58:39 2013 +0200

    Fix so default categories are used when categories aren't configured

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 82f7b3c..1517306 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -58,13 +58,6 @@ class calendar extends rcube_plugin
     'calendar_time_indicator'  => true,
   );
 
-  private $default_categories = array(
-    'Personal' => 'c0c0c0',
-    'Work'     => 'ff0000',
-    'Family'   => '00ff00',
-    'Holiday'  => 'ff6600',
-  );
-  
   private $ics_parts = array();
 
 
diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php
index 478a08c..43e1345 100644
--- a/plugins/calendar/drivers/calendar_driver.php
+++ b/plugins/calendar/drivers/calendar_driver.php
@@ -91,6 +91,13 @@ abstract class calendar_driver
   public $alarm_absolute = true;
   public $last_error;
 
+  protected $default_categories = array(
+    'Personal' => 'c0c0c0',
+    'Work'     => 'ff0000',
+    'Family'   => '00ff00',
+    'Holiday'  => 'ff6600',
+  );
+
   /**
    * Get a list of available calendars from this source
    *
@@ -328,7 +335,7 @@ abstract class calendar_driver
   public function list_categories()
   {
     $rcmail = rcube::get_instance();
-    return $rcmail->config->get('calendar_categories', array());
+    return $rcmail->config->get('calendar_categories', $this->default_categories);
   }
 
   /**
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 6b980cd..081f2b0 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -698,7 +698,7 @@ class kolab_driver extends calendar_driver
     }
     
     // add new categories to user prefs
-    $old_categories = $this->rc->config->get('calendar_categories', array());
+    $old_categories = $this->rc->config->get('calendar_categories', $this->default_categories);
     if ($newcats = array_diff(array_map('strtolower', array_keys($categories)), array_map('strtolower', array_keys($old_categories)))) {
       foreach ($newcats as $category)
         $old_categories[$category] = '';  // no color set yet
@@ -867,7 +867,7 @@ class kolab_driver extends calendar_driver
   public function list_categories()
   {
     // FIXME: complete list with categories saved in config objects (KEP:12)
-    return $this->rc->config->get('calendar_categories', array());
+    return $this->rc->config->get('calendar_categories', $this->default_categories);
   }
 
   /**





More information about the commits mailing list