aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Friedman <maf675@gmail.com>2015-10-13 23:40:52 -0700
committerMatt Friedman <maf675@gmail.com>2015-10-13 23:40:52 -0700
commitb64a37d451132dcf7ef5fc3d6e700a6fb6decd90 (patch)
tree8432ace2597886cfbf20bcfdd27e39cd17c1f6b1
parent03cb2a7b0c5a3756522c27d708bdaf0bfa771706 (diff)
downloadforums-b64a37d451132dcf7ef5fc3d6e700a6fb6decd90.tar
forums-b64a37d451132dcf7ef5fc3d6e700a6fb6decd90.tar.gz
forums-b64a37d451132dcf7ef5fc3d6e700a6fb6decd90.tar.bz2
forums-b64a37d451132dcf7ef5fc3d6e700a6fb6decd90.tar.xz
forums-b64a37d451132dcf7ef5fc3d6e700a6fb6decd90.zip
[ticket/14237] Use $language class for notifications
PHPBB3-14237
-rw-r--r--phpBB/config/default/container/services_notification.yml2
-rw-r--r--phpBB/phpbb/notification/manager.php36
-rw-r--r--phpBB/phpbb/notification/method/board.php1
-rw-r--r--phpBB/phpbb/notification/method/messenger_base.php1
-rw-r--r--phpBB/phpbb/notification/type/admin_activate_user.php2
-rw-r--r--phpBB/phpbb/notification/type/base.php64
-rw-r--r--phpBB/phpbb/notification/type/disapprove_post.php6
-rw-r--r--phpBB/phpbb/notification/type/disapprove_topic.php6
-rw-r--r--phpBB/phpbb/notification/type/group_request.php2
-rw-r--r--phpBB/phpbb/notification/type/group_request_approved.php2
-rw-r--r--phpBB/phpbb/notification/type/pm.php4
-rw-r--r--phpBB/phpbb/notification/type/post.php11
-rw-r--r--phpBB/phpbb/notification/type/quote.php1
-rw-r--r--phpBB/phpbb/notification/type/report_pm.php23
-rw-r--r--phpBB/phpbb/notification/type/report_pm_closed.php4
-rw-r--r--phpBB/phpbb/notification/type/report_post.php16
-rw-r--r--phpBB/phpbb/notification/type/report_post_closed.php4
-rw-r--r--phpBB/phpbb/notification/type/topic.php8
-rw-r--r--tests/mock/notification_type_post.php3
-rw-r--r--tests/notification/base.php2
-rw-r--r--tests/notification/fixtures/services_notification.yml3
-rw-r--r--tests/notification/submit_post_base.php10
-rw-r--r--tests/notification/user_list_trim_test.php4
23 files changed, 133 insertions, 82 deletions
diff --git a/phpBB/config/default/container/services_notification.yml b/phpBB/config/default/container/services_notification.yml
index c842656575..7337dd7904 100644
--- a/phpBB/config/default/container/services_notification.yml
+++ b/phpBB/config/default/container/services_notification.yml
@@ -9,6 +9,7 @@ services:
- @dispatcher
- @dbal.conn
- @cache
+ - @language
- @user
- %tables.notification_types%
- %tables.user_notifications%
@@ -26,6 +27,7 @@ services:
abstract: true
arguments:
- @dbal.conn
+ - @language
- @user
- @auth
- %core.root_path%
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php
index 4be678ac91..080d2ecb1d 100644
--- a/phpBB/phpbb/notification/manager.php
+++ b/phpBB/phpbb/notification/manager.php
@@ -44,6 +44,9 @@ class manager
/** @var \phpbb\cache\service */
protected $cache;
+ /** @var \phpbb\language\language */
+ protected $language;
+
/** @var \phpbb\user */
protected $user;
@@ -63,13 +66,14 @@ class manager
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\cache\service $cache
+ * @param \phpbb\language\language $language
* @param \phpbb\user $user
* @param string $notification_types_table
* @param string $user_notifications_table
*
* @return \phpbb\notification\manager
*/
- public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\user $user, $notification_types_table, $user_notifications_table)
+ public function __construct($notification_types, $notification_methods, ContainerInterface $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\language\language $language, \phpbb\user $user, $notification_types_table, $user_notifications_table)
{
$this->notification_types = $notification_types;
$this->notification_methods = $notification_methods;
@@ -79,6 +83,7 @@ class manager
$this->phpbb_dispatcher = $phpbb_dispatcher;
$this->db = $db;
$this->cache = $cache;
+ $this->language = $language;
$this->user = $user;
$this->notification_types_table = $notification_types_table;
@@ -111,7 +116,7 @@ class manager
if (! $method instanceof \phpbb\notification\method\method_interface)
{
- throw new \phpbb\notification\exception($this->user->lang('NOTIFICATION_METHOD_INVALID', $method_name));
+ throw new \phpbb\notification\exception($this->language->lang('NOTIFICATION_METHOD_INVALID', $method_name));
}
else if ($method->is_available())
{
@@ -166,7 +171,7 @@ class manager
$notification_type_id = false;
}
- /** @var method_interface $method */
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$method->mark_notifications($notification_type_id, $item_id, $user_id, $time, $mark_read);
@@ -208,6 +213,7 @@ class manager
$notification_type_id = $this->get_notification_type_id($notification_type_name);
}
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$method->mark_notifications_by_parent($notification_type_id, $item_parent_id, $user_id, $time, $mark_read);
@@ -263,8 +269,6 @@ class manager
return $notified_users;
}
- $item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data);
-
// find out which users want to receive this type of notification
$notify_users = $this->get_item_type_class($notification_type_name)->find_users_for_notification($data, $options);
@@ -317,7 +321,7 @@ class manager
$item_id = $this->get_item_type_class($notification_type_name)->get_item_id($data);
$user_ids = array();
- $notification_objects = $notification_methods = array();
+ $notification_methods = array();
// Never send notifications to the anonymous user!
unset($notify_users[ANONYMOUS]);
@@ -325,6 +329,7 @@ class manager
// 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
// We remove each user which was already notified by at least one method.
+ /** @var method\method_interface $method */
foreach ($this->get_subscription_methods_instances() as $method)
{
$notified_users = $method->get_notified_users($notification_type_id, array('item_id' => $item_id));
@@ -415,6 +420,7 @@ class manager
$options['item_id'] = $notification->get_item_id($data);
}
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$method->update_notification($notification, $data, $options);
@@ -443,6 +449,7 @@ class manager
$notification_type_id = $this->get_notification_type_id($notification_type_name);
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$method->delete_notifications($notification_type_id, $item_id, $parent_id, $user_id);
@@ -462,6 +469,7 @@ class manager
foreach ($this->notification_types as $type_name => $data)
{
+ /** @var type\base $type */
$type = $this->get_item_type_class($type_name);
if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available())
@@ -497,6 +505,7 @@ class manager
{
$subscription_methods = array();
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method_name => $method)
{
$subscription_methods[$method_name] = array(
@@ -539,6 +548,7 @@ class manager
{
$subscription_methods = array();
+ /** @var method\method_interface $method */
foreach ($this->get_subscription_methods_instances() as $method_name => $method)
{
if ($method->is_available())
@@ -768,6 +778,7 @@ class manager
{
$notification_type_id = $this->get_notification_type_id($notification_type_name);
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$method->purge_notifications($notification_type_id);
@@ -805,6 +816,7 @@ class manager
*/
public function prune_notifications($timestamp, $only_read = true)
{
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$method->prune_notifications($timestamp, $only_read);
@@ -834,7 +846,9 @@ class manager
/**
* Helper to get the notifications item type class and set it up
*
- * @return type\type_interface
+ * @param string $notification_type_name
+ * @param array $data
+ * @return \phpbb\notification\type\type_interface
*/
public function get_item_type_class($notification_type_name, $data = array())
{
@@ -848,7 +862,8 @@ class manager
/**
* Helper to get the notifications method class and set it up
*
- * @return method\method_interface
+ * @param string $method_name
+ * @return \phpbb\notification\method\method_interface
*/
public function get_method_class($method_name)
{
@@ -858,7 +873,8 @@ class manager
/**
* Helper to load objects (notification types/methods)
*
- * @return method\method_interface|type\type_interface
+ * @param string $object_name
+ * @return \phpbb\notification\method\method_interface|\phpbb\notification\type\type_interface
*/
protected function load_object($object_name)
{
@@ -950,6 +966,8 @@ class manager
$notification_type_id = $this->get_notification_type_id($notification_type_name);
$notified_users = array();
+
+ /** @var method\method_interface $method */
foreach ($this->get_available_subscription_methods() as $method)
{
$notified_users = $notified_users + $method->get_notified_users($notification_type_id, $options);
diff --git a/phpBB/phpbb/notification/method/board.php b/phpBB/phpbb/notification/method/board.php
index c45f3a8caa..931b252daa 100644
--- a/phpBB/phpbb/notification/method/board.php
+++ b/phpBB/phpbb/notification/method/board.php
@@ -266,6 +266,7 @@ class board extends \phpbb\notification\method\base
{
$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notifications_table);
+ /** @var \phpbb\notification\type\type_interface $notification */
foreach ($this->queue as $notification)
{
$data = $notification->get_insert_array();
diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php
index 61119b9882..8a8e284e13 100644
--- a/phpBB/phpbb/notification/method/messenger_base.php
+++ b/phpBB/phpbb/notification/method/messenger_base.php
@@ -82,6 +82,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
$messenger = new \messenger();
// Time to go through the queue and send emails
+ /** @var \phpbb\notification\type\type_interface $notification */
foreach ($this->queue as $notification)
{
if ($notification->get_email_template() === false)
diff --git a/phpBB/phpbb/notification/type/admin_activate_user.php b/phpBB/phpbb/notification/type/admin_activate_user.php
index b191fa62ae..9f2ae857ef 100644
--- a/phpBB/phpbb/notification/type/admin_activate_user.php
+++ b/phpBB/phpbb/notification/type/admin_activate_user.php
@@ -130,7 +130,7 @@ class admin_activate_user extends \phpbb\notification\type\base
{
$username = $this->user_loader->get_username($this->item_id, 'no_profile');
- return $this->user->lang($this->language_key, $username);
+ return $this->language->lang($this->language_key, $username);
}
/**
diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php
index 31e853d7d9..4aacb1c99e 100644
--- a/phpBB/phpbb/notification/type/base.php
+++ b/phpBB/phpbb/notification/type/base.php
@@ -24,6 +24,9 @@ abstract class base implements \phpbb\notification\type\type_interface
/** @var \phpbb\db\driver\driver_interface */
protected $db;
+ /** @var \phpbb\language\language */
+ protected $language;
+
/** @var \phpbb\user */
protected $user;
@@ -56,7 +59,7 @@ abstract class base implements \phpbb\notification\type\type_interface
protected $notification_type_id;
/**
- * Indentification data
+ * Identification data
* notification_type_id - ID of the item type (auto generated, from notification types table)
* item_id - ID of the item (e.g. post_id, msg_id)
* item_parent_id - Parent item id (ex: for topic => forum_id, for post => topic_id, etc)
@@ -71,19 +74,20 @@ abstract class base implements \phpbb\notification\type\type_interface
private $data = array();
/**
- * Notification Type Base Constructor
- *
- * @param \phpbb\db\driver\driver_interface $db
- * @param \phpbb\user $user
- * @param \phpbb\auth\auth $auth
- * @param string $phpbb_root_path
- * @param string $php_ext
- * @param string $user_notifications_table
- * @return \phpbb\notification\type\base
- */
- public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table)
+ * Notification Type Base Constructor
+ *
+ * @param \phpbb\db\driver\driver_interface $db
+ * @param \phpbb\language\language $language
+ * @param \phpbb\user $user
+ * @param \phpbb\auth\auth $auth
+ * @param string $phpbb_root_path
+ * @param string $php_ext
+ * @param string $user_notifications_table
+ */
+ public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\language\language $language, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table)
{
$this->db = $db;
+ $this->language = $language;
$this->user = $user;
$this->auth = $auth;
@@ -192,7 +196,7 @@ abstract class base implements \phpbb\notification\type\type_interface
'notification_time' => time(),
'notification_read' => false,
- 'notification_data' => array(),
+ 'notification_data' => array(),
), $this->data);
}
@@ -304,6 +308,7 @@ abstract class base implements \phpbb\notification\type\type_interface
* URL to unsubscribe to this notification (fall back)
*
* @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item
+ * @return false
*/
public function get_unsubscribe_url($method = false)
{
@@ -371,8 +376,11 @@ abstract class base implements \phpbb\notification\type\type_interface
}
/**
- * Load the special items (fall back)
- */
+ * Load the special items (fall back)
+ *
+ * @param array $data
+ * @param array $notifications
+ */
public function load_special($data, $notifications)
{
return;
@@ -389,10 +397,12 @@ abstract class base implements \phpbb\notification\type\type_interface
}
/**
- * Pre create insert array function (fall back)
- *
- * @return array
- */
+ * Pre create insert array function (fall back)
+ *
+ * @param array $type_data
+ * @param array $notify_users
+ * @return array
+ */
public function pre_create_insert_array($type_data, $notify_users)
{
return array();
@@ -403,13 +413,13 @@ abstract class base implements \phpbb\notification\type\type_interface
*/
/**
- * Find the users who want to receive notifications (helper)
- *
- * @param array $user_ids User IDs to check if they want to receive notifications
- * (Bool False to check all users besides anonymous and bots (USER_IGNORE))
- *
- * @return array
- */
+ * Find the users who want to receive notifications (helper)
+ *
+ * @param array|bool $user_ids User IDs to check if they want to receive notifications
+ * (Bool False to check all users besides anonymous and bots (USER_IGNORE))
+ * @param array $options
+ * @return array
+ */
protected function check_user_notification_options($user_ids = false, $options = array())
{
$options = array_merge(array(
@@ -505,6 +515,8 @@ abstract class base implements \phpbb\notification\type\type_interface
{
$this->notification_manager->mark_notifications($this->get_type(), (int) $this->item_id, (int) $this->user_id, false, $this->notification_read);
}
+
+ return null;
}
/**
diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php
index 21338bddb7..2d908eb254 100644
--- a/phpBB/phpbb/notification/type/disapprove_post.php
+++ b/phpBB/phpbb/notification/type/disapprove_post.php
@@ -73,7 +73,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post
*/
public function get_title()
{
- return $this->user->lang($this->language_key);
+ return $this->language->lang($this->language_key);
}
/**
@@ -83,7 +83,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('topic_title'))
);
@@ -96,7 +96,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post
*/
public function get_reason()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
$this->get_data('disapprove_reason')
);
diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php
index 30a23a83fe..c2522fb562 100644
--- a/phpBB/phpbb/notification/type/disapprove_topic.php
+++ b/phpBB/phpbb/notification/type/disapprove_topic.php
@@ -73,7 +73,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
*/
public function get_title()
{
- return $this->user->lang($this->language_key);
+ return $this->language->lang($this->language_key);
}
/**
@@ -83,7 +83,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('topic_title'))
);
@@ -96,7 +96,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
*/
public function get_reason()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
$this->get_data('disapprove_reason')
);
diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php
index 8a0027bfec..28a9e73bf9 100644
--- a/phpBB/phpbb/notification/type/group_request.php
+++ b/phpBB/phpbb/notification/type/group_request.php
@@ -114,7 +114,7 @@ class group_request extends \phpbb\notification\type\base
{
$username = $this->user_loader->get_username($this->item_id, 'no_profile');
- return $this->user->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name'));
+ return $this->language->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name'));
}
/**
diff --git a/phpBB/phpbb/notification/type/group_request_approved.php b/phpBB/phpbb/notification/type/group_request_approved.php
index dc353f3380..f55d28bafd 100644
--- a/phpBB/phpbb/notification/type/group_request_approved.php
+++ b/phpBB/phpbb/notification/type/group_request_approved.php
@@ -69,7 +69,7 @@ class group_request_approved extends \phpbb\notification\type\base
*/
public function get_title()
{
- return $this->user->lang('NOTIFICATION_GROUP_REQUEST_APPROVED', $this->get_data('group_name'));
+ return $this->language->lang('NOTIFICATION_GROUP_REQUEST_APPROVED', $this->get_data('group_name'));
}
/**
diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php
index 2de2dcfa0b..8fb9172911 100644
--- a/phpBB/phpbb/notification/type/pm.php
+++ b/phpBB/phpbb/notification/type/pm.php
@@ -128,7 +128,7 @@ class pm extends \phpbb\notification\type\base
{
$username = $this->user_loader->get_username($this->get_data('from_user_id'), 'no_profile');
- return $this->user->lang('NOTIFICATION_PM', $username);
+ return $this->language->lang('NOTIFICATION_PM', $username);
}
/**
@@ -138,7 +138,7 @@ class pm extends \phpbb\notification\type\base
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
$this->get_data('message_subject')
);
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index f3dd6d531a..b54a6610b2 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -83,6 +83,7 @@ class post extends \phpbb\notification\type\base
* Get the id of the item
*
* @param array $post The data from the post
+ * @return int The post id
*/
static public function get_item_id($post)
{
@@ -93,6 +94,7 @@ class post extends \phpbb\notification\type\base
* Get the id of the parent
*
* @param array $post The data from the post
+ * @return int The topic id
*/
static public function get_item_parent_id($post)
{
@@ -218,14 +220,14 @@ class post extends \phpbb\notification\type\base
if ($trimmed_responders_cnt > 20)
{
- $usernames[] = $this->user->lang('NOTIFICATION_MANY_OTHERS');
+ $usernames[] = $this->language->lang('NOTIFICATION_MANY_OTHERS');
}
else if ($trimmed_responders_cnt)
{
- $usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt);
+ $usernames[] = $this->language->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt);
}
- return $this->user->lang(
+ return $this->language->lang(
$this->language_key,
phpbb_generate_string_list($usernames, $this->user),
$responders_cnt
@@ -239,7 +241,7 @@ class post extends \phpbb\notification\type\base
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('topic_title'))
);
@@ -407,6 +409,7 @@ class post extends \phpbb\notification\type\base
* Add responders to the notification
*
* @param mixed $post
+ * @return array Array of responder data
*/
public function add_responders($post)
{
diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php
index 1cd879579a..9e759ef137 100644
--- a/phpBB/phpbb/notification/type/quote.php
+++ b/phpBB/phpbb/notification/type/quote.php
@@ -106,6 +106,7 @@ class quote extends \phpbb\notification\type\post
* Update a notification
*
* @param array $post Data specific for this type that will be updated
+ * @return true
*/
public function update_notifications($post)
{
diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php
index 0f7dce0a68..b80afc1039 100644
--- a/phpBB/phpbb/notification/type/report_pm.php
+++ b/phpBB/phpbb/notification/type/report_pm.php
@@ -70,6 +70,7 @@ class report_pm extends \phpbb\notification\type\pm
* Get the id of the parent
*
* @param array $pm The data from the pm
+ * @return int The report id
*/
static public function get_item_parent_id($pm)
{
@@ -144,10 +145,10 @@ class report_pm extends \phpbb\notification\type\pm
$user_data = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
return array(
- 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
- 'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
+ 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
+ 'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
- 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details",
+ 'U_VIEW_REPORT' => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details",
);
}
@@ -168,11 +169,11 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function get_title()
{
- $this->user->add_lang('mcp');
+ $this->language->add_lang('mcp');
$username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
- return $this->user->lang(
+ return $this->language->lang(
$this->language_key,
$username
);
@@ -185,7 +186,7 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('message_subject'))
);
@@ -200,21 +201,21 @@ class report_pm extends \phpbb\notification\type\pm
{
if ($this->get_data('report_text'))
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
$this->get_data('report_text')
);
}
- if (isset($this->user->lang[$this->get_data('reason_title')]))
+ if ($this->language->is_set($this->get_data('reason_title')))
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
- $this->user->lang[$this->get_data('reason_title')]
+ $this->language->lang($this->get_data('reason_title'))
);
}
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
$this->get_data('reason_description')
);
diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php
index f793c7df9a..5e98eb5feb 100644
--- a/phpBB/phpbb/notification/type/report_pm_closed.php
+++ b/phpBB/phpbb/notification/type/report_pm_closed.php
@@ -106,7 +106,7 @@ class report_pm_closed extends \phpbb\notification\type\pm
{
$username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile');
- return $this->user->lang(
+ return $this->language->lang(
$this->language_key,
$username
);
@@ -119,7 +119,7 @@ class report_pm_closed extends \phpbb\notification\type\pm
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('message_subject'))
);
diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php
index 6eefd53832..84a5241417 100644
--- a/phpBB/phpbb/notification/type/report_post.php
+++ b/phpBB/phpbb/notification/type/report_post.php
@@ -139,11 +139,11 @@ class report_post extends \phpbb\notification\type\post_in_queue
*/
public function get_title()
{
- $this->user->add_lang('mcp');
+ $this->language->add_lang('mcp');
$username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
- return $this->user->lang(
+ return $this->language->lang(
$this->language_key,
$username
);
@@ -156,7 +156,7 @@ class report_post extends \phpbb\notification\type\post_in_queue
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('post_subject'))
);
@@ -171,21 +171,21 @@ class report_post extends \phpbb\notification\type\post_in_queue
{
if ($this->get_data('report_text'))
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
$this->get_data('report_text')
);
}
- if (isset($this->user->lang[$this->get_data('reason_title')]))
+ if ($this->language->is_set($this->get_data('reason_title')))
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
- $this->user->lang[$this->get_data('reason_title')]
+ $this->language->lang($this->get_data('reason_title'))
);
}
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REASON',
$this->get_data('reason_description')
);
diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php
index 6327011f2d..165034d57e 100644
--- a/phpBB/phpbb/notification/type/report_post_closed.php
+++ b/phpBB/phpbb/notification/type/report_post_closed.php
@@ -113,7 +113,7 @@ class report_post_closed extends \phpbb\notification\type\post
{
$username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile');
- return $this->user->lang(
+ return $this->language->lang(
$this->language_key,
$username
);
@@ -126,7 +126,7 @@ class report_post_closed extends \phpbb\notification\type\post
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('post_subject'))
);
diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php
index 4812e8b5af..671c34fe96 100644
--- a/phpBB/phpbb/notification/type/topic.php
+++ b/phpBB/phpbb/notification/type/topic.php
@@ -83,6 +83,7 @@ class topic extends \phpbb\notification\type\base
* Get the id of the item
*
* @param array $post The data from the post
+ * @return int The topic id
*/
static public function get_item_id($post)
{
@@ -93,6 +94,7 @@ class topic extends \phpbb\notification\type\base
* Get the id of the parent
*
* @param array $post The data from the post
+ * @return int The forum id
*/
static public function get_item_parent_id($post)
{
@@ -154,7 +156,7 @@ class topic extends \phpbb\notification\type\base
$username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile');
}
- return $this->user->lang(
+ return $this->language->lang(
$this->language_key,
$username
);
@@ -167,7 +169,7 @@ class topic extends \phpbb\notification\type\base
*/
public function get_reference()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_REFERENCE',
censor_text($this->get_data('topic_title'))
);
@@ -180,7 +182,7 @@ class topic extends \phpbb\notification\type\base
*/
public function get_forum()
{
- return $this->user->lang(
+ return $this->language->lang(
'NOTIFICATION_FORUM',
$this->get_data('forum_name')
);
diff --git a/tests/mock/notification_type_post.php b/tests/mock/notification_type_post.php
index fd2d1b63cd..4116fecf5e 100644
--- a/tests/mock/notification_type_post.php
+++ b/tests/mock/notification_type_post.php
@@ -21,11 +21,12 @@ if (!defined('IN_PHPBB'))
class phpbb_mock_notification_type_post extends \phpbb\notification\type\post
{
- public function __construct($user_loader, $db, $cache, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table)
+ public function __construct($user_loader, $db, $cache, $language, $user, $auth, $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table)
{
$this->user_loader = $user_loader;
$this->db = $db;
$this->cache = $cache;
+ $this->language = $language;
$this->user = $user;
$this->auth = $auth;
$this->config = $config;
diff --git a/tests/notification/base.php b/tests/notification/base.php
index 1295f099f0..b64e25cf8c 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -90,6 +90,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$loader->load('services_notification.yml');
$phpbb_container->set('user_loader', $this->user_loader);
$phpbb_container->set('user', $user);
+ $phpbb_container->set('language', $lang);
$phpbb_container->set('config', $this->config);
$phpbb_container->set('dbal.conn', $this->db);
$phpbb_container->set('auth', $auth);
@@ -111,6 +112,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$this->phpbb_dispatcher,
$this->db,
$this->cache,
+ $lang,
$this->user,
'phpbb_notification_types',
'phpbb_user_notifications'
diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml
index e0a404b12b..6e68cccff6 100644
--- a/tests/notification/fixtures/services_notification.yml
+++ b/tests/notification/fixtures/services_notification.yml
@@ -17,6 +17,9 @@ services:
dbal.conn:
synthetic: true
+ language:
+ synthetic: true
+
auth:
synthetic: true
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 72b25abf0a..14ca4499d2 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -54,7 +54,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
{
parent::setUp();
- global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $user, $request, $phpEx, $phpbb_root_path, $user_loader;
+ global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader;
// Database
$this->db = $this->new_dbal();
@@ -91,9 +91,12 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
// Event dispatcher
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ // Language
+ $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
+
// User
$user = $this->getMock('\phpbb\user', array(), array(
- new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ $lang,
'\phpbb\datetime'
));
$user->ip = '';
@@ -117,6 +120,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$loader->load('services_notification.yml');
$phpbb_container->set('user_loader', $user_loader);
$phpbb_container->set('user', $user);
+ $phpbb_container->set('language', $lang);
$phpbb_container->set('config', $config);
$phpbb_container->set('dbal.conn', $db);
$phpbb_container->set('auth', $auth);
@@ -146,7 +150,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, $notification_methods_array,
- $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $user,
+ $phpbb_container, $user_loader, $phpbb_dispatcher, $db, $cache, $lang, $user,
NOTIFICATION_TYPES_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
}
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index d57fbf0485..9f6eb492f6 100644
--- a/tests/notification/user_list_trim_test.php
+++ b/tests/notification/user_list_trim_test.php
@@ -55,13 +55,13 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$user->data = array('user_lang' => 'en');
- $user->add_lang('common');
+ $lang->add_lang('common');
$user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
$user_loader->load_users(array(2, 3, 4, 5, 6));
$this->notification = new phpbb_mock_notification_type_post(
- $user_loader, null, null, $user, null, null, $phpbb_root_path, $phpEx, null, null
+ $user_loader, null, null, $lang, $user, null, null, $phpbb_root_path, $phpEx, null, null
);
}