/**
  * Resynchronizes a folder type of a device & user
  *
  * @param string    $deviceId       the id of the device
  * @param string    $user           the user
  * @param string    $type           the folder type
  *
  * @return
  * @access private
  */
 private static function resyncFolder($deviceId, $user, $type)
 {
     $device = ZPushAdmin::GetDeviceDetails($deviceId, $user);
     if (!$device instanceof ASDevice) {
         echo sprintf("Folder resync failed: %s\n", ZLog::GetLastMessage(LOGLEVEL_ERROR));
         return false;
     }
     $folders = array();
     foreach ($device->GetAllFolderIds() as $folderid) {
         // if  submitting a folderid as type to resync a specific folder.
         if ($folderid == $type) {
             printf("Found and resynching requested folderid '%s' on device '%s' of user '%s'\n", $folderid, $deviceId, $user);
             $folders[] = $folderid;
             break;
         }
         if ($device->GetFolderUUID($folderid)) {
             $foldertype = $device->GetFolderType($folderid);
             switch ($foldertype) {
                 case SYNC_FOLDER_TYPE_APPOINTMENT:
                 case SYNC_FOLDER_TYPE_USER_APPOINTMENT:
                     if ($type == "calendar") {
                         $folders[] = $folderid;
                     }
                     break;
                 case SYNC_FOLDER_TYPE_CONTACT:
                 case SYNC_FOLDER_TYPE_USER_CONTACT:
                     if ($type == "contact") {
                         $folders[] = $folderid;
                     }
                     break;
                 case SYNC_FOLDER_TYPE_TASK:
                 case SYNC_FOLDER_TYPE_USER_TASK:
                     if ($type == "task") {
                         $folders[] = $folderid;
                     }
                     break;
                 case SYNC_FOLDER_TYPE_NOTE:
                 case SYNC_FOLDER_TYPE_USER_NOTE:
                     if ($type == "note") {
                         $folders[] = $folderid;
                     }
                     break;
                 default:
                     if ($type == "email") {
                         $folders[] = $folderid;
                     }
                     break;
             }
         }
     }
     $stat = ZPushAdmin::ResyncFolder($user, $deviceId, $folders);
     echo sprintf("Resync of %d folders of type %s on device '%s' of user '%s': %s\n", count($folders), $type, $deviceId, $user, $stat ? 'Requested' : ZLog::GetLastMessage(LOGLEVEL_ERROR));
 }
Beispiel #2
0
 /**
  * Marks a folder of a device of the Request::GetGETUser() for resynchronization.
  *
  * @param string    $deviceId       the device id
  * @param string    $folderId       the folder id
  *
  * @access public
  * @return boolean
  * @throws SoapFault
  */
 public function ResyncFolder($deviceId, $folderId)
 {
     $deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
     $folderId = preg_replace("/[^A-Za-z0-9]/", "", $folderId);
     ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceDevice::ResyncFolder('%s','%s'): mark folder of a device of user '%s' for resynchronization", $deviceId, $folderId, Request::GetGETUser()));
     if (!ZPushAdmin::ResyncFolder(Request::GetGETUser(), $deviceId, $folderId)) {
         ZPush::GetTopCollector()->AnnounceInformation(ZLog::GetLastMessage(LOGLEVEL_ERROR), true);
         throw new SoapFault("ERROR", ZLog::GetLastMessage(LOGLEVEL_ERROR));
     }
     ZPush::GetTopCollector()->AnnounceInformation(sprintf("Folder resync requested - device id '%s', folder id '%s", $deviceId, $folderId), true);
     return true;
 }
Beispiel #3
0
 /**
  * Imports a move of a message. This occurs when a user moves an item to another folder
  *
  * @param string        $id
  * @param string        $newfolder
  *
  * @access public
  * @return boolean
  */
 public function ImportMessageMove($id, $newfolder)
 {
     ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesCombined->ImportMessageMove('%s', '%s')", $id, $newfolder));
     if (!$this->icc) {
         ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ImportMessageMove icc not configured");
         return false;
     }
     if ($this->backend->GetBackendId($this->folderid) != $this->backend->GetBackendId($newfolder)) {
         ZLog::Write(LOGLEVEL_WARN, "ImportChangesCombined->ImportMessageMove() cannot move message between two backends");
         return false;
     }
     $res = $this->icc->ImportMessageMove($id, $this->backend->GetBackendFolder($newfolder));
     if ($res) {
         //TODO: we should add newid to new folder, instead of a full folder resync
         ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesCombined->ImportMessageMove(): Force resync of dest folder (%s)", $newfolder));
         ZPushAdmin::ResyncFolder(Request::GetAuthUser(), Request::GetDeviceID(), $newfolder);
     }
     return $res;
 }
Beispiel #4
0
 /**
  * Resynchronizes a folder type of a device & user
  *
  * @param string    $deviceId       the id of the device
  * @param string    $user           the user
  * @param string    $type           the folder type
  *
  * @return
  * @access private
  */
 private static function resyncFolder($deviceId, $user, $type)
 {
     $device = ZPushAdmin::GetDeviceDetails($deviceId, $user);
     if (!$device instanceof ASDevice) {
         echo sprintf("Folder resync failed: %s\n", ZLog::GetLastMessage(LOGLEVEL_ERROR));
         return false;
     }
     $folders = array();
     $searchFor = $type;
     // get the KOE gab folderid
     if ($type == self::TYPE_OPTION_GAB) {
         if (@constant('KOE_GAB_FOLDERID') !== '') {
             $gab = KOE_GAB_FOLDERID;
         } else {
             $gab = $device->GetKoeGabBackendFolderId();
         }
         if (!$gab) {
             printf("Could not find KOE GAB folderid for device '%s' of user '%s'\n", $deviceId, $user);
             return false;
         }
         $searchFor = $gab;
     }
     // potential long ids are converted to folderids here, incl. the gab id
     $searchFor = strtolower($device->GetFolderIdForBackendId($searchFor, false, false, null));
     foreach ($device->GetAllFolderIds() as $folderid) {
         // if  submitting a folderid as type to resync a specific folder.
         if (strtolower($folderid) === $searchFor) {
             printf("Found and resynching requested folderid '%s' on device '%s' of user '%s'\n", $folderid, $deviceId, $user);
             $folders[] = $folderid;
             break;
         }
         if ($device->GetFolderUUID($folderid)) {
             $foldertype = $device->GetFolderType($folderid);
             switch ($foldertype) {
                 case SYNC_FOLDER_TYPE_APPOINTMENT:
                 case SYNC_FOLDER_TYPE_USER_APPOINTMENT:
                     if ($searchFor == "calendar") {
                         $folders[] = $folderid;
                     }
                     break;
                 case SYNC_FOLDER_TYPE_CONTACT:
                 case SYNC_FOLDER_TYPE_USER_CONTACT:
                     if ($searchFor == "contact") {
                         $folders[] = $folderid;
                     }
                     break;
                 case SYNC_FOLDER_TYPE_TASK:
                 case SYNC_FOLDER_TYPE_USER_TASK:
                     if ($searchFor == "task") {
                         $folders[] = $folderid;
                     }
                     break;
                 case SYNC_FOLDER_TYPE_NOTE:
                 case SYNC_FOLDER_TYPE_USER_NOTE:
                     if ($searchFor == "note") {
                         $folders[] = $folderid;
                     }
                     break;
                 default:
                     if ($searchFor == "email") {
                         $folders[] = $folderid;
                     }
                     break;
             }
         }
     }
     $stat = ZPushAdmin::ResyncFolder($user, $deviceId, $folders);
     echo sprintf("Resync of %d folders of type '%s' on device '%s' of user '%s': %s\n", count($folders), $type, $deviceId, $user, $stat ? 'Requested' : ZLog::GetLastMessage(LOGLEVEL_ERROR));
 }