diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2012-09-27 18:25:37 -0500 |
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2012-09-27 18:25:37 -0500 |
| commit | 48ccc9eb93c8413f05f6a50d40e597f560c671d8 (patch) | |
| tree | 20ba16edf636eeb2523c51559d33462d1fea07f3 /phpBB/includes/notifications/service.php | |
| parent | f062087f30fab4ce497333cd88735920efe0737f (diff) | |
| download | forums-48ccc9eb93c8413f05f6a50d40e597f560c671d8.tar forums-48ccc9eb93c8413f05f6a50d40e597f560c671d8.tar.gz forums-48ccc9eb93c8413f05f6a50d40e597f560c671d8.tar.bz2 forums-48ccc9eb93c8413f05f6a50d40e597f560c671d8.tar.xz forums-48ccc9eb93c8413f05f6a50d40e597f560c671d8.zip | |
[ticket/11103] UCP Notification Options can now be set
PHPBB3-11103
Diffstat (limited to 'phpBB/includes/notifications/service.php')
| -rw-r--r-- | phpBB/includes/notifications/service.php | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 174b73f9a5..2c1eb859c7 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -503,6 +503,46 @@ class phpbb_notifications_service } /** + * 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 * * @param string $item_type Type identifier of the 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); |
