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


PHP Attachment::addFile方法代码示例

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


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

示例1: addFile

 /**
  * Upload single file to an issue.
  *
  * @param int $issue_id
  * @param string $filename
  * @param string $mimetype
  * @param base64 $contents
  * @param string $file_description
  * @param bool $internal_only
  * @return struct
  * @access protected
  * @since 3.0.2
  */
 public function addFile($issue_id, $filename, $mimetype, $contents, $file_description, $internal_only)
 {
     $filesize = strlen($contents);
     if (!$filesize) {
         throw new RemoteApiException('Empty file uploaded');
     }
     $usr_id = Auth::getUserID();
     if (!$usr_id) {
         throw new RemoteApiException('Not authenticated');
     }
     $iaf_id = Attachment::addFile(0, $filename, $mimetype, $contents);
     if (!$iaf_id) {
         throw new RemoteApiException('File not uploaded');
     }
     $iaf_ids = array($iaf_id);
     Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, $internal_only, $file_description);
     $res = array('usr_id' => $usr_id, 'iaf_id' => $iaf_id, 'filesize' => $filesize);
     return $res;
 }
开发者ID:dabielkabuto,项目名称:eventum,代码行数:32,代码来源:RemoteApi.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

示例3: 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

示例4: insert


//.........这里部分代码省略.........
         $actions = Notification::getDefaultActions();
         foreach ($emails as $address) {
             Notification::subscribeEmail($usr_id, $new_issue_id, $address, $actions);
         }
         // only assign the issue to an user if the associated customer has any technical account managers
         $users = array();
         $has_TAM = false;
         if (Customer::hasCustomerIntegration($prj_id) && count($manager_usr_ids) > 0) {
             foreach ($manager_usr_ids as $manager_usr_id) {
                 $users[] = $manager_usr_id;
                 Issue::addUserAssociation($usr_id, $new_issue_id, $manager_usr_id, false);
                 History::add($new_issue_id, $usr_id, History::getTypeID('issue_auto_assigned'), 'Issue auto-assigned to ' . User::getFullName($manager_usr_id) . ' (TAM)');
             }
             $has_TAM = true;
         }
         // now add the user/issue association (aka assignments)
         if (@count($HTTP_POST_VARS["users"]) > 0) {
             for ($i = 0; $i < count($HTTP_POST_VARS["users"]); $i++) {
                 Notification::subscribeUser($usr_id, $new_issue_id, $HTTP_POST_VARS["users"][$i], $actions);
                 Issue::addUserAssociation($usr_id, $new_issue_id, $HTTP_POST_VARS["users"][$i]);
                 if ($HTTP_POST_VARS["users"][$i] != $usr_id) {
                     $users[] = $HTTP_POST_VARS["users"][$i];
                 }
             }
         } else {
             // only use the round-robin feature if this new issue was not
             // already assigned to a customer account manager
             if (@count($manager_usr_ids) < 1) {
                 $assignee = Round_Robin::getNextAssignee($prj_id);
                 // assign the issue to the round robin person
                 if (!empty($assignee)) {
                     $users[] = $assignee;
                     Issue::addUserAssociation($usr_id, $new_issue_id, $assignee, false);
                     History::add($new_issue_id, APP_SYSTEM_USER_ID, History::getTypeID('rr_issue_assigned'), 'Issue auto-assigned to ' . User::getFullName($assignee) . ' (RR)');
                     $has_RR = true;
                 }
             }
         }
         // now process any files being uploaded
         $found = 0;
         for ($i = 0; $i < count(@$HTTP_POST_FILES["file"]["name"]); $i++) {
             if (!@empty($HTTP_POST_FILES["file"]["name"][$i])) {
                 $found = 1;
                 break;
             }
         }
         if ($found) {
             $files = array();
             for ($i = 0; $i < count($HTTP_POST_FILES["file"]["name"]); $i++) {
                 $filename = @$HTTP_POST_FILES["file"]["name"][$i];
                 if (empty($filename)) {
                     continue;
                 }
                 $blob = Misc::getFileContents($HTTP_POST_FILES["file"]["tmp_name"][$i]);
                 if (empty($blob)) {
                     // error reading a file
                     $insert_errors["file[{$i}]"] = "There was an error uploading the file '{$filename}'.";
                     continue;
                 }
                 $files[] = array("filename" => $filename, "type" => $HTTP_POST_FILES['file']['type'][$i], "blob" => $blob);
             }
             if (count($files) > 0) {
                 $attachment_id = Attachment::add($new_issue_id, $usr_id, 'Files uploaded at issue creation time');
                 foreach ($files as $file) {
                     Attachment::addFile($attachment_id, $new_issue_id, $file["filename"], $file["type"], $file["blob"]);
                 }
             }
         }
         // need to associate any emails ?
         if (!empty($HTTP_POST_VARS["attached_emails"])) {
             $items = explode(",", $HTTP_POST_VARS["attached_emails"]);
             Support::associate($usr_id, $new_issue_id, $items, true);
         }
         // need to notify any emails being converted into issues ?
         if (@count($HTTP_POST_VARS["notify_senders"]) > 0) {
             $recipients = Notification::notifyEmailConvertedIntoIssue($prj_id, $new_issue_id, $HTTP_POST_VARS["notify_senders"], $customer_id);
         } else {
             $recipients = array();
         }
         // need to process any custom fields ?
         if (@count($HTTP_POST_VARS["custom_fields"]) > 0) {
             foreach ($HTTP_POST_VARS["custom_fields"] as $fld_id => $value) {
                 Custom_Field::associateIssue($new_issue_id, $fld_id, $value);
             }
         }
         // also send a special confirmation email to the customer contact
         if (@$HTTP_POST_VARS['notify_customer'] == 'yes' && !empty($HTTP_POST_VARS['contact'])) {
             // also need to pass the list of sender emails already notified,
             // so we can avoid notifying the same person again
             $contact_email = User::getEmailByContactID($HTTP_POST_VARS['contact']);
             if (@(!in_array($contact_email, $recipients))) {
                 Customer::notifyCustomerIssue($prj_id, $new_issue_id, $HTTP_POST_VARS['contact']);
             }
         }
         Workflow::handleNewIssue($prj_id, $new_issue_id, $has_TAM, $has_RR);
         // also notify any users that want to receive emails anytime a new issue is created
         Notification::notifyNewIssue($prj_id, $new_issue_id);
         return $new_issue_id;
     }
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:101,代码来源:class.issue.php


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