diff options
Diffstat (limited to 'phpBB/includes/ucp')
-rw-r--r-- | phpBB/includes/ucp/info/ucp_notifications.php | 34 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_notifications.php | 141 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_prefs.php | 18 |
3 files changed, 175 insertions, 18 deletions
diff --git a/phpBB/includes/ucp/info/ucp_notifications.php b/phpBB/includes/ucp/info/ucp_notifications.php new file mode 100644 index 0000000000..4bc9ae2cea --- /dev/null +++ b/phpBB/includes/ucp/info/ucp_notifications.php @@ -0,0 +1,34 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @package module_install +*/ +class ucp_notifications_info +{ + function module() + { + return array( + 'filename' => 'ucp_notifications', + 'title' => 'UCP_NOTIFICATION_OPTIONS', + 'version' => '1.0.0', + 'modes' => array( + 'notification_options' => array('title' => 'UCP_NOTIFICATION_OPTIONS', 'auth' => '', 'cat' => array('UCP_MAIN')), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php new file mode 100644 index 0000000000..950b70a156 --- /dev/null +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -0,0 +1,141 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +class ucp_notifications +{ + public $u_action; + + public function main($id, $mode) + { + global $phpbb_container; + + add_form_key('ucp_notification_options'); + + $phpbb_notifications = $phpbb_container->get('notifications'); + $template = $phpbb_container->get('template'); + $user = $phpbb_container->get('user'); + $request = $phpbb_container->get('request'); + + $subscriptions = $phpbb_notifications->get_subscriptions(false, true); + + // Add/remove subscriptions + if ($request->is_set_post('submit')) + { + if (!check_form_key('ucp_notification_options')) + { + trigger_error('FORM_INVALID'); + } + + $notification_methods = $phpbb_notifications->get_subscription_methods(); + + foreach($phpbb_notifications->get_subscription_types() as $type => $data) + { + if ($request->is_set_post($type . '_notification') && !isset($subscriptions[$type])) + { + // 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]))) + { + // 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); + } + } + } + } + + // todo include language files for extensions? + + $this->output_notification_methods('notification_methods', $phpbb_notifications, $template, $user); + + $this->output_notification_types('notification_types', $phpbb_notifications, $template, $user); + + $this->tpl_name = 'ucp_notifications'; + $this->page_title = 'UCP_NOTIFICATIONS'; + } + + /** + * Output all the notification types to the template + * + * @param string $block + * @param phpbb_notifications_service $phpbb_notifications + * @param phpbb_template $template + * @param phpbb_user $user + */ + public function output_notification_types($block = 'notification_types', phpbb_notifications_service $phpbb_notifications, phpbb_template $template, phpbb_user $user) + { + $notification_methods = $phpbb_notifications->get_subscription_methods(); + $subscriptions = $phpbb_notifications->get_subscriptions(false, true); + + foreach($phpbb_notifications->get_subscription_types() as $type => $data) + { + $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, + )); + + 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, + )); + } + } + } + + /** + * Output all the notification methods to the template + * + * @param string $block + * @param phpbb_notifications_service $phpbb_notifications + * @param phpbb_template $template + * @param phpbb_user $user + */ + public function output_notification_methods($block = 'notification_methods', phpbb_notifications_service $phpbb_notifications, phpbb_template $template, phpbb_user $user) + { + $notification_methods = $phpbb_notifications->get_subscription_methods(); + + foreach($notification_methods as $method) + { + $template->assign_block_vars($block, array( + 'METHOD' => $method, + + 'NAME' => $user->lang('NOTIFICATION_METHOD_' . strtoupper($method)), + )); + } + } +} diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 2228bc7931..709d2a90b0 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -37,7 +37,6 @@ class ucp_prefs case 'personal': add_form_key('ucp_prefs_personal'); $data = array( - 'notifymethod' => request_var('notifymethod', $user->data['user_notify_type']), 'dateformat' => request_var('dateformat', $user->data['user_dateformat'], true), 'lang' => basename(request_var('lang', $user->data['user_lang'])), 'style' => request_var('style', (int) $user->data['user_style']), @@ -46,17 +45,9 @@ class ucp_prefs 'viewemail' => request_var('viewemail', (bool) $user->data['user_allow_viewemail']), 'massemail' => request_var('massemail', (bool) $user->data['user_allow_massemail']), 'hideonline' => request_var('hideonline', (bool) !$user->data['user_allow_viewonline']), - 'notifypm' => request_var('notifypm', (bool) $user->data['user_notify_pm']), - 'popuppm' => request_var('popuppm', (bool) $user->optionget('popuppm')), 'allowpm' => request_var('allowpm', (bool) $user->data['user_allow_pm']), ); - if ($data['notifymethod'] == NOTIFY_IM && (!$config['jab_enable'] || !$user->data['user_jabber'] || !@extension_loaded('xml'))) - { - // Jabber isnt enabled, or no jabber field filled in. Update the users table to be sure its correct. - $data['notifymethod'] = NOTIFY_BOTH; - } - if ($submit) { if ($config['override_user_style']) @@ -81,15 +72,11 @@ class ucp_prefs if (!sizeof($error)) { - $user->optionset('popuppm', $data['popuppm']); - $sql_ary = array( 'user_allow_pm' => $data['allowpm'], 'user_allow_viewemail' => $data['viewemail'], 'user_allow_massemail' => $data['massemail'], 'user_allow_viewonline' => ($auth->acl_get('u_hideonline')) ? !$data['hideonline'] : $user->data['user_allow_viewonline'], - 'user_notify_type' => $data['notifymethod'], - 'user_notify_pm' => $data['notifypm'], 'user_options' => $user->data['user_options'], 'user_dateformat' => $data['dateformat'], @@ -135,15 +122,10 @@ class ucp_prefs $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '', - 'S_NOTIFY_EMAIL' => ($data['notifymethod'] == NOTIFY_EMAIL) ? true : false, - 'S_NOTIFY_IM' => ($data['notifymethod'] == NOTIFY_IM) ? true : false, - 'S_NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false, 'S_VIEW_EMAIL' => $data['viewemail'], 'S_MASS_EMAIL' => $data['massemail'], 'S_ALLOW_PM' => $data['allowpm'], 'S_HIDE_ONLINE' => $data['hideonline'], - 'S_NOTIFY_PM' => $data['notifypm'], - 'S_POPUP_PM' => $data['popuppm'], 'DATE_FORMAT' => $data['dateformat'], 'A_DATE_FORMAT' => addslashes($data['dateformat']), |