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


PHP SugarEmailAddress::getBeansByEmailAddress方法代码示例

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


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

示例1: SugarPHPMailer

 /**
  * Sends Email for Email 2.0
  */
 function email2Send($request)
 {
     global $mod_strings;
     global $app_strings;
     global $current_user;
     global $sugar_config;
     global $locale;
     global $timedate;
     global $beanList;
     global $beanFiles;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     /**********************************************************************
      * Sugar Email PREP
      */
     /* preset GUID */
     $orignialId = "";
     if (!empty($this->id)) {
         $orignialId = $this->id;
     }
     // if
     if (empty($this->id)) {
         $this->id = create_guid();
         $this->new_with_id = true;
     }
     /* satisfy basic HTML email requirements */
     $this->name = $request['sendSubject'];
     $this->description_html = '<html><body>' . $request['sendDescription'] . '</body></html>';
     /**********************************************************************
      * PHPMAILER PREP
      */
     $mail = new SugarPHPMailer();
     $mail = $this->setMailer($mail, '', $_REQUEST['fromAccount']);
     if (empty($mail->Host) && !$this->isDraftEmail($request)) {
         $this->status = 'send_error';
         if ($mail->oe->type == 'system') {
             echo $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND'];
         } else {
             echo $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND'];
         }
         return false;
     }
     $subject = $this->name;
     $mail->Subject = from_html($this->name);
     // work-around legacy code in SugarPHPMailer
     if ($_REQUEST['setEditor'] == 1) {
         $_REQUEST['description_html'] = $_REQUEST['sendDescription'];
         $this->description_html = $_REQUEST['description_html'];
     } else {
         $this->description_html = '';
         $this->description = $_REQUEST['sendDescription'];
     }
     // end work-around
     if ($this->isDraftEmail($request)) {
         if ($this->type != 'draft' && $this->status != 'draft') {
             $this->id = create_guid();
             $this->new_with_id = true;
             $this->date_entered = "";
         }
         // if
         $q1 = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$this->id}'";
         $r1 = $this->db->query($q1);
     }
     // if
     if (isset($request['saveDraft'])) {
         $this->type = 'draft';
         $this->status = 'draft';
         $forceSave = true;
     } else {
         /* Apply Email Templates */
         // do not parse email templates if the email is being saved as draft....
         $toAddresses = $this->email2ParseAddresses($_REQUEST['sendTo']);
         $sea = new SugarEmailAddress();
         $object_arr = array();
         if (isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id']) && ($_REQUEST['parent_type'] == 'Accounts' || $_REQUEST['parent_type'] == 'Contacts' || $_REQUEST['parent_type'] == 'Leads' || $_REQUEST['parent_type'] == 'Users' || $_REQUEST['parent_type'] == 'Prospects')) {
             if (isset($beanList[$_REQUEST['parent_type']]) && !empty($beanList[$_REQUEST['parent_type']])) {
                 $className = $beanList[$_REQUEST['parent_type']];
                 if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
                     if (!class_exists($className)) {
                         require_once $beanFiles[$className];
                     }
                     $bean = new $className();
                     $bean->retrieve($_REQUEST['parent_id']);
                     $object_arr[$bean->module_dir] = $bean->id;
                 }
                 // if
             }
             // if
         }
         foreach ($toAddresses as $addrMeta) {
             $addr = $addrMeta['email'];
             $beans = $sea->getBeansByEmailAddress($addr);
             foreach ($beans as $bean) {
                 if (!isset($object_arr[$bean->module_dir])) {
                     $object_arr[$bean->module_dir] = $bean->id;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:101,代码来源:Email.php

示例2: saveEmailUpdate

 /**
  * Called when saving a new email and adds the case update to the case.
  * @param $bean
  * @param $event
  * @param $arguments
  */
 public function saveEmailUpdate($bean, $event, $arguments)
 {
     global $mod_strings;
     if ($bean->intent != "createcase" || $bean->parent_type != "Cases") {
         $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate: Not a create case or wrong parent type");
         return;
     }
     if (!$bean->parent_id) {
         $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate No parent id");
         return;
     }
     if ($bean->cases) {
         $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate cases already set");
         return;
     }
     if ($bean->fetched_row['parent_id']) {
         //Will have been processed already
         return;
     }
     $contact = BeanFactory::getBean("Contact");
     $ea = new SugarEmailAddress();
     $beans = $ea->getBeansByEmailAddress($bean->from_addr);
     $contact_id = null;
     foreach ($beans as $emailBean) {
         if ($emailBean->module_name == "Contacts") {
             $contact_id = $emailBean->id;
             $this->linkAccountAndCase($bean->parent_id, $emailBean->account_id);
         }
     }
     $case_update = new AOP_Case_Updates();
     $case_update->name = $bean->name;
     $case_update->contact_id = $contact_id;
     $updateText = $this->unquoteEmail($bean->description_html ? $bean->description_html : $bean->description);
     $case_update->description = $updateText;
     $case_update->internal = false;
     $case_update->case_id = $bean->parent_id;
     $case_update->save();
 }
开发者ID:omusico,项目名称:windcrm,代码行数:44,代码来源:CaseUpdatesHook.php

示例3: saveEmailUpdate

 /**
  * Called when saving a new email and adds the case update to the case.
  * @param $bean
  * @param $event
  * @param $arguments
  */
 public function saveEmailUpdate($bean, $event, $arguments)
 {
     global $mod_strings;
     if ($bean->intent != "createcase" || $bean->parent_type != "Cases") {
         $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate: Not a create case or wrong parent type");
         return;
     }
     if (!isAOPEnabled()) {
         return;
     }
     if (!$bean->parent_id) {
         $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate No parent id");
         return;
     }
     if ($bean->cases) {
         $GLOBALS['log']->warn("CaseUpdatesHook: saveEmailUpdate cases already set");
         return;
     }
     if ($bean->fetched_row['parent_id']) {
         //Will have been processed already
         return;
     }
     $contact = BeanFactory::getBean("Contact");
     $ea = new SugarEmailAddress();
     $beans = $ea->getBeansByEmailAddress($bean->from_addr);
     $contact_id = null;
     foreach ($beans as $emailBean) {
         if ($emailBean->module_name == "Contacts" && !empty($emailBean->id)) {
             $contact_id = $emailBean->id;
             $this->linkAccountAndCase($bean->parent_id, $emailBean->account_id);
         }
     }
     $case_update = new AOP_Case_Updates();
     $case_update->name = $bean->name;
     $case_update->contact_id = $contact_id;
     $updateText = $this->unquoteEmail($bean->description_html ? $bean->description_html : $bean->description);
     $case_update->description = $updateText;
     $case_update->internal = false;
     $case_update->case_id = $bean->parent_id;
     $case_update->save();
     $notes = $bean->get_linked_beans('notes', 'Notes');
     foreach ($notes as $note) {
         //Link notes to case update also
         $newNote = BeanFactory::newBean('Notes');
         $newNote->name = $note->name;
         $newNote->file_mime_type = $note->file_mime_type;
         $newNote->filename = $note->filename;
         $newNote->parent_type = 'AOP_Case_Updates';
         $newNote->parent_id = $case_update->id;
         $newNote->save();
         $srcFile = "upload://{$note->id}";
         $destFile = "upload://{$newNote->id}";
         copy($srcFile, $destFile);
     }
     $this->updateCaseStatus($case_update->case_id);
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:62,代码来源:CaseUpdatesHook.php

示例4: sendEmailTemplate

 /**
  * Send Email with attachment Report to specified emails
  * @param string $attachFileName
  *  name of report file
  * @param string $attachFilePath
  *  path to report file for read it and attach to email
  * @param array $toAddresses
  *  array with email and names of contacts for send him this email
  *  array( array('email' => EMAIL_ADDR, 'display' => DISPLAY_NAME) )
  * @param string $templateId
  *  optional argument. Id of Email template
  * @param SugarBean $bean
  * 	optional argument, uses for parse template with values of this bean
  * @return array
  * return array with status send email in this format: array('status' => TRUE_OR_FALSE, 'error' => ERROR_MSG)
  */
 public static function sendEmailTemplate($attachFileName, $attachFilePath, $toAddresses, $templateId = '', $bean = NULL)
 {
     global $locale, $current_user, $app_strings;
     $sea = new SugarEmailAddress();
     $answer = array('status' => true, 'error' => '');
     $email = new Email();
     $email->email2init();
     $email->type = 'out';
     $email->status = 'sent';
     $email->id = create_guid();
     $email->new_with_id = true;
     $emailTemplate = new EmailTemplate();
     $emailTemplate->retrieve($templateId);
     if (empty($emailTemplate->subject)) {
         $emailTemplate->subject = $attachFileName;
         //set file name as subject
     }
     $email->name = $emailTemplate->subject;
     $email->description = $emailTemplate->body;
     $email->description_html = '<html><body>' . $emailTemplate->body_html . '</body></html>';
     $mail = new SugarPHPMailer();
     $mail = $email->setMailer($mail, '', '');
     if (empty($mail->Host)) {
         if ($mail->oe->type == 'system') {
             $answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND'];
         } else {
             $answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND'];
         }
         $answer['status'] = false;
         return $answer;
     }
     $object_arr = array();
     if ($bean !== NULL) {
         $object_arr[$bean->module_dir] = $bean->id;
     }
     foreach ($toAddresses as $addrMeta) {
         $addr = $addrMeta['email'];
         $beans = $sea->getBeansByEmailAddress($addr);
         foreach ($beans as $bean) {
             if (!isset($object_arr[$bean->module_dir])) {
                 $object_arr[$bean->module_dir] = $bean->id;
             }
         }
     }
     $object_arr['Users'] = $current_user->id;
     $email->description_html = $email->decodeDuringSend(from_html(EmailTemplate::parse_template($email->description_html, $object_arr)));
     $email->description = $email->decodeDuringSend(html_entity_decode(EmailTemplate::parse_template($email->description, $object_arr), ENT_COMPAT, 'UTF-8'));
     $email->name = from_html(EmailTemplate::parse_template($email->name, $object_arr));
     $mail->Body = $email->description_html;
     $mail->AltBody = $email->description;
     $mail->Subject = $email->name;
     $replyToAddress = $current_user->emailAddress->getReplyToAddress($current_user);
     $defaults = $current_user->getPreferredEmail();
     $mail->From = $defaults['email'];
     $mail->FromName = $defaults['name'];
     $mail->Sender = $mail->From;
     /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
     $replyToName = $mail->FromName;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     if (!empty($replyToAddress)) {
         $mail->AddReplyTo($replyToAddress, $locale->translateCharsetMIME(trim($replyToName), 'UTF-8', $OBCharset));
     } else {
         $mail->AddReplyTo($mail->From, $locale->translateCharsetMIME(trim($mail->FromName), 'UTF-8', $OBCharset));
     }
     foreach ($toAddresses as $addr_arr) {
         if (empty($addr_arr['email'])) {
             continue;
         }
         if (empty($addr_arr['display'])) {
             $mail->AddAddress($addr_arr['email'], "");
         } else {
             $mail->AddAddress($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
     }
     $mail->AddAttachment($attachFilePath, $attachFileName, 'base64', self::getMimeType($attachFileName));
     $mail->prepForOutbound();
     $mail->Body = $email->decodeDuringSend($mail->Body);
     $mail->AltBody = $email->decodeDuringSend($mail->AltBody);
     if (!$mail->Send()) {
         ob_clean();
         $answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $mail->ErrorInfo;
         $answer['status'] = false;
         return $answer;
     }
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:sugar_work,代码行数:101,代码来源:Utils.php


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