aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/develop/create_schema_files.php8
-rw-r--r--phpBB/includes/functions.php33
-rw-r--r--phpBB/includes/functions_admin.php14
-rw-r--r--phpBB/includes/functions_posting.php30
-rw-r--r--phpBB/includes/functions_privmsgs.php14
-rw-r--r--phpBB/includes/mcp/mcp_pm_reports.php2
-rw-r--r--phpBB/includes/mcp/mcp_queue.php28
-rw-r--r--phpBB/includes/mcp/mcp_reports.php10
-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
-rw-r--r--phpBB/includes/ucp/ucp_notifications.php4
-rw-r--r--phpBB/install/database_update.php8
-rw-r--r--phpBB/install/schemas/firebird_schema.sql10
-rw-r--r--phpBB/install/schemas/mssql_schema.sql10
-rw-r--r--phpBB/install/schemas/mysql_40_schema.sql10
-rw-r--r--phpBB/install/schemas/mysql_41_schema.sql10
-rw-r--r--phpBB/install/schemas/oracle_schema.sql10
-rw-r--r--phpBB/install/schemas/postgres_schema.sql10
-rw-r--r--phpBB/install/schemas/sqlite_schema.sql10
-rw-r--r--phpBB/language/en/ucp.php4
-rw-r--r--phpBB/report.php4
-rw-r--r--tests/notification/ext/test/notification/type/test.php30
-rw-r--r--tests/notification/notification.php285
39 files changed, 402 insertions, 533 deletions
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index aa0f13ccb3..b0cffd167f 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -1298,12 +1298,12 @@ function get_schema_struct()
$schema_data['phpbb_notifications'] = array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),
- 'item_type' => array('VCHAR:25', ''),
+ 'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'unread' => array('BOOL', 1),
- 'is_enabled' => array('BOOL', 0),
+ 'is_enabled' => array('BOOL', 1),
'time' => array('TIMESTAMP', 1),
'data' => array('TEXT_UNI', ''),
),
@@ -1777,10 +1777,10 @@ function get_schema_struct()
$schema_data['phpbb_user_notifications'] = array(
'COLUMNS' => array(
- 'item_type' => array('VCHAR:25', ''),
+ 'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
- 'method' => array('VCHAR:25', ''),
+ 'method' => array('VCHAR:255', ''),
),
'PRIMARY_KEY' => array(
'item_type',
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 2827dae1a8..3488a3003b 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1330,7 +1330,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
// Mark all forums read (index page)
// Mark all topic notifications read for this user
- $phpbb_notifications->mark_notifications_read(array('topic', 'quote', 'bookmark', 'post', 'approve_topic', 'approve_post'), false, $user->data['user_id'], $post_time);
+ $phpbb_notifications->mark_notifications_read(array(
+ 'phpbb_notification_type_topic',
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ 'phpbb_notification_type_approve_topic',
+ 'phpbb_notification_type_approve_post',
+ ), false, $user->data['user_id'], $post_time);
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
@@ -1386,7 +1393,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
$forum_id = array($forum_id);
}
- $phpbb_notifications->mark_notifications_read_by_parent(array('topic', 'approve_topic'), $forum_id, $user->data['user_id'], $post_time);
+ $phpbb_notifications->mark_notifications_read_by_parent(array(
+ 'phpbb_notification_type_topic',
+ 'phpbb_notification_type_approve_topic',
+ ), $forum_id, $user->data['user_id'], $post_time);
// Mark all post/quote notifications read for this user in this forum
$topic_ids = array();
@@ -1400,7 +1410,12 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
}
$db->sql_freeresult($result);
- $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_ids, $user->data['user_id'], $post_time);
+ $phpbb_notifications->mark_notifications_read_by_parent(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ 'phpbb_notification_type_approve_post',
+ ), $topic_ids, $user->data['user_id'], $post_time);
// Add 0 to forums array to mark global announcements correctly
// $forum_id[] = 0;
@@ -1500,8 +1515,16 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $
}
// Mark post notifications read for this user in this topic
- $phpbb_notifications->mark_notifications_read(array('topic', 'approve_topic'), $topic_id, $user->data['user_id'], $post_time);
- $phpbb_notifications->mark_notifications_read_by_parent(array('quote', 'bookmark', 'post', 'approve_post'), $topic_id, $user->data['user_id'], $post_time);
+ $phpbb_notifications->mark_notifications_read(array(
+ 'phpbb_notification_type_topic',
+ 'phpbb_notification_type_approve_topic',
+ ), $topic_id, $user->data['user_id'], $post_time);
+ $phpbb_notifications->mark_notifications_read_by_parent(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ 'phpbb_notification_type_approve_post',
+ ), $topic_id, $user->data['user_id'], $post_time);
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 893c7a247d..fdae1905a0 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -716,7 +716,11 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
set_config_count('num_topics', $approved_topics * (-1), true);
}
- $phpbb_notifications->delete_notifications(array('topic', 'approve_topic', 'topic_in_queue'), $topic_ids);
+ $phpbb_notifications->delete_notifications(array(
+ 'phpbb_notification_type_topic',
+ 'phpbb_notification_type_approve_topic',
+ 'phpbb_notification_type_topic_in_queue',
+ ), $topic_ids);
return $return;
}
@@ -896,7 +900,13 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false);
}
- $phpbb_notifications->delete_notifications(array('quote', 'bookmark', 'post', 'approve_post', 'post_in_queue'), $post_ids);
+ $phpbb_notifications->delete_notifications(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ 'phpbb_notification_type_approve_post',
+ 'phpbb_notification_type_post_in_queue',
+ ), $post_ids);
return sizeof($post_ids);
}
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 4deffe653b..02c31eb6cc 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -2234,19 +2234,31 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
switch ($mode)
{
case 'post':
- $phpbb_notifications->add_notifications(array('quote', 'topic'), $notification_data);
+ $phpbb_notifications->add_notifications(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_topic',
+ ), $notification_data);
break;
case 'reply':
case 'quote':
- $phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), $notification_data);
+ $phpbb_notifications->add_notifications(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ ), $notification_data);
break;
case 'edit_topic':
case 'edit_first_post':
case 'edit':
case 'edit_last_post':
- $phpbb_notifications->update_notifications(array('quote', 'bookmark', 'topic', 'post'), $notification_data);
+ $phpbb_notifications->update_notifications(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_topic',
+ 'phpbb_notification_type_post',
+ ), $notification_data);
break;
}
}
@@ -2255,20 +2267,24 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
switch ($mode)
{
case 'post':
- $phpbb_notifications->add_notifications(array('topic_in_queue'), $notification_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_topic_in_queue', $notification_data);
break;
case 'reply':
case 'quote':
- $phpbb_notifications->add_notifications(array('post_in_queue'), $notification_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_post_in_queue', $notification_data);
break;
case 'edit_topic':
case 'edit_first_post':
case 'edit':
case 'edit_last_post':
- $phpbb_notifications->delete_notifications('topic', $data['topic_id']);
- $phpbb_notifications->delete_notifications(array('quote', 'bookmark', 'post'), $data['post_id']);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_topic', $data['topic_id']);
+ $phpbb_notifications->delete_notifications(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ ), $data['post_id']);
break;
}
}
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 4638091601..ec671e4f41 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -878,7 +878,7 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id)
global $db, $user, $phpbb_notifications;
- $phpbb_notifications->mark_notifications_read('pm', $msg_id, $user_id);
+ $phpbb_notifications->mark_notifications_read('phpbb_notification_type_pm', $msg_id, $user_id);
$sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . "
SET pm_unread = 0
@@ -1096,7 +1096,7 @@ function delete_pm($user_id, $msg_ids, $folder_id)
$user->data['user_unread_privmsg'] -= $num_unread;
}
- $phpbb_notifications->delete_notifications('pm', array_keys($delete_rows));
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', array_keys($delete_rows));
// Now we have to check which messages we can delete completely
$sql = 'SELECT msg_id
@@ -1260,7 +1260,7 @@ function phpbb_delete_user_pms($user_id)
AND ' . $db->sql_in_set('msg_id', $delivered_msg);
$db->sql_query($sql);
- $phpbb_notifications->delete_notifications('pm', $delivered_msg);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', $delivered_msg);
}
if (!empty($undelivered_msg))
@@ -1273,7 +1273,7 @@ function phpbb_delete_user_pms($user_id)
WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
$db->sql_query($sql);
- $phpbb_notifications->delete_notifications('pm', $undelivered_msg);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', $undelivered_msg);
}
}
@@ -1317,7 +1317,7 @@ function phpbb_delete_user_pms($user_id)
WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
$db->sql_query($sql);
- $phpbb_notifications->delete_notifications('pm', $delete_ids);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', $delete_ids);
}
}
@@ -1862,11 +1862,11 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
if ($mode == 'edit')
{
- $phpbb_notifications->update_notifications('pm', $pm_data);
+ $phpbb_notifications->update_notifications('phpbb_notification_type_pm', $pm_data);
}
else
{
- $phpbb_notifications->add_notifications('pm', $pm_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_pm', $pm_data);
}
return $data['msg_id'];
diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php
index 001edfd8db..572969af4a 100644
--- a/phpBB/includes/mcp/mcp_pm_reports.php
+++ b/phpBB/includes/mcp/mcp_pm_reports.php
@@ -90,7 +90,7 @@ class mcp_pm_reports
trigger_error('NO_REPORT');
}
- $phpbb_notifications->mark_notifications_read_by_parent('report_pm', $report_id, $user->data['user_id']);
+ $phpbb_notifications->mark_notifications_read_by_parent('phpbb_notification_type_report_pm', $report_id, $user->data['user_id']);
$pm_id = $report['pm_id'];
$report_id = $report['report_id'];
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 72f1c00c72..f13ce914bf 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -86,7 +86,7 @@ class mcp_queue
{
$post_id = (int) $topic_info[$topic_id]['topic_first_post_id'];
- $phpbb_notifications->mark_notifications_read('topic_in_queue', $topic_id, $user->data['user_id']);
+ $phpbb_notifications->mark_notifications_read('phpbb_notification_type_topic_in_queue', $topic_id, $user->data['user_id']);
}
else
{
@@ -94,7 +94,7 @@ class mcp_queue
}
}
- $phpbb_notifications->mark_notifications_read('post_in_queue', $post_id, $user->data['user_id']);
+ $phpbb_notifications->mark_notifications_read('phpbb_notification_type_post_in_queue', $post_id, $user->data['user_id']);
$post_info = get_post_data(array($post_id), 'm_approve', true);
@@ -610,24 +610,28 @@ function approve_post($post_id_list, $id, $mode)
{
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
{
- $phpbb_notifications->delete_notifications(array('topic_in_queue'), $post_data['topic_id']);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_topic_in_queue', $post_data['topic_id']);
- $phpbb_notifications->add_notifications('topic', $post_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_topic', $post_data);
if ($notify_poster)
{
- $phpbb_notifications->add_notifications('approve_topic', $post_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_approve_topic', $post_data);
}
}
else
{
- $phpbb_notifications->delete_notifications(array('post_in_queue'), $post_id);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_post_in_queue', $post_id);
- $phpbb_notifications->add_notifications(array('quote', 'bookmark', 'post'), $post_data);
+ $phpbb_notifications->add_notifications(array(
+ 'phpbb_notification_type_quote',
+ 'phpbb_notification_type_bookmark',
+ 'phpbb_notification_type_post',
+ ), $post_data);
if ($notify_poster)
{
- $phpbb_notifications->add_notifications('approve_post', $post_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_approve_post', $post_data);
}
}
}
@@ -855,11 +859,11 @@ function disapprove_post($post_id_list, $id, $mode)
{
if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id'])
{
- $phpbb_notifications->delete_notifications(array('topic_in_queue'), $post_data['topic_id']);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_topic_in_queue', $post_data['topic_id']);
}
else
{
- $phpbb_notifications->delete_notifications(array('post_in_queue'), $post_id);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_post_in_queue', $post_id);
}
}
@@ -905,14 +909,14 @@ function disapprove_post($post_id_list, $id, $mode)
{
if ($notify_poster)
{
- $phpbb_notifications->add_notifications('disapprove_topic', $post_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_disapprove_topic', $post_data);
}
}
else
{
if ($notify_poster)
{
- $phpbb_notifications->add_notifications('disapprove_post', $post_data);
+ $phpbb_notifications->add_notifications('phpbb_notification_type_disapprove_post', $post_data);
}
}
}
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index f6121e7e03..5bda6f2de7 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -88,7 +88,7 @@ class mcp_reports
trigger_error('NO_REPORT');
}
- $phpbb_notifications->mark_notifications_read('report_post', $post_id, $user->data['user_id']);
+ $phpbb_notifications->mark_notifications_read('phpbb_notification_type_report_post', $post_id, $user->data['user_id']);
if (!$report_id && $report['report_closed'])
{
@@ -647,20 +647,20 @@ function close_report($report_id_list, $mode, $action, $pm = false)
if ($pm)
{
- $phpbb_notifications->add_notifications('report_pm_closed', array_merge($post_info[$post_id], array(
+ $phpbb_notifications->add_notifications('phpbb_notification_type_report_pm_closed', array_merge($post_info[$post_id], array(
'reporter' => $reporter['user_id'],
'closer_id' => $user->data['user_id'],
'from_user_id' => $post_info[$post_id]['author_id'],
)));
- $phpbb_notifications->delete_notifications('report_pm', $post_id);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_report_pm', $post_id);
}
else
{
- $phpbb_notifications->add_notifications('report_post_closed', array_merge($post_info[$post_id], array(
+ $phpbb_notifications->add_notifications('phpbb_notification_type_report_post_closed', array_merge($post_info[$post_id], array(
'reporter' => $reporter['user_id'],
'closer_id' => $user->data['user_id'],
)));
- $phpbb_notifications->delete_notifications('report_post', $post_id);
+ $phpbb_notifications->delete_notifications('phpbb_notification_type_report_post', $post_id);
}
}
}
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
diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php
index aeace13968..8749c88ba1 100644
--- a/phpBB/includes/ucp/ucp_notifications.php
+++ b/phpBB/includes/ucp/ucp_notifications.php
@@ -192,7 +192,7 @@ class ucp_notifications
$template->assign_block_vars($block . '.notification_methods', array(
'METHOD' => $method,
- 'NAME' => $user->lang('NOTIFICATION_METHOD_' . strtoupper($method)),
+ 'NAME' => $user->lang(strtoupper($method)),
'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) ? true : false,
));
@@ -218,7 +218,7 @@ class ucp_notifications
$template->assign_block_vars($block, array(
'METHOD' => $method,
- 'NAME' => $user->lang('NOTIFICATION_METHOD_' . strtoupper($method)),
+ 'NAME' => $user->lang(strtoupper($method)),
));
}
}
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index eceb0c8fc3..c24877fd74 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -1128,12 +1128,12 @@ function database_update_info()
NOTIFICATIONS_TABLE => array(
'COLUMNS' => array(
'notification_id' => array('UINT', NULL, 'auto_increment'),
- 'item_type' => array('VCHAR:25', ''),
+ 'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'item_parent_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'unread' => array('BOOL', 1),
- 'is_enabled' => array('BOOL', 0),
+ 'is_enabled' => array('BOOL', 1),
'time' => array('TIMESTAMP', 1),
'data' => array('TEXT_UNI', ''),
),
@@ -1150,10 +1150,10 @@ function database_update_info()
),
USER_NOTIFICATIONS_TABLE => array(
'COLUMNS' => array(
- 'item_type' => array('VCHAR:25', ''),
+ 'item_type' => array('VCHAR:255', ''),
'item_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
- 'method' => array('VCHAR:25', ''),
+ 'method' => array('VCHAR:255', ''),
),
'PRIMARY_KEY' => array(
'item_type',
diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql
index 1e4ae2e132..5e13f98f25 100644
--- a/phpBB/install/schemas/firebird_schema.sql
+++ b/phpBB/install/schemas/firebird_schema.sql
@@ -621,12 +621,12 @@ END;;
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id INTEGER NOT NULL,
- item_type VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL,
+ item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
item_id INTEGER DEFAULT 0 NOT NULL,
item_parent_id INTEGER DEFAULT 0 NOT NULL,
user_id INTEGER DEFAULT 0 NOT NULL,
unread INTEGER DEFAULT 1 NOT NULL,
- is_disabled INTEGER DEFAULT 0 NOT NULL,
+ is_enabled INTEGER DEFAULT 1 NOT NULL,
time INTEGER DEFAULT 1 NOT NULL,
data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL
);;
@@ -639,7 +639,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id)
CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);;
CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);;
CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);;
-CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications(is_disabled);;
+CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications(is_enabled);;
CREATE GENERATOR phpbb_notifications_gen;;
SET GENERATOR phpbb_notifications_gen TO 0;;
@@ -1237,10 +1237,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status)
# Table: 'phpbb_user_notifications'
CREATE TABLE phpbb_user_notifications (
- item_type VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL,
+ item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL,
item_id INTEGER DEFAULT 0 NOT NULL,
user_id INTEGER DEFAULT 0 NOT NULL,
- method VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL
+ method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL
);;
ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);;
diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql
index 5a397743c4..d463afb17c 100644
--- a/phpBB/install/schemas/mssql_schema.sql
+++ b/phpBB/install/schemas/mssql_schema.sql
@@ -756,12 +756,12 @@ GO
*/
CREATE TABLE [phpbb_notifications] (
[notification_id] [int] IDENTITY (1, 1) NOT NULL ,
- [item_type] [varchar] (25) DEFAULT ('') NOT NULL ,
+ [item_type] [varchar] (255) DEFAULT ('') NOT NULL ,
[item_id] [int] DEFAULT (0) NOT NULL ,
[item_parent_id] [int] DEFAULT (0) NOT NULL ,
[user_id] [int] DEFAULT (0) NOT NULL ,
[unread] [int] DEFAULT (1) NOT NULL ,
- [is_disabled] [int] DEFAULT (0) NOT NULL ,
+ [is_enabled] [int] DEFAULT (1) NOT NULL ,
[time] [int] DEFAULT (1) NOT NULL ,
[data] [varchar] (4000) DEFAULT ('') NOT NULL
) ON [PRIMARY]
@@ -792,7 +792,7 @@ GO
CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY]
GO
-CREATE INDEX [is_disabled] ON [phpbb_notifications]([is_disabled]) ON [PRIMARY]
+CREATE INDEX [is_enabled] ON [phpbb_notifications]([is_enabled]) ON [PRIMARY]
GO
@@ -1523,10 +1523,10 @@ GO
Table: 'phpbb_user_notifications'
*/
CREATE TABLE [phpbb_user_notifications] (
- [item_type] [varchar] (25) DEFAULT ('') NOT NULL ,
+ [item_type] [varchar] (255) DEFAULT ('') NOT NULL ,
[item_id] [int] DEFAULT (0) NOT NULL ,
[user_id] [int] DEFAULT (0) NOT NULL ,
- [method] [varchar] (25) DEFAULT ('') NOT NULL
+ [method] [varchar] (255) DEFAULT ('') NOT NULL
) ON [PRIMARY]
GO
diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql
index fd7f9a6025..9272e18735 100644
--- a/phpBB/install/schemas/mysql_40_schema.sql
+++ b/phpBB/install/schemas/mysql_40_schema.sql
@@ -433,12 +433,12 @@ CREATE TABLE phpbb_modules (
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id mediumint(8) UNSIGNED NOT NULL auto_increment,
- item_type varbinary(25) DEFAULT '' NOT NULL,
+ item_type varbinary(255) DEFAULT '' NOT NULL,
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
- is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
time int(11) UNSIGNED DEFAULT '1' NOT NULL,
data blob NOT NULL,
PRIMARY KEY (notification_id),
@@ -448,7 +448,7 @@ CREATE TABLE phpbb_notifications (
KEY user_id (user_id),
KEY time (time),
KEY unread (unread),
- KEY is_disabled (is_disabled)
+ KEY is_enabled (is_enabled)
);
@@ -873,10 +873,10 @@ CREATE TABLE phpbb_topics_watch (
# Table: 'phpbb_user_notifications'
CREATE TABLE phpbb_user_notifications (
- item_type varbinary(25) DEFAULT '' NOT NULL,
+ item_type varbinary(255) DEFAULT '' NOT NULL,
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
- method varbinary(25) DEFAULT '' NOT NULL,
+ method varbinary(255) DEFAULT '' NOT NULL,
PRIMARY KEY (item_type, item_id, user_id, method),
KEY it (item_type),
KEY uid (user_id)
diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql
index 8700b46c91..a73fda41f5 100644
--- a/phpBB/install/schemas/mysql_41_schema.sql
+++ b/phpBB/install/schemas/mysql_41_schema.sql
@@ -433,12 +433,12 @@ CREATE TABLE phpbb_modules (
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id mediumint(8) UNSIGNED NOT NULL auto_increment,
- item_type varchar(25) DEFAULT '' NOT NULL,
+ item_type varchar(255) DEFAULT '' NOT NULL,
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
- is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL,
time int(11) UNSIGNED DEFAULT '1' NOT NULL,
data text NOT NULL,
PRIMARY KEY (notification_id),
@@ -448,7 +448,7 @@ CREATE TABLE phpbb_notifications (
KEY user_id (user_id),
KEY time (time),
KEY unread (unread),
- KEY is_disabled (is_disabled)
+ KEY is_enabled (is_enabled)
) CHARACTER SET `utf8` COLLATE `utf8_bin`;
@@ -873,10 +873,10 @@ CREATE TABLE phpbb_topics_watch (
# Table: 'phpbb_user_notifications'
CREATE TABLE phpbb_user_notifications (
- item_type varchar(25) DEFAULT '' NOT NULL,
+ item_type varchar(255) DEFAULT '' NOT NULL,
item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
- method varchar(25) DEFAULT '' NOT NULL,
+ method varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (item_type, item_id, user_id, method),
KEY it (item_type),
KEY uid (user_id)
diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql
index f2f22e2f5e..02be9566dc 100644
--- a/phpBB/install/schemas/oracle_schema.sql
+++ b/phpBB/install/schemas/oracle_schema.sql
@@ -845,12 +845,12 @@ END;
*/
CREATE TABLE phpbb_notifications (
notification_id number(8) NOT NULL,
- item_type varchar2(25) DEFAULT '' ,
+ item_type varchar2(255) DEFAULT '' ,
item_id number(8) DEFAULT '0' NOT NULL,
item_parent_id number(8) DEFAULT '0' NOT NULL,
user_id number(8) DEFAULT '0' NOT NULL,
unread number(1) DEFAULT '1' NOT NULL,
- is_disabled number(1) DEFAULT '0' NOT NULL,
+ is_enabled number(1) DEFAULT '1' NOT NULL,
time number(11) DEFAULT '1' NOT NULL,
data clob DEFAULT '' ,
CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id)
@@ -869,7 +869,7 @@ CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time)
/
CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread)
/
-CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled)
+CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled)
/
CREATE SEQUENCE phpbb_notifications_seq
@@ -1641,10 +1641,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status
Table: 'phpbb_user_notifications'
*/
CREATE TABLE phpbb_user_notifications (
- item_type varchar2(25) DEFAULT '' ,
+ item_type varchar2(255) DEFAULT '' ,
item_id number(8) DEFAULT '0' NOT NULL,
user_id number(8) DEFAULT '0' NOT NULL,
- method varchar2(25) DEFAULT '' ,
+ method varchar2(255) DEFAULT '' ,
CONSTRAINT pk_phpbb_user_notifications PRIMARY KEY (item_type, item_id, user_id, method)
)
/
diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql
index ffba657475..784e3c8c68 100644
--- a/phpBB/install/schemas/postgres_schema.sql
+++ b/phpBB/install/schemas/postgres_schema.sql
@@ -603,12 +603,12 @@ CREATE SEQUENCE phpbb_notifications_seq;
CREATE TABLE phpbb_notifications (
notification_id INT4 DEFAULT nextval('phpbb_notifications_seq'),
- item_type varchar(25) DEFAULT '' NOT NULL,
+ item_type varchar(255) DEFAULT '' NOT NULL,
item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0),
item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0),
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0),
- is_disabled INT2 DEFAULT '0' NOT NULL CHECK (is_disabled >= 0),
+ is_enabled INT2 DEFAULT '1' NOT NULL CHECK (is_enabled >= 0),
time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0),
data varchar(4000) DEFAULT '' NOT NULL,
PRIMARY KEY (notification_id)
@@ -620,7 +620,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id
CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id);
CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time);
CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread);
-CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled);
+CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled);
/*
Table: 'phpbb_poll_options'
@@ -1123,10 +1123,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status
Table: 'phpbb_user_notifications'
*/
CREATE TABLE phpbb_user_notifications (
- item_type varchar(25) DEFAULT '' NOT NULL,
+ item_type varchar(255) DEFAULT '' NOT NULL,
item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0),
user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0),
- method varchar(25) DEFAULT '' NOT NULL,
+ method varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (item_type, item_id, user_id, method)
);
diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql
index b63569ce3e..2fdac43947 100644
--- a/phpBB/install/schemas/sqlite_schema.sql
+++ b/phpBB/install/schemas/sqlite_schema.sql
@@ -420,12 +420,12 @@ CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id
# Table: 'phpbb_notifications'
CREATE TABLE phpbb_notifications (
notification_id INTEGER PRIMARY KEY NOT NULL ,
- item_type varchar(25) NOT NULL DEFAULT '',
+ item_type varchar(255) NOT NULL DEFAULT '',
item_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
unread INTEGER UNSIGNED NOT NULL DEFAULT '1',
- is_disabled INTEGER UNSIGNED NOT NULL DEFAULT '0',
+ is_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1',
time INTEGER UNSIGNED NOT NULL DEFAULT '1',
data text(65535) NOT NULL DEFAULT ''
);
@@ -436,7 +436,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id
CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id);
CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time);
CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread);
-CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled);
+CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled);
# Table: 'phpbb_poll_options'
CREATE TABLE phpbb_poll_options (
@@ -846,10 +846,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status
# Table: 'phpbb_user_notifications'
CREATE TABLE phpbb_user_notifications (
- item_type varchar(25) NOT NULL DEFAULT '',
+ item_type varchar(255) NOT NULL DEFAULT '',
item_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
user_id INTEGER UNSIGNED NOT NULL DEFAULT '0',
- method varchar(25) NOT NULL DEFAULT '',
+ method varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (item_type, item_id, user_id, method)
);
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index 7c3960204a..5b1e7add02 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -295,8 +295,6 @@ $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',
@@ -376,6 +374,8 @@ $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.',
diff --git a/phpBB/report.php b/phpBB/report.php
index 07b9711ae1..63e6afcf66 100644
--- a/phpBB/report.php
+++ b/phpBB/report.php
@@ -185,7 +185,7 @@ if ($submit && $reason_id)
$lang_return = $user->lang['RETURN_TOPIC'];
$lang_success = $user->lang['POST_REPORTED_SUCCESS'];
- $phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data, array(
+ $phpbb_notifications->add_notifications('phpbb_notification_type_report_post', array_merge($report_data, $row, $forum_data, array(
'report_text' => $report_text,
)));
}
@@ -215,7 +215,7 @@ if ($submit && $reason_id)
$lang_return = $user->lang['RETURN_PM'];
$lang_success = $user->lang['PM_REPORTED_SUCCESS'];
- $phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array(
+ $phpbb_notifications->add_notifications('phpbb_notification_type_report_pm', array_merge($report_data, $row, array(
'report_text' => $report_text,
'from_user_id' => $report_data['author_id'],
'report_id' => $report_id,
diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php
index f3aa8ba6f3..e76bdb5e0c 100644
--- a/tests/notification/ext/test/notification/type/test.php
+++ b/tests/notification/ext/test/notification/type/test.php
@@ -17,13 +17,6 @@ if (!defined('IN_PHPBB'))
class phpbb_ext_test_notification_type_test extends phpbb_notification_type_base
{
- public $email_template = 'topic_notify';
-
- public static function get_item_type()
- {
- return 'ext_test-test';
- }
-
public static function get_item_id($post)
{
return (int) $post['post_id'];
@@ -39,11 +32,25 @@ class phpbb_ext_test_notification_type_test extends phpbb_notification_type_base
return $this->_find_users_for_notification(0, $options);
}
- public function create_insert_array($post)
+ public function create_insert_array($post, $pre_create_data = array())
{
$this->time = $post['post_time'];
- return parent::create_insert_array($post);
+ return parent::create_insert_array($post, $pre_create_data);
+ }
+
+ public function create_update_array($type_data)
+ {
+ $data = $this->create_insert_array($type_data);
+
+ // Unset data unique to each row
+ unset(
+ $data['notification_id'],
+ $data['unread'],
+ $data['user_id']
+ );
+
+ return $data;
}
public function get_title()
@@ -61,6 +68,11 @@ class phpbb_ext_test_notification_type_test extends phpbb_notification_type_base
return '';
}
+ public function get_email_template()
+ {
+ return false;
+ }
+
public function get_email_template_variables()
{
return array();
diff --git a/tests/notification/notification.php b/tests/notification/notification.php
index 13fc99bed3..0bb69dc2c5 100644
--- a/tests/notification/notification.php
+++ b/tests/notification/notification.php
@@ -95,13 +95,20 @@ class phpbb_notification_test extends phpbb_database_test_case
public function test_get_subscription_types()
{
- $this->assertArrayHasKey('ext_test-test', $this->notifications->get_subscription_types());
- $this->assertArrayHasKey('moderation_queue', $this->notifications->get_subscription_types());
- $this->assertArrayHasKey('bookmark', $this->notifications->get_subscription_types());
- $this->assertArrayHasKey('pm', $this->notifications->get_subscription_types());
- $this->assertArrayHasKey('post', $this->notifications->get_subscription_types());
- $this->assertArrayHasKey('quote', $this->notifications->get_subscription_types());
- $this->assertArrayHasKey('topic', $this->notifications->get_subscription_types());
+ $subscription_types = $this->notifications->get_subscription_types();
+
+ $this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types);
+ $this->assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types);
+
+ $this->assertArrayHasKey('phpbb_notification_type_bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ $this->assertArrayHasKey('phpbb_notification_type_post', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ $this->assertArrayHasKey('phpbb_notification_type_quote', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+ $this->assertArrayHasKey('phpbb_notification_type_topic', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+
+ $this->assertArrayHasKey('moderation_queue', $subscription_types['NOTIFICATION_GROUP_POSTING']);
+
+ $this->assertArrayHasKey('phpbb_notification_type_pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
+ $this->assertArrayHasKey('phpbb_ext_test_notification_type_test', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']);
//get_subscription_types
//get_subscription_methods
@@ -109,23 +116,23 @@ class phpbb_notification_test extends phpbb_database_test_case
public function test_subscriptions()
{
- $this->notifications->add_subscription('post', 0, '');
- $this->notifications->add_subscription('post', 0, '', 1);
- $this->notifications->add_subscription('quote', 0, '', 1);
-
- $this->notifications->add_subscription('post', 0, '', 2);
- $this->notifications->add_subscription('post', 0, 'email', 2);
- $this->notifications->add_subscription('post', 0, 'jabber', 2);
- $this->notifications->add_subscription('post', 1, '', 2);
- $this->notifications->add_subscription('post', 1, 'email', 2);
- $this->notifications->add_subscription('post', 1, 'jabber', 2);
- $this->notifications->add_subscription('post', 2, '', 2);
- $this->notifications->add_subscription('post', 2, 'email', 2);
- $this->notifications->add_subscription('post', 2, 'jabber', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 0, '');
+ $this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 1);
+ $this->notifications->add_subscription('phpbb_notification_type_quote', 0, '', 1);
+
+ $this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 0, 'email', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 0, 'jabber', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 1, '', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 1, 'email', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 1, 'jabber', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 2, '', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 2, 'email', 2);
+ $this->notifications->add_subscription('phpbb_notification_type_post', 2, 'jabber', 2);
$this->assertEquals(array(
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 0,
'method' => '',
@@ -134,13 +141,13 @@ class phpbb_notification_test extends phpbb_database_test_case
$this->assertEquals(array(
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 1,
'method' => '',
),
array(
- 'item_type' => 'quote',
+ 'item_type' => 'phpbb_notification_type_quote',
'item_id' => 0,
'user_id' => 1,
'method' => '',
@@ -149,55 +156,55 @@ class phpbb_notification_test extends phpbb_database_test_case
$this->assertEquals(array(
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => '',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'email',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'jabber',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => '',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => 'email',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => 'jabber',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => '',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => 'email',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => 'jabber',
@@ -205,50 +212,50 @@ class phpbb_notification_test extends phpbb_database_test_case
), $this->notifications->get_subscriptions(2));
$this->assertEquals(array(
- 'post' => array(
+ 'phpbb_notification_type_post' => array(
'',
'email',
'jabber',
),
), $this->notifications->get_subscriptions(2, true));
- $this->notifications->delete_subscription('post', 0, '', 2);
- $this->notifications->delete_subscription('post', 1, 'email', 2);
- $this->notifications->delete_subscription('post', 2, 'jabber', 2);
+ $this->notifications->delete_subscription('phpbb_notification_type_post', 0, '', 2);
+ $this->notifications->delete_subscription('phpbb_notification_type_post', 1, 'email', 2);
+ $this->notifications->delete_subscription('phpbb_notification_type_post', 2, 'jabber', 2);
$this->assertEquals(array(
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'email',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 0,
'user_id' => 2,
'method' => 'jabber',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => '',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 1,
'user_id' => 2,
'method' => 'jabber',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => '',
),
array(
- 'item_type' => 'post',
+ 'item_type' => 'phpbb_notification_type_post',
'item_id' => 2,
'user_id' => 2,
'method' => 'email',
@@ -260,7 +267,7 @@ class phpbb_notification_test extends phpbb_database_test_case
{
global $db;
- $this->notifications->add_subscription('ext_test-test');
+ $this->notifications->add_subscription('phpbb_ext_test_notification_type_test');
// Used to test post notifications later
$db->sql_query('INSERT INTO ' . TOPICS_WATCH_TABLE . ' ' . $db->sql_build_array('INSERT', array(
@@ -277,25 +284,25 @@ class phpbb_notification_test extends phpbb_database_test_case
'count_unread' => true,
)));
- $this->notifications->add_notifications('ext_test-test', array(
+ $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array(
'post_id' => '1',
'topic_id' => '1',
'post_time' => 1349413321,
));
- $this->notifications->add_notifications('ext_test-test', array(
+ $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array(
'post_id' => '2',
'topic_id' => '2',
'post_time' => 1349413322,
));
- $this->notifications->add_notifications('ext_test-test', array(
+ $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array(
'post_id' => '3',
'topic_id' => '2',
'post_time' => 1349413323,
));
- $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'ext_test-test'), array(
+ $this->notifications->add_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array(
'post_id' => '4',
'topic_id' => '2',
'post_time' => 1349413324,
@@ -310,9 +317,9 @@ class phpbb_notification_test extends phpbb_database_test_case
'topic_id' => 2,
'user_id' => 0,
)));
- $this->notifications->add_subscription('bookmark');
+ $this->notifications->add_subscription('phpbb_notification_type_bookmark');
- $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'ext_test-test'), array(
+ $this->notifications->add_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array(
'post_id' => '5',
'topic_id' => '2',
'post_time' => 1349413325,
@@ -323,9 +330,9 @@ class phpbb_notification_test extends phpbb_database_test_case
'forum_name' => 'Your first forum',
));
- $this->notifications->delete_subscription('ext_test-test');
+ $this->notifications->delete_subscription('phpbb_ext_test_notification_type_test');
- $this->notifications->add_notifications('ext_test-test', array(
+ $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array(
'post_id' => '6',
'topic_id' => '2',
'post_time' => 1349413326,
@@ -336,13 +343,40 @@ class phpbb_notification_test extends phpbb_database_test_case
));
$expected = array(
- 5 => array(
- 'item_type' => 'bookmark',
- 'item_id' => 5,
+ 1 => array(
+ 'item_type' => 'phpbb_ext_test_notification_type_test',
+ 'item_id' => 1,
+ 'item_parent_id' => 1,
+ 'user_id' => 0,
+ 'unread' => 1,
+ 'time' => 1349413321,
+ 'data' => array(),
+ ),
+ 2 => array(
+ 'item_type' => 'phpbb_ext_test_notification_type_test',
+ 'item_id' => 2,
'item_parent_id' => 2,
'user_id' => 0,
'unread' => 1,
- 'time' => 1349413325,
+ 'time' => 1349413322,
+ 'data' => array(),
+ ),
+ 3 => array(
+ 'item_type' => 'phpbb_ext_test_notification_type_test',
+ 'item_id' => 3,
+ 'item_parent_id' => 2,
+ 'user_id' => 0,
+ 'unread' => 1,
+ 'time' => 1349413323,
+ 'data' => array(),
+ ),
+ 4 => array(
+ 'item_type' => 'phpbb_notification_type_post',
+ 'item_id' => 4,
+ 'item_parent_id' => 2,
+ 'user_id' => 0,
+ 'unread' => 1,
+ 'time' => 1349413324,
'data' => array(
'poster_id' => 2,
'topic_title' => 'test-title',
@@ -352,13 +386,13 @@ class phpbb_notification_test extends phpbb_database_test_case
'forum_name' => 'Your first forum',
),
),
- 4 => array(
- 'item_type' => 'post',
- 'item_id' => 4,
+ 5 => array(
+ 'item_type' => 'phpbb_notification_type_bookmark',
+ 'item_id' => 5,
'item_parent_id' => 2,
'user_id' => 0,
'unread' => 1,
- 'time' => 1349413324,
+ 'time' => 1349413325,
'data' => array(
'poster_id' => 2,
'topic_title' => 'test-title',
@@ -368,72 +402,41 @@ class phpbb_notification_test extends phpbb_database_test_case
'forum_name' => 'Your first forum',
),
),
- 3 => array(
- 'item_type' => 'ext_test-test',
- 'item_id' => 3,
- 'item_parent_id' => 2,
- 'user_id' => 0,
- 'unread' => 1,
- 'time' => 1349413323,
- 'data' => array(),
- ),
- 2 => array(
- 'item_type' => 'ext_test-test',
- 'item_id' => 2,
- 'item_parent_id' => 2,
- 'user_id' => 0,
- 'unread' => 1,
- 'time' => 1349413322,
- 'data' => array(),
- ),
- 1 => array(
- 'item_type' => 'ext_test-test',
- 'item_id' => 1,
- 'item_parent_id' => 1,
- 'user_id' => 0,
- 'unread' => 1,
- 'time' => 1349413321,
- 'data' => array(),
- ),
);
$this->assertEquals(sizeof($expected), $notifications['unread_count']);
$notifications = $notifications['notifications'];
- $i = 0;
foreach ($expected as $notification_id => $notification_data)
{
- //echo $notifications[$i];
+ //echo $notifications[$notification_id];
- $this->assertEquals($notification_id, $notifications[$i]->notification_id, 'notification_id');
+ $this->assertEquals($notification_id, $notifications[$notification_id]->notification_id, 'notification_id');
foreach ($notification_data as $key => $value)
{
- $this->assertEquals($value, $notifications[$i]->$key, $key . ' ' . $notification_id);
+ $this->assertEquals($value, $notifications[$notification_id]->$key, $key . ' ' . $notification_id);
}
-
- $i++;
}
// Now test updating -------------------------------
- $this->notifications->update_notifications('ext_test-test', array(
+ $this->notifications->update_notifications('phpbb_ext_test_notification_type_test', array(
'post_id' => '1',
'topic_id' => '2', // change parent_id
'post_time' => 1349413321,
));
- $this->notifications->update_notifications('ext_test-test', array(
+ $this->notifications->update_notifications('phpbb_ext_test_notification_type_test', array(
'post_id' => '3',
'topic_id' => '2',
- 'post_time' => 1234, // change post_time
+ 'post_time' => 1234, // change time
));
- $this->notifications->update_notifications(array('quote', 'bookmark', 'post', 'ext_test-test'), array(
+ $this->notifications->update_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array(
'post_id' => '5',
'topic_id' => '2',
- 'post_time' => 12345, // change post_time
'poster_id' => 2,
'topic_title' => 'test-title2', // change topic_title
'post_subject' => 'Re: test-title2', // change post_subject
@@ -446,24 +449,17 @@ class phpbb_notification_test extends phpbb_database_test_case
));
$expected = array(
- 4 => array(
- 'item_type' => 'post',
- 'item_id' => 4,
+ 1 => array(
+ 'item_type' => 'phpbb_ext_test_notification_type_test',
+ 'item_id' => 1,
'item_parent_id' => 2,
'user_id' => 0,
'unread' => 1,
- 'time' => 1349413324,
- 'data' => array(
- 'poster_id' => 2,
- 'topic_title' => 'test-title',
- 'post_subject' => 'Re: test-title',
- 'post_username' => '',
- 'forum_id' => 2,
- 'forum_name' => 'Your first forum',
- ),
+ 'time' => 1349413321,
+ 'data' => array(),
),
2 => array(
- 'item_type' => 'ext_test-test',
+ 'item_type' => 'phpbb_ext_test_notification_type_test',
'item_id' => 2,
'item_parent_id' => 2,
'user_id' => 0,
@@ -471,22 +467,38 @@ class phpbb_notification_test extends phpbb_database_test_case
'time' => 1349413322,
'data' => array(),
),
- 1 => array(
- 'item_type' => 'ext_test-test',
- 'item_id' => 1,
+ 3 => array(
+ 'item_type' => 'phpbb_ext_test_notification_type_test',
+ 'item_id' => 3,
'item_parent_id' => 2,
'user_id' => 0,
'unread' => 1,
- 'time' => 1349413321,
+ 'time' => 1234,
'data' => array(),
),
+ 4 => array(
+ 'item_type' => 'phpbb_notification_type_post',
+ 'item_id' => 4,
+ 'item_parent_id' => 2,
+ 'user_id' => 0,
+ 'unread' => 1,
+ 'time' => 1349413324,
+ 'data' => array(
+ 'poster_id' => 2,
+ 'topic_title' => 'test-title',
+ 'post_subject' => 'Re: test-title',
+ 'post_username' => '',
+ 'forum_id' => 2,
+ 'forum_name' => 'Your first forum',
+ ),
+ ),
5 => array(
- 'item_type' => 'bookmark',
+ 'item_type' => 'phpbb_notification_type_bookmark',
'item_id' => 5,
'item_parent_id' => 2,
'user_id' => 0,
'unread' => 1,
- 'time' => 12345,
+ 'time' => 1349413325,
'data' => array(
'poster_id' => 2,
'topic_title' => 'test-title2',
@@ -496,56 +508,21 @@ class phpbb_notification_test extends phpbb_database_test_case
'forum_name' => 'Your second forum',
),
),
- 3 => array(
- 'item_type' => 'ext_test-test',
- 'item_id' => 3,
- 'item_parent_id' => 2,
- 'user_id' => 0,
- 'unread' => 1,
- 'time' => 1234,
- 'data' => array(),
- ),
);
$this->assertEquals(sizeof($expected), $notifications['unread_count']);
$notifications = $notifications['notifications'];
- $i = 0;
foreach ($expected as $notification_id => $notification_data)
{
- //echo $notifications[$i];
+ //echo $notifications[$notification_id];
- $this->assertEquals($notification_id, $notifications[$i]->notification_id, 'notification_id');
+ $this->assertEquals($notification_id, $notifications[$notification_id]->notification_id, 'notification_id');
foreach ($notification_data as $key => $value)
{
- $this->assertEquals($value, $notifications[$i]->$key, $key . ' ' . $notification_id);
- }
-
- $i++;
- }
- }
-
- private function dump($array, $pre = '')
- {
- echo ($pre == '') ? "\n------------------------------------------------\n" : '';
-
- foreach ($array as $key => $value)
- {
- echo $pre . $key . ' => ';
-
- if (is_array($value))
- {
- echo "\n";
-
- $this->dump($value, $pre . "\t");
- }
- else
- {
- echo (string) $value;
-
- echo "\n";
+ $this->assertEquals($value, $notifications[$notification_id]->$key, $key . ' ' . $notification_id);
}
}
}