aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/notification/type/post.php
diff options
context:
space:
mode:
authorNicofuma <github@nicofuma.fr>2014-04-28 14:00:27 +0200
committerTristan Darricau <tristan.darricau@sensiolabs.com>2015-07-13 22:41:13 +0200
commitbe0d4e20d4be8bc3217e5d025058e065b8f2071a (patch)
tree557a9732223835282b86ba8986120d978bca5260 /phpBB/phpbb/notification/type/post.php
parent58d1d37c167c978257c9a4680d56835c63202738 (diff)
downloadforums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar
forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar.gz
forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar.bz2
forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.tar.xz
forums-be0d4e20d4be8bc3217e5d025058e065b8f2071a.zip
[ticket/11444] Moving the in-board notifications to a method class
Currently the in-board method for the notifications is hardcoded and cannot be disabled. This method should be in his own class extending `phpbb\notification\method\method_interface`. It also add the possibility, for each method, to be enabled by default (ie: no entry in the DB => notification enabled). https://tracker.phpbb.com/browse/PHPBB3-11444 https://tracker.phpbb.com/browse/PHPBB3-11967 PHPBB3-11444
Diffstat (limited to 'phpBB/phpbb/notification/type/post.php')
-rw-r--r--phpBB/phpbb/notification/type/post.php41
1 files changed, 15 insertions, 26 deletions
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php
index f6b3136a21..e310484187 100644
--- a/phpBB/phpbb/notification/type/post.php
+++ b/phpBB/phpbb/notification/type/post.php
@@ -131,31 +131,26 @@ class post extends \phpbb\notification\type\base
}
// Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications
- $update_notifications = array();
- $sql = 'SELECT n.*
- FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
- WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
- AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . '
- AND n.notification_read = 0
- AND nt.notification_type_id = n.notification_type_id
- AND nt.notification_type_enabled = 1';
- $result = $this->db->sql_query($sql);
- while ($row = $this->db->sql_fetchrow($result))
+ $notified_users = $this->notification_manager->get_notified_users($this->get_type(), array(
+ 'item_parent_id' => self::get_item_parent_id($post),
+ 'read' => 0,
+ ));
+
+ foreach ($notified_users as $user => $notification_data)
{
- // Do not create a new notification
- unset($notify_users[$row['user_id']]);
+ unset($notify_users[$user]);
- $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
+ $notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
$update_responders = $notification->add_responders($post);
if (!empty($update_responders))
{
- $sql = 'UPDATE ' . $this->notifications_table . '
- SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
- WHERE notification_id = ' . $row['notification_id'];
- $this->db->sql_query($sql);
+ $this->notification_manager->update_notification($notification, $update_responders, array(
+ 'item_parent_id' => self::get_item_parent_id($post),
+ 'read' => 0,
+ 'user_id' => $user,
+ ));
}
}
- $this->db->sql_freeresult($result);
return $notify_users;
}
@@ -363,13 +358,7 @@ class post extends \phpbb\notification\type\base
}
/**
- * Function for preparing the data for insertion in an SQL query
- * (The service handles insertion)
- *
- * @param array $post Data from submit_post
- * @param array $pre_create_data Data from pre_create_insert_array()
- *
- * @return array Array of data ready to be inserted into the database
+ * {@inheritdoc}
*/
public function create_insert_array($post, $pre_create_data = array())
{
@@ -394,7 +383,7 @@ class post extends \phpbb\notification\type\base
$this->notification_read = true;
}
- return parent::create_insert_array($post, $pre_create_data);
+ parent::create_insert_array($post, $pre_create_data);
}
/**