コード例 #1
0
ファイル: ClientSort.php プロジェクト: netcon-source/apps
 /**
  * Sort search results client side if the server does not support the SORT
  * IMAP extension (RFC 5256).
  *
  * @param Horde_Imap_Client_Ids $res  The search results.
  * @param array $opts                 The options to _search().
  *
  * @return array  The sort results.
  *
  * @throws Horde_Imap_Client_Exception
  */
 public function clientSort($res, $opts)
 {
     if (!count($res)) {
         return $res;
     }
     /* Generate the FETCH command needed. */
     $query = new Horde_Imap_Client_Fetch_Query();
     foreach ($opts['sort'] as $val) {
         switch ($val) {
             case Horde_Imap_Client::SORT_ARRIVAL:
                 $query->imapDate();
                 break;
             case Horde_Imap_Client::SORT_DATE:
                 $query->imapDate();
                 $query->envelope();
                 break;
             case Horde_Imap_Client::SORT_CC:
             case Horde_Imap_Client::SORT_DISPLAYFROM:
             case Horde_Imap_Client::SORT_DISPLAYTO:
             case Horde_Imap_Client::SORT_FROM:
             case Horde_Imap_Client::SORT_SUBJECT:
             case Horde_Imap_Client::SORT_TO:
                 $query->envelope();
                 break;
             case Horde_Imap_Client::SORT_SIZE:
                 $query->size();
                 break;
         }
     }
     if (!count($query)) {
         return $res;
     }
     $mbox = $this->_socket->currentMailbox();
     $fetch_res = $this->_socket->fetch($mbox['mailbox'], $query, array('ids' => $res));
     return $this->_clientSortProcess($res->ids, $fetch_res, $opts['sort']);
 }