本文整理汇总了PHP中Notification::subscribeEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::subscribeEmail方法的具体用法?PHP Notification::subscribeEmail怎么用?PHP Notification::subscribeEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::subscribeEmail方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Modifies an Issue's Reporter.
*
* @param integer $issue_id The id of the issue.
* @param string $fullname The id of the user.
* @param boolean $add_history If this should be logged.
* @return int
*/
public static function update($issue_id, $email, $add_history = true)
{
$email = strtolower(Mail_Helper::getEmailAddress($email));
$usr_id = User::getUserIDByEmail($email, true);
// If no valid user found reset to system account
if (!$usr_id) {
$usr_id = APP_SYSTEM_USER_ID;
}
$sql = 'UPDATE
{{%issue}}
SET
iss_usr_id = ?
WHERE
iss_id = ?';
try {
DB_Helper::getInstance()->query($sql, array($usr_id, $issue_id));
} catch (DbException $e) {
return -1;
}
if ($add_history) {
// TRANSLATORS: %1: email, %2: full name
$current_usr_id = Auth::getUserID();
History::add($issue_id, $current_usr_id, 'issue_updated', 'Reporter was changed to {email} by {user}', array('email' => $email, 'user' => User::getFullName($current_usr_id)));
}
// Add new user to notification list
if ($usr_id > 0) {
Notification::subscribeEmail($usr_id, $issue_id, $email, Notification::getDefaultActions());
}
return 1;
}
示例2: createFromPost
/**
* Method used to add a new issue using the normal report form.
*
* @return integer The new issue ID
*/
public static function createFromPost()
{
$keys = array('add_primary_contact', 'attached_emails', 'category', 'contact', 'contact_email', 'contact_extra_emails', 'contact_person_fname', 'contact_person_lname', 'contact_phone', 'contact_timezone', 'contract', 'customer', 'custom_fields', 'description', 'estimated_dev_time', 'group', 'notify_customer', 'notify_senders', 'priority', 'private', 'release', 'severity', 'summary', 'users', 'product', 'product_version', 'expected_resolution_date', 'associated_issues');
$data = array();
foreach ($keys as $key) {
if (isset($_POST[$key])) {
$data[$key] = $_POST[$key];
}
}
$prj_id = Auth::getCurrentProject();
$current_usr_id = Auth::getUserID();
$usr_id = $current_usr_id;
// if we are creating an issue for a customer, put the
// main customer contact as the reporter for it
if (CRM::hasCustomerIntegration($prj_id)) {
$crm = CRM::getInstance($prj_id);
$contact_usr_id = User::getUserIDByContactID($data['contact']);
if (empty($contact_usr_id)) {
$contact_usr_id = $usr_id;
}
$data['reporter'] = $contact_usr_id;
} else {
$data['reporter'] = $usr_id;
}
$data['msg_id'] = Mail_Helper::generateMessageID();
$issue_id = self::insertIssue($prj_id, $data);
if ($issue_id == -1) {
return -1;
}
$has_RR = false;
$info = User::getNameEmail($usr_id);
// log the creation of the issue
History::add($issue_id, $current_usr_id, 'issue_opened', 'Issue opened by {user}', array('user' => User::getFullName($current_usr_id)));
$clone_iss_id = isset($_POST['clone_iss_id']) ? (int) $_POST['clone_iss_id'] : null;
if ($clone_iss_id && Access::canCloneIssue($clone_iss_id, $current_usr_id)) {
History::add($issue_id, $current_usr_id, 'issue_cloned_from', 'Issue cloned from #{issue_id}', array('issue_id' => $clone_iss_id));
History::add($clone_iss_id, $current_usr_id, 'issue_cloned_to', 'Issue cloned to #{issue_id}', array('issue_id' => $issue_id));
self::addAssociation($issue_id, $clone_iss_id, $usr_id, true);
}
$emails = array();
if (CRM::hasCustomerIntegration($prj_id)) {
$customer = $crm->getCustomer($data['customer']);
$contract = $crm->getContract($data['contract']);
if (!empty($data['contact_extra_emails']) && count($data['contact_extra_emails']) > 0) {
$emails = $data['contact_extra_emails'];
}
// add the primary contact to the notification list
if (isset($data['add_primary_contact']) && $data['add_primary_contact'] == 'yes') {
$contact_email = User::getEmailByContactID($data['contact']);
if (!empty($contact_email)) {
$emails[] = $contact_email;
}
}
// if there are any technical account managers associated with this customer, add these users to the notification list
$managers = $customer->getEventumAccountManagers();
foreach ($managers as $manager) {
$emails[] = $manager['usr_email'];
}
}
// add the reporter to the notification list
$emails[] = $info['usr_email'];
$emails = array_unique($emails);
foreach ($emails as $address) {
Notification::subscribeEmail($usr_id, $issue_id, $address, Notification::getDefaultActions($issue_id, $address, 'new_issue'));
}
// only assign the issue to an user if the associated customer has any technical account managers
$users = array();
$has_TAM = false;
if (CRM::hasCustomerIntegration($prj_id) && count($managers) > 0) {
foreach ($managers as $manager) {
if ($manager['cam_type'] == 'intpart') {
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
//.........这里部分代码省略.........
示例3: addExtraRecipientsToNotificationList
public function addExtraRecipientsToNotificationList($prj_id, $email, $is_auto_created = false)
{
if (empty($email['to']) && !empty($email['sup_to'])) {
$email['to'] = $email['sup_to'];
}
if (empty($email['cc']) && !empty($email['sup_cc'])) {
$email['cc'] = $email['sup_cc'];
}
$project_details = Project::getDetails($prj_id);
$addresses_not_too_add = explode(',', strtolower($project_details['prj_mail_aliases']));
array_push($addresses_not_too_add, $project_details['prj_outgoing_sender_email']);
$addresses = array();
$to_addresses = Mail_Helper::getEmailAddresses(@$email['to']);
if (count($to_addresses)) {
$addresses = $to_addresses;
}
$cc_addresses = Mail_Helper::getEmailAddresses(@$email['cc']);
if (count($cc_addresses)) {
$addresses = array_merge($addresses, $cc_addresses);
}
$subscribers = Notification::getSubscribedEmails($email['issue_id']);
foreach ($addresses as $address) {
$address = strtolower($address);
if (!in_array($address, $subscribers) && !in_array($address, $addresses_not_too_add)) {
Notification::subscribeEmail(Auth::getUserID(), $email['issue_id'], $address, Notification::getDefaultActions($email['issue_id'], $address, 'add_extra_recipients'));
if ($is_auto_created) {
Notification::notifyAutoCreatedIssue($prj_id, $email['issue_id'], $email['from'], $email['date'], $email['subject'], $address);
}
}
}
}
示例4: Template_API
$tpl = new Template_API();
$tpl->setTemplate("notification.tpl.html");
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
$issue_id = @$HTTP_POST_VARS["issue_id"] ? $HTTP_POST_VARS["issue_id"] : $HTTP_GET_VARS["iss_id"];
$tpl->assign("issue_id", $issue_id);
// format default actions properly
$default = Notification::getDefaultActions();
$res = array();
foreach ($default as $action) {
$res[$action] = 1;
}
$tpl->assign("default_actions", $res);
if (@$HTTP_POST_VARS["cat"] == "insert") {
$res = Notification::subscribeEmail($usr_id, $issue_id, $HTTP_POST_VARS['email'], $HTTP_POST_VARS['actions']);
$tpl->assign("insert_result", $res);
} elseif (@$HTTP_GET_VARS["cat"] == "edit") {
$res = Notification::getDetails($HTTP_GET_VARS["id"]);
$tpl->assign("info", $res);
} elseif (@$HTTP_POST_VARS["cat"] == "update") {
$res = Notification::update($HTTP_POST_VARS["id"]);
$tpl->assign("update_result", $res);
} elseif (@$HTTP_POST_VARS["cat"] == "delete") {
$res = Notification::remove($HTTP_POST_VARS["items"]);
$tpl->assign("delete_result", $res);
}
$tpl->assign("list", Notification::getSubscriberListing($issue_id));
$t = Project::getAddressBook($prj_id, $issue_id);
$tpl->assign("assoc_users", $t);
$tpl->assign("allowed_emails", Project::getAddressBookEmails($prj_id, $issue_id));
示例5: array
if (!Access::canViewNotificationList($issue_id, Auth::getUserID())) {
$tpl->setTemplate('permission_denied.tpl.html');
$tpl->displayTemplate();
exit;
}
// format default actions properly
$default = Notification::getDefaultActions();
// first setup defaults
$res = array('updated' => 0, 'closed' => 0, 'files' => 0, 'emails' => 0);
foreach ($default as $action) {
$res[$action] = 1;
}
$tpl->assign('default_actions', $res);
$cat = isset($_POST['cat']) ? (string) $_POST['cat'] : (isset($_GET['cat']) ? (string) $_GET['cat'] : null);
if ($cat == 'insert') {
$res = Notification::subscribeEmail($usr_id, $issue_id, $_POST['email'], $_POST['actions']);
if ($res == 1) {
Misc::setMessage(ev_gettext('Thank you, the email has been subscribed to the issue.'));
}
} elseif ($cat == 'update') {
$res = Notification::update($issue_id, $_POST['id'], $_POST['email']);
if ($res == 1) {
Misc::setMessage(ev_gettext('Thank you, the notification entry was updated successfully.'));
} elseif ($res == -1) {
Misc::setMessage(ev_gettext('An error occurred while trying to update the notification entry.'), Misc::MSG_ERROR);
} elseif ($res == -2) {
Misc::setMessage(ev_gettext('Error: the given email address is not allowed to be added to the notification list.'), Misc::MSG_ERROR);
}
Auth::redirect(APP_RELATIVE_URL . 'notification.php?iss_id=' . $issue_id);
} elseif ($cat == 'edit') {
$res = Notification::getDetails($_GET['id']);
示例6: 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
//.........这里部分代码省略.........
示例7: insert
//.........这里部分代码省略.........
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
return -1;
} else {
$new_issue_id = $GLOBALS["db_api"]->get_last_insert_id();
$has_TAM = false;
$has_RR = false;
$info = User::getNameEmail($usr_id);
// log the creation of the issue
History::add($new_issue_id, Auth::getUserID(), History::getTypeID('issue_opened'), 'Issue opened by ' . User::getFullName(Auth::getUserID()));
$emails = array();
if (Customer::hasCustomerIntegration($prj_id)) {
if (@count($HTTP_POST_VARS['contact_extra_emails']) > 0) {
$emails = $HTTP_POST_VARS['contact_extra_emails'];
}
// add the primary contact to the notification list
if ($HTTP_POST_VARS['add_primary_contact'] == 'yes') {
$contact_email = User::getEmailByContactID($HTTP_POST_VARS['contact']);
if (!empty($contact_email)) {
$emails[] = $contact_email;
}
}
// if there are any technical account managers associated with this customer, add these users to the notification list
$managers = Customer::getAccountManagers($prj_id, $HTTP_POST_VARS['customer']);
$manager_usr_ids = array_keys($managers);
$manager_emails = array_values($managers);
$emails = array_merge($emails, $manager_emails);
}
// add the reporter to the notification list
$emails[] = $info['usr_email'];
$emails = array_unique($emails);
// COMPAT: version >= 4.0.1
$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;
示例8: notifyNewEmail
/**
* Method used to forward the new email to the list of subscribers.
*
* @access public
* @param integer $user_id The user ID of the person performing this action
* @param integer $issue_id The issue ID
* @param array $message An array containing the email
* @param boolean $internal_only Whether the email should only be redirected to internal users or not
* @param boolean $assignee_only Whether the email should only be sent to the assignee
* @param boolean $type The type of email this is
* @param integer $sup_id the ID of this email
* @return void
*/
function notifyNewEmail($usr_id, $issue_id, $message, $internal_only = FALSE, $assignee_only = FALSE, $type = '', $sup_id = false)
{
$full_message = $message['full_email'];
$sender = $message['from'];
$sender_email = strtolower(Mail_API::getEmailAddress($sender));
// get ID of whoever is sending this.
$sender_usr_id = User::getUserIDByEmail($sender_email);
if (empty($sender_usr_id)) {
$sender_usr_id = false;
}
// automatically subscribe this sender to email notifications on this issue
$subscribed_emails = Notification::getSubscribedEmails($issue_id, 'emails');
$subscribed_emails = array_map('strtolower', $subscribed_emails);
if (!Notification::isIssueRoutingSender($issue_id, $sender) && !Notification::isBounceMessage($sender_email) && !in_array($sender_email, $subscribed_emails)) {
$actions = array('emails');
Notification::subscribeEmail($usr_id, $issue_id, $sender_email, $actions);
}
// get the subscribers
$emails = array();
$users = Notification::getUsersByIssue($issue_id, 'emails');
for ($i = 0; $i < count($users); $i++) {
if (empty($users[$i]["sub_usr_id"])) {
if ($internal_only == false) {
$email = $users[$i]["sub_email"];
}
} else {
// if we are only supposed to send email to internal users, check if the role is lower than standard user
if ($internal_only == true && User::getRoleByUser($users[$i]["sub_usr_id"], Issue::getProjectID($issue_id)) < User::getRoleID('standard user')) {
continue;
}
// check if we are only supposed to send email to the assignees
if ($internal_only == true && $assignee_only == true) {
$assignee_usr_ids = Issue::getAssignedUserIDs($issue_id);
if (!in_array($users[$i]["sub_usr_id"], $assignee_usr_ids)) {
continue;
}
}
$email = User::getFromHeader($users[$i]["sub_usr_id"]);
}
if (!empty($email)) {
// don't send the email to the same person who sent it
if (strtolower(Mail_API::getEmailAddress($email)) == $sender_email) {
continue;
}
$emails[] = $email;
}
}
if (count($emails) == 0) {
return;
}
$setup = Setup::load();
// change the sender of the message to {prefix}{issue_id}@{host}
// - keep everything else in the message, except 'From:', 'Sender:', 'To:', 'Cc:'
// make 'Joe Blow <joe@example.com>' become 'Joe Blow [CSC] <eventum_59@example.com>'
$from = Notification::getFixedFromHeader($issue_id, $sender, 'issue');
list($_headers, $body) = Mime_Helper::splitBodyHeader($full_message);
// strip any 'Received:' headers
$_headers = Mail_API::stripHeaders($_headers);
$header_names = Mime_Helper::getHeaderNames($_headers);
// we don't want to keep the (B)Cc list for an eventum-based email
$ignore_headers = array('to', 'cc', 'bcc');
$headers = array();
// build the headers array required by the smtp library
foreach ($message['headers'] as $header_name => $value) {
if (in_array(strtolower($header_name), $ignore_headers) || !in_array($header_name, array_keys($header_names)) || strstr($header_name, ' ')) {
continue;
} elseif ($header_name == 'from') {
$headers['From'] = $from;
} else {
if (is_array($value)) {
$value = implode("; ", $value);
}
$headers[$header_names[$header_name]] = $value;
}
}
$headers["Subject"] = Mail_API::formatSubject($issue_id, $headers['Subject']);
if (empty($type)) {
if (User::getRoleByUser($usr_id, Issue::getProjectID($issue_id)) == User::getRoleID("Customer")) {
$type = 'customer_email';
} else {
$type = 'other_email';
}
}
@(include_once APP_PEAR_PATH . 'Mail/mime.php');
foreach ($emails as $to) {
$recipient_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($to));
$to = MIME_Helper::encodeAddress($to);
//.........这里部分代码省略.........