From c5f280351a96aaebd90c27da095c9b1ff28624a5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 13 Oct 2012 23:52:49 -0500 Subject: [ticket/11103] UCP Notification option grouping Also add the ability to specify an _EXPLAIN text for the notification option PHPBB3-11103 --- phpBB/includes/ucp/ucp_notifications.php | 67 +++++++++++++++++++------------- 1 file changed, 39 insertions(+), 28 deletions(-) (limited to 'phpBB/includes/ucp/ucp_notifications.php') diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php index 35783e1b56..98165a7bf7 100644 --- a/phpBB/includes/ucp/ucp_notifications.php +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -44,30 +44,33 @@ class ucp_notifications $notification_methods = $phpbb_notifications->get_subscription_methods(); - foreach($phpbb_notifications->get_subscription_types() as $type => $data) + foreach($phpbb_notifications->get_subscription_types() as $group => $subscription_types) { - if ($request->is_set_post($type . '_notification') && !isset($subscriptions[$type])) + foreach($subscription_types as $type => $data) { - // add - $phpbb_notifications->add_subscription($type); - } - else if (!$request->is_set_post($type . '_notification') && isset($subscriptions[$type])) - { - // remove - $phpbb_notifications->delete_subscription($type); - } - - foreach($notification_methods as $method) - { - if ($request->is_set_post($type . '_' . $method) && (!isset($subscriptions[$type]) || !in_array($method, $subscriptions[$type]))) + if ($request->is_set_post($type . '_notification') && !isset($subscriptions[$type])) { // add - $phpbb_notifications->add_subscription($type, 0, $method); + $phpbb_notifications->add_subscription($type); } - else if (!$request->is_set_post($type . '_' . $method) && isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) + else if (!$request->is_set_post($type . '_notification') && isset($subscriptions[$type])) { // remove - $phpbb_notifications->delete_subscription($type, 0, $method); + $phpbb_notifications->delete_subscription($type); + } + + foreach($notification_methods as $method) + { + if ($request->is_set_post($type . '_' . $method) && (!isset($subscriptions[$type]) || !in_array($method, $subscriptions[$type]))) + { + // add + $phpbb_notifications->add_subscription($type, 0, $method); + } + else if (!$request->is_set_post($type . '_' . $method) && isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) + { + // remove + $phpbb_notifications->delete_subscription($type, 0, $method); + } } } } @@ -172,25 +175,33 @@ class ucp_notifications $notification_methods = $phpbb_notifications->get_subscription_methods(); $subscriptions = $phpbb_notifications->get_subscriptions(false, true); - foreach($phpbb_notifications->get_subscription_types() as $type => $data) + foreach($phpbb_notifications->get_subscription_types() as $group => $subscription_types) { $template->assign_block_vars($block, array( - 'TYPE' => $type, - - 'NAME' => (is_array($data) && isset($data['lang'])) ? $user->lang($data['lang']) : $user->lang('NOTIFICATION_TYPE_' . strtoupper($type)), - - 'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false, + 'GROUP_NAME' => $user->lang($group), )); - foreach($notification_methods as $method) + foreach($subscription_types as $type => $data) { - $template->assign_block_vars($block . '.notification_methods', array( - 'METHOD' => $method, + $template->assign_block_vars($block, array( + 'TYPE' => $type, - 'NAME' => $user->lang('NOTIFICATION_METHOD_' . strtoupper($method)), + 'NAME' => $user->lang($data['lang']), + 'EXPLAIN' => (isset($user->lang[$data['lang'] . '_EXPLAIN'])) ? $user->lang($data['lang'] . '_EXPLAIN') : '', - 'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) ? true : false, + 'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false, )); + + foreach($notification_methods as $method) + { + $template->assign_block_vars($block . '.notification_methods', array( + 'METHOD' => $method, + + 'NAME' => $user->lang('NOTIFICATION_METHOD_' . strtoupper($method)), + + 'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) ? true : false, + )); + } } } } -- cgit v1.2.1