From 7ce009f2e29045b2bd29dd670c900b79f7f3bd70 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 12:46:20 +0100 Subject: [PATCH 01/15] [ticket/10954] Mark forums read without popup or page refresh PHPBB3-10954 --- phpBB/includes/functions_display.php | 36 ++++++++++++++++--- phpBB/styles/prosilver/template/ajax.js | 16 +++++++++ .../styles/prosilver/template/index_body.html | 2 +- .../prosilver/template/viewforum_body.html | 2 +- 4 files changed, 49 insertions(+), 7 deletions(-) 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 { diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index fa31d3268f..4ae4f91d8d 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -2,6 +2,22 @@ "use strict"; +// This callback will mark all forum icons read +phpbb.add_ajax_callback('mark_forums_read', function(res) { + var read_title = res.NO_UNREAD_POSTS; + var unread_title = res.UNREAD_POSTS; + + $('li.row dl.forum_unread').each(function(e) { + $(this).removeClass('forum_unread').addClass('forum_read'); + $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); + }); + + $('li.row dl.forum_unread_subforum').each(function(e) { + $(this).removeClass('forum_unread_subforum').addClass('forum_read_subforum'); + $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); + }); +}); + // This callback finds the post from the delete link, and removes it. phpbb.add_ajax_callback('post_delete', function() { var el = $(this), diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html index 6babbf5997..0682abffed 100644 --- a/phpBB/styles/prosilver/template/index_body.html +++ b/phpBB/styles/prosilver/template/index_body.html @@ -8,7 +8,7 @@
  • {L_SEARCH_UNANSWERED}{L_SEARCH_UNREAD}{L_SEARCH_NEW}{L_SEARCH_ACTIVE_TOPICS}
  • -
  • {L_MARK_FORUMS_READ}
  • +
  • {L_MARK_FORUMS_READ}
  • diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index a3239602ae..0f2c1a30ec 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -28,7 +28,7 @@ From a57c81481d21433bdb185accfd7f2b82858ba461 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 12 Dec 2012 18:38:17 +0100 Subject: [PATCH 02/15] [ticket/10954] Mark topics read without popup Also added missing handling of locked forums. PHPBB3-10954 --- phpBB/styles/prosilver/template/ajax.js | 37 +++++++++++++++++++ .../prosilver/template/viewforum_body.html | 4 +- phpBB/viewforum.php | 15 +++++++- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 4ae4f91d8d..7752c00367 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -16,6 +16,43 @@ phpbb.add_ajax_callback('mark_forums_read', function(res) { $(this).removeClass('forum_unread_subforum').addClass('forum_read_subforum'); $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); }); + + $('li.row dl.forum_unread_locked').each(function(e) { + $(this).removeClass('forum_unread_locked').addClass('forum_read_locked'); + $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); + }); +}); + +// This callback will mark all topic icons read +phpbb.add_ajax_callback('mark_topics_read', function(res) { + var i,j; + var read_title = res.NO_UNREAD_POSTS; + var unread_title = res.UNREAD_POSTS; + var icons_array = [ + ['global_unread', 'global_read'], + ['announce_unread', 'announce_read'], + ['sticky_unread', 'sticky_read'], + ['topic_unread', 'topic_read'] + ]; + + var icons_state = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine']; + + // Make sure all icons are marked as read + for (i = 0; i < icons_array.length; i++) + { + for (j = 0; j < icons_state.length; j++) + { + $('li.row dl.' + icons_array[i][0] + icons_state[j]).each(function(e) { + $(this).removeClass(icons_array[i][0] + icons_state[j]).addClass(icons_array[i][1] + icons_state[j]); + $(this).children('dt[title=' + unread_title + ']').attr('title', read_title); + }); + } + } + + // Remove link to first unread post + $('span.icon_topic_newest').each(function(e) { + $(this).remove(); + }); }); // This callback finds the post from the delete link, and removes it. diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 0f2c1a30ec..b47c13d573 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -57,7 +57,7 @@