Exemplo n.º 1
0
 /**
  * Fetches index data from IMAP server
  */
 private function get_index_data($mailbox, $sort_field, $sort_order, $mbox_data = array())
 {
     $data = array();
     if (empty($mbox_data)) {
         $mbox_data = $this->imap->mailbox_data($mailbox);
     }
     // Prevent infinite loop.
     // It happens when rcube_imap::message_index_direct() is called.
     // There id2uid() is called which will again call get_index() and so on.
     if (!$sort_field && !$this->skip_deleted) {
         $this->icache['pending_index_update'] = true;
     }
     if ($mbox_data['EXISTS']) {
         // fetch sorted sequence numbers
         $data_seq = $this->imap->message_index_direct($mailbox, $sort_field, $sort_order);
         // fetch UIDs
         if (!empty($data_seq)) {
             // Seek in internal cache
             if (array_key_exists('index', (array) $this->icache[$mailbox]) && array_key_exists('result', (array) $this->icache[$mailbox]['index'])) {
                 $data_uid = $this->icache[$mailbox]['index']['result'];
             } else {
                 $data_uid = $this->imap->conn->fetchUIDs($mailbox, $data_seq);
             }
             // build index
             if (!empty($data_uid)) {
                 foreach ($data_seq as $seq) {
                     if ($uid = $data_uid[$seq]) {
                         $data[$seq] = $uid;
                     }
                 }
             }
         }
     }
     // Reset internal flags
     $this->icache['pending_index_update'] = false;
     return $data;
 }