equals() публичный Метод

Compares this mailbox to another mailbox string.
public equals ( $mbox ) : boolean
Результат boolean True if the items are equal.
Пример #1
0
 /**
  */
 protected function _renameMailbox(Horde_Imap_Client_Mailbox $old, Horde_Imap_Client_Mailbox $new)
 {
     // Some IMAP servers will not allow a rename of a currently open
     // mailbox.
     if ($old->equals($this->_selected)) {
         $this->close();
     }
     // RENAME returns no untagged information (RFC 3501 [6.3.5])
     $this->_sendCmd($this->_command('RENAME')->add(array(new Horde_Imap_Client_Data_Format_Mailbox($old), new Horde_Imap_Client_Data_Format_Mailbox($new))));
 }
Пример #2
0
 /**
  */
 protected function _status(Horde_Imap_Client_Mailbox $mailbox, $flags)
 {
     $data = array();
     $query = new Horde_Imap_Client_Data_Format_List();
     $search = null;
     $items = array(Horde_Imap_Client::STATUS_MESSAGES => 'messages', Horde_Imap_Client::STATUS_RECENT => 'recent', Horde_Imap_Client::STATUS_UIDNEXT => 'uidnext', Horde_Imap_Client::STATUS_UIDVALIDITY => 'uidvalidity', Horde_Imap_Client::STATUS_UNSEEN => 'unseen', Horde_Imap_Client::STATUS_FIRSTUNSEEN => 'firstunseen', Horde_Imap_Client::STATUS_FLAGS => 'flags', Horde_Imap_Client::STATUS_PERMFLAGS => 'permflags', Horde_Imap_Client::STATUS_UIDNOTSTICKY => 'uidnotsticky');
     /* Don't include modseq returns if server does not support it. */
     if ($this->queryCapability('CONDSTORE')) {
         $items[Horde_Imap_Client::STATUS_HIGHESTMODSEQ] = 'highestmodseq';
         /* Even though CONDSTORE is available, it may not yet have been
          * enabled. */
         if ($flags & Horde_Imap_Client::STATUS_HIGHESTMODSEQ && !isset($this->_init['enabled']['CONDSTORE'])) {
             $this->_setInit('enabled', array_merge($this->_init['enabled'], array('CONDSTORE' => true)));
         }
         /* If highestmodseq for the current mailbox is -1, and that is
          * the mailbox we are querying, then we need to close the current
          * mailbox; CONDSTORE is preventing us from getting the updated
          * value within the current mailbox. */
         if ($mailbox->equals($this->_selected) && isset($this->_temp['mailbox']['highestmodseq']) && $this->_temp['mailbox']['highestmodseq'] === -1) {
             $this->close();
         }
     }
     /* If FLAGS/PERMFLAGS/UIDNOTSTICKY/FIRSTUNSEEN are needed, we must do
      * a SELECT/EXAMINE to get this information (data will be caught in
      * the code below). */
     if ($flags & Horde_Imap_Client::STATUS_FIRSTUNSEEN || $flags & Horde_Imap_Client::STATUS_FLAGS || $flags & Horde_Imap_Client::STATUS_PERMFLAGS || $flags & Horde_Imap_Client::STATUS_UIDNOTSTICKY) {
         $this->openMailbox($mailbox);
     }
     foreach ($items as $key => $val) {
         if ($key & $flags) {
             if ($mailbox->equals($this->_selected)) {
                 if (isset($this->_temp['mailbox'][$val])) {
                     $data[$val] = $this->_temp['mailbox'][$val];
                 } elseif ($key == Horde_Imap_Client::STATUS_UIDNEXT) {
                     /* UIDNEXT is not strictly required on mailbox open.
                      * See RFC 3501 [6.3.1]. */
                     $data[$val] = 0;
                     if ($flags & Horde_Imap_Client::STATUS_UIDNEXT_FORCE && !empty($this->_temp['mailbox']['messages'])) {
                         $squery = new Horde_Imap_Client_Search_Query();
                         $squery->ids($this->getIdsOb(Horde_Imap_Client_Ids::LARGEST));
                         $s_res = $this->search($this->_selected, $squery);
                         $data[$val] = $s_res['match']->ids[0] + 1;
                     }
                 } elseif ($key == Horde_Imap_Client::STATUS_UIDNOTSTICKY) {
                     /* In the absence of uidnotsticky information, or
                      * if UIDPLUS is not supported, we assume the UIDs
                      * are sticky. */
                     $data[$val] = false;
                 } elseif ($key == Horde_Imap_Client::STATUS_PERMFLAGS) {
                     /* If PERMFLAGS is not returned by server, must assume
                      * that all flags can be changed permanently. See
                      * RFC 3501 [6.3.1]. */
                     $data[$val] = isset($this->_temp['mailbox'][$items[Horde_Imap_Client::STATUS_FLAGS]]) ? $this->_temp['mailbox'][$items[Horde_Imap_Client::STATUS_FLAGS]] : array();
                     $data[$val][] = "\\*";
                 } elseif (in_array($key, array(Horde_Imap_Client::STATUS_FIRSTUNSEEN, Horde_Imap_Client::STATUS_UNSEEN))) {
                     /* If we already know there are no messages in the
                      * current mailbox, we know there is no firstunseen
                      * and unseen info also. */
                     if (empty($this->_temp['mailbox']['messages'])) {
                         $data[$val] = $key == Horde_Imap_Client::STATUS_FIRSTUNSEEN ? null : 0;
                     } else {
                         /* RFC 3501 [6.3.1] - FIRSTUNSEEN information is
                          * not mandatory. If missing in EXAMINE/SELECT
                          * results, we need to do a search. An UNSEEN
                          * count also requires a search. */
                         if (is_null($search)) {
                             $search_query = new Horde_Imap_Client_Search_Query();
                             $search_query->flag(Horde_Imap_Client::FLAG_SEEN, false);
                             $search = $this->search($mailbox, $search_query, array('results' => array($key == Horde_Imap_Client::STATUS_FIRSTUNSEEN ? Horde_Imap_Client::SEARCH_RESULTS_MIN : Horde_Imap_Client::SEARCH_RESULTS_COUNT), 'sequence' => true));
                         }
                         $data[$val] = $search[$key == Horde_Imap_Client::STATUS_FIRSTUNSEEN ? 'min' : 'count'];
                     }
                 }
             } else {
                 $query->add(strtoupper($val));
             }
         }
     }
     if (!count($query)) {
         return $data;
     }
     $cmd = $this->_clientCommand(array('STATUS', new Horde_Imap_Client_Data_Format_Mailbox($mailbox), $query));
     $this->_sendLine($cmd);
     return $this->_temp['status'][strval($mailbox)];
 }