示例#1
0
 /**
  * @param Folder $folder
  * @return bool
  */
 function PurgeFolder(&$folder, $pop3EmptyTrash = false)
 {
     $result = true;
     if ($this->_settings->StoreMailsInDb) {
         /* remove messages from db, read messages from file system */
         if (!$this->_dbConnection->Execute($this->_commandCreator->SelectDeletedMessagesId($folder, $this->Account, $pop3EmptyTrash))) {
             return false;
         }
         $msgIdSet = array();
         while (false !== ($row = $this->_dbConnection->GetNextRecord())) {
             $msgIdSet[] = $row->id_msg;
         }
         if (count($msgIdSet) > 0) {
             $result &= $this->_dbConnection->Execute($this->_commandCreator->PurgeAllMessagesBody($msgIdSet, $this->Account->Id));
             $result &= $this->_dbConnection->Execute($this->_commandCreator->PurgeAllMessageHeaders($folder, $this->Account, $pop3EmptyTrash));
             return $result;
         } else {
             return true;
         }
     }
     /* read messages from file system */
     if (!$this->_dbConnection->Execute($this->_commandCreator->SelectAllDeletedMsgId($folder, $this->Account, $pop3EmptyTrash))) {
         return false;
     }
     $messageIdSet = array();
     while (false !== ($row = $this->_dbConnection->GetNextRecord())) {
         $messageIdSet[] = $row->id_msg;
     }
     if (count($messageIdSet) > 0) {
         $fs = new FileSystem(INI_DIR . '/mail', strtolower($this->Account->Email), $this->Account->Id);
         $result &= $fs->DeleteMessages($messageIdSet, $folder);
     }
     return $result && $this->_dbConnection->Execute($this->_commandCreator->PurgeAllMessageHeaders($folder, $this->Account, $pop3EmptyTrash));
 }