summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-07 09:31:30 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-05-07 09:31:30 (GMT)
commitde71de2fdae07d72f0e5d176c124cb03ac8775c5 (patch)
tree6e033b77ca4a5302762d24e71e343ffd3ad55835
parentaae87c8954a10288b8cffdbcf937269b465486e5 (diff)
downloadroundcubemail-plugins-kolab-de71de2fdae07d72f0e5d176c124cb03ac8775c5.tar.gz
Fix code bugs caught in static code analysis
-rw-r--r--plugins/calendar/calendar.php18
-rw-r--r--plugins/calendar/drivers/calendar_driver.php4
-rw-r--r--plugins/calendar/drivers/database/database_driver.php7
-rw-r--r--plugins/calendar/drivers/kolab/kolab_calendar.php2
-rw-r--r--plugins/calendar/drivers/kolab/kolab_driver.php10
-rw-r--r--plugins/calendar/lib/calendar_ui.php11
6 files changed, 25 insertions, 27 deletions
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 regular 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, ' &raquo; ', kolab_storage::object_name($folder)))
+ $formfields['name']['value'] = Q(str_replace($delim, ' &raquo; ', 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(