add() public method

Input format:
1 argument:
-----------
+ Array
  Either:
    KEYS: Mailbox names
    VALUES: UIDs -or- Horde_Imap_Client_Ids object
 -or-
    VALUES: IMAP sequence strings
+ IMP_Compose object
+ IMP_Contents object
+ IMP_Indices object
+ String
  Format: IMAP sequence string

2 arguments:
------------
1st argument: Mailbox name -or- IMP_Mailbox object
2nd argument: Either a single UID, array of UIDs, or a
              Horde_Imap_Client_Ids object.
public add ( )
示例#1
0
 /**
  */
 public function getIndicesOb()
 {
     $this->_buildMailbox();
     $ob = new IMP_Indices();
     reset($this->_sorted);
     while (list($k, $v) = each($this->_sorted)) {
         $ob->add($this->_sortedMbox[$k], $v);
     }
     return $ob;
 }
示例#2
0
文件: Mailbox.php 项目: Gomez/horde
 /**
  * Create a BUID indices object from a list of UIDs.
  *
  * @param IMP_Indices $uids  UIDs.
  *
  * @return IMP_Indices  An indices object.
  */
 public function toBuids(IMP_Indices $uids)
 {
     $list_ob = $this->list_ob;
     $out = new IMP_Indices();
     foreach ($uids as $val) {
         foreach ($val->uids as $val2) {
             $out->add($this->_mbox, $list_ob->getBuid($val->mbox, $val2));
         }
     }
     return $out;
 }
示例#3
0
 /**
  * Resumes a previously saved draft message.
  *
  * @param IMP_Indices $indices  See resumeDraft().
  * @param integer $type         Compose type.
  * @param array $opts           Additional options:
  *   - format: (string) Force to this format.
  *             DEFAULT: Auto-determine.
  *
  * @return mixed  See resumeDraft().
  *
  * @throws IMP_Compose_Exception
  */
 protected function _resumeDraft($indices, $type, $opts)
 {
     global $injector, $notification, $prefs;
     $contents_factory = $injector->getInstance('IMP_Factory_Contents');
     try {
         $contents = $contents_factory->create($indices);
     } catch (IMP_Exception $e) {
         throw new IMP_Compose_Exception($e);
     }
     $headers = $contents->getHeader();
     $imp_draft = false;
     if ($draft_url = $headers[self::DRAFT_REPLY]) {
         if (is_null($type) && !($type = $headers[self::DRAFT_REPLY_TYPE])) {
             $type = self::REPLY;
         }
         $imp_draft = self::REPLY;
     } elseif ($draft_url = $headers[self::DRAFT_FWD]) {
         $imp_draft = self::FORWARD;
         if (is_null($type)) {
             $type = self::FORWARD;
         }
     } elseif (isset($headers[self::DRAFT_HDR])) {
         $imp_draft = self::COMPOSE;
     }
     if (!empty($opts['format'])) {
         $compose_html = $opts['format'] == 'html';
     } elseif ($prefs->getValue('compose_html')) {
         $compose_html = true;
     } else {
         switch ($type) {
             case self::EDITASNEW:
             case self::FORWARD:
             case self::FORWARD_BODY:
             case self::FORWARD_BOTH:
                 $compose_html = $prefs->getValue('forward_format');
                 break;
             case self::REPLY:
             case self::REPLY_ALL:
             case self::REPLY_LIST:
             case self::REPLY_SENDER:
                 $compose_html = $prefs->getValue('reply_format');
                 break;
             case self::TEMPLATE:
                 $compose_html = true;
                 break;
             default:
                 /* If this is an draft saved by IMP, we know 100% for sure
                  * that if an HTML part exists, the user was composing in
                  * HTML. */
                 $compose_html = $imp_draft !== false;
                 break;
         }
     }
     $msg_text = $this->_getMessageText($contents, array('html' => $compose_html, 'imp_msg' => $imp_draft, 'toflowed' => false));
     if (empty($msg_text)) {
         $body = '';
         $format = 'text';
         $text_id = 0;
     } else {
         /* Use charset at time of initial composition if this is an IMP
          * draft. */
         if ($imp_draft !== false) {
             $this->charset = $msg_text['charset'];
         }
         $body = $msg_text['text'];
         $format = $msg_text['mode'];
         $text_id = $msg_text['id'];
     }
     $mime_message = $contents->getMIMEMessage();
     /* Add attachments. */
     $parts = array();
     if ($mime_message->getPrimaryType() == 'multipart' && $mime_message->getType() != 'multipart/alternative') {
         for ($i = 1;; ++$i) {
             if (intval($text_id) == $i) {
                 continue;
             }
             if ($part = $contents->getMimePart($i)) {
                 $parts[] = $part;
             } else {
                 break;
             }
         }
     } elseif ($mime_message->getDisposition() == 'attachment') {
         $parts[] = $contents->getMimePart('1');
     }
     foreach ($parts as $val) {
         try {
             $this->addAttachmentFromPart($val);
         } catch (IMP_Compose_Exception $e) {
             $notification->push($e, 'horde.warning');
         }
     }
     $alist = new Horde_Mail_Rfc822_List();
     $addr = array('to' => clone $alist, 'cc' => clone $alist, 'bcc' => clone $alist);
     if ($type != self::EDITASNEW) {
         foreach (array('to', 'cc', 'bcc') as $val) {
             if ($h = $headers[$val]) {
                 $addr[$val] = $h->getAddressList(true);
             }
         }
         if ($val = $headers['References']) {
             $this->_setMetadata('references', $val->getIdentificationOb()->ids);
             if ($val = $headers['In-Reply-To']) {
                 $this->_setMetadata('in_reply_to', $val);
             }
         }
         if ($draft_url) {
             $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
             $indices = new IMP_Indices();
             foreach (explode(',', $draft_url->value_single) as $val) {
                 $imap_url = new Horde_Imap_Client_Url(rtrim(ltrim($val, '<'), '>'));
                 try {
                     if ($imap_url->protocol == ($imp_imap->isImap() ? 'imap' : 'pop') && $imap_url->username == $imp_imap->getParam('username') && IMP_Mailbox::get($imap_url->mailbox)->uidvalid == $imap_url->uidvalidity && $contents_factory->create(new IMP_Indices($imap_url->mailbox, $imap_url->uid))) {
                         $indices->add($imap_url->mailbox, $imap_url->uid);
                     }
                 } catch (Exception $e) {
                 }
             }
             if (count($indices)) {
                 $this->_setMetadata('indices', $indices);
                 $this->_replytype = $type;
             }
         }
     }
     $mdn = new Horde_Mime_Mdn($headers);
     $readreceipt = (bool) $mdn->getMdnReturnAddr();
     $this->changed = 'changed';
     return array('addr' => $addr, 'body' => $body, 'format' => $format, 'identity' => $this->_getMatchingIdentity($headers, array('from')), 'priority' => $injector->getInstance('IMP_Mime_Headers')->getPriority($headers), 'readreceipt' => $readreceipt, 'subject' => strval($headers['Subject']), 'type' => $type);
 }