当前位置: 首页>>代码示例>>PHP>>正文


PHP Horde_Imap_Client_Fetch_Query类代码示例

本文整理汇总了PHP中Horde_Imap_Client_Fetch_Query的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Imap_Client_Fetch_Query类的具体用法?PHP Horde_Imap_Client_Fetch_Query怎么用?PHP Horde_Imap_Client_Fetch_Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Horde_Imap_Client_Fetch_Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @param IMP_Indices $indices  The index of the message.
  * @param boolean $peek         Don't set seen flag?
  */
 public function __construct(IMP_Indices $indices, $peek = false)
 {
     global $injector;
     /* Get envelope/header information. We don't use flags in this
      * view. */
     try {
         list($mbox, $uid) = $indices->getSingle();
         if (!$uid) {
             throw new Exception();
         }
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->envelope();
         $query->headers('imp', self::$headersUsed, array('cache' => true, 'peek' => true));
         $imp_imap = $mbox->imp_imap;
         $imp_imap->openMailbox($mbox, Horde_Imap_Client::OPEN_READWRITE);
         $ret = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
         if (!($ob = $ret->first())) {
             throw new Exception();
         }
         $this->contents = $injector->getInstance('IMP_Factory_Contents')->create($indices);
         if (!$peek) {
             $this->_loadHeaders();
         }
     } catch (Exception $e) {
         throw new IMP_Exception(_("Requested message not found."));
     }
     $this->_envelope = $ob->getEnvelope();
     $this->_headers = $ob->getHeaders('imp', Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
     $this->_indices = $indices;
     $this->_peek = $peek;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:37,代码来源:Message.php

示例2: execute

 /**
  * Renames the old sent-mail mailboxes.
  *
  * Mailbox name: sent-mail-month-year
  *   month = English:         3 letter abbreviation
  *           Other Languages: Month value (01-12)
  *   year  = 4 digit year
  *
  * The mailbox name needs to be in this specific format (as opposed to a
  * user-defined one) to ensure that 'delete_sentmail_monthly' processing
  * can accurately find all the old sent-mail mailboxes.
  *
  * @return boolean  Whether all sent-mail mailboxes were renamed.
  */
 public function execute()
 {
     global $notification;
     $date_format = substr($GLOBALS['language'], 0, 2) == 'en' ? 'M-Y' : 'm-Y';
     $datetime = new DateTime();
     $now = $datetime->format($date_format);
     foreach ($this->_getSentmail() as $sent) {
         /* Display a message to the user and rename the mailbox.
          * Only do this if sent-mail mailbox currently exists. */
         if ($sent->exists) {
             $notification->push(sprintf(_("\"%s\" mailbox being renamed at the start of the month."), $sent->display), 'horde.message');
             $query = new Horde_Imap_Client_Fetch_Query();
             $query->imapDate();
             $query->uid();
             $imp_imap = $sent->imp_imap;
             $res = $imp_imap->fetch($sent, $query);
             $msgs = array();
             foreach ($res as $val) {
                 $date_string = $val->getImapDate()->format($date_format);
                 if (!isset($msgs[$date_string])) {
                     $msgs[$date_string] = $imp_imap->getIdsOb();
                 }
                 $msgs[$date_string]->add($val->getUid());
             }
             unset($msgs[$now]);
             foreach ($msgs as $key => $val) {
                 $new_mbox = IMP_Mailbox::get(strval($sent) . '-' . Horde_String::lower($key));
                 $imp_imap->copy($sent, $new_mbox, array('create' => true, 'ids' => $val, 'move' => true));
             }
         }
     }
     return true;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:47,代码来源:RenameSentmailMonthly.php

示例3: getMessages

 public function getMessages($from = 0, $count = 2)
 {
     $total = $this->getTotalMessages();
     if ($from + $count > $total) {
         $count = $total - $from;
     }
     $headers = array();
     $fetch_query = new \Horde_Imap_Client_Fetch_Query();
     $fetch_query->envelope();
     $fetch_query->flags();
     $fetch_query->seq();
     $fetch_query->size();
     $fetch_query->uid();
     $fetch_query->imapDate();
     $headers = array_merge($headers, array('importance', 'list-post', 'x-priority'));
     $headers[] = 'content-type';
     $fetch_query->headers('imp', $headers, array('cache' => true, 'peek' => true));
     $opt = array('ids' => $from + 1 . ':' . ($from + 1 + $count));
     $opt = array();
     // $list is an array of Horde_Imap_Client_Data_Fetch objects.
     $headers = $this->conn->fetch($this->folder_id, $fetch_query, $opt);
     ob_start();
     // fix for Horde warnings
     $messages = array();
     foreach ($headers as $message_id => $header) {
         $message = new Message($this->conn, $this->folder_id, $message_id);
         $message->setInfo($header);
         $messages[] = $message->getListArray();
     }
     ob_clean();
     return $messages;
 }
开发者ID:netcon-source,项目名称:apps,代码行数:32,代码来源:mailbox.php

示例4: fetchEnvelope

 /**
  */
 public function fetchEnvelope($indices)
 {
     if ($GLOBALS['registry']->hasMethod('mail/imapOb')) {
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->envelope();
         $query->uid();
         try {
             return $GLOBALS['registry']->call('mail/imapOb')->fetch($this->_getMboxOb(), $query, array('ids' => new Horde_Imap_Client_Ids($indices)));
         } catch (Horde_Imap_Client_Exception $e) {
         }
     }
     return false;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:15,代码来源:Live.php

示例5: getMessageIds

 /**
  */
 public function getMessageIds()
 {
     if (isset($this->_msgids)) {
         return $this->_msgids;
     }
     $this->_msgids = array();
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->envelope();
     $ret = $this->_mbox->imp_imap->fetch($this->_mbox, $query, array('ids' => $this->_ids));
     foreach ($ret as $ob) {
         $this->_msgids[] = $ob->getEnvelope()->message_id;
     }
     return $this->_msgids;
 }
开发者ID:horde,项目名称:horde,代码行数:16,代码来源:Messages.php

示例6: load

 private function load()
 {
     $headers = [];
     $fetch_query = new \Horde_Imap_Client_Fetch_Query();
     $fetch_query->bodyPart($this->attachmentId);
     $fetch_query->mimeHeader($this->attachmentId);
     $headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
     $headers[] = 'content-type';
     $fetch_query->headers('imp', $headers, ['cache' => true]);
     // $list is an array of Horde_Imap_Client_Data_Fetch objects.
     $ids = new \Horde_Imap_Client_Ids($this->messageId);
     $headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
     /** @var $fetch Horde_Imap_Client_Data_Fetch */
     if (!isset($headers[$this->messageId])) {
         throw new DoesNotExistException('Unable to load the attachment.');
     }
     $fetch = $headers[$this->messageId];
     $mimeHeaders = $fetch->getMimeHeader($this->attachmentId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
     $this->mimePart = new \Horde_Mime_Part();
     // To prevent potential problems with the SOP we serve all files with the
     // MIME type "application/octet-stream"
     $this->mimePart->setType('application/octet-stream');
     // Serve all files with a content-disposition of "attachment" to prevent Cross-Site Scripting
     $this->mimePart->setDisposition('attachment');
     // Extract headers from part
     $contentDisposition = $mimeHeaders->getValue('content-disposition', \Horde_Mime_Headers::VALUE_PARAMS);
     if (!is_null($contentDisposition)) {
         $vars = ['filename'];
         foreach ($contentDisposition as $key => $val) {
             if (in_array($key, $vars)) {
                 $this->mimePart->setDispositionParameter($key, $val);
             }
         }
     } else {
         $contentDisposition = $mimeHeaders->getValue('content-type', \Horde_Mime_Headers::VALUE_PARAMS);
         $vars = ['name'];
         foreach ($contentDisposition as $key => $val) {
             if (in_array($key, $vars)) {
                 $this->mimePart->setContentTypeParameter($key, $val);
             }
         }
     }
     /* Content transfer encoding. */
     if ($tmp = $mimeHeaders->getValue('content-transfer-encoding')) {
         $this->mimePart->setTransferEncoding($tmp);
     }
     $body = $fetch->getBodyPart($this->attachmentId);
     $this->mimePart->setContents($body);
 }
开发者ID:matiasdelellis,项目名称:mail,代码行数:49,代码来源:attachment.php

示例7: getMessages

 public function getMessages($from = 0, $count = 2, $filter = '')
 {
     if ($filter instanceof Horde_Imap_Client_Search_Query) {
         $query = $filter;
     } else {
         $query = new Horde_Imap_Client_Search_Query();
         if ($filter) {
             $query->text($filter, false);
         }
     }
     if ($this->getSpecialRole() !== 'trash') {
         $query->flag(Horde_Imap_Client::FLAG_DELETED, false);
     }
     $result = $this->conn->search($this->mailBox, $query, ['sort' => [Horde_Imap_Client::SORT_DATE]]);
     $ids = array_reverse($result['match']->ids);
     if ($from >= 0 && $count >= 0) {
         $ids = array_slice($ids, $from, $count);
     }
     $ids = new \Horde_Imap_Client_Ids($ids, false);
     $headers = [];
     $fetch_query = new \Horde_Imap_Client_Fetch_Query();
     $fetch_query->envelope();
     $fetch_query->flags();
     $fetch_query->size();
     $fetch_query->uid();
     $fetch_query->imapDate();
     $fetch_query->structure();
     $headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
     $headers[] = 'content-type';
     $fetch_query->headers('imp', $headers, ['cache' => true, 'peek' => true]);
     $options = ['ids' => $ids];
     // $list is an array of Horde_Imap_Client_Data_Fetch objects.
     $headers = $this->conn->fetch($this->mailBox, $fetch_query, $options);
     ob_start();
     // fix for Horde warnings
     $messages = [];
     foreach ($headers->ids() as $message_id) {
         $header = $headers[$message_id];
         $message = new IMAPMessage($this->conn, $this->mailBox, $message_id, $header);
         $messages[] = $message->getListArray();
     }
     ob_get_clean();
     // sort by time
     usort($messages, function ($a, $b) {
         return $a['dateInt'] < $b['dateInt'];
     });
     return $messages;
 }
开发者ID:Gomez,项目名称:mail,代码行数:48,代码来源:mailbox.php

示例8: getSize

 /**
  * Obtain the mailbox size
  *
  * @param IMP_Mailbox $mbox   The mailbox to obtain the size of.
  * @param boolean $formatted  Whether to return a human readable value.
  *
  * @return mixed  Either the size of the mailbox (in bytes) or a formatted
  *                string with this information.
  */
 public function getSize(IMP_Mailbox $mbox, $formatted = true)
 {
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->size();
     try {
         $imp_imap = $mbox->imp_imap;
         $res = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb(Horde_Imap_Client_Ids::ALL, true)));
         $size = 0;
         foreach ($res as $v) {
             $size += $v->getSize();
         }
         return $formatted ? sprintf(_("%.2fMB"), $size / (1024 * 1024)) : $size;
     } catch (IMP_Imap_Exception $e) {
         return 0;
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:25,代码来源:Size.php

示例9: __get

 /**
  */
 public function __get($name)
 {
     switch ($name) {
         case 'indices':
             return $this->_indices;
         case 'msgid':
             if (!$this->_msgid) {
                 list($mbox, $uid) = $this->indices->getSingle();
                 $query = new Horde_Imap_Client_Fetch_Query();
                 $query->envelope();
                 $imp_imap = $mbox->imp_imap;
                 $ret = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
                 $this->_msgid = ($ob = $ret->first()) ? $ob->getEnvelope()->message_id : '';
             }
             return $this->_msgid;
     }
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:19,代码来源:Message.php

示例10: getLog

 /**
  */
 public function getLog(IMP_Maillog_Message $msg, array $types = array())
 {
     $log_ob = new IMP_Maillog_Log_Mdn();
     if (!empty($types) && !in_array('IMP_Maillog_Log_Mdn', $types) || !$this->isAvailable($msg, $log_ob)) {
         return array();
     }
     list($mbox, $uid) = $msg->indices->getSingle();
     $imp_imap = $mbox->imp_imap;
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->flags();
     try {
         $flags = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)))->first()->getFlags();
     } catch (IMP_Imap_Exception $e) {
         $flags = array();
     }
     return in_array(Horde_Imap_Client::FLAG_MDNSENT, $flags) ? array($log_ob) : array();
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:19,代码来源:Mdnsent.php

示例11: getLog

 /**
  */
 public function getLog(IMP_Maillog_Message $msg, array $filter = array())
 {
     if (!$msg->indices || in_array('mdn', $filter)) {
         return array();
     }
     list($mbox, $uid) = $msg->indices->getSingle();
     if (!$mbox->permflags->allowed(Horde_Imap_Client::FLAG_MDNSENT)) {
         return array();
     }
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->flags();
     $imp_imap = $mbox->imp_imap;
     try {
         $flags = $imp_imap->fetch($mbox, $query, array('ids' => $imp_imap->getIdsOb($uid)))->first()->getFlags();
     } catch (IMP_Imap_Exception $e) {
         $flags = array();
     }
     return in_array(Horde_Imap_Client::FLAG_MDNSENT, $flags) ? array(new IMP_Maillog_Log_Mdn()) : array();
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:21,代码来源:Mdnsent.php

示例12: clientSort

 /**
  * 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_SEQUENCE:
                 $query->seq();
                 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']);
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:50,代码来源:ClientSort.php

示例13: _content

 /**
  */
 protected function _content()
 {
     $inbox = IMP_Mailbox::get('INBOX');
     /* Filter on INBOX display, if requested. */
     $inbox->filterOnDisplay();
     $query = new Horde_Imap_Client_Search_Query();
     $query->flag(Horde_Imap_Client::FLAG_SEEN, false);
     $ids = $inbox->runSearchQuery($query, Horde_Imap_Client::SORT_SEQUENCE, 1);
     $indices = $ids['INBOX'];
     $html = '<table cellspacing="0" width="100%">';
     $text = _("Go to your Inbox...");
     if (empty($indices)) {
         $html .= '<tr><td><em>' . _("No unread messages") . '</em></td></tr>';
     } else {
         $imp_ui = new IMP_Mailbox_Ui($inbox);
         $shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown'];
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->envelope();
         try {
             $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create($inbox);
             $fetch_ret = $imp_imap->fetch($inbox, $query, array('ids' => $imp_imap->getIdsOb(array_slice($indices, 0, $shown))));
         } catch (IMP_Imap_Exception $e) {
             $fetch_ret = new Horde_Imap_Client_Fetch_Results();
         }
         foreach ($fetch_ret as $uid => $ob) {
             $envelope = $ob->getEnvelope();
             $date = $imp_ui->getDate(isset($envelope->date) ? $envelope->date : null);
             $from = $imp_ui->getFrom($envelope);
             $subject = $imp_ui->getSubject($envelope->subject, true);
             $html .= '<tr style="cursor:pointer" class="text"><td>' . $inbox->url('message', $uid)->link() . '<strong>' . htmlspecialchars($from['from'], ENT_QUOTES, 'UTF-8') . '</strong><br />' . $subject . '</a></td>' . '<td>' . htmlspecialchars($date, ENT_QUOTES, 'UTF-8') . '</td></tr>';
         }
         $more_msgs = count($indices) - $shown;
         if ($more_msgs > 0) {
             $text = sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs);
         }
     }
     return $html . '<tr><td colspan="2" style="cursor:pointer" align="right">' . $inbox->url('mailbox')->link() . $text . '</a></td></tr>' . '</table>';
 }
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:40,代码来源:Newmail.php

示例14: getChanges

 /**
  * Return a folder object containing all IMAP server change information.
  *
  * @param array $options  An array of options.
  *        @see Horde_ActiveSync_Imap_Adapter::getMessageChanges
  *
  * @return Horde_ActiveSync_Folder_Base  The populated folder object.
  */
 public function getChanges(array $options)
 {
     $this->_logger->info(sprintf('[%s] NO CONDSTORE or per mailbox MODSEQ. minuid: %s, total_messages: %s', $this->_procid, $this->_folder->minuid(), $this->_status['messages']));
     $query = new Horde_Imap_Client_Search_Query();
     if (!empty($options['sincedate'])) {
         $query->dateSearch(new Horde_Date($options['sincedate']), Horde_Imap_Client_Search_Query::DATE_SINCE);
     }
     try {
         $search_ret = $this->_imap_ob->search($this->_mbox, $query, array('results' => array(Horde_Imap_Client::SEARCH_RESULTS_MATCH)));
     } catch (Horde_Imap_Client_Exception $e) {
         $this->_logger->err($e->getMessage());
         throw new Horde_ActiveSync_Exception($e);
     }
     $cnt = $search_ret['count'] / Horde_ActiveSync_Imap_Adapter::MAX_FETCH + 1;
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->flags();
     $flags = array();
     for ($i = 0; $i <= $cnt; $i++) {
         $ids = new Horde_Imap_Client_Ids(array_slice($search_ret['match']->ids, $i * Horde_ActiveSync_Imap_Adapter::MAX_FETCH, Horde_ActiveSync_Imap_Adapter::MAX_FETCH));
         try {
             $fetch_ret = $this->_imap_ob->fetch($this->_mbox, $query, array('ids' => $ids));
         } catch (Horde_Imap_Client_Exception $e) {
             $this->_logger->err($e->getMessage());
             throw new Horde_ActiveSync_Exception($e);
         }
         foreach ($fetch_ret as $uid => $data) {
             $flags[$uid] = array('read' => array_search(Horde_Imap_Client::FLAG_SEEN, $data->getFlags()) !== false ? 1 : 0);
             if ($options['protocolversion'] > Horde_ActiveSync::VERSION_TWOFIVE) {
                 $flags[$uid]['flagged'] = array_search(Horde_Imap_Client::FLAG_FLAGGED, $data->getFlags()) !== false ? 1 : 0;
             }
         }
     }
     if (!empty($flags)) {
         $this->_folder->setChanges($search_ret['match']->ids, $flags);
     }
     $this->_folder->setRemoved($this->_imap_ob->vanished($this->_mbox, null, array('ids' => new Horde_Imap_Client_Ids($this->_folder->messages())))->ids);
     return $this->_folder;
 }
开发者ID:horde,项目名称:horde,代码行数:46,代码来源:Plain.php

示例15: searchCallback

 /**
  */
 public function searchCallback(IMP_Mailbox $mbox, array $ids)
 {
     $fetch_query = new Horde_Imap_Client_Fetch_Query();
     $fetch_query->structure();
     $fetch_res = $mbox->imp_imap->fetch($mbox, $fetch_query, array('ids' => $mbox->imp_imap->getIdsOb($ids)));
     $out = array();
     foreach ($ids as $v) {
         if (isset($fetch_res[$v])) {
             $atc = false;
             foreach ($fetch_res[$v]->getStructure()->partIterator() as $val) {
                 if ($val->isAttachment()) {
                     $atc = true;
                     break;
                 }
             }
             if ($this->_data && $atc || !$this->_data && !$atc) {
                 continue;
             }
         }
         $out[] = $v;
     }
     return $out;
 }
开发者ID:horde,项目名称:horde,代码行数:25,代码来源:Attachment.php


注:本文中的Horde_Imap_Client_Fetch_Query类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。