本文整理汇总了PHP中Notification::notify方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::notify方法的具体用法?PHP Notification::notify怎么用?PHP Notification::notify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::notify方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrDelete
public function createOrDelete($id)
{
$topic = Topic::find($id);
if (Favorite::isUserFavoritedTopic(Auth::user(), $topic)) {
Auth::user()->favoriteTopics()->detach($topic->id);
} else {
Auth::user()->favoriteTopics()->attach($topic->id);
Notification::notify('topic_favorite', Auth::user(), $topic->user, $topic);
}
Flash::success(lang('Operation succeeded.'));
return Redirect::route('topics.show', $topic->id);
}
示例2: createOrDelete
public function createOrDelete($id)
{
$topic = Topic::find($id);
if (Attention::isUserAttentedTopic(Auth::user(), $topic)) {
$message = lang('Successfully remove attention.');
Auth::user()->attentTopics()->detach($topic->id);
} else {
$message = lang('Successfully_attention');
Auth::user()->attentTopics()->attach($topic->id);
Notification::notify('topic_attent', Auth::user(), $topic->user, $topic);
}
Flash::success($message);
return Redirect::route('topics.show', $topic->id);
}
示例3: 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;
}
示例4: Position
function add_feed($feed_id_in){
if($this->screen_set){
if(is_array($this->screen_pos))
foreach($this->screen_pos as $pos){
if($pos->feed_id == $feed_id_in){
return true; //The mapping already exists. Someone cannot see that, maybe they are using an iphone and the screen is tiny. dumb iphone
}
}
$new_pos = new Position();
if($new_pos->create_position($this->screen_id, $feed_id_in, $this->id)){
$this->screen_pos[] = $new_pos;
$notify = new Notification();
$notify->notify('screen', $this->screen_id, 'feed', $feed_id_in, 'subscribe');
return true;
} else {
return false;
}
} else {
return false; //No screen = no fun :-(
}
}
示例5: destroy
function destroy(){
$sql = "DELETE FROM feed_content WHERE feed_id = $this->id";
$res = sql_query($sql);
if(!$res){
return false; //Error unmapping content!
}
$sql1 = "SELECT field_id, screen_id FROM position WHERE feed_id = $this->id";
$res1 = sql_query($sql1);
if(!$res1){
return false; //Error grabbing positions/fields
}
$i=0;
while($row = sql_row_keyed($res1,$i)){
$field = new Field($row['field_id'],$row['screen_id']);
$field->delete_feed($this->id);
//$field->rebalance_scale();
$i++;
}
$sql = "DELETE FROM feed WHERE id = $this->id";
$res = sql_query($sql);
if(!$res){
return false; //Error with the final delete!!!
}
$notify = new Notification();
$notify->notify('feed', $this->id, 'user', $_SESSION['user']->id, 'delete');
//Then we just clear the variables
$this->id = '';
$this->name = '';
$this->description = '';
$this->group_id='';
$this->set = false;
return true;
}
示例6: destroy
function destroy(){
$sql = "DELETE FROM `position` WHERE screen_id = $this->id";
$res = sql_query($sql);
if(!$res){
return false;
}
$sql = "DELETE FROM `screen` WHERE id = $this->id LIMIT 1";
$res = sql_query($sql);
if(!$res){
return false;
}
$notify = new Notification();
$notify->notify('screen', $this->id, 'user', $_SESSION['user']->id, 'delete');
return true;
}
示例7: 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;
}
示例8: attachFiles
/**
* Attach uploaded files to an issue
* It also notifies any subscribers of this new attachment.
*
* @param int $issue_id The issue ID
* @param int $usr_id The user ID
* @param int[] $iaf_ids attachment file id-s to attach
* @param boolean $internal_only Whether this attachment is supposed to be internal only or not
* @param string $file_description File description text
* @param string $unknown_user The email of the user who originally sent this email, who doesn't have an account.
* @param integer $associated_note_id The note ID that these attachments should be associated with
*/
public static function attachFiles($issue_id, $usr_id, $iaf_ids, $internal_only, $file_description, $unknown_user = null, $associated_note_id = null)
{
if (!$iaf_ids) {
throw new LogicException('No attachment ids');
}
$attachment_id = self::add($issue_id, $usr_id, $file_description, $internal_only, $unknown_user, $associated_note_id);
self::associateFiles($attachment_id, $iaf_ids);
Issue::markAsUpdated($issue_id, 'file uploaded');
History::add($issue_id, $usr_id, 'attachment_added', 'Attachment uploaded by {user}', array('user' => User::getFullName($usr_id)));
// if there is customer integration, mark last customer action
$prj_id = Issue::getProjectID($issue_id);
$has_crm = CRM::hasCustomerIntegration($prj_id);
$is_customer = User::getRoleByUser($usr_id, $prj_id) == User::ROLE_CUSTOMER;
if ($has_crm && $is_customer) {
Issue::recordLastCustomerAction($issue_id);
}
Workflow::handleAttachment($prj_id, $issue_id, $usr_id);
Notification::notify($issue_id, 'files', $attachment_id, $internal_only);
}
示例9: wiki
public function wiki($id)
{
$topic = Topic::findOrFail($id);
$topic->is_wiki = !$topic->is_wiki;
$topic->save();
Flash::success(lang('Operation succeeded.'));
Notification::notify('topic_mark_wiki', Auth::user(), $topic->user, $topic);
return Redirect::route('topics.show', $topic->id);
}
示例10: 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;
}
}
示例11: destroy
function destroy(){
$return = true;
if($data = $this->list_feeds()){ // To get all the feeds the content is in
foreach($data as $feed_row){
$return = $return * $feed_row['feed']->content_remove($this->id);
}
}
if(!$return){
return false; //Failure to remove the content from all the feeds it was in
}
if($this->mime_type != 'text/plain' && $this->mime_type != 'text/html' && $this->mime_type != 'text/time'){
$path = IMAGE_DIR . $this->content;
if(unlink($path)){
$this->status = "File deleted.";
}else{
$this->status = "Trouble finding content, maybe you already removed it?";
}
}
if(!$return){
return false; //Failure to delete content
}
$sql = "DELETE FROM content WHERE id = $this->id";
$res = sql_query($sql);
if($res){
if($this->user_id != 0){
$notify = new Notification();
$notify->notify('content', $this->id, 'user', $_SESSION['user']->id, 'delete');
}
return true;
} else {
return false;
}
}
示例12: 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;
}
}
示例13: subdate
include_once APP_INC_PATH . "class.issue.php";
include_once APP_INC_PATH . "class.status.php";
include_once APP_INC_PATH . "class.notification.php";
include_once APP_INC_PATH . "class.note.php";
include_once APP_INC_PATH . "db_access.php";
$day_limit = 4;
$sql = "SELECT \n\t\t\tiss_id,iss_prj_id\n\t\tFROM \n\t\t\t`ev_issue` \n\t\t\tleft join ev_status on sta_id = `iss_sta_id` \n\t\twhere \n\t\t\tsta_is_closed = 0 \n\t\t\tand `iss_control_status` = 'Answered' \n\t\t\tand iss_last_response_date < subdate(now(),interval {$day_limit} day);\n\t\t";
$issues = $GLOBALS["db_api"]->dbh->getAll($sql);
$closed_id = Status::getStatusID('Closed');
$c = 0;
$k = 0;
foreach ($issues as $issue) {
$res = Issue::setStatus($issue[0], $closed_id);
if ($res == 1) {
History::add($HTTP_GET_VARS["iss_id"], 0, History::getTypeID('status_changed'), "Issue automatically set to status '" . Status::getStatusTitle(7) . "' due to ({$day_limit}) day inactivity ");
Notification::notify($issue[0], 'closed');
}
$c++;
}
$killed_id = Status::getStatusID('Killed');
$sql = "SELECT \n\t\t\tiss_id\n\t\tFROM \n\t\t\t`ev_issue` \n\t\t\tleft join ev_status on sta_id = `iss_sta_id` \n\t\twhere \n\t\t\tsta_is_closed = 1\n\t\t\tand `iss_sta_id` = '{$killed_id}'\n\t\t";
$issues = $GLOBALS["db_api"]->dbh->getCol($sql);
foreach ($issues as $issue) {
$GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue` where iss_id = '" . $issue . "'");
$GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_subscription` where sub_iss_id = '" . $issue . "'");
$GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue_user` where isu_iss_id = '" . $issue . "'");
$GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue_history` where his_iss_id = '" . $issue . "'");
$GLOBALS["db_api"]->dbh->query("DELETE FROM `ev_issue_user_replier` where iur_iss_id = '" . $issue . "'");
$k++;
}
echo "({$c}) Closed. ({$k}) Deleted";
示例14: unset
function remove_from_group($group_id)
{
if (in_array($group_id, $this->groups)) {
$sql = "DELETE FROM user_group WHERE user_id = {$this->id} AND group_id = {$group_id} LIMIT 1";
$res = sql_query($sql);
if ($res != 0) {
$key = array_search($group_id, $this->groups);
unset($this->groups[$key]);
$notify = new Notification();
$notify->notify('group', $group_id, 'user', $this->id, 'leave');
return true;
} else {
return false;
}
} else {
return true;
}
}