Merge branch 'develop-ascraeus' into develop

# By Marc Alexander
# Via Dhruv Goel (1) and Marc Alexander (1)
* develop-ascraeus:
  [ticket/12742] Add sorting back to bookmark notification list of users
  [ticket/12742] Add sort options for notification types requiring sorting
  [ticket/12742] Remove unneeded sort of users
  [ticket/12742] Replace authenticated with authorised
  [ticket/12742] Add check for empty $users and add method to fitting methods
  [ticket/12742] Add method for getting authenticated recipients
This commit is contained in:
Dhruv 2014-08-09 20:03:17 +02:00
commit e12969d2c7
7 changed files with 43 additions and 69 deletions

View file

@ -81,14 +81,7 @@ class approve_post extends \phpbb\notification\type\post
$users = array();
$users[$post['poster_id']] = array('');
$auth_read = $this->auth->acl_get_list(array_keys($users), 'f_read', $post['forum_id']);
if (empty($auth_read))
{
return array();
}
return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array(
return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array(
'item_type' => self::$notification_option['id'],
)));
}

View file

@ -81,14 +81,7 @@ class approve_topic extends \phpbb\notification\type\topic
$users = array();
$users[$post['poster_id']] = array('');
$auth_read = $this->auth->acl_get_list(array_keys($users), 'f_read', $post['forum_id']);
if (empty($auth_read))
{
return array();
}
return $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], array_merge($options, array(
return $this->get_authorised_recipients(array_keys($users), $post['forum_id'], array_merge($options, array(
'item_type' => self::$notification_option['id'],
)));
}

View file

@ -533,4 +533,37 @@ abstract class base implements \phpbb\notification\type\type_interface
WHERE ' . $where;
$this->db->sql_query($sql);
}
/**
* Get a list of users that are authorised to receive notifications
*
* @param array $users Array of users that have subscribed to a notification
* @param int $forum_id Forum ID of the forum
* @param array $options Array of notification options
* @param bool $sort Whether the users array should be sorted. Default: false
* @return array Array of users that are authorised recipients
*/
protected function get_authorised_recipients($users, $forum_id, $options, $sort = false)
{
if (empty($users))
{
return array();
}
$users = array_unique($users);
if ($sort)
{
sort($users);
}
$auth_read = $this->auth->acl_get_list($users, 'f_read', $forum_id);
if (empty($auth_read))
{
return array();
}
return $this->check_user_notification_options($auth_read[$forum_id]['f_read'], $options);
}
}

View file

@ -83,20 +83,12 @@ class bookmark extends \phpbb\notification\type\post
}
$this->db->sql_freeresult($result);
if (empty($users))
$notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
if (empty($notify_users))
{
return array();
}
sort($users);
$auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']);
if (empty($auth_read))
{
return array();
}
$notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options);
// 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();

View file

@ -123,23 +123,13 @@ class post extends \phpbb\notification\type\base
}
$this->db->sql_freeresult($result);
if (empty($users))
$notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
if (empty($notify_users))
{
return array();
}
$users = array_unique($users);
sort($users);
$auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']);
if (empty($auth_read))
{
return array();
}
$notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options);
// 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.*

View file

@ -102,22 +102,7 @@ class quote extends \phpbb\notification\type\post
}
$this->db->sql_freeresult($result);
if (empty($users))
{
return array();
}
sort($users);
$auth_read = $this->auth->acl_get_list($users, 'f_read', $post['forum_id']);
if (empty($auth_read))
{
return array();
}
$notify_users = $this->check_user_notification_options($auth_read[$post['forum_id']]['f_read'], $options);
return $notify_users;
return $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
}
/**

View file

@ -111,19 +111,7 @@ class topic extends \phpbb\notification\type\base
}
$this->db->sql_freeresult($result);
if (empty($users))
{
return array();
}
$auth_read = $this->auth->acl_get_list($users, 'f_read', $topic['forum_id']);
if (empty($auth_read))
{
return array();
}
return $this->check_user_notification_options($auth_read[$topic['forum_id']]['f_read'], $options);
return $this->get_authorised_recipients($users, $topic['forum_id'], $options);
}
/**