예제 #1
0
 /**
  * add/clear flags on imap server
  * 
  * @param array $_imapMessageUids
  * @param array $_flags
  * @param Felamimail_Backend_ImapProxy $_imapBackend
  * @throws Felamimail_Exception_IMAP
  */
 protected function _updateFlagsOnImap($_imapMessageUids, $_flags, $_imapBackend, $_mode)
 {
     $flagsToChange = array_intersect($_flags, array_keys(self::$_allowedFlags));
     if (empty($flagsToChange)) {
         return;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $_mode . 'ing flags on IMAP server for ' . print_r($_imapMessageUids, TRUE) . ' messages:' . print_r($flagsToChange, TRUE));
     }
     try {
         if ($_mode === 'add') {
             $_imapBackend->addFlags($_imapMessageUids, $flagsToChange);
         } else {
             if ($_mode === 'clear') {
                 $_imapBackend->clearFlags($_imapMessageUids, $flagsToChange);
             }
         }
     } catch (Zend_Mail_Storage_Exception $zmse) {
         throw new Felamimail_Exception_IMAP($zmse->getMessage());
     }
 }
 /**
  * move messages on imap server
  * 
  * @param array $_uids
  * @param string $_targetFolderName
  * @param Felamimail_Backend_ImapProxy $_imap
  * 
  * @todo perhaps we should check the existance of the messages on the imap instead of catching the exceptions here
  */
 protected function _moveBatchOfMessages($_uids, $_targetFolderName, Felamimail_Backend_ImapProxy $_imap)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Move ' . count($_uids) . ' messages to folder ' . $_targetFolderName . ' on imap server');
     }
     try {
         $_imap->copyMessage($_uids, Felamimail_Model_Folder::encodeFolderName($_targetFolderName));
         $_imap->addFlags($_uids, array(Zend_Mail_Storage::FLAG_DELETED));
     } catch (Zend_Mail_Storage_Exception $zmse) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' ' . $zmse);
         }
     } catch (Felamimail_Exception_IMAP $fei) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' ' . $fei);
         }
     }
 }