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


PHP Note::setAttachmentFlag方法代码示例

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


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

示例1: extractAttachments

 /**
  * Method used to extract and associate attachments in an email
  * to the given issue.
  *
  * @param   integer $issue_id The issue ID
  * @param   mixed   $input The full body of the message or decoded email.
  * @param   boolean $internal_only Whether these files are supposed to be internal only or not
  * @param   integer $associated_note_id The note ID that these attachments should be associated with
  * @return  void
  */
 public static function extractAttachments($issue_id, $input, $internal_only = false, $associated_note_id = null)
 {
     if (!is_object($input)) {
         $input = Mime_Helper::decode($input, true, true);
     }
     // figure out who should be the 'owner' of this attachment
     $sender_email = strtolower(Mail_Helper::getEmailAddress($input->headers['from']));
     $usr_id = User::getUserIDByEmail($sender_email);
     $prj_id = Issue::getProjectID($issue_id);
     $unknown_user = false;
     if (empty($usr_id)) {
         if (CRM::hasCustomerIntegration($prj_id)) {
             // try checking if a customer technical contact has this email associated with it
             try {
                 $crm = CRM::getInstance($prj_id);
                 $contact = $crm->getContactByEmail($sender_email);
                 $usr_id = User::getUserIDByContactID($contact->getContactID());
             } catch (CRMException $e) {
                 $usr_id = null;
             }
         }
         if (empty($usr_id)) {
             // if we couldn't find a real customer by that email, set the usr_id to be the system user id,
             // and store the actual email address in the unknown_user field.
             $usr_id = APP_SYSTEM_USER_ID;
             $unknown_user = $input->headers['from'];
         }
     }
     // now for the real thing
     $attachments = Mime_Helper::getAttachments($input);
     if (count($attachments) > 0) {
         if (empty($associated_note_id)) {
             $history_log = ev_gettext('Attachment originated from an email');
         } else {
             $history_log = ev_gettext('Attachment originated from a note');
         }
         $iaf_ids = array();
         foreach ($attachments as &$attachment) {
             $attach = Workflow::shouldAttachFile($prj_id, $issue_id, $usr_id, $attachment);
             if (!$attach) {
                 continue;
             }
             $iaf_id = Attachment::addFile(0, $attachment['filename'], $attachment['filetype'], $attachment['blob']);
             if (!$iaf_id) {
                 continue;
             }
             $iaf_ids[] = $iaf_id;
         }
         if ($iaf_ids) {
             Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, $internal_only, $history_log, $unknown_user, $associated_note_id);
         }
         // mark the note as having attachments (poor man's caching system)
         if ($associated_note_id != false) {
             Note::setAttachmentFlag($associated_note_id);
         }
     }
 }
开发者ID:korusdipl,项目名称:eventum,代码行数:67,代码来源:class.support.php

示例2: extractAttachments

 /**
  * Method used to extract and associate attachments in an email
  * to the given issue.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   string $full_email The full contents of the email
  * @param   boolean $internal_only Whether these files are supposed to be internal only or not
  * @param   integer $associated_note_id The note ID that these attachments should be associated with
  * @return  void
  */
 function extractAttachments($issue_id, $full_email, $internal_only = false, $associated_note_id = false)
 {
     // figure out who should be the 'owner' of this attachment
     $structure = Mime_Helper::decode($full_email, false, false);
     $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
     $usr_id = User::getUserIDByEmail($sender_email);
     $unknown_user = false;
     if (empty($usr_id)) {
         $prj_id = Issue::getProjectID($issue_id);
         if (Customer::hasCustomerIntegration($prj_id)) {
             // try checking if a customer technical contact has this email associated with it
             list(, $contact_id) = Customer::getCustomerIDByEmails($prj_id, array($sender_email));
             if (!empty($contact_id)) {
                 $usr_id = User::getUserIDByContactID($contact_id);
             }
         }
         if (empty($usr_id)) {
             // if we couldn't find a real customer by that email, set the usr_id to be the system user id,
             // and store the actual email address in the unknown_user field.
             $usr_id = APP_SYSTEM_USER_ID;
             $unknown_user = $structure->headers['from'];
         }
     }
     // now for the real thing
     $attachments = Mime_Helper::getAttachments($full_email);
     if (count($attachments) > 0) {
         if (empty($associated_note_id)) {
             $history_log = 'Attachment originated from an email';
         } else {
             $history_log = 'Attachment originated from a note';
         }
         $attachment_id = Attachment::add($issue_id, $usr_id, $history_log, $internal_only, $unknown_user, $associated_note_id);
         for ($i = 0; $i < count($attachments); $i++) {
             Attachment::addFile($attachment_id, $issue_id, $attachments[$i]['filename'], $attachments[$i]['filetype'], $attachments[$i]['blob']);
         }
         // mark the note as having attachments (poor man's caching system)
         if ($associated_note_id != false) {
             Note::setAttachmentFlag($associated_note_id);
         }
     }
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:52,代码来源:class.support.php


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