summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-11-21 11:37:21 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-11-21 11:37:21 (GMT)
commitc79937f2a59ba0ac31619970f97cef47d9be0512 (patch)
tree4a275966183ca4163179fd892915b3b96e2f434e
parentf824ad56747cb387df363279fa033ff27c55b38e (diff)
downloadkolab-syncroton-c79937f2a59ba0ac31619970f97cef47d9be0512.tar.gz
Fix some issues found in static code analysis
-rw-r--r--lib/kolab_sync.php2
-rw-r--r--lib/kolab_sync_backend.php3
-rw-r--r--lib/kolab_sync_backend_content.php2
-rw-r--r--lib/kolab_sync_backend_device.php2
-rw-r--r--lib/kolab_sync_data.php14
-rw-r--r--lib/kolab_sync_data_calendar.php3
-rw-r--r--lib/kolab_sync_data_email.php30
-rw-r--r--lib/kolab_sync_data_gal.php3
-rw-r--r--lib/kolab_sync_data_notes.php4
-rw-r--r--lib/kolab_sync_data_tasks.php4
-rw-r--r--lib/kolab_sync_message.php2
-rw-r--r--lib/kolab_sync_transaction_manager.php2
12 files changed, 32 insertions, 39 deletions
diff --git a/lib/kolab_sync.php b/lib/kolab_sync.php
index 515076e..803752d 100644
--- a/lib/kolab_sync.php
+++ b/lib/kolab_sync.php
@@ -251,7 +251,7 @@ class kolab_sync extends rcube
// take the first entry if $host is not found
if (is_array($host)) {
- list($key, $val) = each($default_host);
+ list($key, $val) = each($host);
$host = is_numeric($key) ? $val : $key;
}
}
diff --git a/lib/kolab_sync_backend.php b/lib/kolab_sync_backend.php
index 8af2633..56a411d 100644
--- a/lib/kolab_sync_backend.php
+++ b/lib/kolab_sync_backend.php
@@ -246,11 +246,10 @@ class kolab_sync_backend
* @param string $old_name Old folder name (UTF7-IMAP)
* @param string $new_name New folder name (UTF7-IMAP)
* @param int $type Folder (ActiveSync) type
- * @param string $deviceid Device identifier
*
* @return bool True on success, False on failure
*/
- public function folder_rename($old_name, $new_name, $type, $deviceid)
+ public function folder_rename($old_name, $new_name, $type)
{
$this->folder_meta = null;
diff --git a/lib/kolab_sync_backend_content.php b/lib/kolab_sync_backend_content.php
index 793c136..948939c 100644
--- a/lib/kolab_sync_backend_content.php
+++ b/lib/kolab_sync_backend_content.php
@@ -122,7 +122,7 @@ class kolab_sync_backend_content extends kolab_sync_backend_common implements Sy
$folderId = $_folderId instanceof Syncroton_Model_IFolder ? $_folderId->id : $_folderId;
$cachekey = $deviceId . ':' . $folderId;
- unset($this->cache['content_folderstate'][$cache_key]);
+ unset($this->cache['content_folderstate'][$cachekey]);
$where[] = $this->db->quote_identifier('device_id') . ' = ' . $this->db->quote($deviceId);
$where[] = $this->db->quote_identifier('folder_id') . ' = ' . $this->db->quote($folderId);
diff --git a/lib/kolab_sync_backend_device.php b/lib/kolab_sync_backend_device.php
index 315afb5..4df6a86 100644
--- a/lib/kolab_sync_backend_device.php
+++ b/lib/kolab_sync_backend_device.php
@@ -308,7 +308,7 @@ class kolab_sync_backend_device extends kolab_sync_backend_common implements Syn
$plugin = $engine->plugins->get_plugin('managesieve');
$vacation = $plugin->get_engine('vacation');
- if ($error = $vacation->connect($engine->username, $engine->password)) {
+ if ($vacation->connect($engine->username, $engine->password)) {
throw new Exception("Connection to managesieve server failed");
}
diff --git a/lib/kolab_sync_data.php b/lib/kolab_sync_data.php
index 9589b73..59bff31 100644
--- a/lib/kolab_sync_data.php
+++ b/lib/kolab_sync_data.php
@@ -339,7 +339,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
// @TODO: folder type change?
}
else {
- $result = $this->backend->folder_rename($old_name, $name, $type, $this->device->deviceid);
+ $result = $this->backend->folder_rename($old_name, $name, $type);
}
if ($result) {
@@ -665,7 +665,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
$changed = false;
// compare states, get members of changed relations
- foreach ($relations as $idx => $relation) {
+ foreach ($relations as $relation) {
$rel_id = $relation['uid'];
if ($relation['changed']) {
@@ -1551,7 +1551,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
// Tasks do not support exceptions
if ($type == 'Event') {
- $result['exceptions'] = $this->exceptions_from_kolab($collection, $data, $result);
+ $result['exceptions'] = $this->exceptions_from_kolab($collection, $data);
}
}
@@ -1629,7 +1629,7 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
/**
* Convert Kolab event recurrence exceptions into ActiveSync
*/
- protected function exceptions_from_kolab($collection, $data, $result)
+ protected function exceptions_from_kolab($collection, $data)
{
if (empty($data['recurrence']['EXCEPTIONS']) && empty($data['recurrence']['EXDATE'])) {
return null;
@@ -1732,10 +1732,8 @@ abstract class kolab_sync_data implements Syncroton_Data_IData
*/
protected function setKolabTags($uid, $tags)
{
- if (isset($data->categories)) {
- $config = kolab_storage_config::get_instance();
- $config->save_tags($uid, $tags);
- }
+ $config = kolab_storage_config::get_instance();
+ $config->save_tags($uid, $tags);
}
/**
diff --git a/lib/kolab_sync_data_calendar.php b/lib/kolab_sync_data_calendar.php
index a762356..c4b2f6b 100644
--- a/lib/kolab_sync_data_calendar.php
+++ b/lib/kolab_sync_data_calendar.php
@@ -270,7 +270,6 @@ class kolab_sync_data_calendar extends kolab_sync_data implements Syncroton_Data
if (!empty($event['attendees'])) {
foreach ($event['attendees'] as $idx => $attendee) {
if ($attendee['role'] == 'ORGANIZER') {
- $organizer = $attendee;
if ($name = $attendee['name']) {
$result['organizerName'] = $name;
}
@@ -298,7 +297,7 @@ class kolab_sync_data_calendar extends kolab_sync_data implements Syncroton_Data
if ($this->asversion >= 12) {
$type = isset($attendee['role']) ? $this->attendeeTypeMap[$attendee['role']] : null;
- $status = isset($attendee['status']) ? $this->attendeeStatusMap[$attende['status']] : null;
+ $status = isset($attendee['status']) ? $this->attendeeStatusMap[$attendee['status']] : null;
$att['attendeeType'] = $type ? $type : self::ATTENDEE_TYPE_REQUIRED;
$att['attendeeStatus'] = $status ? $status : self::ATTENDEE_STATUS_UNKNOWN;
diff --git a/lib/kolab_sync_data_email.php b/lib/kolab_sync_data_email.php
index 434416b..48e8d0d 100644
--- a/lib/kolab_sync_data_email.php
+++ b/lib/kolab_sync_data_email.php
@@ -129,7 +129,6 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
throw new Syncroton_Exception_NotFound("Message $serverId not found");
}
- $msg = $this->parseMessageId($serverId);
$headers = $message->headers; // rcube_message_header
// Calendar namespace fields
@@ -643,7 +642,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
* @param mixed $message MIME message
* @param boolean $saveInSent Enables saving the sent message in Sent folder
*
- * @param throws Syncroton_Exception_Status
+ * @throws Syncroton_Exception_Status
*/
public function sendEmail($message, $saveInSent)
{
@@ -676,7 +675,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
* @param boolean $saveInSent Enables saving the sent message in Sent folder
* @param boolean $replaceMime If enabled, original message would be appended
*
- * @param throws Syncroton_Exception_Status
+ * @throws Syncroton_Exception_Status
*/
public function forwardEmail($itemId, $body, $saveInSent, $replaceMime)
{
@@ -693,9 +692,10 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
or a meeting, the behavior of the SmartForward command is the same as that of the SmartReply command (section 2.2.2.18).
*/
- $msg = $this->parseMessageId($itemId);
+ $msg = $this->parseMessageId($itemId);
+ $message = $this->getObject($itemId);
- if (empty($msg)) {
+ if (empty($message)) {
throw new Syncroton_Exception_Status(Syncroton_Exception_Status::ITEM_NOT_FOUND);
}
@@ -720,7 +720,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
}
// Send message
- $sent = $this->sendEmail($sync_msg, $saveInSent);
+ $this->sendEmail($sync_msg, $saveInSent);
// Set FORWARDED flag on the replied message
if (empty($message->headers->flags['FORWARDED'])) {
@@ -737,7 +737,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
* @param boolean $saveInSent Enables saving the sent message in Sent folder
* @param boolean $replaceMime If enabled, original message would be appended
*
- * @param throws Syncroton_Exception_Status
+ * @throws Syncroton_Exception_Status
*/
public function replyEmail($itemId, $body, $saveInSent, $replaceMime)
{
@@ -770,7 +770,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
}
// Send message
- $sent = $this->sendEmail($sync_msg, $saveInSent);
+ $this->sendEmail($sync_msg, $saveInSent);
// Set ANSWERED flag on the replied message
if (empty($message->headers->flags['ANSWERED'])) {
@@ -812,10 +812,8 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
$changed_msgs = $this->getChangesByRelations($folderid, $filter);
$result = $result_type == self::RESULT_COUNT ? 0 : array();
- // no sorting for best performance
- $sort_by = null;
- $found = 0;
- $ts = time();
+ $found = 0;
+ $ts = time();
foreach ($folders as $folder_id) {
$foldername = $this->backend->folder_id2name($folder_id, $this->device->deviceid);
@@ -947,7 +945,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
// convert filter into one IMAP search string
$filter_str = 'ALL UNDELETED';
- foreach ($filter as $idx => $filter_item) {
+ foreach ($filter as $filter_item) {
if (is_string($filter_item)) {
$filter_str .= ' ' . $filter_item;
}
@@ -984,7 +982,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
$search = '';
$search_count = 0;
- foreach ($result as $folder => $data) {
+ foreach ($result as $data) {
foreach ($data as $p) {
$search_params = array();
$search_count++;
@@ -1036,8 +1034,6 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
}
$result = array();
- // no sorting for best performance
- $sort_by = null;
// @TODO: caching with Options->RebuildResults support
@@ -1399,7 +1395,7 @@ class kolab_sync_data_email extends kolab_sync_data implements Syncroton_Data_ID
$uri = kolab_storage_config::get_message_uri($message->headers, $folder);
// for all tag objects...
- foreach ($config->get_tags() as $idx => $relation) {
+ foreach ($config->get_tags() as $relation) {
// resolve members if it wasn't done recently
$uid = $relation['uid'];
$force = empty($this->tag_rts[$uid]) || $this->tag_rts[$uid] <= time() - $delta;
diff --git a/lib/kolab_sync_data_gal.php b/lib/kolab_sync_data_gal.php
index 95e3e17..297a4a9 100644
--- a/lib/kolab_sync_data_gal.php
+++ b/lib/kolab_sync_data_gal.php
@@ -286,7 +286,6 @@ class kolab_sync_data_gal extends kolab_sync_data implements Syncroton_Data_IDat
*/
protected function get_address_book($id)
{
- $contacts = null;
$config = rcube::get_instance()->config;
$ldap_config = (array) $config->get('ldap_public');
@@ -311,7 +310,7 @@ class kolab_sync_data_gal extends kolab_sync_data implements Syncroton_Data_IDat
/*
// set configured sort order
if ($sort_col = $this->config->get('addressbook_sort_col'))
- $contacts->set_sort_order($sort_col);
+ $book->set_sort_order($sort_col);
*/
// add to the 'books' array for shutdown function
$this->address_books[$id] = $book;
diff --git a/lib/kolab_sync_data_notes.php b/lib/kolab_sync_data_notes.php
index 480da1d..4d8f38c 100644
--- a/lib/kolab_sync_data_notes.php
+++ b/lib/kolab_sync_data_notes.php
@@ -85,7 +85,7 @@ class kolab_sync_data_notes extends kolab_sync_data
public function getEntry(Syncroton_Model_SyncCollection $collection, $serverId, $as_array = false)
{
$note = is_array($serverId) ? $serverId : $this->getObject($collection->collectionId, $serverId);
- $config = $this->getFolderConfig($note['_mailbox']);
+// $config = $this->getFolderConfig($note['_mailbox']);
$result = array();
// Calendar namespace fields
@@ -130,7 +130,7 @@ class kolab_sync_data_notes extends kolab_sync_data
{
$note = !empty($entry) ? $entry : array();
$foldername = isset($note['_mailbox']) ? $note['_mailbox'] : $this->getFolderName($folderid);
- $config = $this->getFolderConfig($foldername);
+// $config = $this->getFolderConfig($foldername);
// Calendar namespace fields
foreach ($this->mapping as $key => $name) {
diff --git a/lib/kolab_sync_data_tasks.php b/lib/kolab_sync_data_tasks.php
index 61beb7c..d30a6cf 100644
--- a/lib/kolab_sync_data_tasks.php
+++ b/lib/kolab_sync_data_tasks.php
@@ -113,7 +113,7 @@ class kolab_sync_data_tasks extends kolab_sync_data
public function getEntry(Syncroton_Model_SyncCollection $collection, $serverId, $as_array = false)
{
$task = is_array($serverId) ? $serverId : $this->getObject($collection->collectionId, $serverId);
- $config = $this->getFolderConfig($task['_mailbox']);
+// $config = $this->getFolderConfig($task['_mailbox']);
$result = array();
// Completion status (required)
@@ -177,7 +177,7 @@ class kolab_sync_data_tasks extends kolab_sync_data
{
$task = !empty($entry) ? $entry : array();
$foldername = isset($task['_mailbox']) ? $task['_mailbox'] : $this->getFolderName($folderid);
- $config = $this->getFolderConfig($foldername);
+// $config = $this->getFolderConfig($foldername);
$task['allday'] = 0;
diff --git a/lib/kolab_sync_message.php b/lib/kolab_sync_message.php
index c8b0a47..5054166 100644
--- a/lib/kolab_sync_message.php
+++ b/lib/kolab_sync_message.php
@@ -258,6 +258,8 @@ class kolab_sync_message
$sent = mail($to, $subject, $msg_body, $header_str);
}
else {
+ $from = rcube_mime::decode_address_list($headers['From'], 1, false, null, true);
+ $from = $from[0];
$sent = mail($to, $subject, $msg_body, $header_str, "-f$from");
}
}
diff --git a/lib/kolab_sync_transaction_manager.php b/lib/kolab_sync_transaction_manager.php
index 2121d89..99ec9be 100644
--- a/lib/kolab_sync_transaction_manager.php
+++ b/lib/kolab_sync_transaction_manager.php
@@ -140,7 +140,7 @@ class kolab_sync_transaction_manager implements Syncroton_TransactionManagerInte
$numOpenTransactions = count($this->_openTransactions);
if ($numOpenTransactions === 0) {
- foreach ($this->_openTransactionables as $transactionableIdx => $transactionable) {
+ foreach ($this->_openTransactionables as $transactionable) {
if ($transactionable instanceof rcube_db) {
$transactionable->endTransaction();
}