本文整理汇总了PHP中Support::buildFullHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Support::buildFullHeaders方法的具体用法?PHP Support::buildFullHeaders怎么用?PHP Support::buildFullHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Support
的用法示例。
在下文中一共展示了Support::buildFullHeaders方法的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: close
/**
* Method used to close off an issue.
*
* @param integer $usr_id The user ID
* @param integer $issue_id The issue ID
* @param bool $send_notification Whether to send a notification about this action or not
* @param integer $resolution_id The resolution ID
* @param integer $status_id The status ID
* @param string $reason The reason for closing this issue
* @param string $send_notification_to Who this notification should be sent too
* @return integer 1 if the update worked, -1 otherwise
*/
public static function close($usr_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason, $send_notification_to = 'internal')
{
$usr_id = (int) $usr_id;
$issue_id = (int) $issue_id;
$resolution_id = (int) $resolution_id;
$status_id = (int) $status_id;
$params = array('iss_updated_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_type' => 'closed', 'iss_closed_date' => Date_Helper::getCurrentDateGMT(), 'iss_sta_id' => $status_id);
if (!empty($resolution_id)) {
$params['iss_res_id'] = $resolution_id;
}
$stmt = 'UPDATE {{%issue}} SET ' . DB_Helper::buildSet($params) . ' WHERE iss_id=?';
$params[] = $issue_id;
try {
DB_Helper::getInstance()->query($stmt, $params);
} catch (DbException $e) {
return -1;
}
$prj_id = self::getProjectID($issue_id);
// record the change
History::add($issue_id, $usr_id, 'issue_closed', "Issue updated to status '{status}' by {user}", array('status' => Status::getStatusTitle($status_id), 'user' => User::getFullName($usr_id)));
if ($send_notification_to == 'all') {
$from = User::getFromHeader($usr_id);
$message_id = User::getFromHeader($usr_id);
$full_email = Support::buildFullHeaders($issue_id, $message_id, $from, '', '', 'Issue closed comments', $reason, '');
$structure = Mime_Helper::decode($full_email, true, false);
$email = array('ema_id' => Email_Account::getEmailAccount(self::getProjectID($issue_id)), 'issue_id' => $issue_id, 'message_id' => $message_id, 'date' => Date_Helper::getCurrentDateGMT(), 'subject' => 'Issue closed comments', 'from' => $from, 'has_attachment' => 0, 'body' => $reason, 'full_email' => $full_email, 'headers' => $structure->headers);
$sup_id = null;
Support::insertEmail($email, $structure, $sup_id, true);
$ids = $sup_id;
} else {
// add note with the reason to close the issue
$_POST['title'] = 'Issue closed comments';
$_POST['note'] = $reason;
Note::insertFromPost($usr_id, $issue_id, false, true, true, $send_notification);
$ids = false;
}
if ($send_notification) {
if (CRM::hasCustomerIntegration($prj_id)) {
$crm = CRM::getInstance($prj_id);
// send a special confirmation email when customer issues are closed
$stmt = 'SELECT
iss_customer_contact_id
FROM
{{%issue}}
WHERE
iss_id=?';
$customer_contact_id = DB_Helper::getInstance()->getOne($stmt, array($issue_id));
if (!empty($customer_contact_id)) {
try {
$contact = $crm->getContact($customer_contact_id);
$contact->notifyIssueClosed($issue_id, $reason);
} catch (CRMException $e) {
}
}
}
// send notifications for the issue being closed
Notification::notify($issue_id, 'closed', $ids);
}
Workflow::handleIssueClosed($prj_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason, $usr_id);
return 1;
}
示例3: close
/**
* Method used to close off an issue.
*
* @access public
* @param integer $usr_id The user ID
* @param integer $issue_id The issue ID
* @param bool $send_notification Whether to send a notification about this action or not
* @param integer $resolution_id The resolution ID
* @param integer $status_id The status ID
* @param string $reason The reason for closing this issue
* @param string $send_notification_to Who this notification should be sent too
* @return integer 1 if the update worked, -1 otherwise
*/
function close($usr_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason, $send_notification_to = 'internal')
{
global $HTTP_POST_VARS;
$usr_id = Misc::escapeInteger($usr_id);
$issue_id = Misc::escapeInteger($issue_id);
$resolution_id = Misc::escapeInteger($resolution_id);
$status_id = Misc::escapeInteger($status_id);
$stmt = "UPDATE\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n SET\n iss_updated_date='" . Date_API::getCurrentDateGMT() . "',\n iss_last_public_action_date='" . Date_API::getCurrentDateGMT() . "',\n iss_last_public_action_type='closed',\n iss_closed_date='" . Date_API::getCurrentDateGMT() . "',\n";
if (!empty($resolution_id)) {
$stmt .= "iss_res_id={$resolution_id},\n";
}
$stmt .= "iss_sta_id={$status_id}\n WHERE\n iss_id={$issue_id}";
$res = $GLOBALS["db_api"]->dbh->query($stmt);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
return -1;
} else {
$prj_id = Issue::getProjectID($issue_id);
// record the change
History::add($issue_id, $usr_id, History::getTypeID('issue_closed'), "Issue updated to status '" . Status::getStatusTitle($status_id) . "' by " . User::getFullName($usr_id));
if ($send_notification_to == 'all') {
$from = User::getFromHeader($usr_id);
$message_id = User::getFromHeader($usr_id);
$full_email = Support::buildFullHeaders($issue_id, $message_id, $from, '', '', 'Issue closed comments', $reason, '');
$structure = Mime_Helper::decode($full_email, true, false);
$email = array('ema_id' => Email_Account::getEmailAccount(), 'issue_id' => $issue_id, 'message_id' => $message_id, 'date' => Date_API::getCurrentDateGMT(), 'subject' => 'Issue closed comments', 'from' => $from, 'has_attachment' => 0, 'body' => $reason, 'full_email' => $full_email, 'headers' => $structure->headers);
Support::insertEmail($email, $structure, $sup_id, true);
$ids = $sup_id;
} else {
// add note with the reason to close the issue
$HTTP_POST_VARS['title'] = 'Issue closed comments';
$HTTP_POST_VARS["note"] = $reason;
Note::insert($usr_id, $issue_id, false, true, true);
$ids = false;
}
if ($send_notification) {
if (Customer::hasCustomerIntegration($prj_id)) {
// send a special confirmation email when customer issues are closed
$stmt = "SELECT\n iss_customer_contact_id\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n WHERE\n iss_id={$issue_id}";
$customer_contact_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
if (!empty($customer_contact_id)) {
Customer::notifyIssueClosed($prj_id, $issue_id, $customer_contact_id);
}
}
// send notifications for the issue being closed
Notification::notify($issue_id, 'closed', $ids);
}
Workflow::handleIssueClosed($prj_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason);
return 1;
}
}