Skip to content

Commit

Permalink
Attempt to report back the successfully deleted ids, if there was an …
Browse files Browse the repository at this point in the history
…error.

Not ideal, but it's the best we can do until Horde 6. Not to mention
most clients don't even check this for deletes. Needed since a
shared resource available for sync might not have Horde_Perms::DELETE.
  • Loading branch information
mrubinsk committed Nov 16, 2013
1 parent 86913e9 commit 1655ef5
Showing 1 changed file with 51 additions and 4 deletions.
55 changes: 51 additions & 4 deletions framework/Core/lib/Horde/Core/ActiveSync/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -1387,10 +1387,6 @@ public function deleteMessage($folderid, array $ids)
$folderid,
print_r($ids, true))
);
// TODO: Need to have the various connector methods report back
// successfully deleted ids. Currently the APIs do not report
// this for anything other than email.
$results = $ids;

$parts = $this->_parseFolderId($folderid);
if (is_array($parts)) {
Expand All @@ -1401,12 +1397,25 @@ public function deleteMessage($folderid, array $ids)
$folder_id = null;
}
ob_start();
$results = $ids;
switch ($class) {
case Horde_ActiveSync::CLASS_CALENDAR:
try {
$this->_connector->calendar_delete($ids, $folder_id);
} catch (Horde_Exception $e) {
// Since we don't get back successfully deleted ids and we can
// can pass an array of ids to delete, we need to see what ids
// were deleted if there was an error.
// @todo For Horde 6, the API should return successfully
// deleted ids.
$this->_logger->err($e->getMessage());
$success = array();
foreach ($ids as $uid) {
if ($mod_time = $this->_connector->calendar_getActionTimestamp($uid, 'delete', $folder_id)) {
$success[] = $uid;
}
}
$results = $success;
}
break;

Expand All @@ -1415,6 +1424,19 @@ public function deleteMessage($folderid, array $ids)
$this->_connector->contacts_delete($ids);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
// Since we don't get back successfully deleted ids and we can
// can pass an array of ids to delete, we need to see what ids
// were deleted if there was an error.
// @todo For Horde 6, the API should return successfully
// deleted ids.
$this->_logger->err($e->getMessage());
$success = array();
foreach ($ids as $uid) {
if ($mod_time = $this->_connector->contacts_getActionTimestamp($uid, 'delete', $folder_id)) {
$success[] = $uid;
}
}
$results = $success;
}
break;

Expand All @@ -1423,6 +1445,19 @@ public function deleteMessage($folderid, array $ids)
$this->_connector->tasks_delete($ids);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
// Since we don't get back successfully deleted ids and we can
// can pass an array of ids to delete, we need to see what ids
// were deleted if there was an error.
// @todo For Horde 6, the API should return successfully
// deleted ids.
$this->_logger->err($e->getMessage());
$success = array();
foreach ($ids as $uid) {
if ($mod_time = $this->_connector->tasks_getActionTimestamp($uid, 'delete', $folder_id)) {
$success[] = $uid;
}
}
$results = $success;
}
break;

Expand All @@ -1431,6 +1466,18 @@ public function deleteMessage($folderid, array $ids)
$this->_connector->notes_delete($ids);
} catch (Horde_Exception $e) {
$this->_logger->err($e->getMessage());
// Since we don't get back successfully deleted ids and we can
// can pass an array of ids to delete, we need to see what ids
// were deleted if there was an error.
// @todo For Horde 6, the API should return successfully
// deleted ids.
$success = array();
foreach ($ids as $uid) {
if ($mod_time = $this->_connector->tasks_getActionTimestamp($uid, 'delete', $folder_id)) {
$success[] = $uid;
}
}
$results = $success;
}
break;
default:
Expand Down

0 comments on commit 1655ef5

Please sign in to comment.