Fix undefined variable related errors caught in static code analysis

This commit is contained in:
Aleksander Machniak 2013-05-07 12:56:18 +02:00
parent 27e57c7335
commit 1857a64d4f
9 changed files with 20 additions and 26 deletions

View file

@ -168,7 +168,7 @@ class kolab_format_event extends kolab_format_xcal
if ($status == kolabformat::StatusTentative)
$object['free_busy'] = 'tentative';
else if ($status == kolabformat::StatusCancelled)
$objec['cancelled'] = true;
$object['cancelled'] = true;
// handle attachments
$vattach = $this->obj->attachments();
@ -235,16 +235,15 @@ class kolab_format_event extends kolab_format_xcal
*/
private function compact_exception($exception, $master)
{
static $forbidden = array('recurrence','organizer','attendees','sequence');
$forbidden = array('recurrence','organizer','attendees','sequence');
$out = $exception;
foreach ($exception as $prop => $val) {
if (in_array($prop, $forbidden)) {
unset($out[$prop]);
foreach ($forbidden as $prop) {
if (array_key_exists($prop, $exception)) {
unset($exception[$prop]);
}
}
return $out;
return $exception;
}
/**

View file

@ -105,7 +105,7 @@ abstract class kolab_format_xcal extends kolab_format
'title' => $this->obj->summary(),
'location' => $this->obj->location(),
'description' => $this->obj->description(),
'status' => $this->status_map[$this->obj->status()],
'status' => $status_map[$this->obj->status()],
'sensitivity' => $sensitivity_map[$this->obj->classification()],
'priority' => $this->obj->priority(),
'categories' => self::vector2array($this->obj->categories()),

View file

@ -39,7 +39,6 @@ class kolab_storage
private static $subscriptions;
private static $states;
private static $config;
private static $cache;
private static $imap;
@ -291,7 +290,7 @@ class kolab_storage
else {
// these characters are problematic e.g. when used in LIST/LSUB
foreach (array($delimiter, '%', '*') as $char) {
if (strpos($folder, $delimiter) !== false) {
if (strpos($folder, $char) !== false) {
self::$last_error = 'forbiddencharacter';
return false;
}

View file

@ -157,7 +157,7 @@ class kolab_storage_cache
{
// delegate to another cache instance
if ($foldername && $foldername != $this->folder->name) {
return kolab_storage::get_folder($foldername)->cache->get($msguid, $object);
return kolab_storage::get_folder($foldername)->cache->get($msguid, $type);
}
// load object if not in memory
@ -275,12 +275,12 @@ class kolab_storage_cache
* @param string Entry's Object UID
* @param string Target IMAP folder to move it to
*/
public function move($msguid, $objuid, $target_folder)
public function move($msguid, $uid, $target_folder)
{
$target = kolab_storage::get_folder($target_folder);
// resolve new message UID in target folder
if ($new_msguid = $target->cache->uid2msguid($objuid)) {
if ($new_msguid = $target->cache->uid2msguid($uid)) {
$this->db->query(
"UPDATE kolab_cache SET resource=?, msguid=? ".
"WHERE resource=? AND msguid=? AND type<>?",
@ -418,7 +418,7 @@ class kolab_storage_cache
$sql_where = '';
foreach ($query as $param) {
if (is_array($param[0])) {
$subs = array();
$subq = array();
foreach ($param[0] as $q) {
$subq[] = preg_replace('/^\s*AND\s+/i', '', $this->_sql_where(array($q)));
}

View file

@ -55,7 +55,6 @@ class kolab_storage_folder
private $idata;
private $owner;
private $resource_uri;
private $uid2msg = array();
/**
@ -161,7 +160,6 @@ class kolab_storage_folder
break;
default:
$owner = '';
list($prefix, $user) = explode($this->imap->get_hierarchy_delimiter(), $info['name']);
if (strpos($user, '@') === false) {
$domain = strstr($rcmail->get_user_name(), '@');
@ -635,7 +633,7 @@ class kolab_storage_folder
}
// save contact photo to attachment for Kolab2 format
if (kolab_storage::$version == '2.0' && $object['photo'] && !$existing_photo) {
if (kolab_storage::$version == '2.0' && $object['photo']) {
$attkey = 'kolab-picture.png'; // this file name is hard-coded in libkolab/kolabformatV2/contact.cpp
$object['_attachments'][$attkey] = array(
'mimetype'=> rc_image_content_type($object['photo']),
@ -843,7 +841,7 @@ class kolab_storage_folder
public function move($uid, $target_folder)
{
if ($msguid = $this->cache->uid2msguid($uid)) {
if ($success = $this->imap->move_message($msguid, $target_folder, $this->name)) {
if ($this->imap->move_message($msguid, $target_folder, $this->name)) {
$this->cache->move($msguid, $uid, $target_folder);
return true;
}

View file

@ -30,7 +30,6 @@ class tasklist_database_driver extends tasklist_driver
private $rc;
private $plugin;
private $cache = array();
private $lists = array();
private $list_ids = '';
@ -173,12 +172,13 @@ class tasklist_database_driver extends tasklist_driver
public function remove_list($prop)
{
$list_id = $prop['id'];
if ($this->lists[$list_id]) {
// delete all tasks linked with this list
$this->rc->db->query(
"DELETE FROM " . $this->db_tasks . "
WHERE tasklist_id=?",
$lisr_id
$list_id
);
// delete list record
@ -301,8 +301,6 @@ class tasklist_database_driver extends tasklist_driver
$tasks = array();
if (!empty($list_ids)) {
$datecol = $this->rc->db->quote_identifier('date');
$timecol = $this->rc->db->quote_identifier('time');
$result = $this->rc->db->query(sprintf(
"SELECT * FROM " . $this->db_tasks . "
WHERE tasklist_id IN (%s)

View file

@ -68,7 +68,7 @@ class tasklist_kolab_driver extends tasklist_driver
// convert to UTF8 and sort
$names = array();
$default_folder = null;
foreach ($this->folders as $i => $folder) {
foreach ($this->folders as $folder) {
$names[$folder->name] = rcube_charset::convert($folder->name, 'UTF7-IMAP');
$this->folders[$folder->name] = $folder;
if ($folder->default)

View file

@ -266,7 +266,7 @@ abstract class tasklist_driver
public function tasklist_edit_form($formfields)
{
$html = '';
foreach ($formfields as $prop => $field) {
foreach ($formfields as $field) {
$html .= html::div('form-section',
html::label($field['id'], $field['label']) .
$field['value']);

View file

@ -247,7 +247,7 @@ class tasklist extends rcube_plugin
break;
case 'collapse':
if ($collapsed = intval(get_input_value('collapsed', RCUBE_INPUT_GPC))) {
if (intval(get_input_value('collapsed', RCUBE_INPUT_GPC))) {
$this->collapsed_tasks[] = $rec['id'];
}
else {
@ -383,7 +383,7 @@ class tasklist extends rcube_plugin
}
// alarms cannot work without a date
if ($rec['alarms'] && !$rec['date'] && !$rec['startdate'] && strpos($task['alarms'], '@') === false)
if ($rec['alarms'] && !$rec['date'] && !$rec['startdate'] && strpos($rec['alarms'], '@') === false)
$rec['alarms'] = '';
$attachments = array();