[ticket/11103] Update notifications on post/topic edit

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-09-09 14:55:40 -05:00
parent 3624d2c50a
commit e09f25d597
4 changed files with 34 additions and 13 deletions

View file

@ -2220,12 +2220,18 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
// Send Notifications
if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval)
if ($post_approval)
{
$notifications = $phpbb_container->get('notifications');
switch ($mode)
{
case 'post' :
$notifications->add_notifications('topic', array_merge($data, array(
'post_username' => $username,
)));
break;
case 'reply' :
case 'quote' :
$notifications->add_notifications('post', array_merge($data, array(
@ -2233,8 +2239,15 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
)));
break;
case 'post' :
$notifications->add_notifications('topic', array_merge($data, array(
case 'edit_topic' :
case 'edit_first_post' :
case 'edit' :
case 'edit_last_post' :
$notifications->update_notifications('topic', array_merge($data, array(
'post_username' => $username,
'topic_title' => $subject,
)));
$notifications->update_notifications('post', array_merge($data, array(
'post_username' => $username,
)));
break;

View file

@ -58,10 +58,10 @@ class phpbb_notifications_service
// Merge default options
$options = array_merge(array(
'user_id' => $user->data['user_id'],
'limit' => 5,
'start' => 0,
'order_by' => 'time',
'order_dir' => 'DESC',
'limit' => 5,
'start' => 0,
), $options);
$notifications = $user_ids = array();
@ -147,7 +147,7 @@ class phpbb_notifications_service
foreach ($methods as $method)
{
// setup the notification methods and add the notification to the queue
if ($method)
if ($method) // blank means we just insert it as a notification, but do not notify them by any other means
{
if (!isset($notification_methods[$method]))
{

View file

@ -96,7 +96,11 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
}
return $this->phpbb_container->get('user')->lang('NOTIFICATION_POST', $username, censor_text($this->get_data('topic_title')));
return $this->phpbb_container->get('user')->lang(
'NOTIFICATION_POST',
$username,
censor_text($this->get_data('topic_title'))
);
}
/**
@ -117,7 +121,11 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
$username = $user_data['username'];
}
return $this->phpbb_container->get('user')->lang('NOTIFICATION_POST', $username, censor_text($this->get_data('topic_title')));
return $this->phpbb_container->get('user')->lang(
'NOTIFICATION_POST',
$username,
censor_text($this->get_data('topic_title'))
);
}
/**
@ -166,7 +174,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
$this->set_data('topic_title', $post['topic_title']);
$this->set_data('post_username', $post['post_username']);
$this->set_data('post_username', (($post['post_username'] != $this->phpbb_container->get('user')->data['username']) ? $post['post_username'] : ''));
$this->set_data('forum_name', $post['forum_name']);

View file

@ -137,7 +137,7 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
*/
public function get_url()
{
return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t{$this->item_id}");
return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t={$this->item_id}");
}
/**
@ -147,7 +147,7 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
*/
public function get_full_url()
{
return generate_board_url() . "/viewtopic.{$this->php_ext}?t{$this->item_id}";
return generate_board_url() . "/viewtopic.{$this->php_ext}?t={$this->item_id}";
}
/**
@ -170,13 +170,13 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
*/
public function create_insert_array($post)
{
$this->item_id = $post['post_id'];
$this->item_id = $post['topic_id'];
$this->set_data('poster_id', $post['poster_id']);
$this->set_data('topic_title', $post['topic_title']);
$this->set_data('post_username', $post['post_username']);
$this->set_data('post_username', (($post['post_username'] != $this->phpbb_container->get('user')->data['username']) ? $post['post_username'] : ''));
$this->set_data('forum_name', $post['forum_name']);