mirror of
https://github.com/phpbb/phpbb.git
synced 2025-10-18 18:26:13 +02:00
[ticket/11103] UCP Notification Options can now be set
PHPBB3-11103
This commit is contained in:
@@ -502,6 +502,46 @@ class phpbb_notifications_service
|
||||
return $subscription_methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subscriptions
|
||||
*
|
||||
* @param bool|int $user_id The user_id to add the subscription for (bool false for current user)
|
||||
* @param bool $only_global True to select only global subscription options (item_id = 0)
|
||||
*
|
||||
* @return array Subscriptions
|
||||
*/
|
||||
public function get_subscriptions($user_id = false, $only_global = false)
|
||||
{
|
||||
$user_id = ($user_id === false) ? $this->phpbb_container->get('user')->data['user_id'] : $user_id;
|
||||
|
||||
$subscriptions = array();
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . USER_NOTIFICATIONS_TABLE . '
|
||||
WHERE user_id = ' . (int) $user_id .
|
||||
(($only_global) ? ' AND item_id = 0' : '');
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if ($only_global)
|
||||
{
|
||||
if (!isset($subscriptions[$row['item_type']]))
|
||||
{
|
||||
$subscriptions[$row['item_type']] = array();
|
||||
}
|
||||
|
||||
$subscriptions[$row['item_type']][] = $row['method'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$subscriptions[] = $row;
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $subscriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a subscription
|
||||
*
|
||||
@@ -510,7 +550,7 @@ class phpbb_notifications_service
|
||||
* @param string $method The method of the notification e.g. '', 'email', or 'jabber'
|
||||
* @param bool|int $user_id The user_id to add the subscription for (bool false for current user)
|
||||
*/
|
||||
public function add_subscription($item_type, $item_id, $method = '', $user_id = false)
|
||||
public function add_subscription($item_type, $item_id = 0, $method = '', $user_id = false)
|
||||
{
|
||||
$this->get_item_type_class_name($item_type);
|
||||
|
||||
@@ -534,7 +574,7 @@ class phpbb_notifications_service
|
||||
* @param string $method The method of the notification e.g. '', 'email', or 'jabber'
|
||||
* @param bool|int $user_id The user_id to add the subscription for (bool false for current user)
|
||||
*/
|
||||
public function delete_subscription($item_type, $item_id, $method = '', $user_id = false)
|
||||
public function delete_subscription($item_type, $item_id = 0, $method = '', $user_id = false)
|
||||
{
|
||||
$this->get_item_type_class_name($item_type);
|
||||
|
||||
|
Reference in New Issue
Block a user