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


PHP Support::blockEmailIfNeeded方法代码示例

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


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

示例1: route_emails


//.........这里部分代码省略.........
     }
     $issue_prj_id = Issue::getProjectID($issue_id);
     if (empty($issue_prj_id)) {
         return array(self::EX_DATAERR, ev_gettext('Error: The routed email had no associated Eventum issue ID or had an invalid recipient address.') . "\n");
     }
     $email_account_id = Email_Account::getEmailAccount($issue_prj_id);
     if (empty($email_account_id)) {
         return array(self::EX_CONFIG, ev_gettext('Error: Please provide the email account ID.') . "\n");
     }
     $body = $structure->body;
     // hack for clients that set more then one from header
     if (is_array($structure->headers['from'])) {
         $structure->headers['from'] = $structure->headers['from'][0];
     }
     // associate the email to the issue
     $parts = array();
     Mime_Helper::parse_output($structure, $parts);
     // get the sender's email address
     $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
     // strip out the warning message sent to staff users
     if ($setup['email_routing']['status'] == 'enabled' && $setup['email_routing']['warning']['status'] == 'enabled') {
         $full_message = Mail_Helper::stripWarningMessage($full_message);
         $body = Mail_Helper::stripWarningMessage($body);
     }
     $prj_id = Issue::getProjectID($issue_id);
     AuthCookie::setAuthCookie(APP_SYSTEM_USER_ID);
     AuthCookie::setProjectCookie($prj_id);
     if (Mime_Helper::hasAttachments($structure)) {
         $has_attachments = 1;
     } else {
         $has_attachments = 0;
     }
     // remove certain CC addresses
     if (!empty($structure->headers['cc']) && $setup['smtp']['save_outgoing_email'] == 'yes') {
         $ccs = explode(',', @$structure->headers['cc']);
         foreach ($ccs as $i => $address) {
             if (Mail_Helper::getEmailAddress($address) == $setup['smtp']['save_address']) {
                 unset($ccs[$i]);
             }
         }
         $structure->headers['cc'] = implode(', ', $ccs);
     }
     // Remove excess Re's
     $structure->headers['subject'] = Mail_Helper::removeExcessRe(@$structure->headers['subject'], true);
     $t = array('issue_id' => $issue_id, 'ema_id' => $email_account_id, 'message_id' => @$structure->headers['message-id'], 'date' => Date_Helper::getCurrentDateGMT(), 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => @$body, 'full_email' => @$full_message, 'has_attachment' => $has_attachments, 'headers' => @$structure->headers);
     // automatically associate this incoming email with a customer
     if (CRM::hasCustomerIntegration($prj_id)) {
         $crm = CRM::getInstance($prj_id);
         if (!empty($structure->headers['from'])) {
             try {
                 $contact = $crm->getContactByEmail($sender_email);
                 $issue_contract = $crm->getContract(Issue::getContractID($issue_id));
                 if ($contact->canAccessContract($issue_contract)) {
                     $t['customer_id'] = $issue_contract->getCustomerID();
                 }
             } catch (CRMException $e) {
             }
         }
     }
     if (empty($t['customer_id'])) {
         $t['customer_id'] = null;
     }
     if (Support::blockEmailIfNeeded($t)) {
         return true;
     }
     // re-write Threading headers if needed
     list($t['full_email'], $t['headers']) = Mail_Helper::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
     $res = Support::insertEmail($t, $structure, $sup_id);
     if ($res != -1) {
         Support::extractAttachments($issue_id, $structure);
         // notifications about new emails are always external
         $internal_only = false;
         $assignee_only = false;
         // special case when emails are bounced back, so we don't want a notification to customers about those
         if (Notification::isBounceMessage($sender_email)) {
             // broadcast this email only to the assignees for this issue
             $internal_only = true;
             $assignee_only = true;
         }
         Notification::notifyNewEmail(Auth::getUserID(), $issue_id, $t, $internal_only, $assignee_only, '', $sup_id);
         // try to get usr_id of sender, if not, use system account
         $usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($structure->headers['from']));
         if (!$usr_id) {
             $usr_id = APP_SYSTEM_USER_ID;
         }
         // mark this issue as updated
         if (!empty($t['customer_id']) && $t['customer_id'] != null) {
             Issue::markAsUpdated($issue_id, 'customer action');
         } else {
             if (!empty($usr_id) && $usr_id != APP_SYSTEM_USER_ID && User::getRoleByUser($usr_id, $prj_id) > User::ROLE_CUSTOMER) {
                 Issue::markAsUpdated($issue_id, 'staff response');
             } else {
                 Issue::markAsUpdated($issue_id, 'user response');
             }
         }
         // log routed email
         History::add($issue_id, $usr_id, 'email_routed', 'Email routed from {from}', array('from' => $structure->headers['from']));
     }
     return true;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:101,代码来源:class.routing.php

示例2: getEmailInfo


//.........这里部分代码省略.........
             $t['customer_id'] = $should_create_array['customer_id'];
         }
         if (empty($t['issue_id'])) {
             $t['issue_id'] = 0;
         } else {
             $prj_id = Issue::getProjectID($t['issue_id']);
             Auth::createFakeCookie(APP_SYSTEM_USER_ID, $prj_id);
         }
         if ($should_create_array['type'] == 'note') {
             // assume that this is not a valid note
             $res = -1;
             if ($t['issue_id'] != 0) {
                 // check if this is valid user
                 $usr_id = User::getUserIDByEmail($sender_email);
                 if (!empty($usr_id)) {
                     $role_id = User::getRoleByUser($usr_id, $prj_id);
                     if ($role_id > User::getRoleID("Customer")) {
                         // actually a valid user so insert the note
                         Auth::createFakeCookie($usr_id, $prj_id);
                         $users = Project::getUserEmailAssocList($prj_id, 'active', User::getRoleID('Customer'));
                         $user_emails = array_map('strtolower', array_values($users));
                         $users = array_flip($users);
                         $addresses = array();
                         $to_addresses = Mail_API::getEmailAddresses(@$structure->headers['to']);
                         if (count($to_addresses)) {
                             $addresses = $to_addresses;
                         }
                         $cc_addresses = Mail_API::getEmailAddresses(@$structure->headers['cc']);
                         if (count($cc_addresses)) {
                             $addresses = array_merge($addresses, $cc_addresses);
                         }
                         $cc_users = array();
                         foreach ($addresses as $email) {
                             if (in_array(strtolower($email), $user_emails)) {
                                 $cc_users[] = $users[$email];
                             }
                         }
                         $GLOBALS['HTTP_POST_VARS'] = array('title' => Mail_API::removeExcessRe($t['subject']), 'note' => $t['body'], 'note_cc' => $cc_users, 'add_extra_recipients' => 'yes', 'message_id' => $t['message_id'], 'parent_id' => $should_create_array['parent_id']);
                         $res = Note::insert($usr_id, $t['issue_id']);
                     }
                 }
             }
         } else {
             // check if we need to block this email
             if ($should_create_issue == true || !Support::blockEmailIfNeeded($t)) {
                 if (!empty($t['issue_id'])) {
                     list($t['full_email'], $t['headers']) = Mail_API::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
                 }
                 $res = Support::insertEmail($t, $structure, $sup_id);
                 if ($res != -1) {
                     // only extract the attachments from the email if we are associating the email to an issue
                     if (!empty($t['issue_id'])) {
                         Support::extractAttachments($t['issue_id'], $t['full_email']);
                         // notifications about new emails are always external
                         $internal_only = false;
                         $assignee_only = false;
                         // special case when emails are bounced back, so we don't want a notification to customers about those
                         if (Notification::isBounceMessage($sender_email)) {
                             // broadcast this email only to the assignees for this issue
                             $internal_only = true;
                             $assignee_only = true;
                         }
                         Notification::notifyNewEmail(Auth::getUserID(), $t['issue_id'], $t, $internal_only, $assignee_only, '', $sup_id);
                         // try to get usr_id of sender, if not, use system account
                         $usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($structure->headers['from']));
                         if (!$usr_id) {
                             $usr_id = APP_SYSTEM_USER_ID;
                         }
                         // mark this issue as updated
                         if (!empty($t['customer_id']) && $t['customer_id'] != 'NULL') {
                             Issue::markAsUpdated($t['issue_id'], 'customer action');
                         } else {
                             if (!empty($usr_id) && User::getRoleByUser($usr_id, $prj_id) > User::getRoleID('Customer')) {
                                 Issue::markAsUpdated($t['issue_id'], 'staff response');
                             } else {
                                 Issue::markAsUpdated($t['issue_id'], 'user response');
                             }
                         }
                         // log routed email
                         History::add($t['issue_id'], $usr_id, History::getTypeID('email_routed'), "Email routed from " . $structure->headers['from']);
                     }
                 }
             } else {
                 $res = 1;
             }
         }
         if ($res > 0) {
             // need to delete the message from the server?
             if (!$info['ema_leave_copy']) {
                 @imap_delete($mbox, $num);
             } else {
                 // mark the message as already read
                 @imap_setflag_full($mbox, $num, "\\Seen");
             }
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:101,代码来源:class.support.php

示例3: route_emails


//.........这里部分代码省略.........
         $issue_prj_id = Issue::getProjectID($issue_id);
         if (empty($issue_prj_id)) {
             return array(65, "Error: The routed email had no associated Eventum issue ID or had an invalid recipient address.\n");
         }
         $email_account_id = Email_Account::getEmailAccount($issue_prj_id);
     }
     if (empty($email_account_id)) {
         return array(78, "Error: Please provide the email account ID.\n");
     }
     $body = Mime_Helper::getMessageBody($structure);
     // hack for clients that set more then one from header
     if (is_array($structure->headers['from'])) {
         $structure->headers['from'] = $structure->headers['from'][0];
     }
     // associate the email to the issue
     $parts = array();
     Mime_Helper::parse_output($structure, $parts);
     // get the sender's email address
     $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
     // strip out the warning message sent to staff users
     if ($setup['email_routing']['status'] == 'enabled' && $setup['email_routing']['warning']['status'] == 'enabled') {
         $full_message = Mail_API::stripWarningMessage($full_message);
         $body = Mail_API::stripWarningMessage($body);
     }
     $prj_id = Issue::getProjectID($issue_id);
     Auth::createFakeCookie(APP_SYSTEM_USER_ID, $prj_id);
     $staff_emails = Project::getUserEmailAssocList($prj_id, 'active', User::getRoleID('Customer'));
     $staff_emails = array_map('strtolower', $staff_emails);
     // only allow staff users to use the magic cookie
     if (!in_array($sender_email, array_values($staff_emails))) {
         $has_magic_cookie = false;
     }
     if (Mime_Helper::hasAttachments($full_message)) {
         $has_attachments = 1;
     } else {
         $has_attachments = 0;
     }
     // remove certain CC addresses
     if (!empty($structure->headers['cc']) && @$setup['smtp']['save_outgoing_email'] == 'yes') {
         $ccs = explode(",", @$structure->headers['cc']);
         for ($i = 0; $i < count($ccs); $i++) {
             if (Mail_API::getEmailAddress($ccs[$i]) == $setup['smtp']['save_address']) {
                 unset($ccs[$i]);
             }
         }
         @($structure->headers['cc'] = join(', ', $ccs));
     }
     // Remove excess Re's
     @($structure->headers['subject'] = Mail_API::removeExcessRe(@$structure->headers['subject'], true));
     $t = array('issue_id' => $issue_id, 'ema_id' => $email_account_id, 'message_id' => @$structure->headers['message-id'], 'date' => Date_API::getCurrentDateGMT(), 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => @$body, 'full_email' => @$full_message, 'has_attachment' => $has_attachments, 'headers' => @$structure->headers);
     // automatically associate this incoming email with a customer
     if (Customer::hasCustomerIntegration($prj_id)) {
         if (!empty($structure->headers['from'])) {
             list($customer_id, ) = Customer::getCustomerIDByEmails($prj_id, array($sender_email));
             if (!empty($customer_id)) {
                 $t['customer_id'] = $customer_id;
             }
         }
     }
     if (empty($t['customer_id'])) {
         $t['customer_id'] = "NULL";
     }
     if (!$has_magic_cookie && Support::blockEmailIfNeeded($t)) {
         return true;
     }
     // re-write Threading headers if needed
     list($t['full_email'], $t['headers']) = Mail_API::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], "email");
     $res = Support::insertEmail($t, $structure, $sup_id);
     if ($res != -1) {
         Support::extractAttachments($issue_id, $full_message);
         // notifications about new emails are always external
         $internal_only = false;
         $assignee_only = false;
         // special case when emails are bounced back, so we don't want a notification to customers about those
         if (Notification::isBounceMessage($sender_email)) {
             // broadcast this email only to the assignees for this issue
             $internal_only = true;
             $assignee_only = true;
         }
         Notification::notifyNewEmail(Auth::getUserID(), $issue_id, $t, $internal_only, $assignee_only, '', $sup_id);
         // try to get usr_id of sender, if not, use system account
         $usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($structure->headers['from']));
         if (!$usr_id) {
             $usr_id = APP_SYSTEM_USER_ID;
         }
         // mark this issue as updated
         if (!empty($t['customer_id']) && $t['customer_id'] != 'NULL') {
             Issue::markAsUpdated($issue_id, 'customer action');
         } else {
             if (!empty($usr_id) && User::getRoleByUser($usr_id, $prj_id) > User::getRoleID('Customer')) {
                 Issue::markAsUpdated($issue_id, 'staff response');
             } else {
                 Issue::markAsUpdated($issue_id, 'user response');
             }
         }
         // log routed email
         History::add($issue_id, $usr_id, History::getTypeID('email_routed'), "Email routed from " . $structure->headers['from']);
     }
     return true;
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:101,代码来源:class.routing.php


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