aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Guse <nathaniel.guse@gmail.com>2012-11-09 07:40:08 -0600
committerNathaniel Guse <nathaniel.guse@gmail.com>2012-11-09 07:40:08 -0600
commitf09ee162528d931aabc3f216410d02d3a072c21d (patch)
tree22f20e453d830258f65f318c39a59ff6354cabbc
parent03e348cf58c9b71ab00f0badb76a4426c2c71289 (diff)
downloadforums-f09ee162528d931aabc3f216410d02d3a072c21d.tar
forums-f09ee162528d931aabc3f216410d02d3a072c21d.tar.gz
forums-f09ee162528d931aabc3f216410d02d3a072c21d.tar.bz2
forums-f09ee162528d931aabc3f216410d02d3a072c21d.tar.xz
forums-f09ee162528d931aabc3f216410d02d3a072c21d.zip
[ticket/11103] Use phpBB Container to load types/methods
PHPBB3-11103
-rw-r--r--phpBB/config/notifications.yml272
-rw-r--r--phpBB/config/services.yml2
-rw-r--r--phpBB/includes/notification/manager.php70
-rw-r--r--phpBB/includes/notification/method/email.php10
-rw-r--r--phpBB/includes/notification/method/interface.php7
-rw-r--r--phpBB/includes/notification/method/jabber.php10
-rw-r--r--phpBB/includes/notification/type/approve_post.php10
-rw-r--r--phpBB/includes/notification/type/approve_topic.php10
-rw-r--r--phpBB/includes/notification/type/base.php6
-rw-r--r--phpBB/includes/notification/type/bookmark.php14
-rw-r--r--phpBB/includes/notification/type/disapprove_post.php10
-rw-r--r--phpBB/includes/notification/type/disapprove_topic.php10
-rw-r--r--phpBB/includes/notification/type/interface.php7
-rw-r--r--phpBB/includes/notification/type/pm.php10
-rw-r--r--phpBB/includes/notification/type/post.php14
-rw-r--r--phpBB/includes/notification/type/post_in_queue.php10
-rw-r--r--phpBB/includes/notification/type/quote.php20
-rw-r--r--phpBB/includes/notification/type/report_pm.php10
-rw-r--r--phpBB/includes/notification/type/report_pm_closed.php10
-rw-r--r--phpBB/includes/notification/type/report_post.php10
-rw-r--r--phpBB/includes/notification/type/report_post_closed.php10
-rw-r--r--phpBB/includes/notification/type/topic.php10
-rw-r--r--phpBB/includes/notification/type/topic_in_queue.php10
-rw-r--r--phpBB/includes/ucp/ucp_notifications.php24
-rw-r--r--phpBB/language/en/ucp.php4
25 files changed, 505 insertions, 75 deletions
diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml
new file mode 100644
index 0000000000..78fcd7c2d9
--- /dev/null
+++ b/phpBB/config/notifications.yml
@@ -0,0 +1,272 @@
+services:
+ notification.type.approve_post:
+ class: phpbb_notification_type_approve_post
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.approve_topic:
+ class: phpbb_notification_type_approve_topic
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.bookmark:
+ class: phpbb_notification_type_bookmark
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.disapprove_post:
+ class: phpbb_notification_type_disapprove_post
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.disapprove_topic:
+ class: phpbb_notification_type_disapprove_topic
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.pm:
+ class: phpbb_notification_type_pm
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.post:
+ class: phpbb_notification_type_post
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.post_in_queue:
+ class: phpbb_notification_type_post_in_queue
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.quote:
+ class: phpbb_notification_type_quote
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.report_pm:
+ class: phpbb_notification_type_report_pm
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.report_pm_closed:
+ class: phpbb_notification_type_report_pm_closed
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.report_post:
+ class: phpbb_notification_type_report_post
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.report_post_closed:
+ class: phpbb_notification_type_report_post
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.topic:
+ class: phpbb_notification_type_topic
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.type.topic_in_queue:
+ class: phpbb_notification_type_topic_in_queue
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.type }
+
+ notification.method.email:
+ class: phpbb_notification_method_email
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.method }
+
+ notification.method.jabber:
+ class: phpbb_notification_method_jabber
+ arguments:
+ - @notification_manager
+ - @dbal.conn
+ - @cache.driver
+ - @template
+ - @ext.manager
+ - @user
+ - @auth
+ - @config
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: notification.method } \ No newline at end of file
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 4ae519091b..e780dc986f 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -1,6 +1,7 @@
imports:
- { resource: tables.yml }
- { resource: cron_tasks.yml }
+ - { resource: notifications.yml }
services:
auth:
@@ -92,6 +93,7 @@ services:
notification_manager:
class: phpbb_notification_manager
arguments:
+ - @container
- @dbal.conn
- @cache.driver
- @template
diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php
index fef93a30c2..102623ab93 100644
--- a/phpBB/includes/notification/manager.php
+++ b/phpBB/includes/notification/manager.php
@@ -7,6 +7,8 @@
*
*/
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
/**
* @ignore
*/
@@ -21,6 +23,9 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_notification_manager
{
+ /** @var ContainerBuilder */
+ protected $phpbb_container = null;
+
/** @var dbal */
protected $db = null;
@@ -55,8 +60,9 @@ class phpbb_notification_manager
*/
protected $users = array();
- public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
+ public function __construct(ContainerBuilder $phpbb_container, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
{
+ $this->phpbb_container = $phpbb_container;
$this->db = $db;
$this->cache = $cache;
$this->template = $template;
@@ -495,17 +501,17 @@ class phpbb_notification_manager
{
$subscription_types = array();
- foreach ($this->get_subscription_files('notification/type/') as $class_name)
+ foreach ($this->phpbb_container->findTaggedServiceIds('notification.type') as $type_name => $data)
{
- $class = $this->get_item_type_class($class_name);
+ $type = $this->get_item_type_class($type_name);
- if ($class instanceof phpbb_notification_type_interface && $class->is_available())
+ if ($type instanceof phpbb_notification_type_interface && $type->is_available())
{
$options = array_merge(array(
- 'id' => $class_name,
- 'lang' => 'NOTIFICATION_TYPE_' . strtoupper($class_name),
+ 'id' => $type->get_type(),
+ 'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()),
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
- ), (($class_name::$notification_option !== false) ? $class_name::$notification_option : array()));
+ ), (($type::$notification_option !== false) ? $type::$notification_option : array()));
$subscription_types[$options['group']][$options['id']] = $options;
}
@@ -531,13 +537,16 @@ class phpbb_notification_manager
{
$subscription_methods = array();
- foreach ($this->get_subscription_files('notification/method/') as $class_name)
+ foreach ($this->phpbb_container->findTaggedServiceIds('notification.method') as $method_name => $data)
{
- $method = $this->get_method_class($class_name);
+ $method = $this->get_method_class($method_name);
if ($method instanceof phpbb_notification_method_interface && $method->is_available())
{
- $subscription_methods[] = $class_name;
+ $subscription_methods[$method_name] = array(
+ 'id' => $method->get_type(),
+ 'lang' => 'NOTIFICATION_METHOD_' . strtoupper($method->get_type()),
+ );
}
}
@@ -783,7 +792,7 @@ class phpbb_notification_manager
*/
public function get_item_type_class($item_type, $data = array())
{
- $item = new $item_type($this, $this->db, $this->cache, $this->template, $this->extension_manager, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext);
+ $item = $this->phpbb_container->get($item_type);
$item->set_initial_data($data);
@@ -795,43 +804,6 @@ class phpbb_notification_manager
*/
public function get_method_class($method_name)
{
- return new $method_name($this, $this->db, $this->cache, $this->template, $this->extension_manager, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext);
- }
-
- /**
- * Helper to get subscription related files with the finder
- */
- private function get_subscription_files($path)
- {
- $finder = $this->extension_manager->get_finder();
-
- $subscription_files = array();
-
- $classes = $finder
- ->core_path('includes/' . $path)
- ->extension_directory($path)
- ->get_classes();
-
- if (array_search('phpbb_notification_type_interface', $classes) !== false)
- {
- unset($classes[array_search('phpbb_notification_type_interface', $classes)]);
- }
-
- if (array_search('phpbb_notification_type_base', $classes) !== false)
- {
- unset($classes[array_search('phpbb_notification_type_base', $classes)]);
- }
-
- if (array_search('phpbb_notification_method_interface', $classes) !== false)
- {
- unset($classes[array_search('phpbb_notification_method_interface', $classes)]);
- }
-
- if (array_search('phpbb_notification_method_base', $classes) !== false)
- {
- unset($classes[array_search('phpbb_notification_method_base', $classes)]);
- }
-
- return $classes;
+ return $this->phpbb_container->get($method_name);
}
}
diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php
index df7edb13e7..a47284bc61 100644
--- a/phpBB/includes/notification/method/email.php
+++ b/phpBB/includes/notification/method/email.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_method_email extends phpbb_notification_method_base
{
/**
+ * Get notification method name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'email';
+ }
+
+ /**
* Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication)
*
* @var mixed
diff --git a/phpBB/includes/notification/method/interface.php b/phpBB/includes/notification/method/interface.php
index 3c6c757d5c..ef875942cc 100644
--- a/phpBB/includes/notification/method/interface.php
+++ b/phpBB/includes/notification/method/interface.php
@@ -22,6 +22,13 @@ if (!defined('IN_PHPBB'))
interface phpbb_notification_method_interface
{
/**
+ * Get notification method name
+ *
+ * @return string
+ */
+ public function get_type();
+
+ /**
* Is this method available for the user?
* This is checked on the notifications options
*/
diff --git a/phpBB/includes/notification/method/jabber.php b/phpBB/includes/notification/method/jabber.php
index 664e387d61..fc43d8d4b9 100644
--- a/phpBB/includes/notification/method/jabber.php
+++ b/phpBB/includes/notification/method/jabber.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_method_jabber extends phpbb_notification_method_email
{
/**
+ * Get notification method name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'jabber';
+ }
+
+ /**
* Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication)
*
* @var mixed
diff --git a/phpBB/includes/notification/type/approve_post.php b/phpBB/includes/notification/type/approve_post.php
index d79bc6ae13..38ff3f1d70 100644
--- a/phpBB/includes/notification/type/approve_post.php
+++ b/phpBB/includes/notification/type/approve_post.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_approve_post extends phpbb_notification_type_post
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'approve_post';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/approve_topic.php b/phpBB/includes/notification/type/approve_topic.php
index 605965bf2f..5b9ea409fe 100644
--- a/phpBB/includes/notification/type/approve_topic.php
+++ b/phpBB/includes/notification/type/approve_topic.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_approve_topic extends phpbb_notification_type_topic
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'approve_topic';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php
index fdd8a5b9cb..2b201c2752 100644
--- a/phpBB/includes/notification/type/base.php
+++ b/phpBB/includes/notification/type/base.php
@@ -116,7 +116,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
public function __toString()
{
- return (!empty($this->data)) ? var_export($this->data, true) : get_class($this);
+ return (!empty($this->data)) ? var_export($this->data, true) : $this->get_type();
}
/**
@@ -156,7 +156,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
// Defaults
$this->data = array_merge(array(
'item_id' => static::get_item_id($type_data),
- 'item_type' => get_class($this),
+ 'item_type' => $this->get_type(),
'item_parent_id' => static::get_item_parent_id($type_data),
'time' => time(),
@@ -319,7 +319,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
{
$options = array_merge(array(
'ignore_users' => array(),
- 'item_type' => get_class($this),
+ 'item_type' => $this->get_type(),
'item_id' => 0, // Global by default
), $options);
diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php
index 6fe00d9dd0..e5ad4132fb 100644
--- a/phpBB/includes/notification/type/bookmark.php
+++ b/phpBB/includes/notification/type/bookmark.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_bookmark extends phpbb_notification_type_post
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'bookmark';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
@@ -93,7 +103,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
$update_notifications = array();
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . get_class($this) . "'
+ WHERE item_type = '" . $this->get_type() . "'
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
AND unread = 1
AND is_enabled = 1';
@@ -103,7 +113,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
// Do not create a new notification
unset($notify_users[$row['user_id']]);
- $notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
+ $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
WHERE notification_id = ' . $row['notification_id'];
diff --git a/phpBB/includes/notification/type/disapprove_post.php b/phpBB/includes/notification/type/disapprove_post.php
index ddacd4d367..d1d56086e7 100644
--- a/phpBB/includes/notification/type/disapprove_post.php
+++ b/phpBB/includes/notification/type/disapprove_post.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_disapprove_post extends phpbb_notification_type_approve_post
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'disapprove_post';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/disapprove_topic.php b/phpBB/includes/notification/type/disapprove_topic.php
index dfda4f8371..7affaa8afa 100644
--- a/phpBB/includes/notification/type/disapprove_topic.php
+++ b/phpBB/includes/notification/type/disapprove_topic.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_approve_topic
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'disapprove_topic';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/interface.php b/phpBB/includes/notification/type/interface.php
index 9d9965261e..a40fdafd09 100644
--- a/phpBB/includes/notification/type/interface.php
+++ b/phpBB/includes/notification/type/interface.php
@@ -22,6 +22,13 @@ if (!defined('IN_PHPBB'))
interface phpbb_notification_type_interface
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type();
+
+ /**
* Set initial data from the database
*
* @param array $data Row directly from the database
diff --git a/phpBB/includes/notification/type/pm.php b/phpBB/includes/notification/type/pm.php
index 1c38002892..fbdf351062 100644
--- a/phpBB/includes/notification/type/pm.php
+++ b/phpBB/includes/notification/type/pm.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_pm extends phpbb_notification_type_base
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'pm';
+ }
+
+ /**
* Notification option data (for outputting to the user)
*
* @var bool|array False if the service should use it's default data
diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php
index b1a3ee9a26..a99558efe7 100644
--- a/phpBB/includes/notification/type/post.php
+++ b/phpBB/includes/notification/type/post.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_post extends phpbb_notification_type_base
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'post';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
@@ -114,7 +124,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
$update_notifications = array();
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . get_class($this) . "'
+ WHERE item_type = '" . $this->get_type() . "'
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
AND unread = 1
AND is_enabled = 1';
@@ -124,7 +134,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
// Do not create a new notification
unset($notify_users[$row['user_id']]);
- $notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
+ $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
WHERE notification_id = ' . $row['notification_id'];
diff --git a/phpBB/includes/notification/type/post_in_queue.php b/phpBB/includes/notification/type/post_in_queue.php
index e9e7c6120e..95e0ce02bb 100644
--- a/phpBB/includes/notification/type/post_in_queue.php
+++ b/phpBB/includes/notification/type/post_in_queue.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'post_in_queue';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php
index c9f0f923c1..c3763da229 100644
--- a/phpBB/includes/notification/type/quote.php
+++ b/phpBB/includes/notification/type/quote.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_quote extends phpbb_notification_type_post
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'quote';
+ }
+
+ /**
* regular expression to match to find usernames
*
* @var string
@@ -112,7 +122,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
$update_notifications = array();
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . get_class($this) . "'
+ WHERE item_type = '" . $this->get_type() . "'
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
AND unread = 1
AND is_enabled = 1';
@@ -122,7 +132,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
// Do not create a new notification
unset($notify_users[$row['user_id']]);
- $notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
+ $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
WHERE notification_id = ' . $row['notification_id'];
@@ -143,7 +153,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
$old_notifications = array();
$sql = 'SELECT user_id
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . get_class($this) . "'
+ WHERE item_type = '" . $this->get_type() . "'
AND item_id = " . self::get_item_id($post) . '
AND is_enabled = 1';
$result = $this->db->sql_query($sql);
@@ -167,13 +177,13 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
}
// Add the necessary notifications
- $this->notification_manager->add_notifications_for_users(get_class($this), $post, $add_notifications);
+ $this->notification_manager->add_notifications_for_users($this->get_type(), $post, $add_notifications);
// Remove the necessary notifications
if (!empty($remove_notifications))
{
$sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . get_class($this) . "'
+ WHERE item_type = '" . $this->get_type() . "'
AND item_id = " . self::get_item_id($post) . '
AND ' . $this->db->sql_in_set('user_id', $remove_notifications);
$this->db->sql_query($sql);
diff --git a/phpBB/includes/notification/type/report_pm.php b/phpBB/includes/notification/type/report_pm.php
index 63d153bd27..2841468475 100644
--- a/phpBB/includes/notification/type/report_pm.php
+++ b/phpBB/includes/notification/type/report_pm.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'report_pm';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/report_pm_closed.php b/phpBB/includes/notification/type/report_pm_closed.php
index c86fe77b0e..de87c9f760 100644
--- a/phpBB/includes/notification/type/report_pm_closed.php
+++ b/phpBB/includes/notification/type/report_pm_closed.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_pm
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'report_pm_closed';
+ }
+
+ /**
* Email template to use to send notifications
*
* @var string
diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/includes/notification/type/report_post.php
index 26dd9512bf..433a5e835d 100644
--- a/phpBB/includes/notification/type/report_post.php
+++ b/phpBB/includes/notification/type/report_post.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_report_post extends phpbb_notification_type_post_in_queue
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'report_post';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/report_post_closed.php b/phpBB/includes/notification/type/report_post_closed.php
index 7454760dc0..cde0ff85a8 100644
--- a/phpBB/includes/notification/type/report_post_closed.php
+++ b/phpBB/includes/notification/type/report_post_closed.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_report_post_closed extends phpbb_notification_type_post
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'report_post_closed';
+ }
+
+ /**
* Email template to use to send notifications
*
* @var string
diff --git a/phpBB/includes/notification/type/topic.php b/phpBB/includes/notification/type/topic.php
index db268fa53e..4eb03194f5 100644
--- a/phpBB/includes/notification/type/topic.php
+++ b/phpBB/includes/notification/type/topic.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_topic extends phpbb_notification_type_base
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'topic';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/notification/type/topic_in_queue.php b/phpBB/includes/notification/type/topic_in_queue.php
index 66aecb0d05..38bc2ab58d 100644
--- a/phpBB/includes/notification/type/topic_in_queue.php
+++ b/phpBB/includes/notification/type/topic_in_queue.php
@@ -24,6 +24,16 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_topic
{
/**
+ * Get notification type name
+ *
+ * @return string
+ */
+ public function get_type()
+ {
+ return 'topic_in_queue';
+ }
+
+ /**
* Language key used to output the text
*
* @var string
diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php
index 8810ac9ce6..e8ceac3f59 100644
--- a/phpBB/includes/ucp/ucp_notifications.php
+++ b/phpBB/includes/ucp/ucp_notifications.php
@@ -48,15 +48,15 @@ class ucp_notifications
{
foreach($subscription_types as $type => $data)
{
- foreach($notification_methods as $method)
+ foreach($notification_methods as $method => $method_data)
{
- if ($request->is_set_post($type . '_' . $method) && (!isset($subscriptions[$type]) || !in_array($method, $subscriptions[$type])))
+ if ($request->is_set_post($type . '_' . $method_data['id']) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
{
- $phpbb_notifications->add_subscription($type, 0, $method);
+ $phpbb_notifications->add_subscription($type, 0, $method_data['id']);
}
- else if (!$request->is_set_post($type . '_' . $method) && isset($subscriptions[$type]) && in_array($method, $subscriptions[$type]))
+ else if (!$request->is_set_post($type . '_' . $method_data['id']) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type]))
{
- $phpbb_notifications->delete_subscription($type, 0, $method);
+ $phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
}
}
@@ -186,14 +186,14 @@ class ucp_notifications
'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
));
- foreach($notification_methods as $method)
+ foreach($notification_methods as $method => $method_data)
{
$template->assign_block_vars($block . '.notification_methods', array(
- 'METHOD' => $method,
+ 'METHOD' => $method_data['id'],
- 'NAME' => $user->lang(strtoupper($method)),
+ 'NAME' => $user->lang($method_data['lang']),
- 'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) ? true : false,
+ 'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) ? true : false,
));
}
}
@@ -212,12 +212,12 @@ class ucp_notifications
{
$notification_methods = $phpbb_notifications->get_subscription_methods();
- foreach($notification_methods as $method)
+ foreach($notification_methods as $method => $method_data)
{
$template->assign_block_vars($block, array(
- 'METHOD' => $method,
+ 'METHOD' => $method_data['id'],
- 'NAME' => $user->lang(strtoupper($method)),
+ 'NAME' => $user->lang($method_data['lang']),
));
}
}
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 5b1e7add02..7c3960204a 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -295,6 +295,8 @@ $lang = array_merge($lang, array(
'NOTIFICATION_GROUP_MISCELLANEOUS' => 'Miscellaneous Notifications',
'NOTIFICATION_GROUP_MODERATION' => 'Moderation Notifications',
'NOTIFICATION_GROUP_POSTING' => 'Posting Notifications',
+ 'NOTIFICATION_METHOD_EMAIL' => 'Email',
+ 'NOTIFICATION_METHOD_JABBER' => 'Jabber',
'NOTIFICATION_TYPE' => 'Notification type',
'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked',
'NOTIFICATION_TYPE_IN_MODERATION_QUEUE' => 'A post or topic needs approval',
@@ -374,8 +376,6 @@ $lang = array_merge($lang, array(
'PASSWORD_UPDATED' => 'A new password was sent to your registered email address.',
'PERMISSIONS_RESTORED' => 'Successfully restored original permissions.',
'PERMISSIONS_TRANSFERRED' => 'Successfully transferred permissions from <strong>%s</strong>, you are now able to browse the board with this user’s permissions.<br />Please note that admin permissions were not transferred. You are able to revert to your permission set at any time.',
- 'PHPBB_NOTIFICATION_METHOD_EMAIL' => 'Email',
- 'PHPBB_NOTIFICATION_METHOD_JABBER' => 'Jabber',
'PM_DISABLED' => 'Private messaging has been disabled on this board.',
'PM_FROM' => 'From',
'PM_FROM_REMOVED_AUTHOR' => 'This message was sent by a user no longer registered.',