本文整理汇总了PHP中Attachment::attachFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachment::attachFiles方法的具体用法?PHP Attachment::attachFiles怎么用?PHP Attachment::attachFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachment
的用法示例。
在下文中一共展示了Attachment::attachFiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromPost
//.........这里部分代码省略.........
continue;
}
$users[] = $manager['cam_usr_id'];
self::addUserAssociation($usr_id, $issue_id, $manager['cam_usr_id'], false);
History::add($issue_id, $usr_id, 'issue_auto_assigned', 'Issue auto-assigned to {assignee} (TAM)', array('assignee' => User::getFullName($manager['cam_usr_id'])));
}
$has_TAM = true;
}
// now add the user/issue association (aka assignments)
if (!empty($data['users']) && count($data['users']) > 0) {
foreach ($data['users'] as $user) {
$actions = Notification::getDefaultActions($issue_id, User::getEmail($user), 'new_issue');
Notification::subscribeUser($usr_id, $issue_id, $user, $actions);
self::addUserAssociation($usr_id, $issue_id, $user);
if ($user != $usr_id) {
$users[] = $user;
}
}
} else {
// only use the round-robin feature if this new issue was not
// already assigned to a customer account manager
if (@count($managers) < 1) {
$assignee = Round_Robin::getNextAssignee($prj_id);
// assign the issue to the round robin person
if (!empty($assignee)) {
$users[] = $assignee;
self::addUserAssociation($usr_id, $issue_id, $assignee, false);
History::add($issue_id, APP_SYSTEM_USER_ID, 'rr_issue_assigned', 'Issue auto-assigned to {assignee} (RR)', array('assignee' => User::getFullName($assignee)));
$has_RR = true;
}
}
}
// set product and version
if (isset($data['product']) && $data['product'] != '-1') {
Product::addIssueProductVersion($issue_id, $data['product'], $data['product_version']);
}
// process any files being uploaded
// from ajax upload, attachment file ids
$iaf_ids = !empty($_POST['iaf_ids']) ? explode(',', $_POST['iaf_ids']) : null;
// if no iaf_ids passed, perhaps it's old style upload
// TODO: verify that the uploaded file(s) owner is same as attachment owner.
if (!$iaf_ids && isset($_FILES['file'])) {
$iaf_ids = Attachment::addFiles($_FILES['file']);
}
if ($iaf_ids) {
Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, false, 'Files uploaded at issue creation time');
}
// need to associate any emails ?
if (!empty($data['attached_emails'])) {
$items = explode(',', $data['attached_emails']);
Support::associate($usr_id, $issue_id, $items);
}
// need to notify any emails being converted into issues ?
if (@count($data['notify_senders']) > 0) {
$recipients = Notification::notifyEmailConvertedIntoIssue($prj_id, $issue_id, $data['notify_senders'], @$data['customer']);
} else {
$recipients = array();
}
// need to process any custom fields ?
if (@count($data['custom_fields']) > 0) {
foreach ($data['custom_fields'] as $fld_id => $value) {
Custom_Field::associateIssue($issue_id, $fld_id, $value);
}
}
// also send a special confirmation email to the customer contact
if (@$data['notify_customer'] == 'yes' && !empty($data['contact'])) {
$contact = $contract->getContact($data['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($data['contact']);
if (@(!in_array($contact_email, $recipients))) {
$contact->notifyNewIssue($issue_id);
}
// now check for additional emails in contact_extra_emails
if (@count($data['contact_extra_emails']) > 0) {
$notification_emails = $data['contact_extra_emails'];
foreach ($notification_emails as $notification_email) {
if (@(!in_array($notification_email, $recipients))) {
try {
$notification_contact = $crm->getContactByEmail($notification_email);
$notification_contact->notifyNewIssue($issue_id);
} catch (ContactNotFoundException $e) {
}
}
}
}
}
// handle associated issues
if (isset($data['associated_issues'])) {
$associated_issues = explode(',', $data['associated_issues']);
if ($clone_iss_id) {
$associated_issues[] = $clone_iss_id;
}
self::updateAssociatedIssuesRelations($issue_id, $associated_issues);
}
Workflow::handleNewIssue($prj_id, $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, $issue_id);
return $issue_id;
}
示例2: sendEmail
/**
* TODO: merge use of $options and $email arrays to just $email
*
* @param int $issue_id
* @param string $type type of email
* @param string $from
* @param string $to
* @param string $cc
* @param string $subject
* @param string $body
* @param array $options optional parameters
* - (int) parent_sup_id
* - (array) iaf_ids attachment file ids
* - (bool) add_unknown
* - (int) ema_id
* @return int 1 if it worked, -1 otherwise
*/
public static function sendEmail($issue_id, $type, $from, $to, $cc, $subject, $body, $options = array())
{
$parent_sup_id = $options['parent_sup_id'];
$iaf_ids = $options['iaf_ids'];
$add_unknown = $options['add_unknown'];
$ema_id = $options['ema_id'];
$current_usr_id = Auth::getUserID();
$prj_id = Issue::getProjectID($issue_id);
// if we are replying to an existing email, set the In-Reply-To: header accordingly
$in_reply_to = $parent_sup_id ? self::getMessageIDByID($parent_sup_id) : false;
// get ID of whoever is sending this.
$sender_usr_id = User::getUserIDByEmail(Mail_Helper::getEmailAddress($from)) ?: false;
// remove extra 'Re: ' from subject
$subject = Mail_Helper::removeExcessRe($subject, true);
$internal_only = false;
$message_id = Mail_Helper::generateMessageID();
// process any files being uploaded
// from ajax upload, attachment file ids
if ($iaf_ids) {
// FIXME: is it correct to use sender from post data?
$attach_usr_id = $sender_usr_id ?: $current_usr_id;
Attachment::attachFiles($issue_id, $attach_usr_id, $iaf_ids, false, 'Attachment originated from outgoing email');
}
// hack needed to get the full headers of this web-based email
$full_email = self::buildFullHeaders($issue_id, $message_id, $from, $to, $cc, $subject, $body, $in_reply_to, $iaf_ids);
// email blocking should only be done if this is an email about an associated issue
if ($issue_id) {
$user_info = User::getNameEmail($current_usr_id);
// check whether the current user is allowed to send this email to customers or not
if (!self::isAllowedToEmail($issue_id, $user_info['usr_email'])) {
// add the message body as a note
$note = Mail_Helper::getCannedBlockedMsgExplanation() . $body;
$note_options = array('full_message' => $full_email, 'is_blocked' => true);
Note::insertNote($current_usr_id, $issue_id, $subject, $note, $note_options);
$email_details = array('from' => $from, 'to' => $to, 'cc' => $cc, 'subject' => $subject, 'body' => &$body, 'message' => &$body, 'title' => $subject);
Workflow::handleBlockedEmail($prj_id, $issue_id, $email_details, 'web');
return 1;
}
}
// only send a direct email if the user doesn't want to add the Cc'ed people to the notification list
if (($add_unknown || Workflow::shouldAutoAddToNotificationList($prj_id)) && $issue_id) {
// add the recipients to the notification list of the associated issue
$recipients = array($to);
$recipients = array_merge($recipients, self::getRecipientsCC($cc));
foreach ($recipients as $address) {
if ($address && !Notification::isIssueRoutingSender($issue_id, $address)) {
$actions = Notification::getDefaultActions($issue_id, $address, 'add_unknown_user');
Notification::subscribeEmail($current_usr_id, $issue_id, Mail_Helper::getEmailAddress($address), $actions);
}
}
} else {
// Usually when sending out emails associated to an issue, we would
// simply insert the email in the table and call the Notification::notifyNewEmail() method,
// but on this case we need to actually send the email to the recipients that are not
// already in the notification list for the associated issue, if any.
// In the case of replying to an email that is not yet associated with an issue, then
// we are always directly sending the email, without using any notification list
// functionality.
if ($issue_id) {
// send direct emails only to the unknown addresses, and leave the rest to be
// catched by the notification list
$from = Notification::getFixedFromHeader($issue_id, $from, 'issue');
// build the list of unknown recipients
if ($to) {
$recipients = array($to);
$recipients = array_merge($recipients, self::getRecipientsCC($cc));
} else {
$recipients = self::getRecipientsCC($cc);
}
$unknowns = array();
foreach ($recipients as $address) {
if (!Notification::isSubscribedToEmails($issue_id, $address)) {
$unknowns[] = $address;
}
}
if ($unknowns) {
$to2 = array_shift($unknowns);
$cc2 = implode('; ', $unknowns);
// send direct emails
self::sendDirectEmail($issue_id, $from, $to2, $cc2, $subject, $body, $_FILES['attachment'], $message_id, $sender_usr_id);
}
} else {
// send direct emails to all recipients, since we don't have an associated issue
//.........这里部分代码省略.........
示例3: 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;
}
示例4: Template_Helper
$usr_id = Auth::getUserID();
$tpl = new Template_Helper();
$tpl->setTemplate('file_upload.tpl.html');
$issue_id = isset($_POST['issue_id']) ? $_POST['issue_id'] : $_GET['iss_id'];
$cat = isset($_POST['cat']) ? $_POST['cat'] : null;
// handle uploads
if ($cat == 'upload_file') {
// attachment status (public or internal)
$status = isset($_POST['status']) ? $_POST['status'] : null;
$internal_only = $status == 'internal';
// from ajax upload, attachment file ids
$iaf_ids = !empty($_POST['iaf_ids']) ? explode(',', $_POST['iaf_ids']) : null;
// description for attachments
$file_description = isset($_POST['file_description']) ? $_POST['file_description'] : null;
// if no iaf_ids passed, perhaps it's old style upload
// TODO: verify that the uploaded file(s) owner is same as attachment owner.
if (!$iaf_ids && isset($_FILES['attachment'])) {
$iaf_ids = Attachment::addFiles($_FILES['attachment']);
}
try {
Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, $internal_only, $file_description);
$res = 1;
} catch (Exception $e) {
error_log($e->getMessage());
error_log($e->getTraceAsString());
$res = -1;
}
$tpl->assign('upload_file_result', $res);
}
$tpl->assign(array('issue_id' => $issue_id, 'current_user_prefs' => Prefs::get(Auth::getUserID()), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'max_attachment_bytes' => Attachment::getMaxAttachmentSize(true)));
$tpl->displayTemplate();