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


PHP Support::extractAttachments方法代码示例

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


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

示例1: convertNote

 /**
  * Converts a note to a draft or an email
  *
  * @param int $note_id The id of the note
  * @param string $target What the note should be converted too (email, etc)
  * @param bool $authorize_sender If $authorize_sender If the sender should be added to authorized senders list.
  * @return int
  */
 public static function convertNote($note_id, $target, $authorize_sender = false)
 {
     $issue_id = self::getIssueID($note_id);
     $email_account_id = Email_Account::getEmailAccount();
     $blocked_message = self::getBlockedMessage($note_id);
     $unknown_user = self::getUnknownUser($note_id);
     $structure = Mime_Helper::decode($blocked_message, true, true);
     $body = $structure->body;
     $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
     $current_usr_id = Auth::getUserID();
     if ($target == 'email') {
         if (Mime_Helper::hasAttachments($structure)) {
             $has_attachments = 1;
         } else {
             $has_attachments = 0;
         }
         list($blocked_message, $headers) = Mail_Helper::rewriteThreadingHeaders($issue_id, $blocked_message, @$structure->headers);
         $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' => @$blocked_message, 'has_attachment' => $has_attachments, 'headers' => $headers);
         // need to check for a possible customer association
         if (!empty($structure->headers['from'])) {
             $details = Email_Account::getDetails($email_account_id);
             // check from the associated project if we need to lookup any customers by this email address
             if (CRM::hasCustomerIntegration($details['ema_prj_id'])) {
                 $crm = CRM::getInstance($details['ema_prj_id']);
                 // check for any customer contact association
                 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'])) {
             $update_type = 'staff response';
             $t['customer_id'] = null;
         } else {
             $update_type = 'customer action';
         }
         $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;
             // special case when emails are bounced back, so we don't want to notify the customer about those
             if (Notification::isBounceMessage($sender_email)) {
                 $internal_only = true;
             }
             Notification::notifyNewEmail($current_usr_id, $issue_id, $t, $internal_only, false, '', $sup_id);
             Issue::markAsUpdated($issue_id, $update_type);
             self::remove($note_id, false);
             History::add($issue_id, $current_usr_id, 'note_converted_email', 'Note converted to e-mail (from: {from}) by {user}', array('from' => @$structure->headers['from'], 'user' => User::getFullName($current_usr_id)));
             // now add sender as an authorized replier
             if ($authorize_sender) {
                 Authorized_Replier::manualInsert($issue_id, @$structure->headers['from']);
             }
         }
         return $res;
     }
     // save message as a draft
     $res = Draft::saveEmail($issue_id, $structure->headers['to'], $structure->headers['cc'], $structure->headers['subject'], $body, false, $unknown_user);
     // remove the note, if the draft was created successfully
     if ($res) {
         self::remove($note_id, false);
         $usr_id = $current_usr_id;
         History::add($issue_id, $usr_id, 'note_converted_draft', 'Note converted to draft (from: {from}) by {user}', array('from' => @$structure->headers['from'], 'user' => User::getFullName($current_usr_id)));
     }
     return $res;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:79,代码来源:class.note.php

示例2: getEmailInfo


//.........这里部分代码省略.........
         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(function ($s) {
                         return strtolower($s);
                     }, array_values($users));
                     $users = array_flip($users);
                     $addresses = array();
                     $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
                     if (count($to_addresses)) {
                         $addresses = $to_addresses;
                     }
                     $cc_addresses = Mail_Helper::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[strtolower($email)];
                         }
                     }
                     // XXX FIXME, this is not nice thing to do
                     $_POST = array('title' => Mail_Helper::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::insertFromPost($usr_id, $t['issue_id']);
                     // need to handle attachments coming from notes as well
                     if ($res != -1) {
                         Support::extractAttachments($t['issue_id'], $structure, true, $res);
                     }
                 }
             }
         }
     } else {
         // check if we need to block this email
         if ($should_create_issue == true || !self::blockEmailIfNeeded($t)) {
             if (!empty($t['issue_id'])) {
                 list($t['full_email'], $t['headers']) = Mail_Helper::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], 'email');
             }
             // make variable available for workflow to be able to detect whether this email created new issue
             $t['should_create_issue'] = $should_create_array['should_create_issue'];
             $res = self::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'])) {
                     self::extractAttachments($t['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;
                     } elseif ($should_create_issue == true) {
                         // if a new issue was created, only send a copy of the email to the assignee (if any), don't resend to the original TO/CC list
                         $assignee_only = true;
                         $internal_only = true;
                     }
                     if (Workflow::shouldAutoAddToNotificationList($info['ema_prj_id'])) {
                         self::addExtraRecipientsToNotificationList($info['ema_prj_id'], $t, $should_create_issue);
开发者ID:korusdipl,项目名称:eventum,代码行数:67,代码来源:class.support.php

示例3: route_notes

 /**
  * Routes a note to the correct issue
  *
  * @param   string $full_message The full note
  * @return  mixed   true or array(ERROR_CODE, ERROR_STRING) in case of failure
  */
 public static function route_notes($full_message)
 {
     // save the full message for logging purposes
     Note::saveRoutedNote($full_message);
     // join the Content-Type line (for easier parsing?)
     if (preg_match('/^boundary=/m', $full_message)) {
         $pattern = "#(Content-Type: multipart/.+); ?\r?\n(boundary=.*)\$#im";
         $replacement = '$1; $2';
         $full_message = preg_replace($pattern, $replacement, $full_message);
     }
     list($headers) = Mime_Helper::splitHeaderBody($full_message);
     // need some validation here
     if (empty($full_message)) {
         return array(self::EX_NOINPUT, ev_gettext('Error: The email message was empty.') . "\n");
     }
     // remove the reply-to: header
     if (preg_match('/^reply-to:.*/im', $full_message)) {
         $full_message = preg_replace("/^(reply-to:).*\n/im", '', $full_message, 1);
     }
     // check if the email routing interface is even supposed to be enabled
     $setup = Setup::get();
     if ($setup['note_routing']['status'] != 'enabled') {
         return array(self::EX_CONFIG, ev_gettext('Error: The internal note routing interface is disabled.') . "\n");
     }
     if (empty($setup['note_routing']['address_prefix'])) {
         return array(self::EX_CONFIG, ev_gettext('Error: Please configure the email address prefix.') . "\n");
     }
     if (empty($setup['note_routing']['address_host'])) {
         return array(self::EX_CONFIG, ev_gettext('Error: Please configure the email address domain.') . "\n");
     }
     $structure = Mime_Helper::decode($full_message, true, true);
     // find which issue ID this email refers to
     if (isset($structure->headers['to'])) {
         $issue_id = self::getMatchingIssueIDs($structure->headers['to'], 'note');
     }
     // validation is always a good idea
     if (empty($issue_id) and isset($structure->headers['cc'])) {
         // we need to try the Cc header as well
         $issue_id = self::getMatchingIssueIDs($structure->headers['cc'], 'note');
     }
     if (empty($issue_id)) {
         return array(self::EX_DATAERR, ev_gettext('Error: The routed note had no associated Eventum issue ID or had an invalid recipient address.') . "\n");
     }
     $prj_id = Issue::getProjectID($issue_id);
     // check if the sender is allowed in this issue' project and if it is an internal user
     $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from']));
     $sender_usr_id = User::getUserIDByEmail($sender_email, true);
     if ((empty($sender_usr_id) || User::getRoleByUser($sender_usr_id, $prj_id) < User::ROLE_USER || User::isPartner($sender_usr_id) && !Access::canViewInternalNotes($issue_id, $sender_usr_id)) && !Workflow::canSendNote($prj_id, $issue_id, $sender_email, $structure)) {
         return array(self::EX_NOPERM, ev_gettext("Error: The sender of this email is not allowed in the project associated with issue #{$issue_id}.") . "\n");
     }
     if (empty($sender_usr_id)) {
         $sender_usr_id = APP_SYSTEM_USER_ID;
         $unknown_user = $structure->headers['from'];
     } else {
         $unknown_user = false;
     }
     AuthCookie::setAuthCookie($sender_usr_id);
     AuthCookie::setProjectCookie($prj_id);
     // parse the Cc: list, if any, and add these internal users to the issue notification list
     $addresses = array();
     $to_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['to']);
     if (count($to_addresses)) {
         $addresses = $to_addresses;
     }
     $cc_addresses = Mail_Helper::getEmailAddresses(@$structure->headers['cc']);
     if (count($cc_addresses)) {
         $addresses = array_merge($addresses, $cc_addresses);
     }
     $cc_users = array();
     foreach ($addresses as $email) {
         $cc_usr_id = User::getUserIDByEmail(strtolower($email), true);
         if (!empty($cc_usr_id) && User::getRoleByUser($cc_usr_id, $prj_id) >= User::ROLE_USER) {
             $cc_users[] = $cc_usr_id;
         }
     }
     $body = $structure->body;
     $reference_msg_id = Mail_Helper::getReferenceMessageID($headers);
     if (!empty($reference_msg_id)) {
         $parent_id = Note::getIDByMessageID($reference_msg_id);
     } else {
         $parent_id = false;
     }
     // insert the new note and send notification about it
     $_POST = array('title' => @$structure->headers['subject'], 'note' => $body, 'note_cc' => $cc_users, 'add_extra_recipients' => 'yes', 'message_id' => @$structure->headers['message-id'], 'parent_id' => $parent_id);
     // add the full email to the note if there are any attachments
     // this is needed because the front end code will display attachment links
     if (Mime_Helper::hasAttachments($structure)) {
         $_POST['full_message'] = $full_message;
     }
     $usr_id = Auth::getUserID();
     $res = Note::insertFromPost($usr_id, $issue_id, $unknown_user, false);
     // need to handle attachments coming from notes as well
     if ($res != -1) {
         Support::extractAttachments($issue_id, $structure, true, $res);
//.........这里部分代码省略.........
开发者ID:dabielkabuto,项目名称:eventum,代码行数:101,代码来源:class.routing.php

示例4: blockEmailIfNeeded

 /**
  * Check if this email needs to be blocked and if so, block it.
  *
  *
  */
 function blockEmailIfNeeded($email)
 {
     global $HTTP_POST_VARS;
     if (empty($email['issue_id'])) {
         return false;
     }
     $issue_id = $email['issue_id'];
     $prj_id = Issue::getProjectID($issue_id);
     $sender_email = strtolower(Mail_API::getEmailAddress($email['headers']['from']));
     if (Mail_API::isVacationAutoResponder($email['headers']) || Notification::isBounceMessage($sender_email) || !Support::isAllowedToEmail($issue_id, $sender_email)) {
         // add the message body as a note
         $HTTP_POST_VARS = array('blocked_msg' => $email['full_email'], 'title' => @$email['headers']['subject'], 'note' => Mail_API::getCannedBlockedMsgExplanation($issue_id) . $email['body']);
         // avoid having this type of message re-open the issue
         if (Mail_API::isVacationAutoResponder($email['headers'])) {
             $closing = true;
         } else {
             $closing = false;
         }
         $res = Note::insert(Auth::getUserID(), $issue_id, $email['headers']['from'], false, $closing);
         // associate the email attachments as internal-only files on this issue
         if ($res != -1) {
             Support::extractAttachments($issue_id, $email['full_email'], true, $res);
         }
         $HTTP_POST_VARS['issue_id'] = $issue_id;
         $HTTP_POST_VARS['from'] = $sender_email;
         // avoid having this type of message re-open the issue
         if (Mail_API::isVacationAutoResponder($email['headers'])) {
             $email_type = 'vacation-autoresponder';
         } else {
             $email_type = 'routed';
         }
         Workflow::handleBlockedEmail($prj_id, $issue_id, $HTTP_POST_VARS, $email_type);
         // try to get usr_id of sender, if not, use system account
         $usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($email['from']));
         if (!$usr_id) {
             $usr_id = APP_SYSTEM_USER_ID;
         }
         // log blocked email
         History::add($issue_id, $usr_id, History::getTypeID('email_blocked'), "Email from '" . $email['from'] . "' blocked.");
         return true;
     }
     return false;
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:48,代码来源:class.support.php

示例5: route_notes

 /**
  * Routes a note to the correct issue
  *
  * @param   string $full_message The full note
  */
 function route_notes($full_message)
 {
     global $HTTP_POST_VARS;
     // save the full message for logging purposes
     Note::saveRoutedNote($full_message);
     if (preg_match("/^(boundary=).*/m", $full_message)) {
         $pattern = "/(Content-Type: multipart\\/)(.+); ?\r?\n(boundary=)(.*)\$/im";
         $replacement = '$1$2; $3$4';
         $full_message = preg_replace($pattern, $replacement, $full_message);
     }
     list($headers, ) = Mime_Helper::splitHeaderBody($full_message);
     // need some validation here
     if (empty($full_message)) {
         return array(66, "Error: The email message was empty.\n");
     }
     //
     // DON'T EDIT ANYTHING BELOW THIS LINE
     //
     // remove the reply-to: header
     if (preg_match("/^(reply-to:).*/im", $full_message)) {
         $full_message = preg_replace("/^(reply-to:).*\n/im", '', $full_message, 1);
     }
     // check if the email routing interface is even supposed to be enabled
     $setup = Setup::load();
     if (@$setup['note_routing']['status'] != 'enabled') {
         return array(78, "Error: The internal note routing interface is disabled.\n");
     }
     $prefix = $setup['note_routing']['address_prefix'];
     // escape plus signs so 'note+1@example.com' becomes a valid routing address
     $prefix = str_replace('+', '\\+', $prefix);
     $mail_domain = quotemeta($setup['note_routing']['address_host']);
     if (empty($prefix)) {
         return array(78, "Error: Please configure the email address prefix.\n");
     }
     if (empty($mail_domain)) {
         return array(78, "Error: Please configure the email address domain.\n");
     }
     $structure = Mime_Helper::decode($full_message, true, true);
     // find which issue ID this email refers to
     @preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $structure->headers['to'], $matches);
     @($issue_id = $matches[1]);
     // validation is always a good idea
     if (empty($issue_id)) {
         // we need to try the Cc header as well
         @preg_match("/{$prefix}(\\d*)@{$mail_domain}/i", $structure->headers['cc'], $matches);
         if (!empty($matches[1])) {
             $issue_id = $matches[1];
         } else {
             return array(65, "Error: The routed note had no associated Eventum issue ID or had an invalid recipient address.\n");
         }
     }
     $prj_id = Issue::getProjectID($issue_id);
     // check if the sender is allowed in this issue' project and if it is an internal user
     $users = Project::getUserEmailAssocList($prj_id, 'active', User::getRoleID('Customer'));
     $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
     $user_emails = array_map('strtolower', array_values($users));
     if (!in_array($sender_email, $user_emails)) {
         return array(77, "Error: The sender of this email is not allowed in the project associated with issue #{$issue_id}.\n");
     }
     Auth::createFakeCookie(User::getUserIDByEmail($sender_email), $prj_id);
     // parse the Cc: list, if any, and add these internal users to the issue notification list
     $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];
         }
     }
     $body = Mime_Helper::getMessageBody($structure);
     $reference_msg_id = Mail_API::getReferenceMessageID($headers);
     if (!empty($reference_msg_id)) {
         $parent_id = Note::getIDByMessageID($reference_msg_id);
     } else {
         $parent_id = false;
     }
     // insert the new note and send notification about it
     $HTTP_POST_VARS = array('title' => @$structure->headers['subject'], 'note' => $body, 'note_cc' => $cc_users, 'add_extra_recipients' => 'yes', 'message_id' => @$structure->headers['message-id'], 'parent_id' => $parent_id);
     // add the full email to the note if there are any attachments
     // this is needed because the front end code will display attachment links
     if (Mime_Helper::hasAttachments($full_message)) {
         $HTTP_POST_VARS['blocked_msg'] = $full_message;
     }
     $res = Note::insert(Auth::getUserID(), $issue_id, false, false);
     // need to handle attachments coming from notes as well
     if ($res != -1) {
         Support::extractAttachments($issue_id, $full_message, true, $res);
//.........这里部分代码省略.........
开发者ID:juliogallardo1326,项目名称:proc,代码行数:101,代码来源:class.routing.php


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