aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-09-09 09:10:11 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2012-09-09 09:10:11 -0500
commit2fb9f2ce6ad44e6dcacc6914379b09d795daace2 (patch)
treec58d683bdb0d9255f6960ef21f197d2630ec4c84 /phpBB/includes
parentb58ef116e1157311463ae9c5c313b314764eb9e2 (diff)
parent98a03090a05b1d7651c05ad23802973cf20dcf6b (diff)
downloadforums-2fb9f2ce6ad44e6dcacc6914379b09d795daace2.tar
forums-2fb9f2ce6ad44e6dcacc6914379b09d795daace2.tar.gz
forums-2fb9f2ce6ad44e6dcacc6914379b09d795daace2.tar.bz2
forums-2fb9f2ce6ad44e6dcacc6914379b09d795daace2.tar.xz
forums-2fb9f2ce6ad44e6dcacc6914379b09d795daace2.zip
Merge branch 'ticket/11103' of github.com:EXreaction/phpbb3 into ticket/11103
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/notifications/method/email.php23
-rw-r--r--phpBB/includes/notifications/service.php7
-rw-r--r--phpBB/includes/notifications/type/interface.php2
-rw-r--r--phpBB/includes/notifications/type/pm.php28
4 files changed, 39 insertions, 21 deletions
diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php
index 0120485cff..2b80b5bf3a 100644
--- a/phpBB/includes/notifications/method/email.php
+++ b/phpBB/includes/notifications/method/email.php
@@ -23,6 +23,10 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_notifications_method_email extends phpbb_notifications_method_base
{
+ /**
+ * Is this method available for the user?
+ * This is checked on the notifications options
+ */
public static function is_available()
{
// Email is always available
@@ -48,6 +52,13 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
$user_ids[] = $notification->user_id;
}
+ // We do not send emails to banned users
+ if (!function_exists('phpbb_get_banned_user_ids'))
+ {
+ include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext'));
+ }
+ $banned_users = phpbb_get_banned_user_ids($user_ids);
+
$sql = 'SELECT * FROM ' . USERS_TABLE . '
WHERE ' . $this->db->sql_in_set('user_id', $user_ids);
$result = $this->db->sql_query($sql);
@@ -68,6 +79,11 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
// Time to go through the queue and send emails
foreach ($this->queue as $notification)
{
+ if (in_array($notification->user_id, $banned_users))
+ {
+ continue;
+ }
+
$notification->users($users);
$user = $notification->get_user($notification->user_id);
@@ -77,12 +93,9 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base
$messenger->to($user['user_email'], $user['username']);
$messenger->assign_vars(array(
- 'SUBJECT' => htmlspecialchars_decode($notification->get_title()),
- 'AUTHOR_NAME' => '',
- 'USERNAME' => htmlspecialchars_decode($user['username']),
+ 'SUBJECT' => htmlspecialchars_decode($notification->get_title()),
- 'U_INBOX' => $board_url . "/ucp.{$this->php_ext}?i=pm&folder=inbox",
- 'U_VIEW_MESSAGE' => $board_url . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$notification->item_id}",
+ 'U_VIEW_MESSAGE' => $notification->get_full_url(),
));
$messenger->send('email');
diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php
index 74e2e29e1a..4794472883 100644
--- a/phpBB/includes/notifications/service.php
+++ b/phpBB/includes/notifications/service.php
@@ -46,6 +46,8 @@ class phpbb_notifications_service
*
* @param array $options Optional options to control what notifications are loaded
* user_id User id to load notifications for (Default: $user->data['user_id'])
+ * order_by Order by (Default: time)
+ * order_dir Order direction (Default: DESC)
* limit Number of notifications to load (Default: 5)
* start Notifications offset (Default: 0)
*/
@@ -58,12 +60,15 @@ class phpbb_notifications_service
'user_id' => $user->data['user_id'],
'limit' => 5,
'start' => 0,
+ 'order_by' => 'time',
+ 'order_dir' => 'DESC',
), $options);
$notifications = $user_ids = array();
$sql = 'SELECT * FROM ' . NOTIFICATIONS_TABLE . '
- WHERE user_id = ' . (int) $options['user_id'];
+ WHERE user_id = ' . (int) $options['user_id'] . '
+ 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))
diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php
index ccd963ba06..03e24358a9 100644
--- a/phpBB/includes/notifications/type/interface.php
+++ b/phpBB/includes/notifications/type/interface.php
@@ -29,6 +29,8 @@ interface phpbb_notifications_type_interface
public function get_url();
+ public function get_full_url();
+
public function create_insert_array($type_data);
public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data);
diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php
index 2b2a835470..92026c08d7 100644
--- a/phpBB/includes/notifications/type/pm.php
+++ b/phpBB/includes/notifications/type/pm.php
@@ -65,7 +65,17 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
*/
public function get_url()
{
- return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&amp;mode=view&p={$this->item_id}");
+ return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&amp;mode=view&amp;p={$this->item_id}");
+ }
+
+ /**
+ * Get the full url to this item
+ *
+ * @return string URL
+ */
+ public function get_full_url()
+ {
+ return generate_board_url() . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$this->item_id}";
}
/**
@@ -108,20 +118,8 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base
$db = $phpbb_container->get('dbal.conn');
$user = $phpbb_container->get('user');
- // Exclude guests, current user and banned users from notifications
- unset($pm['recipients'][ANONYMOUS]);//, $pm['recipients'][$user->data['user_id']]);
-
- if (!sizeof($pm['recipients']))
- {
- return;
- }
-
- if (!function_exists('phpbb_get_banned_user_ids'))
- {
- include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext'));
- }
- $banned_users = phpbb_get_banned_user_ids(array_keys($pm['recipients']));
- $pm['recipients'] = array_diff(array_keys($pm['recipients']), $banned_users);
+ // Exclude guests and current user from notifications
+ unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]);
if (!sizeof($pm['recipients']))
{