aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/notification
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/notification')
-rw-r--r--phpBB/includes/notification/manager.php200
-rw-r--r--phpBB/includes/notification/type/approve_post.php9
-rw-r--r--phpBB/includes/notification/type/approve_topic.php9
-rw-r--r--phpBB/includes/notification/type/base.php6
-rw-r--r--phpBB/includes/notification/type/bookmark.php20
-rw-r--r--phpBB/includes/notification/type/disapprove_post.php9
-rw-r--r--phpBB/includes/notification/type/disapprove_topic.php9
-rw-r--r--phpBB/includes/notification/type/interface.php6
-rw-r--r--phpBB/includes/notification/type/pm.php15
-rw-r--r--phpBB/includes/notification/type/post.php16
-rw-r--r--phpBB/includes/notification/type/post_in_queue.php9
-rw-r--r--phpBB/includes/notification/type/quote.php26
-rw-r--r--phpBB/includes/notification/type/report_pm.php9
-rw-r--r--phpBB/includes/notification/type/report_pm_closed.php9
-rw-r--r--phpBB/includes/notification/type/report_post.php9
-rw-r--r--phpBB/includes/notification/type/report_post_closed.php9
-rw-r--r--phpBB/includes/notification/type/topic.php12
-rw-r--r--phpBB/includes/notification/type/topic_in_queue.php9
18 files changed, 109 insertions, 282 deletions
diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php
index 3a4c4cd696..06ebaf24c4 100644
--- a/phpBB/includes/notification/manager.php
+++ b/phpBB/includes/notification/manager.php
@@ -138,32 +138,16 @@ class phpbb_notification_manager
$this->db->sql_freeresult($result);
}
- $rowset = array();
-
- // Get the main notifications
- $sql = 'SELECT *
- FROM ' . NOTIFICATIONS_TABLE . '
- WHERE user_id = ' . (int) $options['user_id'] .
- (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('notification_id', $options['notification_id']) : ' AND notification_id = ' . (int) $options['notification_id']) : '') . '
- AND is_enabled = 1
- ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']);
- $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']);
-
- while ($row = $this->db->sql_fetchrow($result))
+ if (!$options['count_total'] || $total_count)
{
- $rowset[$row['notification_id']] = $row;
- }
- $this->db->sql_freeresult($result);
+ $rowset = array();
- // Get all unread notifications
- if ($unread_count && $options['all_unread'] && !empty($rowset))
- {
+ // Get the main notifications
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . '
- WHERE user_id = ' . (int) $options['user_id'] . '
- AND unread = 1
- AND ' . $this->db->sql_in_set('notification_id', array_keys($rowset), true) . '
- AND is_is_enabled = 1
+ WHERE user_id = ' . (int) $options['user_id'] .
+ (($options['notification_id']) ? ((is_array($options['notification_id'])) ? ' AND ' . $this->db->sql_in_set('notification_id', $options['notification_id']) : ' AND notification_id = ' . (int) $options['notification_id']) : '') . '
+ AND is_enabled = 1
ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']);
$result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']);
@@ -172,37 +156,52 @@ class phpbb_notification_manager
$rowset[$row['notification_id']] = $row;
}
$this->db->sql_freeresult($result);
- }
-
- foreach ($rowset as $row)
- {
- $item_type_class_name = $this->get_item_type_class_name($row['item_type'], true);
- $notification = $this->get_item_type_class($item_type_class_name, $row);
-
- // Array of user_ids to query all at once
- $user_ids = array_merge($user_ids, $notification->users_to_query());
-
- // Some notification types also require querying additional tables themselves
- if (!isset($load_special[$row['item_type']]))
+ // Get all unread notifications
+ if ($unread_count && $options['all_unread'] && !empty($rowset))
{
- $load_special[$row['item_type']] = array();
+ $sql = 'SELECT *
+ FROM ' . NOTIFICATIONS_TABLE . '
+ WHERE user_id = ' . (int) $options['user_id'] . '
+ AND unread = 1
+ AND ' . $this->db->sql_in_set('notification_id', array_keys($rowset), true) . '
+ AND is_enabled = 1
+ ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']);
+ $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $rowset[$row['notification_id']] = $row;
+ }
+ $this->db->sql_freeresult($result);
}
- $load_special[$row['item_type']] = array_merge($load_special[$row['item_type']], $notification->get_load_special());
- $notifications[$row['notification_id']] = $notification;
- }
+ foreach ($rowset as $row)
+ {
+ $notification = $this->get_item_type_class($row['item_type'], $row);
- $this->load_users($user_ids);
+ // Array of user_ids to query all at once
+ $user_ids = array_merge($user_ids, $notification->users_to_query());
- // Allow each type to load its own special items
- foreach ($load_special as $item_type => $data)
- {
- $item_type_class_name = $this->get_item_type_class_name($item_type, true);
+ // Some notification types also require querying additional tables themselves
+ if (!isset($load_special[$row['item_type']]))
+ {
+ $load_special[$row['item_type']] = array();
+ }
+ $load_special[$row['item_type']] = array_merge($load_special[$row['item_type']], $notification->get_load_special());
+
+ $notifications[$row['notification_id']] = $notification;
+ }
+
+ $this->load_users($user_ids);
- $item_class = $this->get_item_type_class($item_type_class_name);
+ // Allow each type to load its own special items
+ foreach ($load_special as $item_type => $data)
+ {
+ $item_class = $this->get_item_type_class($item_type);
- $item_class->load_special($data, $notifications);
+ $item_class->load_special($data, $notifications);
+ }
}
return array(
@@ -234,11 +233,6 @@ class phpbb_notification_manager
$time = ($time) ?: time();
- if ($item_type !== false)
- {
- $this->get_item_type_class_name($item_type);
- }
-
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . "
SET unread = 0
WHERE time <= " . $time .
@@ -270,8 +264,6 @@ class phpbb_notification_manager
$time = ($time) ?: time();
- $item_type_class_name = $this->get_item_type_class_name($item_type);
-
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . "
SET unread = 0
WHERE item_type = '" . $this->db->sql_escape($item_type) . "'
@@ -326,12 +318,10 @@ class phpbb_notification_manager
return $notified_users;
}
- $item_type_class_name = $this->get_item_type_class_name($item_type);
-
- $item_id = $item_type_class_name::get_item_id($data);
+ $item_id = $item_type::get_item_id($data);
// find out which users want to receive this type of notification
- $notify_users = $this->get_item_type_class($item_type_class_name)->find_users_for_notification($data, $options);
+ $notify_users = $this->get_item_type_class($item_type)->find_users_for_notification($data, $options);
$this->add_notifications_for_users($item_type, $data, $notify_users);
@@ -357,9 +347,7 @@ class phpbb_notification_manager
return;
}
- $item_type_class_name = $this->get_item_type_class_name($item_type);
-
- $item_id = $item_type_class_name::get_item_id($data);
+ $item_id = $item_type::get_item_id($data);
$user_ids = array();
$notification_objects = $notification_methods = array();
@@ -388,14 +376,14 @@ class phpbb_notification_manager
}
// Allow notifications to perform actions before creating the insert array (such as run a query to cache some data needed for all notifications)
- $notification = $this->get_item_type_class($item_type_class_name);
+ $notification = $this->get_item_type_class($item_type);
$pre_create_data = $notification->pre_create_insert_array($data, $notify_users);
unset($notification);
// Go through each user so we can insert a row in the DB and then notify them by their desired means
foreach ($notify_users as $user => $methods)
{
- $notification = $this->get_item_type_class($item_type_class_name);
+ $notification = $this->get_item_type_class($item_type);
$notification->user_id = (int) $user;
@@ -412,8 +400,7 @@ class phpbb_notification_manager
{
if (!isset($notification_methods[$method]))
{
- $method_class_name = 'phpbb_notification_method_' . $method;
- $notification_methods[$method] = $this->get_method_class($method_class_name);
+ $notification_methods[$method] = $this->get_method_class($method);
}
$notification_methods[$method]->add_to_queue($notification);
@@ -452,21 +439,19 @@ class phpbb_notification_manager
return;
}
- $item_type_class_name = $this->get_item_type_class_name($item_type);
+ $notification = $this->get_item_type_class($item_type);
// Allow the notifications class to over-ride the update_notifications functionality
- if (method_exists($item_type_class_name, 'update_notifications'))
+ if (method_exists($notification, 'update_notifications'))
{
// Return False to over-ride the rest of the update
- if ($this->get_item_type_class($item_type_class_name)->update_notifications($data) === false)
+ if ($notification->update_notifications($data) === false)
{
return;
}
}
- $item_id = $item_type_class_name::get_item_id($data);
-
- $notification = $this->get_item_type_class($item_type_class_name);
+ $item_id = $item_type::get_item_id($data);
$update_array = $notification->create_update_array($data);
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
@@ -495,8 +480,6 @@ class phpbb_notification_manager
return;
}
- $this->get_item_type_class_name($item_type);
-
$sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . "
WHERE item_type = '" . $this->db->sql_escape($item_type) . "'
AND " . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id);
@@ -512,17 +495,15 @@ class phpbb_notification_manager
{
$subscription_types = array();
- foreach ($this->get_subscription_files('notification/type/') as $class_name => $file)
+ foreach ($this->get_subscription_files('notification/type/') as $class_name)
{
- $class_name = $this->get_item_type_class_name($class_name);
-
$class = $this->get_item_type_class($class_name);
- if ($class instanceof phpbb_notification_type_interface && $class->is_available() && method_exists($class_name, 'get_item_type'))
+ if ($class instanceof phpbb_notification_type_interface && $class->is_available())
{
$options = array_merge(array(
- 'id' => $class_name::get_item_type(),
- 'lang' => 'NOTIFICATION_TYPE_' . strtoupper($class_name::get_item_type()),
+ 'id' => $class_name,
+ 'lang' => 'NOTIFICATION_TYPE_' . strtoupper($class_name),
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
), (($class_name::$notification_option !== false) ? $class_name::$notification_option : array()));
@@ -550,15 +531,13 @@ class phpbb_notification_manager
{
$subscription_methods = array();
- foreach ($this->get_subscription_files('notification/method/') as $method_name => $file)
+ foreach ($this->get_subscription_files('notification/method/') as $class_name)
{
- $class_name = 'phpbb_notification_method_' . $method_name;
-
$method = $this->get_method_class($class_name);
if ($method instanceof phpbb_notification_method_interface && $method->is_available())
{
- $subscription_methods[] = $method_name;
+ $subscription_methods[] = $class_name;
}
}
@@ -615,8 +594,6 @@ class phpbb_notification_manager
*/
public function add_subscription($item_type, $item_id = 0, $method = '', $user_id = false)
{
- $this->get_item_type_class_name($item_type);
-
$user_id = ($user_id === false) ? $this->user->data['user_id'] : $user_id;
$sql = 'INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' .
@@ -639,8 +616,6 @@ class phpbb_notification_manager
*/
public function delete_subscription($item_type, $item_id = 0, $method = '', $user_id = false)
{
- $this->get_item_type_class_name($item_type);
-
$user_id = ($user_id === false) ? $this->user->data['user_id'] : $user_id;
$sql = 'DELETE FROM ' . USER_NOTIFICATIONS_TABLE . "
@@ -693,36 +668,10 @@ class phpbb_notification_manager
}
/**
- * Helper to get the notifications item type class name and clean it if unsafe
- */
- private function get_item_type_class_name(&$item_type, $safe = false)
- {
- if (!$safe)
- {
- $item_type = preg_replace('#[^a-z_-]#', '', $item_type);
- }
-
- if (strpos($item_type, 'ext_') === 0)
- {
- $item_type_ary = explode('-', substr($item_type, 4), 2);
-
- return 'phpbb_ext_' . $item_type_ary[0] . '_notification_type_' . $item_type_ary[1];
- }
-
- return 'phpbb_notification_type_' . $item_type;
- }
-
- /**
* Helper to get the notifications item type class and set it up
*/
public function get_item_type_class($item_type, $data = array())
{
- if (!strpos($item_type, 'notification_type_'))
- {
- $item_class = $this->get_item_type_class_name($item_type);
- $item_type = $item_class;
- }
-
$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->set_initial_data($data);
@@ -747,31 +696,16 @@ class phpbb_notification_manager
$subscription_files = array();
- $files = $finder
+ $classes = $finder
->core_path('includes/' . $path)
->extension_directory($path)
- ->get_files();
- foreach ($files as $file)
- {
- $name = substr($file, strrpos($file, '/'));
- $name = substr($name, 1, (strpos($name, '.' . $this->php_ext) - 1));
+ ->get_classes();
- if ($name == 'interface' || $name == 'base')
- {
- continue;
- }
-
- if (!strpos($file, 'includes/')) // is an extension
- {
- $ext_name = substr($file, (strpos($file, 'ext/') + 4));
- $ext_name = substr($ext_name, 0, strpos($ext_name, '/'));
-
- $name = 'ext_' . $ext_name . '-' . $name;
- }
-
- $subscription_files[$name] = $file;
- }
+ unset($classes[array_search('phpbb_notification_type_interface', $classes)]);
+ unset($classes[array_search('phpbb_notification_type_base', $classes)]);
+ unset($classes[array_search('phpbb_notification_method_interface', $classes)]);
+ unset($classes[array_search('phpbb_notification_method_base', $classes)]);
- return $subscription_files;
+ return $classes;
}
}
diff --git a/phpBB/includes/notification/type/approve_post.php b/phpBB/includes/notification/type/approve_post.php
index 4ed5124415..46f2c16c14 100644
--- a/phpBB/includes/notification/type/approve_post.php
+++ b/phpBB/includes/notification/type/approve_post.php
@@ -43,15 +43,6 @@ class phpbb_notification_type_approve_post extends phpbb_notification_type_post
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'approve_post';
- }
-
- /**
* Is available
*/
public function is_available()
diff --git a/phpBB/includes/notification/type/approve_topic.php b/phpBB/includes/notification/type/approve_topic.php
index 32a1de8cf8..0015858c2e 100644
--- a/phpBB/includes/notification/type/approve_topic.php
+++ b/phpBB/includes/notification/type/approve_topic.php
@@ -43,15 +43,6 @@ class phpbb_notification_type_approve_topic extends phpbb_notification_type_topi
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'approve_topic';
- }
-
- /**
* Is available
*/
public function is_available()
diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php
index 4c496f0a22..df04dc2a49 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) : static::get_item_type();
+ return (!empty($this->data)) ? var_export($this->data, true) : get_class($this);
}
/**
@@ -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' => $this->get_item_type(),
+ 'item_type' => get_class($this),
'item_parent_id' => static::get_item_parent_id($type_data),
'time' => time(),
@@ -324,7 +324,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . static::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND item_id = " . (int) $item_id;
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php
index eb1a735249..4d5a1fd299 100644
--- a/phpBB/includes/notification/type/bookmark.php
+++ b/phpBB/includes/notification/type/bookmark.php
@@ -31,13 +31,15 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
protected $language_key = 'NOTIFICATION_BOOKMARK';
/**
- * Get the type of notification this is
- * phpbb_notification_type_
+ * Notification option data (for outputting to the user)
+ *
+ * @var bool|array False if the service should use it's default data
+ * Array of data (including keys 'id', 'lang', and 'group')
*/
- public static function get_item_type()
- {
- return 'bookmark';
- }
+ public static $notification_option = array(
+ 'lang' => 'NOTIFICATION_TYPE_BOOKMARK',
+ 'group' => 'NOTIFICATION_GROUP_POSTING',
+ );
/**
* Find the users who want to receive notifications
@@ -81,7 +83,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND " . $this->db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
@@ -104,7 +106,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
$update_notifications = array();
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
AND unread = 1
AND is_enabled = 1';
@@ -114,7 +116,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(self::get_item_type(), $row);
+ $notification = $this->notification_manager->get_item_type_class(get_class($this), $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 d4e659c5f3..3b5719c3fe 100644
--- a/phpBB/includes/notification/type/disapprove_post.php
+++ b/phpBB/includes/notification/type/disapprove_post.php
@@ -43,15 +43,6 @@ class phpbb_notification_type_disapprove_post extends phpbb_notification_type_ap
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'disapprove_post';
- }
-
- /**
* Get the HTML formatted title of this notification
*
* @return string
diff --git a/phpBB/includes/notification/type/disapprove_topic.php b/phpBB/includes/notification/type/disapprove_topic.php
index 4bbf458d4a..7369fd64bd 100644
--- a/phpBB/includes/notification/type/disapprove_topic.php
+++ b/phpBB/includes/notification/type/disapprove_topic.php
@@ -43,15 +43,6 @@ class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_a
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'disapprove_topic';
- }
-
- /**
* Get the HTML formatted title of this notification
*
* @return string
diff --git a/phpBB/includes/notification/type/interface.php b/phpBB/includes/notification/type/interface.php
index 25dc24d922..9d9965261e 100644
--- a/phpBB/includes/notification/type/interface.php
+++ b/phpBB/includes/notification/type/interface.php
@@ -29,12 +29,6 @@ interface phpbb_notification_type_interface
public function set_initial_data($data);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type();
-
- /**
* Get the id of the item
*
* @param array $type_data The type specific data
diff --git a/phpBB/includes/notification/type/pm.php b/phpBB/includes/notification/type/pm.php
index 721af4bce5..adb03ab1a3 100644
--- a/phpBB/includes/notification/type/pm.php
+++ b/phpBB/includes/notification/type/pm.php
@@ -24,13 +24,14 @@ if (!defined('IN_PHPBB'))
class phpbb_notification_type_pm extends phpbb_notification_type_base
{
/**
- * Get the type of notification this is
- * phpbb_notification_type_
+ * Notification option data (for outputting to the user)
+ *
+ * @var bool|array False if the service should use it's default data
+ * Array of data (including keys 'id', 'lang', and 'group')
*/
- public static function get_item_type()
- {
- return 'pm';
- }
+ public static $notification_option = array(
+ 'lang' => 'NOTIFICATION_TYPE_PM',
+ );
/**
* Get the id of the
@@ -77,7 +78,7 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND " . $this->db->sql_in_set('user_id', array_keys($pm['recipients'])) . '
AND user_id <> ' . $pm['from_user_id'];
$result = $this->db->sql_query($sql);
diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php
index 9bb06e3620..9317669e57 100644
--- a/phpBB/includes/notification/type/post.php
+++ b/phpBB/includes/notification/type/post.php
@@ -37,19 +37,11 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
* Array of data (including keys 'id', 'lang', and 'group')
*/
public static $notification_option = array(
+ 'lang' => 'NOTIFICATION_TYPE_POST',
'group' => 'NOTIFICATION_GROUP_POSTING',
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'post';
- }
-
- /**
* Get the id of the item
*
* @param array $post The data from the post
@@ -112,7 +104,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND " . $this->db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
@@ -135,7 +127,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
$update_notifications = array();
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
AND unread = 1
AND is_enabled = 1';
@@ -145,7 +137,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(self::get_item_type(), $row);
+ $notification = $this->notification_manager->get_item_type_class(get_class($this), $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 0bf8685660..5771b60df7 100644
--- a/phpBB/includes/notification/type/post_in_queue.php
+++ b/phpBB/includes/notification/type/post_in_queue.php
@@ -50,15 +50,6 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
protected $permission = 'm_approve';
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'post_in_queue';
- }
-
- /**
* Is available
*/
public function is_available()
diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php
index f700821353..e4b40e0aec 100644
--- a/phpBB/includes/notification/type/quote.php
+++ b/phpBB/includes/notification/type/quote.php
@@ -38,13 +38,15 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
protected $language_key = 'NOTIFICATION_QUOTE';
/**
- * Get the type of notification this is
- * phpbb_notification_type_
+ * Notification option data (for outputting to the user)
+ *
+ * @var bool|array False if the service should use it's default data
+ * Array of data (including keys 'id', 'lang', and 'group')
*/
- public static function get_item_type()
- {
- return 'quote';
- }
+ public static $notification_option = array(
+ 'lang' => 'NOTIFICATION_TYPE_QUOTE',
+ 'group' => 'NOTIFICATION_GROUP_POSTING',
+ );
/**
* Find the users who want to receive notifications
@@ -100,7 +102,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND " . $this->db->sql_in_set('user_id', $auth_read[$post['forum_id']]['f_read']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
@@ -123,7 +125,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
$update_notifications = array();
$sql = 'SELECT *
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
AND unread = 1
AND is_enabled = 1';
@@ -133,7 +135,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(self::get_item_type(), $row);
+ $notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
WHERE notification_id = ' . $row['notification_id'];
@@ -154,7 +156,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
$old_notifications = array();
$sql = 'SELECT user_id
FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND item_id = " . self::get_item_id($post) . '
AND is_enabled = 1';
$result = $this->db->sql_query($sql);
@@ -178,13 +180,13 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
}
// Add the necessary notifications
- $this->notification_manager->add_notifications_for_users(self::get_item_type(), $post, $add_notifications);
+ $this->notification_manager->add_notifications_for_users(get_class($this), $post, $add_notifications);
// Remove the necessary notifications
if (!empty($remove_notifications))
{
$sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
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 b18493ff29..42631ca97a 100644
--- a/phpBB/includes/notification/type/report_pm.php
+++ b/phpBB/includes/notification/type/report_pm.php
@@ -50,15 +50,6 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'report_pm';
- }
-
- /**
* Get the id of the parent
*
* @param array $pm The data from the pm
diff --git a/phpBB/includes/notification/type/report_pm_closed.php b/phpBB/includes/notification/type/report_pm_closed.php
index 0bde7dfe48..a7dd341d1d 100644
--- a/phpBB/includes/notification/type/report_pm_closed.php
+++ b/phpBB/includes/notification/type/report_pm_closed.php
@@ -43,15 +43,6 @@ class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_p
}
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'report_pm_closed';
- }
-
- /**
* Find the users who want to receive notifications
*
* @param array $pm Data from
diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/includes/notification/type/report_post.php
index f1ee073a4d..2a493d7f2a 100644
--- a/phpBB/includes/notification/type/report_post.php
+++ b/phpBB/includes/notification/type/report_post.php
@@ -50,15 +50,6 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'report_post';
- }
-
- /**
* Find the users who want to receive notifications
*
* @param array $post Data from the post
diff --git a/phpBB/includes/notification/type/report_post_closed.php b/phpBB/includes/notification/type/report_post_closed.php
index 52bdadc547..38be1d9fee 100644
--- a/phpBB/includes/notification/type/report_post_closed.php
+++ b/phpBB/includes/notification/type/report_post_closed.php
@@ -43,15 +43,6 @@ class phpbb_notification_type_report_post_closed extends phpbb_notification_type
}
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'report_post_closed';
- }
-
- /**
* Find the users who want to receive notifications
*
* @param array $post Data from
diff --git a/phpBB/includes/notification/type/topic.php b/phpBB/includes/notification/type/topic.php
index 4737031e87..db1d4028f0 100644
--- a/phpBB/includes/notification/type/topic.php
+++ b/phpBB/includes/notification/type/topic.php
@@ -37,19 +37,11 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base
* Array of data (including keys 'id', 'lang', and 'group')
*/
public static $notification_option = array(
+ 'lang' => 'NOTIFICATION_TYPE_TOPIC',
'group' => 'NOTIFICATION_GROUP_POSTING',
);
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'topic';
- }
-
- /**
* Get the id of the item
*
* @param array $post The data from the post
@@ -116,7 +108,7 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base
$sql = 'SELECT *
FROM ' . USER_NOTIFICATIONS_TABLE . "
- WHERE item_type = '" . self::get_item_type() . "'
+ WHERE item_type = '" . get_class($this) . "'
AND " . $this->db->sql_in_set('user_id', $auth_read[$topic['forum_id']]['f_read']);
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
diff --git a/phpBB/includes/notification/type/topic_in_queue.php b/phpBB/includes/notification/type/topic_in_queue.php
index ee565ab6e6..91e12fcfbf 100644
--- a/phpBB/includes/notification/type/topic_in_queue.php
+++ b/phpBB/includes/notification/type/topic_in_queue.php
@@ -53,15 +53,6 @@ class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_top
}
/**
- * Get the type of notification this is
- * phpbb_notification_type_
- */
- public static function get_item_type()
- {
- return 'topic_in_queue';
- }
-
- /**
* Find the users who want to receive notifications
*
* @param array $topic Data from the topic