Mark Moderator and Administrator posts as read

Any and all modifications I have created for phpBB3 will be listed here and support will be provided.
Locked
DavidIQ
Site Admin
Posts: 619
Joined: Thu Sep 07, 2006 4:31 pm
Location: Earth
Contact:

Mark Moderator and Administrator posts as read

Post by DavidIQ »

Based on a request over on phpbb.com, I have come up with these changes to add a link to mark moderator and admin posts as read. I might eventually make it MODX compatible and submit it to the MODDB but at the moment it's just a "Hack".

Open viewforum.php

Find

Code: Select all

	trigger_error($user->lang['TOPICS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
}
Add after:

Code: Select all

else if ($mark_read == 'modadmin')
{
	markread('modadmin', $forum_id);

	$redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id);
	meta_refresh(3, $redirect_url);

	trigger_error('All moderator and administrator posts in this forum have been marked as read.<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>'));
}
Open includes/functions.php

Find

Code: Select all

}

/**
* Get topic tracking info by using already fetched info
*/
Add before:

Code: Select all

	else if ($mode == 'modadmin')
	{
		if ($config['load_db_lastread'] && $user->data['is_registered'])
		{
			// Mark all moderator and administrator postings read (index page)
			$db->sql_query('DELETE FROM ' . TOPICS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']} 
					AND topic_id IN (SELECT DISTINCT t.topic_id FROM phpbb_topics t 
					LEFT JOIN " . USERS_TABLE . " u ON u.user_id = t.topic_last_poster_id
					LEFT JOIN " . USER_GROUP_TABLE . " ug ON ug.user_id = u.user_id
					LEFT JOIN " . MODERATOR_CACHE_TABLE . " m ON m.group_id = ug.group_id 
					LEFT JOIN " . GROUPS_TABLE . " g ON g.group_id = ug.group_id
					WHERE u.user_type = " . USER_FOUNDER . " 
					OR g.group_name IN ('ADMINISTRATORS', 'GLOBAL_MODERATORS')
					OR m.group_id IS NOT NULL)" . (!$forum_id ? '' : ' AND forum_id = ' . $forum_id));
			$db->sql_query('DELETE FROM ' . FORUMS_TRACK_TABLE . " WHERE user_id = {$user->data['user_id']} AND forum_id NOT IN (SELECT forum_id FROM phpbb_topics_track WHERE user_id = {$user->data['user_id']})" . (!$forum_id ? '' : ' AND forum_id = ' . $forum_id));
			$db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_lastmark = ' . time() . " WHERE user_id = {$user->data['user_id']}");
		}
		
		return;
	}
Open includes/functions_display.php

Find

Code: Select all

	// Handle marking posts
	if ($mark_read == 'forums' || $mark_read == 'all')
	{
Replace with

Code: Select all

	// Handle marking posts
	if ($mark_read == 'forums' || $mark_read == 'all' || $mark_read == 'modadmin')
	{
Find

Code: Select all

		if ($mark_read == 'all')
		{
			markread('all');

			$message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
		}
Add after

Code: Select all

		else if ($mark_read == 'modadmin')
		{
			markread('modadmin');
			
			$message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
		}
Find

Code: Select all

			trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
Replace with

Code: Select all

		if ($mark_read != 'modadmin')
		{
			trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
		}
		else
		{
			trigger_error('All moderator and administrator posts have been marked as read.<br /><br />' . $message);		
		}
Open styles/prosilver/template/index_body.html

Find

Code: Select all

	<!-- IF not S_IS_BOT and U_MARK_FORUMS --><li class="rightside"><a href="{U_MARK_FORUMS}" accesskey="m">{L_MARK_FORUMS_READ}</a></li><!-- ENDIF -->
Replace with

Code: Select all

	<!-- IF not S_IS_BOT and U_MARK_FORUMS --><li class="rightside"><a href="{U_MARK_FORUMS}" accesskey="m">{L_MARK_FORUMS_READ}</a><!-- IF S_USER_LOGGED_IN --> &bull; <a href="./index.php?mark=modadmin">Mark mod and admin posts as read</a><!-- ENDIF --></li><!-- ENDIF -->
Open styles/prosilver/template/viewforum_body.html

Find

Code: Select all

			<!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a> &bull; <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF -->
Replace with

Code: Select all

			<!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a><!-- IF U_MCP --> &bull; <a href="./viewforum.php?f={FORUM_ID}&mark=modadmin">Mark mod and admin posts as read</a><!-- ENDIF --> &bull; <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF -->
Find

Code: Select all

			<!-- IF TOTAL_TOPICS and not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a> &bull;  <!-- ENDIF -->
Replace with

Code: Select all

			<!-- IF TOTAL_TOPICS and not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a><!-- IF U_MCP --> &bull; <a href="./viewforum.php?f={FORUM_ID}&mark=modadmin">Mark mod and admin posts as read</a><!-- ENDIF --> &bull;  <!-- ENDIF -->
Refresh template and voila! Sample is on this site.
Locked