Beispiel #1
0
 /**
  * Called when the user has requested to delete (really delete) a message
  *
  * @param string              $folderid             id of the folder
  * @param string              $id                   id of the message
  * @param ContentParameters   $contentParameters
  *
  * @access public
  * @return boolean                      status of the operation
  * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
  */
 public function DeleteMessage($folderid, $id, $contentParameters)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->DeleteMessage('%s', '%s')", $folderid, $id));
     $deleted = false;
     $vcardId = $this->getVcardId($id);
     $addressbookUrl = $this->getAddressbookFromId($this->getAddressbookIdFromVcard($id));
     if ($addressbookUrl !== false) {
         try {
             $this->server->set_url($addressbookUrl);
             $deleted = $this->server->delete($vcardId);
         } catch (Exception $ex) {
             ZLog::Write(LOGLEVEL_ERROR, sprintf("BackendCardDAV->DeleteMessage - Error deleting vcard: %s", $ex->getMessage()));
         }
     }
     if ($deleted) {
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->DeleteMessage - vCard deleted"));
     } else {
         ZLog::Write(LOGLEVEL_ERROR, sprintf("BackendCardDAV->DeleteMessage - cannot delete vCard"));
     }
     return $deleted;
 }
 /**
  * Deletes the CardDAV server contact
  *
  * @param  array $carddav_contact_ids CardDAV contact ids
  * @return mixed                      affected CardDAV contacts or false
  */
 private function carddav_delete($carddav_contact_ids)
 {
     $server = current(carddav::get_carddav_server($this->carddav_server_id));
     $carddav_backend = new carddav_backend($server['url']);
     if ($this->rc->decrypt($server['password']) == '%p') {
         $server['password'] = $this->rcpassword;
     }
     $carddav_backend->set_auth($server['username'], $this->rc->decrypt($server['password']), $server['authtype']);
     if ($carddav_backend->check_connection()) {
         foreach ($carddav_contact_ids as $carddav_contact_id) {
             $contact = $this->get_carddav_addressbook_contact($carddav_contact_id);
             $carddav_backend->delete($contact['vcard_id']);
             $this->counter++;
             if ($this->counter < count($carddav_contact_ids)) {
                 continue;
             }
             if ($this->counter > 1) {
                 $contact['vcard_id'] = false;
             }
             $this->carddav_addressbook_sync($server, $carddav_contact_id, $contact['vcard_id']);
         }
         return count($carddav_contact_ids);
     }
     return false;
 }