mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-09 00:55:23 +02:00
[ticket/11103] Topic and post dis/approval notifications
Remove the formatted title function, plaintext is not needed since email templates are used Fix a number of bugs. PHPBB3-11103
This commit is contained in:
parent
fc6457140c
commit
05b573ebf7
@ -1295,7 +1295,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||||||
|
|
||||||
// Mark all topic notifications read for this user
|
// Mark all topic notifications read for this user
|
||||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||||
$phpbb_notifications->mark_notifications_read('topic', false, $user->data['user_id'], $post_time);
|
$phpbb_notifications->mark_notifications_read(array('topic', 'quote', 'bookmark', 'post', 'approve_topic', 'approve_post'), false, $user->data['user_id'], $post_time);
|
||||||
|
|
||||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
||||||
{
|
{
|
||||||
@ -1337,7 +1337,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||||||
|
|
||||||
// Mark topic notifications read for this user in this forum
|
// Mark topic notifications read for this user in this forum
|
||||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||||
$phpbb_notifications->mark_notifications_read_by_parent('topic', $forum_id, $user->data['user_id'], $post_time);
|
$phpbb_notifications->mark_notifications_read_by_parent(array('topic', 'approve_topic'), $forum_id, $user->data['user_id'], $post_time);
|
||||||
|
|
||||||
// Mark all post/quote notifications read for this user in this forum
|
// Mark all post/quote notifications read for this user in this forum
|
||||||
$topic_ids = array();
|
$topic_ids = array();
|
||||||
@ -1351,7 +1351,7 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_ids, $user->data['user_id'], $post_time);
|
$phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_ids, $user->data['user_id'], $post_time);
|
||||||
|
|
||||||
// Add 0 to forums array to mark global announcements correctly
|
// Add 0 to forums array to mark global announcements correctly
|
||||||
// $forum_id[] = 0;
|
// $forum_id[] = 0;
|
||||||
@ -1449,7 +1449,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
|
|||||||
|
|
||||||
// Mark post notifications read for this user in this topic
|
// Mark post notifications read for this user in this topic
|
||||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||||
$phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post'), $topic_id, $user->data['user_id'], $post_time);
|
$phpbb_notifications->mark_notifications_read(array('topic', 'approve_topic'), $topic_id, $user->data['user_id'], $post_time);
|
||||||
|
$phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_id, $user->data['user_id'], $post_time);
|
||||||
|
|
||||||
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
if ($config['load_db_lastread'] && $user->data['is_registered'])
|
||||||
{
|
{
|
||||||
|
@ -2238,6 +2238,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||||||
$phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), array_merge($data, array(
|
$phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), array_merge($data, array(
|
||||||
'post_username' => $username,
|
'post_username' => $username,
|
||||||
'poster_id' => (int) $user->data['user_id'],
|
'poster_id' => (int) $user->data['user_id'],
|
||||||
|
'post_text' => $data['message'],
|
||||||
)));
|
)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -2252,6 +2253,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||||||
|
|
||||||
$phpbb_notifications->update_notifications(array('quote', 'bookmark', 'post'), array_merge($data, array(
|
$phpbb_notifications->update_notifications(array('quote', 'bookmark', 'post'), array_merge($data, array(
|
||||||
'post_username' => $username,
|
'post_username' => $username,
|
||||||
|
'post_text' => $data['message'],
|
||||||
)));
|
)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -597,39 +597,34 @@ function approve_post($post_id_list, $id, $mode)
|
|||||||
sync('forum', 'forum_id', array_keys($forum_id_list), true, true);
|
sync('forum', 'forum_id', array_keys($forum_id_list), true, true);
|
||||||
unset($topic_id_list, $forum_id_list);
|
unset($topic_id_list, $forum_id_list);
|
||||||
|
|
||||||
$phpbb_notifications = $phpbb_container->get('notifications');
|
|
||||||
|
|
||||||
// Notify Poster?
|
|
||||||
if ($notify_poster)
|
|
||||||
{
|
|
||||||
// Forum Notifications
|
|
||||||
foreach ($post_info as $post_id => $post_data)
|
|
||||||
{
|
|
||||||
if ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'])
|
|
||||||
{
|
|
||||||
$phpbb_notifications->add_notifications('approve_topic', $post_data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$phpbb_notifications->add_notifications('approve_post', $post_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send out normal user notifications
|
// Send out normal user notifications
|
||||||
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
|
||||||
|
|
||||||
|
// Handle notifications
|
||||||
|
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||||
foreach ($post_info as $post_id => $post_data)
|
foreach ($post_info as $post_id => $post_data)
|
||||||
{
|
{
|
||||||
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
||||||
{
|
{
|
||||||
// Forum Notifications
|
// Forum Notifications
|
||||||
$phpbb_notifications->add_notifications('topic', $post_data);
|
$phpbb_notifications->add_notifications('topic', $post_data);
|
||||||
|
|
||||||
|
// Notify poster?
|
||||||
|
if ($notify_poster)
|
||||||
|
{
|
||||||
|
$phpbb_notifications->add_notifications('approve_topic', $post_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Topic Notifications
|
// Topic Notifications
|
||||||
$phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), $post_data);
|
$phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), $post_data);
|
||||||
|
|
||||||
|
// Notify poster?
|
||||||
|
if ($notify_poster)
|
||||||
|
{
|
||||||
|
$phpbb_notifications->add_notifications('approve_post', $post_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,7 +714,7 @@ function disapprove_post($post_id_list, $id, $mode)
|
|||||||
{
|
{
|
||||||
global $db, $template, $user, $config;
|
global $db, $template, $user, $config;
|
||||||
global $phpEx, $phpbb_root_path;
|
global $phpEx, $phpbb_root_path;
|
||||||
global $request;
|
global $request, $phpbb_container;
|
||||||
|
|
||||||
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve')))
|
||||||
{
|
{
|
||||||
@ -852,20 +847,16 @@ function disapprove_post($post_id_list, $id, $mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$messenger = new messenger();
|
|
||||||
|
|
||||||
// Notify Poster?
|
// Notify Poster?
|
||||||
if ($notify_poster)
|
if ($notify_poster)
|
||||||
{
|
{
|
||||||
$lang_reasons = array();
|
$lang_reasons = array();
|
||||||
|
|
||||||
|
// Handle notifications
|
||||||
|
$phpbb_notifications = $phpbb_container->get('notifications');
|
||||||
foreach ($post_info as $post_id => $post_data)
|
foreach ($post_info as $post_id => $post_data)
|
||||||
{
|
{
|
||||||
if ($post_data['poster_id'] == ANONYMOUS)
|
$post_data['disapprove_reason'] = '';
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($disapprove_reason_lang))
|
if (isset($disapprove_reason_lang))
|
||||||
{
|
{
|
||||||
// Okay we need to get the reason from the posters language
|
// Okay we need to get the reason from the posters language
|
||||||
@ -891,33 +882,32 @@ function disapprove_post($post_id_list, $id, $mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$email_disapprove_reason = $lang_reasons[$post_data['user_lang']];
|
$post_data['disapprove_reason'] = $lang_reasons[$post_data['user_lang']];
|
||||||
$email_disapprove_reason .= ($reason) ? "\n\n" . $reason : '';
|
$post_data['disapprove_reason'] .= ($reason) ? "\n\n" . $reason : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved';
|
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
|
||||||
|
{
|
||||||
$messenger->template($email_template, $post_data['user_lang']);
|
// Notify poster?
|
||||||
|
if ($notify_poster)
|
||||||
$messenger->to($post_data['user_email'], $post_data['username']);
|
{
|
||||||
$messenger->im($post_data['user_jabber'], $post_data['username']);
|
$phpbb_notifications->add_notifications('disapprove_topic', $post_data);
|
||||||
|
}
|
||||||
$messenger->assign_vars(array(
|
}
|
||||||
'USERNAME' => htmlspecialchars_decode($post_data['username']),
|
else
|
||||||
'REASON' => htmlspecialchars_decode($email_disapprove_reason),
|
{
|
||||||
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])),
|
// Notify poster?
|
||||||
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])))
|
if ($notify_poster)
|
||||||
);
|
{
|
||||||
|
$phpbb_notifications->add_notifications('disapprove_post', $post_data);
|
||||||
$messenger->send($post_data['user_notify_type']);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($lang_reasons);
|
unset($lang_reasons);
|
||||||
}
|
}
|
||||||
unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang);
|
unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang);
|
||||||
|
|
||||||
$messenger->save_queue();
|
|
||||||
|
|
||||||
if ($num_disapproved_topics)
|
if ($num_disapproved_topics)
|
||||||
{
|
{
|
||||||
$success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
$success_msg = ($num_disapproved_topics == 1) ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
|
||||||
|
@ -69,7 +69,10 @@ class phpbb_notifications_service
|
|||||||
// Anonymous users and bots never receive notifications
|
// Anonymous users and bots never receive notifications
|
||||||
if ($options['user_id'] == $user->data['user_id'] && ($user->data['user_id'] == ANONYMOUS || $user->data['user_type'] == USER_IGNORE))
|
if ($options['user_id'] == $user->data['user_id'] && ($user->data['user_id'] == ANONYMOUS || $user->data['user_type'] == USER_IGNORE))
|
||||||
{
|
{
|
||||||
return;
|
return array(
|
||||||
|
'notifications' => array(),
|
||||||
|
'unread_count' => 0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$notifications = $user_ids = array();
|
$notifications = $user_ids = array();
|
||||||
@ -273,8 +276,8 @@ class phpbb_notifications_service
|
|||||||
$notification_objects = $notification_methods = array();
|
$notification_objects = $notification_methods = array();
|
||||||
$new_rows = array();
|
$new_rows = array();
|
||||||
|
|
||||||
// Never send notifications to the anonymous user or the current user!
|
// Never send notifications to the anonymous user!
|
||||||
unset($notify_users[ANONYMOUS], $notify_users[$this->phpbb_container->get('user')->data['user_id']]);
|
unset($notify_users[ANONYMOUS]);
|
||||||
|
|
||||||
// Make sure not to send new notifications to users who've already been notified about this item
|
// Make sure not to send new notifications to users who've already been notified about this item
|
||||||
// This may happen when an item was added, but now new users are able to see the item
|
// This may happen when an item was added, but now new users are able to see the item
|
||||||
@ -457,7 +460,7 @@ class phpbb_notifications_service
|
|||||||
{
|
{
|
||||||
if (!$safe)
|
if (!$safe)
|
||||||
{
|
{
|
||||||
$item_type = preg_replace('#[^a-z]#', '', $item_type);
|
$item_type = preg_replace('#[^a-z_]#', '', $item_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'phpbb_notifications_type_' . $item_type;
|
return 'phpbb_notifications_type_' . $item_type;
|
||||||
|
@ -37,7 +37,7 @@ class phpbb_notifications_type_approve_post extends phpbb_notifications_type_pos
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $language_key = 'NOTIFICATION_POST';
|
protected $language_key = 'NOTIFICATION_POST_APPROVED';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of notification this is
|
* Get the type of notification this is
|
||||||
@ -109,6 +109,8 @@ class phpbb_notifications_type_approve_post extends phpbb_notifications_type_pos
|
|||||||
{
|
{
|
||||||
$this->set_data('post_subject', $post['post_subject']);
|
$this->set_data('post_subject', $post['post_subject']);
|
||||||
|
|
||||||
|
$this->time = time();
|
||||||
|
|
||||||
return parent::create_insert_array($post);
|
return parent::create_insert_array($post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
113
phpBB/includes/notifications/type/approve_topic.php
Normal file
113
phpBB/includes/notifications/type/approve_topic.php
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post notifications class
|
||||||
|
* This class handles notifications for replies to a topic
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
*/
|
||||||
|
class phpbb_notifications_type_approve_topic extends phpbb_notifications_type_topic
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Email template to use to send notifications
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $email_template = 'topic_approved';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language key used to output the text
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $language_key = 'NOTIFICATION_TOPIC_APPROVED';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of notification this is
|
||||||
|
* phpbb_notifications_type_
|
||||||
|
*/
|
||||||
|
public static function get_item_type()
|
||||||
|
{
|
||||||
|
return 'approve_topic';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the users who want to receive notifications
|
||||||
|
*
|
||||||
|
* @param ContainerBuilder $phpbb_container
|
||||||
|
* @param array $post Data from
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function find_users_for_notification(ContainerBuilder $phpbb_container, $post)
|
||||||
|
{
|
||||||
|
$users = array();
|
||||||
|
|
||||||
|
/* todo
|
||||||
|
* find what type of notification they'd like to receive
|
||||||
|
*/
|
||||||
|
$users[$post['poster_id']] = array('');
|
||||||
|
|
||||||
|
$auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']);
|
||||||
|
|
||||||
|
if (empty($auth_read))
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$notify_users = array();
|
||||||
|
|
||||||
|
foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id)
|
||||||
|
{
|
||||||
|
$notify_users[$user_id] = $users[$user_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $notify_users;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get email template variables
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_email_template_variables()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
|
||||||
|
|
||||||
|
'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->item_parent_id}&t={$this->item_id}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for preparing the data for insertion in an SQL query
|
||||||
|
* (The service handles insertion)
|
||||||
|
*
|
||||||
|
* @param array $post Data from submit_post
|
||||||
|
*
|
||||||
|
* @return array Array of data ready to be inserted into the database
|
||||||
|
*/
|
||||||
|
public function create_insert_array($post)
|
||||||
|
{
|
||||||
|
$this->time = time();
|
||||||
|
|
||||||
|
return parent::create_insert_array($post);
|
||||||
|
}
|
||||||
|
}
|
@ -114,8 +114,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
|
|||||||
return array(
|
return array(
|
||||||
'AVATAR' => $this->get_avatar(),
|
'AVATAR' => $this->get_avatar(),
|
||||||
|
|
||||||
'FORMATTED_TITLE' => $this->get_formatted_title(),
|
'FORMATTED_TITLE' => $this->get_title(),
|
||||||
'TITLE' => $this->get_title(),
|
|
||||||
|
|
||||||
'URL' => $this->get_url(),
|
'URL' => $this->get_url(),
|
||||||
'TIME' => $user->format_date($this->time),
|
'TIME' => $user->format_date($this->time),
|
||||||
@ -201,16 +200,6 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
|
|||||||
* -------------- Fall back functions -------------------
|
* -------------- Fall back functions -------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the formatted title of this notification (fall-back)
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_formatted_title()
|
|
||||||
{
|
|
||||||
return $this->get_title();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL to unsubscribe to this notification (fall-back)
|
* URL to unsubscribe to this notification (fall-back)
|
||||||
*
|
*
|
||||||
|
@ -75,6 +75,9 @@ class phpbb_notifications_type_bookmark extends phpbb_notifications_type_post
|
|||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Never notify the poster
|
||||||
|
unset($users[$post['poster_id']]);
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
|
105
phpBB/includes/notifications/type/disapprove_post.php
Normal file
105
phpBB/includes/notifications/type/disapprove_post.php
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post notifications class
|
||||||
|
* This class handles notifications for replies to a topic
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
*/
|
||||||
|
class phpbb_notifications_type_disapprove_post extends phpbb_notifications_type_approve_post
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Email template to use to send notifications
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $email_template = 'post_disapproved';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language key used to output the text
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $language_key = 'NOTIFICATION_POST_DISAPPROVED';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of notification this is
|
||||||
|
* phpbb_notifications_type_
|
||||||
|
*/
|
||||||
|
public static function get_item_type()
|
||||||
|
{
|
||||||
|
return 'disapprove_post';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTML formatted title of this notification
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_title()
|
||||||
|
{
|
||||||
|
return $this->phpbb_container->get('user')->lang(
|
||||||
|
$this->language_key,
|
||||||
|
censor_text($this->get_data('topic_title')),
|
||||||
|
$this->get_data('disapprove_reason')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the url to this item
|
||||||
|
*
|
||||||
|
* @return string URL
|
||||||
|
*/
|
||||||
|
public function get_url()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get email template variables
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_email_template_variables()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'POST_SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))),
|
||||||
|
'REASON' => htmlspecialchars_decode($this->get_data('disapprove_reason')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for preparing the data for insertion in an SQL query
|
||||||
|
* (The service handles insertion)
|
||||||
|
*
|
||||||
|
* @param array $post Data from submit_post
|
||||||
|
*
|
||||||
|
* @return array Array of data ready to be inserted into the database
|
||||||
|
*/
|
||||||
|
public function create_insert_array($post)
|
||||||
|
{
|
||||||
|
$this->set_data('post_subject', $post['post_subject']);
|
||||||
|
$this->set_data('disapprove_reason', $post['disapprove_reason']);
|
||||||
|
|
||||||
|
$this->time = time();
|
||||||
|
|
||||||
|
return parent::create_insert_array($post);
|
||||||
|
}
|
||||||
|
}
|
104
phpBB/includes/notifications/type/disapprove_topic.php
Normal file
104
phpBB/includes/notifications/type/disapprove_topic.php
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
* @copyright (c) 2012 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post notifications class
|
||||||
|
* This class handles notifications for replies to a topic
|
||||||
|
*
|
||||||
|
* @package notifications
|
||||||
|
*/
|
||||||
|
class phpbb_notifications_type_disapprove_topic extends phpbb_notifications_type_approve_topic
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Email template to use to send notifications
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $email_template = 'topic_disapproved';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language key used to output the text
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $language_key = 'NOTIFICATION_TOPIC_DISAPPROVED';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of notification this is
|
||||||
|
* phpbb_notifications_type_
|
||||||
|
*/
|
||||||
|
public static function get_item_type()
|
||||||
|
{
|
||||||
|
return 'disapprove_topic';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HTML formatted title of this notification
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_title()
|
||||||
|
{
|
||||||
|
return $this->phpbb_container->get('user')->lang(
|
||||||
|
$this->language_key,
|
||||||
|
censor_text($this->get_data('topic_title')),
|
||||||
|
$this->get_data('disapprove_reason')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the url to this item
|
||||||
|
*
|
||||||
|
* @return string URL
|
||||||
|
*/
|
||||||
|
public function get_url()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get email template variables
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_email_template_variables()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
|
||||||
|
|
||||||
|
'REASON' => htmlspecialchars_decode($this->get_data('disapprove_reason')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for preparing the data for insertion in an SQL query
|
||||||
|
* (The service handles insertion)
|
||||||
|
*
|
||||||
|
* @param array $post Data from submit_post
|
||||||
|
*
|
||||||
|
* @return array Array of data ready to be inserted into the database
|
||||||
|
*/
|
||||||
|
public function create_insert_array($post)
|
||||||
|
{
|
||||||
|
$this->set_data('disapprove_reason', $post['disapprove_reason']);
|
||||||
|
$this->time = time();
|
||||||
|
|
||||||
|
return parent::create_insert_array($post);
|
||||||
|
}
|
||||||
|
}
|
@ -29,8 +29,6 @@ interface phpbb_notifications_type_interface
|
|||||||
|
|
||||||
public function get_title();
|
public function get_title();
|
||||||
|
|
||||||
public function get_formatted_title();
|
|
||||||
|
|
||||||
public function get_email_template_variables();
|
public function get_email_template_variables();
|
||||||
|
|
||||||
public function get_url();
|
public function get_url();
|
||||||
|
@ -121,7 +121,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_formatted_title()
|
public function get_title()
|
||||||
{
|
{
|
||||||
$user_data = $this->service->get_user($this->get_data('from_user_id'));
|
$user_data = $this->service->get_user($this->get_data('from_user_id'));
|
||||||
|
|
||||||
@ -130,18 +130,6 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
|
|||||||
return $this->phpbb_container->get('user')->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject'));
|
return $this->phpbb_container->get('user')->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the plain text title of this notification
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_title()
|
|
||||||
{
|
|
||||||
$user_data = $this->service->get_user($this->get_data('from_user_id'));
|
|
||||||
|
|
||||||
return $this->phpbb_container->get('user')->lang('NOTIFICATION_PM', $user_data['username'], $this->get_data('message_subject'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get email template variables
|
* Get email template variables
|
||||||
*
|
*
|
||||||
|
@ -101,6 +101,9 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
|||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Never notify the poster
|
||||||
|
unset($users[$post['poster_id']]);
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
@ -136,31 +139,6 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_formatted_title()
|
|
||||||
{
|
|
||||||
if ($this->get_data('post_username'))
|
|
||||||
{
|
|
||||||
$username = $this->get_data('post_username');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$user_data = $this->service->get_user($this->get_data('poster_id'));
|
|
||||||
|
|
||||||
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->phpbb_container->get('user')->lang(
|
|
||||||
$this->language_key,
|
|
||||||
$username,
|
|
||||||
censor_text($this->get_data('topic_title'))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the title of this notification
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_title()
|
public function get_title()
|
||||||
{
|
{
|
||||||
if ($this->get_data('post_username'))
|
if ($this->get_data('post_username'))
|
||||||
@ -171,7 +149,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
|||||||
{
|
{
|
||||||
$user_data = $this->service->get_user($this->get_data('poster_id'));
|
$user_data = $this->service->get_user($this->get_data('poster_id'));
|
||||||
|
|
||||||
$username = $user_data['username'];
|
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->phpbb_container->get('user')->lang(
|
return $this->phpbb_container->get('user')->lang(
|
||||||
@ -238,6 +216,8 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
|
|||||||
|
|
||||||
$this->set_data('forum_name', $post['forum_name']);
|
$this->set_data('forum_name', $post['forum_name']);
|
||||||
|
|
||||||
|
$this->time = $post['post_time'];
|
||||||
|
|
||||||
return parent::create_insert_array($post);
|
return parent::create_insert_array($post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post
|
|||||||
$db = $phpbb_container->get('dbal.conn');
|
$db = $phpbb_container->get('dbal.conn');
|
||||||
|
|
||||||
$usernames = false;
|
$usernames = false;
|
||||||
preg_match_all(self::$regular_expression_match, $post['message'], $usernames);
|
preg_match_all(self::$regular_expression_match, $post['post_text'], $usernames);
|
||||||
|
|
||||||
if (empty($usernames[1]))
|
if (empty($usernames[1]))
|
||||||
{
|
{
|
||||||
@ -94,6 +94,9 @@ class phpbb_notifications_type_quote extends phpbb_notifications_type_post
|
|||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Never notify the poster
|
||||||
|
unset($users[$post['poster_id']]);
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
|
@ -32,6 +32,13 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
|||||||
*/
|
*/
|
||||||
public $email_template = 'newtopic_notify';
|
public $email_template = 'newtopic_notify';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language key used to output the text
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $language_key = 'NOTIFICATION_TOPIC';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of notification this is
|
* Get the type of notification this is
|
||||||
* phpbb_notifications_type_
|
* phpbb_notifications_type_
|
||||||
@ -94,6 +101,9 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
|||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// Never notify the poster
|
||||||
|
unset($users[$topic['poster_id']]);
|
||||||
|
|
||||||
if (empty($users))
|
if (empty($users))
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
@ -129,7 +139,7 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_formatted_title()
|
public function get_title()
|
||||||
{
|
{
|
||||||
if ($this->get_data('post_username'))
|
if ($this->get_data('post_username'))
|
||||||
{
|
{
|
||||||
@ -143,33 +153,7 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->phpbb_container->get('user')->lang(
|
return $this->phpbb_container->get('user')->lang(
|
||||||
'NOTIFICATION_TOPIC',
|
$this->language_key,
|
||||||
$username,
|
|
||||||
censor_text($this->get_data('topic_title')),
|
|
||||||
$this->get_data('forum_name')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the title of this notification
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_title()
|
|
||||||
{
|
|
||||||
if ($this->get_data('post_username'))
|
|
||||||
{
|
|
||||||
$username = $this->get_data('post_username');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$user_data = $this->service->get_user($this->get_data('poster_id'));
|
|
||||||
|
|
||||||
$username = $user_data['username'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->phpbb_container->get('user')->lang(
|
|
||||||
'NOTIFICATION_TOPIC',
|
|
||||||
$username,
|
$username,
|
||||||
censor_text($this->get_data('topic_title')),
|
censor_text($this->get_data('topic_title')),
|
||||||
$this->get_data('forum_name')
|
$this->get_data('forum_name')
|
||||||
@ -230,6 +214,8 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base
|
|||||||
|
|
||||||
$this->set_data('forum_name', $post['forum_name']);
|
$this->set_data('forum_name', $post['forum_name']);
|
||||||
|
|
||||||
|
$this->time = $post['post_time'];
|
||||||
|
|
||||||
return parent::create_insert_array($post);
|
return parent::create_insert_array($post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,8 +389,12 @@ $lang = array_merge($lang, array(
|
|||||||
'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.',
|
'NOTIFICATION_BOOKMARK' => '%1$s replied to the topic "%2$s" you have bookmarked.',
|
||||||
'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".',
|
'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".',
|
||||||
'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".',
|
'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".',
|
||||||
|
'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".',
|
||||||
|
'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved because "%2$s".',
|
||||||
'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".',
|
'NOTIFICATION_QUOTE' => '%1$s quoted you in the post "%2$s".',
|
||||||
'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".',
|
'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".',
|
||||||
|
'NOTIFICATION_TOPIC_APPROVED' => 'Your topic "%2$s" in the forum "%3$s" was approved.',
|
||||||
|
'NOTIFICATION_TOPIC_DISAPPROVED' => 'Your topic "%1$s" was disapproved because "%2$s".',
|
||||||
'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.',
|
'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.',
|
||||||
'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: <a href="mailto:%1$s">%1$s</a>',
|
'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: <a href="mailto:%1$s">%1$s</a>',
|
||||||
'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.',
|
'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.',
|
||||||
|
@ -137,13 +137,13 @@
|
|||||||
<ul style="list-style-type: none;">
|
<ul style="list-style-type: none;">
|
||||||
<!-- BEGIN notifications -->
|
<!-- BEGIN notifications -->
|
||||||
<li style="padding: 10px; width: 290px;<!-- IF notifications.UNREAD --> background-color: grey;<!-- ENDIF -->">
|
<li style="padding: 10px; width: 290px;<!-- IF notifications.UNREAD --> background-color: grey;<!-- ENDIF -->">
|
||||||
<a href="{notifications.URL}" style="text-decoration: none;">
|
<!-- IF notifications.URL --><a href="{notifications.URL}" style="text-decoration: none;"><!-- ENDIF -->
|
||||||
{notifications.AVATAR}
|
{notifications.AVATAR}
|
||||||
<div>
|
<div>
|
||||||
{notifications.FORMATTED_TITLE}<br />
|
{notifications.FORMATTED_TITLE}<br />
|
||||||
{notifications.TIME}
|
{notifications.TIME}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
<!-- IF notifications.URL --></a><!-- ENDIF -->
|
||||||
</li>
|
</li>
|
||||||
<!-- END notifications -->
|
<!-- END notifications -->
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user