aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/notifications
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-09-09 13:29:47 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2012-09-09 13:29:47 -0500
commit74e2a8f893a2e7a69ba129a74dd0b3c31e742e79 (patch)
treeee37d10f14ef100d1b00b64a3d2473e4efb34080 /phpBB/includes/notifications
parent570fe6cee87da807f0917cdc0c84aee604b50510 (diff)
downloadforums-74e2a8f893a2e7a69ba129a74dd0b3c31e742e79.tar
forums-74e2a8f893a2e7a69ba129a74dd0b3c31e742e79.tar.gz
forums-74e2a8f893a2e7a69ba129a74dd0b3c31e742e79.tar.bz2
forums-74e2a8f893a2e7a69ba129a74dd0b3c31e742e79.tar.xz
forums-74e2a8f893a2e7a69ba129a74dd0b3c31e742e79.zip
[ticket/11103] Post notifications
PHPBB3-11103
Diffstat (limited to 'phpBB/includes/notifications')
-rw-r--r--phpBB/includes/notifications/type/base.php32
-rw-r--r--phpBB/includes/notifications/type/pm.php2
-rw-r--r--phpBB/includes/notifications/type/post.php71
3 files changed, 100 insertions, 5 deletions
diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php
index 91cc9f175a..df273f9e81 100644
--- a/phpBB/includes/notifications/type/base.php
+++ b/phpBB/includes/notifications/type/base.php
@@ -175,6 +175,38 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type
}
/**
+ * Find the users who want to receive notifications (helper)
+ *
+ * @param ContainerBuilder $phpbb_container
+ * @param array $item_id The item_id to search for
+ *
+ * @return array
+ */
+ protected static function _find_users_for_notification(ContainerBuilder $phpbb_container, $item_id)
+ {
+ $db = $phpbb_container->get('dbal.conn');
+
+ $rowset = array();
+
+ $sql = 'SELECT * FROM ' . USER_NOTIFICATIONS_TABLE . "
+ WHERE item_type = '" . static::get_item_type() . "'
+ AND item_id = " . (int) $item_id;
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (!isset($rowset[$row['user_id']]))
+ {
+ $rowset[$row['user_id']] = array();
+ }
+
+ $rowset[$row['user_id']][] = $row['method'];
+ }
+ $db->sql_freeresult($result);
+
+ return $rowset;
+ }
+
+ /**
* Get the formatted title of this notification (fall-back)
*
* @return string
diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php
index 702ec39c16..e060b5d658 100644
--- a/phpBB/includes/notifications/type/pm.php
+++ b/phpBB/includes/notifications/type/pm.php
@@ -47,7 +47,9 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
/**
* Find the users who want to receive notifications
*
+ * @param ContainerBuilder $phpbb_container
* @param array $pm Data from
+ *
* @return array
*/
public static function find_users_for_notification(ContainerBuilder $phpbb_container, $pm)
diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php
index 920a53bcf2..96faa0131c 100644
--- a/phpBB/includes/notifications/type/post.php
+++ b/phpBB/includes/notifications/type/post.php
@@ -45,11 +45,45 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
}
/**
- * Get the title of this notification
+ * Find the users who want to receive notifications
+ *
+ * @param ContainerBuilder $phpbb_container
+ * @param array $post Data from
+ *
+ * @return array
+ */
+ public static function find_users_for_notification(ContainerBuilder $phpbb_container, $post)
+ {
+ $users = parent::_find_users_for_notification($phpbb_container, $post['topic_id']);
+
+ if (!sizeof($users))
+ {
+ return array();
+ }
+
+ $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']);
+
+ if (empty($auth_read))
+ {
+ return array();
+ }
+
+ $notify_users = array();
+
+ foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id)
+ {
+ $notify_users[$user_id] = $users[$user_id];
+ }
+
+ return $notify_users;
+ }
+
+ /**
+ * Get the HTML formatted title of this notification
*
* @return string
*/
- public function get_title()
+ public function get_formatted_title()
{
if ($this->get_data('post_username'))
{
@@ -57,7 +91,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
}
else
{
- $user_data = $this->get_user($this->get_data('poster_id'));
+ $user_data = $this->service->get_user($this->get_data('poster_id'));
$username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']);
}
@@ -66,6 +100,25 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
}
/**
+ * Get the title of this notification
+ *
+ * @return string
+ */
+ public function get_title()
+ {
+ if ($this->get_data('post_username'))
+ {
+ $username = $this->get_data('post_username');
+ }
+ else
+ {
+ $username = $user_data['username'];
+ }
+
+ return $username . ' posted in the topic ' . censor_text($this->get_data('topic_title'));
+ }
+
+ /**
* Get the url to this item
*
* @return string URL
@@ -76,6 +129,16 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
}
/**
+ * Get the full url to this item
+ *
+ * @return string URL
+ */
+ public function get_full_url()
+ {
+ return generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}";
+ }
+
+ /**
* Users needed to query before this notification can be displayed
*
* @return array Array of user_ids
@@ -103,8 +166,6 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base
$this->set_data('post_username', $post['post_username']);
- $this->time = $post['post_time'];
-
return parent::create_insert_array($post);
}
}