From 7ce009f2e29045b2bd29dd670c900b79f7f3bd70 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 12:46:20 +0100 Subject: [ticket/10954] Mark forums read without popup or page refresh PHPBB3-10954 --- phpBB/includes/functions_display.php | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 73129803ee..9745d493c4 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -61,10 +61,23 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { markread('all', false, false, request_var('mark_time', 0)); - trigger_error( - $user->lang['FORUMS_MARKED'] . '

' . - sprintf($user->lang['RETURN_INDEX'], '', '') - ); + if (!$request->is_ajax()) + { + trigger_error( + $user->lang['FORUMS_MARKED'] . '

' . + sprintf($user->lang['RETURN_INDEX'], '', '') + ); + } + else + { + // Tell the ajax script what language vars need to be replaced + $data = array( + 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + ); + $json_response = new phpbb_json_response(); + $json_response->send($data); + } } else { @@ -313,7 +326,20 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); - trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); + if (!$request->is_ajax()) + { + trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); + } + else + { + // Tell the ajax script what language vars need to be replaced + $data = array( + 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + ); + $json_response = new phpbb_json_response(); + $json_response->send($data); + } } else { -- cgit v1.2.1 From 7efc37d1f9d4a4335fc91af147cd059c17b7d45e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 19:09:18 +0100 Subject: [ticket/10954] Modify is_ajax check for consistency PHPBB3-10954 --- phpBB/includes/functions_display.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9745d493c4..f3198bc1e5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -61,14 +61,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { markread('all', false, false, request_var('mark_time', 0)); - if (!$request->is_ajax()) - { - trigger_error( - $user->lang['FORUMS_MARKED'] . '

' . - sprintf($user->lang['RETURN_INDEX'], '', '') - ); - } - else + if ($request->is_ajax()) { // Tell the ajax script what language vars need to be replaced $data = array( @@ -78,6 +71,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $json_response = new phpbb_json_response(); $json_response->send($data); } + + trigger_error( + $user->lang['FORUMS_MARKED'] . '

' . + sprintf($user->lang['RETURN_INDEX'], '', '') + ); } else { @@ -326,11 +324,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); - if (!$request->is_ajax()) - { - trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); - } - else + if ($request->is_ajax()) { // Tell the ajax script what language vars need to be replaced $data = array( @@ -340,6 +334,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $json_response = new phpbb_json_response(); $json_response->send($data); } + + trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); } else { -- cgit v1.2.1 From 16c021e98667fe353e6b3a6cb0bbf3b8f2319f98 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Dec 2012 15:46:45 +0100 Subject: [ticket/10954] Change behavior of marking topics/forums It will now display a popup message for 3 seconds which will confirm the taken action. The amount of DOM traversals have been significantly reduced and jQuery.each is now used instead of for loops. Additionally, it is now possible to click on the mark topics/forums read links without triggering an AJAX error. PHPBB3-10954 --- phpBB/includes/functions_display.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_display.php') diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f3198bc1e5..cd4c901b58 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -63,10 +63,13 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod if ($request->is_ajax()) { - // Tell the ajax script what language vars need to be replaced + // Tell the ajax script what language vars and URL need to be replaced $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], + 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] ); $json_response = new phpbb_json_response(); $json_response->send($data); @@ -326,10 +329,13 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod if ($request->is_ajax()) { - // Tell the ajax script what language vars need to be replaced + // Tell the ajax script what language vars and URL need to be replaced $data = array( 'NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], - 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'] + 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], + 'U_MARK_FORUMS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED'] ); $json_response = new phpbb_json_response(); $json_response->send($data); -- cgit v1.2.1