Beispiel #1
0
 /**
  * Deletes entries
  * 
  * @param string|integer|Tinebase_Record_Interface|array $_id
  * @return void
  * @return int The number of affected rows.
  */
 public function delete($_id)
 {
     if (is_array($_id)) {
         foreach ($_id as $id) {
             $decodedIds = self::decodeMessageId($id);
             $globalname = Felamimail_Backend_Cache_Imap_Folder::decodeFolderUid($decodedIds['folderId']);
             $accountId = $decodedIds['accountId'];
             $imap = Felamimail_Backend_ImapFactory::factory($accountId);
             $imap->expunge($globalname['globalName']);
             $return = count($_id);
         }
     }
     return $return;
 }
 /**
  * Compare order of Felamimail_Model_Message acording to Tinebase_Model_Pagination
  * @param Felamimail_Model_Message $msg1
  * @param Felamimail_Model_Message $msg2
  * @return int 
  * 
  * @todo Convert int security value in Expresso_Smime to corresponding string type
  */
 public function compare($msg1, $msg2)
 {
     switch ($this->_pagination->sort) {
         case 'received':
             // Integer
             $value1 = $msg1[$this->_pagination->sort];
             $value2 = $msg2[$this->_pagination->sort];
         case 'sent':
             // Integer
             $value1 = isset($value1) ? $value1 : $msg1['header']['date'];
             $value2 = isset($value2) ? $value2 : $msg2['header']['date'];
             $value1 = intval(Felamimail_Message::convertDate($value1)->format("U"));
             $value2 = intval(Felamimail_Message::convertDate($value2)->format("U"));
         case 'size':
             // Integer
             $value1 = isset($value1) ? $value1 : intval($msg1[$this->_pagination->sort]);
             $value2 = isset($value2) ? $value2 : intval($msg2[$this->_pagination->sort]);
             return $this->compareIntegers($value1, $value2);
         case 'folder_id':
             // Strings
             $folders = array();
             $translate = Tinebase_Translation::getTranslation('Felamimail');
             foreach (array($msg1, $msg2) as $msg) {
                 $folder = Felamimail_Backend_Cache_Imap_Folder::decodeFolderUid($msg[$this->_pagination->sort]);
                 // Optimization! Only create the account object once for every sort operation.
                 $account = array_key_exists($folder['accountId'], $this->_accountMap) ? $this->_accountMap[$folder['accountId']] : ($this->_accountMap[$folder['accountId']] = Felamimail_Controller_Account::getInstance()->get($folder['accountId']));
                 $aux1 = explode('/', $folder['globalName']);
                 $aux2 = '';
                 foreach ($aux1 as $value) {
                     $aux2 .= $translate->_($value) . '/';
                 }
                 $folders[] = $account->name . '/' . substr($aux2, 0, strlen($aux2) - 1);
             }
             list($value1, $value2) = $folders;
             //TODO: Should use a static method implemented on Model_Message or Expresso_Smime
         //TODO: Should use a static method implemented on Model_Message or Expresso_Smime
         case 'smime':
             $value1 = isset($value1) ? $value1 : $this->processSmimeValue($msg1['structure']);
             $value2 = isset($value2) ? $value2 : $this->processSmimeValue($msg2['structure']);
         case 'flags':
             // Strings
             if (!isset($value1)) {
                 sort($msg1['flags']);
                 $value1 = implode(',', $msg1['flags']);
             }
             if (!isset($value2)) {
                 sort($msg2['flags']);
                 $value2 = implode(',', $msg2['flags']);
             }
         case 'subject':
             // Strings
             $value1 = isset($value1) ? $value1 : $msg1['header'][$this->_pagination->sort];
             $value2 = isset($value2) ? $value2 : $msg2['header'][$this->_pagination->sort];
         case 'id':
             // Strings
             $value1 = isset($value1) ? $value1 : $msg1[$this->_pagination->sort];
             $value2 = isset($value2) ? $value2 : $msg2[$this->_pagination->sort];
             return $this->compareStrings($value1, $value2);
         case 'sender':
         case 'to':
         case 'from_name':
         case 'from_email':
             // Strings
             list($header, $field) = explode('_', $this->_pagination->sort);
             $field = empty($field) ? 'email' : $field;
             $address1 = Felamimail_Message::convertAddresses($msg1['header'][$header]);
             $address2 = Felamimail_Message::convertAddresses($msg2['header'][$header]);
             return $this->compareStrings(isset($address1[0]) && array_key_exists($field, $address1[0]) ? $address1[0][$field] : '', isset($address2[0]) && array_key_exists($field, $address2[0]) ? $address2[0][$field] : '');
     }
 }