diff options
author | Cesar G <prototech91@gmail.com> | 2013-11-23 20:11:49 -0800 |
---|---|---|
committer | Cesar G <prototech91@gmail.com> | 2013-12-30 11:12:15 -0800 |
commit | f4b832a27d128ec84142dfe6133dc6ba96b8d3a9 (patch) | |
tree | 02716fb3c67019d8f4749faa7ce554334cff9fa5 /phpBB/index.php | |
parent | be67124dc7d5461c9b085e4dc3f32ece87e4b1aa (diff) | |
download | forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar.gz forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar.bz2 forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.tar.xz forums-f4b832a27d128ec84142dfe6133dc6ba96b8d3a9.zip |
[ticket/12034] AJAXify notifications popup.
PHPBB3-12034
Diffstat (limited to 'phpBB/index.php')
-rw-r--r-- | phpBB/index.php | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/phpBB/index.php b/phpBB/index.php index 74fc1b9bda..51cd9064b8 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -27,24 +27,44 @@ $user->setup('viewforum'); // Mark notifications read if (($mark_notification = $request->variable('mark_notification', 0))) { - $phpbb_notifications = $phpbb_container->get('notification_manager'); - - $notification = $phpbb_notifications->load_notifications(array( - 'notification_id' => $mark_notification - )); + if ($user->data['user_id'] == ANONYMOUS) + { + if ($request->is_ajax()) + { + trigger_error('LOGIN_REQUIRED'); + } + login_box('', $user->lang['LOGIN_REQUIRED']); + } - if (isset($notification['notifications'][$mark_notification])) + if (check_link_hash($request->variable('hash', ''), 'mark_notification_read')) { - $notification = $notification['notifications'][$mark_notification]; + $phpbb_notifications = $phpbb_container->get('notification_manager'); - $notification->mark_read(); + $notification = $phpbb_notifications->load_notifications(array( + 'notification_id' => $mark_notification + )); - if (($redirect = $request->variable('redirect', ''))) + if (isset($notification['notifications'][$mark_notification])) { - redirect(append_sid($phpbb_root_path . $redirect)); - } + $notification = $notification['notifications'][$mark_notification]; + + $notification->mark_read(); + + if ($request->is_ajax()) + { + $json_response = new \phpbb\json_response(); + $json_response->send(array( + 'success' => true, + )); + } - redirect($notification->get_url()); + if (($redirect = $request->variable('redirect', ''))) + { + redirect(append_sid($phpbb_root_path . $redirect)); + } + + redirect($notification->get_url()); + } } } |