本文整理汇总了PHP中Notification::getFixedFromHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getFixedFromHeader方法的具体用法?PHP Notification::getFixedFromHeader怎么用?PHP Notification::getFixedFromHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::getFixedFromHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendEmail
/**
* Method used to send an email from the user interface.
*
* @access public
* @return integer 1 if it worked, -1 otherwise
*/
function sendEmail($parent_sup_id = FALSE)
{
global $HTTP_POST_VARS, $HTTP_SERVER_VARS;
// if we are replying to an existing email, set the In-Reply-To: header accordingly
if ($parent_sup_id) {
$in_reply_to = Support::getMessageIDByID($parent_sup_id);
} else {
$in_reply_to = false;
}
// get ID of whoever is sending this.
$sender_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($HTTP_POST_VARS["from"]));
if (empty($sender_usr_id)) {
$sender_usr_id = false;
}
// get type of email this is
if (!empty($HTTP_POST_VARS['type'])) {
$type = $HTTP_POST_VARS['type'];
} else {
$type = '';
}
// remove extra 'Re: ' from subject
$HTTP_POST_VARS['subject'] = Mail_API::removeExcessRe($HTTP_POST_VARS['subject'], true);
$internal_only = false;
$message_id = Mail_API::generateMessageID();
// hack needed to get the full headers of this web-based email
$full_email = Support::buildFullHeaders($HTTP_POST_VARS["issue_id"], $message_id, $HTTP_POST_VARS["from"], $HTTP_POST_VARS["to"], $HTTP_POST_VARS["cc"], $HTTP_POST_VARS["subject"], $HTTP_POST_VARS["message"], $in_reply_to);
// email blocking should only be done if this is an email about an associated issue
if (!empty($HTTP_POST_VARS['issue_id'])) {
$user_info = User::getNameEmail(Auth::getUserID());
// check whether the current user is allowed to send this email to customers or not
if (!Support::isAllowedToEmail($HTTP_POST_VARS["issue_id"], $user_info['usr_email'])) {
// add the message body as a note
$HTTP_POST_VARS['blocked_msg'] = $full_email;
$HTTP_POST_VARS['title'] = $HTTP_POST_VARS["subject"];
$HTTP_POST_VARS['note'] = Mail_API::getCannedBlockedMsgExplanation() . $HTTP_POST_VARS["message"];
Note::insert(Auth::getUserID(), $HTTP_POST_VARS["issue_id"]);
Workflow::handleBlockedEmail(Issue::getProjectID($HTTP_POST_VARS['issue_id']), $HTTP_POST_VARS['issue_id'], $HTTP_POST_VARS, '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 (@$HTTP_POST_VARS['add_unknown'] == 'yes') {
if (!empty($HTTP_POST_VARS['issue_id'])) {
// add the recipients to the notification list of the associated issue
$recipients = array($HTTP_POST_VARS['to']);
$recipients = array_merge($recipients, Support::getRecipientsCC($HTTP_POST_VARS['cc']));
for ($i = 0; $i < count($recipients); $i++) {
if (!empty($recipients[$i]) && !Notification::isIssueRoutingSender($HTTP_POST_VARS["issue_id"], $recipients[$i])) {
Notification::subscribeEmail(Auth::getUserID(), $HTTP_POST_VARS["issue_id"], Mail_API::getEmailAddress($recipients[$i]), array('emails'));
}
}
}
} 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 (!empty($HTTP_POST_VARS['issue_id'])) {
// send direct emails only to the unknown addresses, and leave the rest to be
// catched by the notification list
$from = Notification::getFixedFromHeader($HTTP_POST_VARS['issue_id'], $HTTP_POST_VARS['from'], 'issue');
// build the list of unknown recipients
if (!empty($HTTP_POST_VARS['to'])) {
$recipients = array($HTTP_POST_VARS['to']);
$recipients = array_merge($recipients, Support::getRecipientsCC($HTTP_POST_VARS['cc']));
} else {
$recipients = Support::getRecipientsCC($HTTP_POST_VARS['cc']);
}
$unknowns = array();
for ($i = 0; $i < count($recipients); $i++) {
if (!Notification::isSubscribedToEmails($HTTP_POST_VARS['issue_id'], $recipients[$i])) {
$unknowns[] = $recipients[$i];
}
}
if (count($unknowns) > 0) {
$to = array_shift($unknowns);
$cc = implode('; ', $unknowns);
// send direct emails
Support::sendDirectEmail($HTTP_POST_VARS['issue_id'], $from, $to, $cc, $HTTP_POST_VARS['subject'], $HTTP_POST_VARS['message'], $message_id, $sender_usr_id);
}
} else {
// send direct emails to all recipients, since we don't have an associated issue
$project_info = Project::getOutgoingSenderAddress(Auth::getCurrentProject());
// use the project-related outgoing email address, if there is one
if (!empty($project_info['email'])) {
$from = Mail_API::getFormattedName(User::getFullName(Auth::getUserID()), $project_info['email']);
} else {
// otherwise, use the real email address for the current user
$from = User::getFromHeader(Auth::getUserID());
}
// send direct emails
//.........这里部分代码省略.........
示例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: notifyNewAssignment
/**
* Method used to send an email notification when an issue is
* assigned to an user.
*
* @access public
* @param array $users The list of users
* @param integer $issue_id The issue ID
* @return void
*/
function notifyNewAssignment($users, $issue_id)
{
$prj_id = Issue::getProjectID($issue_id);
$emails = array();
for ($i = 0; $i < count($users); $i++) {
$prefs = Prefs::get($users[$i]);
if (!empty($prefs) && @$prefs["receive_assigned_emails"][$prj_id]) {
$emails[] = User::getFromHeader($users[$i]);
}
}
if (count($emails) == 0) {
return false;
}
// get issue details
$issue = Notification::getIssueDetails($issue_id);
// open text template
$tpl = new Template_API();
$tpl->setTemplate('notifications/assigned.tpl.text');
$tpl->bulkAssign(array("app_title" => Misc::getToolCaption(), "issue" => $issue, "current_user" => User::getFullName(Auth::getUserID())));
$text_message = $tpl->getTemplateContents();
for ($i = 0; $i < count($emails); $i++) {
// send email (use PEAR's classes)
$mail = new Mail_API();
$mail->setTextBody($text_message);
$mail->setHeaders(Mail_API::getBaseThreadingHeaders($issue_id));
$mail->send(Notification::getFixedFromHeader($issue_id, '', 'issue'), $emails[$i], "[#{$issue_id}] New Assignment: " . $issue['iss_summary'], TRUE, $issue_id, 'assignment');
}
}