/**
  * @inheritdoc
  */
 public function applyForData(array $data)
 {
     try {
         $this->v('message', $data);
         $d =& $data['message'];
         /**
          * @see \Conjoon_Date_Format
          */
         require_once 'Conjoon/Date/Format.php';
         $date = $this->v('date', $d);
         $date = $date ? $date->format('Y-m-d H:i:s') : null;
         $d['date'] = \Conjoon_Date_Format::utcToLocal($date);
         $ccList = $this->buildAddresses($this->v('cc', $d));
         $toList = $this->buildAddresses($this->v('to', $d));
         $usedAccount = $this->guessAccountUsed(array_merge($toList, $ccList));
         //getMessageTextHeader($subject, $date, array $from, array $replyTo, array $to, array $cc)
         /**
          * @see \Conjoon_Filter_StringPrependIf
          */
         require_once 'Conjoon/Filter/StringPrependIf.php';
         $prep = new \Conjoon_Filter_StringPrependIf(array('Fwd: ', 'FWD:'), 'Fwd: ');
         $d['subject'] = $prep->filter($this->v('subject', $d));
         $messageTextHead = $this->getMessageTextHeader($d['subject'], $d['date'], $this->buildAddresses($this->v('from', $d)), $this->buildAddresses($this->v('replyTo', $d)), $toList, $ccList);
         $d['to'] = array();
         $d['cc'] = array();
         $d['bcc'] = array();
         $d['attachments'] = $this->createAttachments($this->v('attachments', $d));
         $d['inReplyTo'] = "";
         $d['references'] = "";
         $d['groupwareEmailAccountsId'] = null;
         if ($usedAccount) {
             $d['groupwareEmailAccountsId'] = $usedAccount->getId();
         }
         $d['contentTextPlain'] = $messageTextHead . $this->getContentTextPlain($this->v('contentTextPlain', $d));
         $d['contentTextHtml'] = "";
         unset($d['messageId']);
         unset($d['replyTo']);
         unset($d['from']);
         $data['draft'] = $data['message'];
         unset($data['message']);
     } catch (\Exception $e) {
         throw new ServicePatronException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function applyForData(array $data)
 {
     try {
         $this->v('message', $data);
         $d =& $data['message'];
         /**
          * @see \Conjoon_Date_Format
          */
         require_once 'Conjoon/Date/Format.php';
         $date = $this->v('date', $d);
         $date = $date ? $date->format('Y-m-d H:i:s') : null;
         $d['date'] = \Conjoon_Date_Format::utcToLocal($date);
         $ccList = $this->buildAddresses($this->v('cc', $d));
         $toList = $this->buildAddresses($this->v('to', $d));
         $usedAccount = $this->guessAccountUsed(array_merge($toList, $ccList));
         // build "cc" before "to" since "to" gets overwritten later on
         $d['cc'] = $this->buildCcAddressList($ccList, $toList, $usedAccount);
         $d['to'] = $this->getToAddress($this->v('from', $d), $this->v('replyTo', $d));
         $d['bcc'] = array();
         $d['attachments'] = array();
         $messageId = $this->v('messageId', $d);
         $d['inReplyTo'] = $messageId;
         $d['references'] = $this->v('references', $d) != '' ? $d['references'] . ' ' . $messageId : $messageId;
         $d['groupwareEmailAccountsId'] = null;
         if ($usedAccount) {
             $d['groupwareEmailAccountsId'] = $usedAccount->getId();
         }
         /**
          * @see \Conjoon_Filter_StringPrependIf
          */
         require_once 'Conjoon/Filter/StringPrependIf.php';
         $prep = new \Conjoon_Filter_StringPrependIf(array('Re: ', 'RE: ', 'Aw: ', 'AW: '), 'Re: ');
         $d['subject'] = $prep->filter($this->v('subject', $d));
         $d['contentTextPlain'] = $this->getContentTextPlain($this->v('contentTextPlain', $d));
         $d['contentTextHtml'] = "";
         unset($d['messageId']);
         unset($d['replyTo']);
         unset($d['from']);
         $data['draft'] = $data['message'];
         unset($data['message']);
     } catch (\Exception $e) {
         throw new ServicePatronException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
     return $data;
 }