本文整理汇总了PHP中Notification::getDefaultActions方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getDefaultActions方法的具体用法?PHP Notification::getDefaultActions怎么用?PHP Notification::getDefaultActions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::getDefaultActions方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: insertNote
/**
* Insert note to system, send out notification and log.
*
* @param int $usr_id The user ID
* @param int $issue_id The issue ID
* @param string $title Title of the note
* @param string $note Note contents
* @param array $options extra optional options:
* - (array) cc: extra recipients to notify (usr_id list)
* - (bool) add_extra_recipients: whether to add recipients in 'cc' to notification list
* - (bool) closing: If The issue is being closed. Default false
* - (bool) is_blocked: FIXME
* - (bool) log: If adding this note should be logged. Default true
* - (bool) send_notification: Whether to send a notification about this note or not. Default true
* - (int) parent_id: FIXME
* - (string) full_message: FIXME
* - (string) message_id: FIXME
* - (string) unknown_user: The email address of a user that sent the blocked email that was turned into this note
* @return int the new note id if the insert worked, -1 or -2 otherwise
*/
public static function insertNote($usr_id, $issue_id, $title, $note, $options = array())
{
if (Validation::isWhitespace($note)) {
return -2;
}
$options = array_merge(array('unknown_user' => null, 'log' => true, 'closing' => false, 'send_notification' => true, 'is_blocked' => false, 'message_id' => null, 'cc' => null, 'full_message' => null, 'parent_id' => null), $options);
$prj_id = Issue::getProjectID($issue_id);
// NOTE: workflow may modify the parameters as $data is passed as reference
$data = array('title' => &$title, 'note' => &$note, 'options' => $options);
$workflow = Workflow::preNoteInsert($prj_id, $issue_id, $data);
if ($workflow !== null) {
// cancel insert of note
return $workflow;
}
// add the poster to the list of people to be subscribed to the notification list
// only if there is no 'unknown user' and the note is not blocked
if (!$options['unknown_user'] && !$options['is_blocked']) {
$note_cc = $options['add_extra_recipients'] ? $options['cc'] : array();
// always add the current user to the note_cc list
$note_cc[] = $usr_id;
$actions = Notification::getDefaultActions($issue_id, User::getEmail($usr_id), 'note');
foreach ($note_cc as $subscriber_usr_id) {
Notification::subscribeUser($usr_id, $issue_id, $subscriber_usr_id, $actions);
}
}
$params = array('not_iss_id' => $issue_id, 'not_usr_id' => $usr_id, 'not_created_date' => Date_Helper::getCurrentDateGMT(), 'not_note' => $note, 'not_title' => $title, 'not_message_id' => $options['message_id'] ?: Mail_Helper::generateMessageID());
if ($options['full_message']) {
$params['not_full_message'] = $options['full_message'];
}
if ($options['is_blocked']) {
$params['not_is_blocked'] = '1';
}
if ($options['parent_id']) {
$params['not_parent_id'] = $options['parent_id'];
}
if ($options['unknown_user']) {
$params['not_unknown_user'] = $options['unknown_user'];
}
$stmt = 'INSERT INTO
{{%note}}
SET ' . DB_Helper::buildSet($params);
try {
DB_Helper::getInstance()->query($stmt, $params);
} catch (DbException $e) {
return -1;
}
$note_id = DB_Helper::get_last_insert_id();
Issue::markAsUpdated($issue_id, 'note');
if ($options['log']) {
// need to save a history entry for this
History::add($issue_id, $usr_id, 'note_added', 'Note added by {subject}', array('subject' => User::getFullName($usr_id)));
}
// send notifications for the issue being updated
if ($options['send_notification']) {
$internal_only = true;
Notification::notify($issue_id, 'notes', $note_id, $internal_only, $options['cc']);
Workflow::handleNewNote($prj_id, $issue_id, $usr_id, $options['closing'], $note_id);
}
// need to return the new note id here so it can
// be re-used to associate internal-only attachments
return $note_id;
}
示例3: dirname
// | 51 Franklin Street, Suite 330 |
// | Boston, MA 02110-1301, USA. |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <jpm@mysql.com> |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('self_assign.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
$issue_id = $_REQUEST['iss_id'];
$tpl->assign('issue_id', $issue_id);
// check if issue is assigned to someone else and if so, confirm change.
$assigned_user_ids = Issue::getAssignedUserIDs($issue_id);
if (count($assigned_user_ids) > 0 && empty($_REQUEST['target'])) {
$tpl->assign(array('prompt_override' => 1, 'assigned_users' => Issue::getAssignedUsers($issue_id)));
} else {
$issue_details = Issue::getDetails($issue_id);
// force assignment change
if (@$_REQUEST['target'] == 'replace') {
// remove current user(s) first
Issue::deleteUserAssociations($issue_id, $usr_id);
}
$res = Issue::addUserAssociation($usr_id, $issue_id, $usr_id);
$tpl->assign('self_assign_result', $res);
Notification::subscribeUser($usr_id, $issue_id, $usr_id, Notification::getDefaultActions($issue_id, User::getEmail($usr_id), 'self_assign'));
Workflow::handleAssignmentChange($prj_id, $issue_id, $usr_id, $issue_details, Issue::getAssignedUserIDs($issue_id), false);
}
$tpl->assign('current_user_prefs', Prefs::get($usr_id));
$tpl->displayTemplate();
示例4: setAssignees
/**
* Sets the assignees for the issue
*
* @param integer $issue_id
* @param array $assignees
* @return int 1 if success, -1 if error, 0 if no change was needed.
*/
public static function setAssignees($issue_id, $assignees)
{
if (!is_array($assignees)) {
$assignees = array();
}
// see if there is anything to change
$old_assignees = self::getAssignedUserIDs($issue_id);
if (count(array_diff($old_assignees, $assignees)) == 0 && count(array_diff($assignees, $old_assignees)) == 0) {
return 0;
}
$old_assignee_names = self::getAssignedUsers($issue_id);
Workflow::handleAssignmentChange(self::getProjectID($issue_id), $issue_id, Auth::getUserID(), self::getDetails($issue_id), $assignees, true);
// clear up the assignments for this issue, and then assign it to the current user
self::deleteUserAssociations($issue_id);
$assignee_names = array();
foreach ($assignees as $assignee) {
$res = self::addUserAssociation(Auth::getUserID(), $issue_id, $assignee, false);
if ($res == -1) {
return -1;
}
$assignee_names[] = User::getFullName($assignee);
Notification::subscribeUser(Auth::getUserID(), $issue_id, $assignee, Notification::getDefaultActions($issue_id, User::getEmail($assignee), 'set_assignees'), false);
}
Notification::notifyNewAssignment($assignees, $issue_id);
$usr_id = Auth::getUserID();
History::add($issue_id, $usr_id, 'user_associated', 'Issue assignment to changed ({changes}) by {user}', array('changes' => History::formatChanges(implode(', ', $old_assignee_names), implode(', ', $assignee_names)), 'user' => User::getFullName($usr_id)));
return 1;
}
示例5: elseif
$res = Support::removeEmails();
$tpl->assign('remove_email_result', $res);
} elseif ($cat == 'clear_duplicate') {
$res = Issue::clearDuplicateStatus($iss_id);
$tpl->assign('clear_duplicate_result', $res);
} elseif ($cat == 'delete_phone') {
$res = Phone_Support::remove($id);
$tpl->assign('delete_phone_result', $res);
} elseif ($cat == 'new_status') {
$res = Issue::setStatus($iss_id, $status_id, true);
if ($res == 1) {
History::add($iss_id, $usr_id, 'status_changed', "Issue manually set to status '{status}' by {user}", array('status' => Status::getStatusTitle($status_id), 'user' => User::getFullName($usr_id)));
}
$tpl->assign('new_status_result', $res);
} elseif ($cat == 'authorize_reply') {
$res = Authorized_Replier::addUser($iss_id, $usr_id);
$tpl->assign('authorize_reply_result', $res);
} elseif ($cat == 'remove_quarantine') {
if (Auth::getCurrentRole() > User::getRoleID('Developer')) {
$res = Issue::setQuarantine($iss_id, 0);
$tpl->assign('remove_quarantine_result', $res);
}
} elseif ($cat == 'selfnotify') {
if (Issue::canAccess($iss_id, $usr_id)) {
$res = Notification::subscribeUser($usr_id, $iss_id, $usr_id, Notification::getDefaultActions($iss_id));
$tpl->assign('selfnotify_result', $res);
}
}
$tpl->assign('current_user_prefs', Prefs::get($usr_id));
$tpl->assign('cat', $cat);
$tpl->displayTemplate();
示例6: 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);
}
}
}
}
示例7: Template_API
include_once "config.inc.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.project.php";
include_once APP_INC_PATH . "class.notification.php";
include_once APP_INC_PATH . "class.prefs.php";
include_once APP_INC_PATH . "db_access.php";
$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") {
示例8: insert
/**
* Method used to add a note using the user interface form
* available in the application.
*
* @param integer $usr_id The user ID
* @param integer $issue_id The issue ID
* @param string $unknown_user The email address of a user that sent the blocked email that was turned into this note. Default is false.
* @param boolean $log If adding this note should be logged. Default true.
* @param boolean $closing If The issue is being closed. Default false
* @param boolean $send_notification Whether to send a notification about this note or not
* @access public
* @return integer the new note id if the insert worked, -1 or -2 otherwise
*/
function insert($usr_id, $issue_id, $unknown_user = FALSE, $log = true, $closing = false, $send_notification = true)
{
global $HTTP_POST_VARS;
$issue_id = Misc::escapeInteger($issue_id);
if (@$HTTP_POST_VARS['add_extra_recipients'] != 'yes') {
$note_cc = array();
} else {
$note_cc = $HTTP_POST_VARS['note_cc'];
}
// add the poster to the list of people to be subscribed to the notification list
// only if there is no 'unknown user'.
$note_cc[] = $usr_id;
if ($unknown_user == false) {
for ($i = 0; $i < count($note_cc); $i++) {
Notification::subscribeUser($usr_id, $issue_id, $note_cc[$i], Notification::getDefaultActions());
}
}
if (Validation::isWhitespace($HTTP_POST_VARS["note"])) {
return -2;
}
if (empty($HTTP_POST_VARS['message_id'])) {
$HTTP_POST_VARS['message_id'] = Mail_API::generateMessageID();
}
$stmt = "INSERT INTO\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "note\n (\n not_iss_id,\n not_usr_id,\n not_created_date,\n not_note,\n not_title";
if (!@empty($HTTP_POST_VARS['blocked_msg'])) {
$stmt .= ", not_blocked_message";
}
$stmt .= ", not_message_id";
if (!@empty($HTTP_POST_VARS['parent_id'])) {
$stmt .= ", not_parent_id";
}
if ($unknown_user != false) {
$stmt .= ", not_unknown_user";
}
$stmt .= "\n ) VALUES (\n {$issue_id},\n {$usr_id},\n '" . Date_API::getCurrentDateGMT() . "',\n '" . Misc::escapeString($HTTP_POST_VARS["note"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["title"]) . "'";
if (!@empty($HTTP_POST_VARS['blocked_msg'])) {
$stmt .= ", '" . Misc::escapeString($HTTP_POST_VARS['blocked_msg']) . "'";
}
$stmt .= ", '" . Misc::escapeString($HTTP_POST_VARS['message_id']) . "'";
if (!@empty($HTTP_POST_VARS['parent_id'])) {
$stmt .= ", " . Misc::escapeInteger($HTTP_POST_VARS['parent_id']) . "";
}
if ($unknown_user != false) {
$stmt .= ", '" . Misc::escapeString($unknown_user) . "'";
}
$stmt .= "\n )";
$res = $GLOBALS["db_api"]->dbh->query($stmt);
if (PEAR::isError($res)) {
Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
return -1;
} else {
$new_note_id = $GLOBALS["db_api"]->get_last_insert_id();
Issue::markAsUpdated($issue_id, 'note');
if ($log) {
// need to save a history entry for this
History::add($issue_id, $usr_id, History::getTypeID('note_added'), 'Note added by ' . User::getFullName($usr_id));
}
// send notifications for the issue being updated
if ($send_notification) {
$internal_only = true;
if (@$HTTP_POST_VARS['add_extra_recipients'] != 'yes' && @count($HTTP_POST_VARS['note_cc']) > 0) {
Notification::notify($issue_id, 'notes', $new_note_id, $internal_only, $HTTP_POST_VARS['note_cc']);
} else {
Notification::notify($issue_id, 'notes', $new_note_id, $internal_only);
}
Workflow::handleNewNote(Issue::getProjectID($issue_id), $issue_id, $usr_id, $closing);
}
// need to return the new note id here so it can
// be re-used to associate internal-only attachments
return $new_note_id;
}
}
示例9: insert
//.........这里部分代码省略.........
$res = $GLOBALS["db_api"]->dbh->query($stmt);
if (PEAR::isError($res)) {
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);
示例10:
$info = $GLOBALS["db_api"]->dbh->getOne($stmt);
if (PEAR::isError($info)) {
Error_Handler::logError(array($info->getMessage(), $info->getDebugInfo()), __FILE__, __LINE__);
return false;
} else {
$target_usr_id = $info;
$newstatus = 8;
$_REQUEST["target"] = "replace";
}
}
}
// check if issue is assigned to someone else and if so, confirm change.
$assigned_user_ids = Issue::getAssignedUserIDs($issue_id);
if (count($assigned_user_ids) > 0 && empty($_REQUEST["target"]) && !$_REQUEST['assigntomerc']) {
$tpl->assign(array("prompt_override" => 1, "assigned_users" => Issue::getAssignedUsers($issue_id)));
} else {
// force assignment change
if (@$_REQUEST["target"] == "replace") {
// remove current user(s) first
Issue::deleteUserAssociations($issue_id, $usr_id);
}
$res = Issue::addUserAssociation($usr_id, $issue_id, $target_usr_id);
$tpl->assign("self_assign_result", $res);
if ($newstatus) {
$res = Issue::setStatus($issue_id, $newstatus, true);
}
Notification::subscribeUser($usr_id, $issue_id, $target_usr_id, Notification::getDefaultActions());
Workflow::handleAssignment($prj_id, $issue_id, $target_usr_id);
}
$tpl->assign("current_user_prefs", Prefs::get($usr_id));
$tpl->displayTemplate();