keep unread flags

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
72
75%
Very Good
16
17%
Good
4
4%
Fair
0
No votes
Poor
4
4%
 
Total votes: 96

User avatar
Wicher
Registered User
Posts: 1806
Joined: Wed May 07, 2003 10:33 pm
Location: Netherlands or Holland, your choice..
Contact:

Post by Wicher »

@Merlin: I am oke with that, would be very pleased in fact.
I also posted it at the home forum of the subforums mod: http://www.pentapenguin.com/forum/viewtopic.php?t=1416
And submitted it to phpbbhacks.com.
If it on phpbbhacks, i will post a link to it here.

In addition to the fix, because i did it one way direction:
If you installed the subforums before unread, then delete from your viewforum.php the codes that i mentioned in this fix to delete from the subforums install file.
After that, install the keep unread flags.

In addition to all that, here is a peace of code from the fix that can be pretty important, for every template the css will be named different, ie: subSilver.css will be in a template called Artemis Artemis.css.

Code: Select all

# 
# OPEN 
# 
subsiver.css 
# 
# FIND 
# 
/* General font families for common tags */ 
# 
# ADD AFTER (BECAUSE WITH SOME TEMPLATES I DONT WORK OTHERWISE) 
# 
a.topic-new, a.topic-new:visited { color: #ffff00; } 
a.topic-new:hover, a.topic-new:active { color: #ffff00; } 
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

That is fine. I suggest that when there are no more bugs and changes, that you create a single update file and send that to asinshesq to add to the zip, that is probably easiest, and then we can also update the first post to say that the simple subforums mod is supported etc.
sikita
Registered User
Posts: 47
Joined: Tue Jun 29, 2004 9:40 am

THANKS

Post by sikita »

Good work Wicher... thanks a lot! This is what we needed! THANKS THANKS

:idea: :idea: :idea: :idea: :idea: :idea: :idea: :idea: :idea:
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Wicher wrote: ...I also posted it at the home forum of the subforums mod: http://www.pentapenguin.com/forum/viewtopic.php?t=1416
And submitted it to phpbbhacks.com.
If it on phpbbhacks, i will post a link to it here....

What about the subforums topic on this board here: http://www.phpbb.com/phpBB/viewtopic.php?t=336974
Merlin wrote: ...I suggest that when there are no more bugs and changes, that you create a single update file and send that to asinshesq to add to the zip, that is probably easiest, and then we can also update the first post to say that the simple subforums mod is supported etc.

That would only be true if we formally submitted the mod for validation here and it went through the process. And that would require some tinkering so that the mod is in the right format for official phpbb validated mods. I guess when Wicher is sure he's done he can pm me the code and I'll repackage it so that it looks like an official mod and then I can submit a new version of keep unreads with that as an additional folder in the contrib folder, but it will take about a month or so to get that validated before it appears in the file that you get when you click the link in the first post of this topic.
White Shadow
Registered User
Posts: 3
Joined: Sat Jan 07, 2006 1:19 pm
Location: Portugal

Post by White Shadow »

Good work! :wink:
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

[quote="asinshesq...That would only be true if we formally submitted the mod for validation...[/quote]

I leave that up to you, if it is worth it, or if we should simply mention the addition with a link in the first post.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Merlin Sythove wrote:
asinshesq wrote:...That would only be true if we formally submitted the mod for validation...


I leave that up to you, if it is worth it, or if we should simply mention the addition with a link in the first post.

We have no power to amend the first post, but we could mention it in the first post one of us made in this topic.
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Post by Mickey14 »

Hello, on several places, it is made mention to the compatibility of this new Keep Unread MOD with category hierarchy prior to 2.1. So far, I did not see any such compatibility file.

I applied this to my CH 2.0.4 equiped board, and it works with Keep Unread 2.0.3c.

Most of this come from the original "Part4" file from Ptirhiik, I adapted the rest for the new KeepUnread.

Hoping this helps,

Michel

Code: Select all

## Files To Edit:
##			index.php
##			includes/functions_categories_hierarchy.php

#
#-----[ OPEN ]------------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : Keep_unread_2 -----------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	if( $userdata['session_logged_in'] )
	{
		setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
	}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//START MOD Keep_unread_2 * Mark everything as read
//MOD Keep_unread_2 * deleted
//	if( $userdata['session_logged_in'] )
//	{
//		setcookie($board_config['cookie_name'] . '_f_all', time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
//	}
//-- add
		// set the cookie to mark all and clean the others
		$board_config['tracking_all'] = time();
		$board_config['tracking_forums'] = array();
		$board_config['tracking_topics'] = array();
		$board_config['tracking_unreads'] = array();
		write_cookies($userdata);
//END MOD Keep_unread_2
#
#-----[ FIND ]------------------------------------------------
#
		if( $userdata['session_logged_in'] )
		{
			// get the list of object authorized
			$keys = array();
			$keys = get_auth_keys($viewcatkey);

			// mark each forums
			for ($i=0; $i < count($keys['id']); $i++) if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
			{
				$forum_id = $tree['id'][ $keys['idx'][$i] ];
				$sql = "SELECT MAX(post_time) AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id";
				if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
				if ( $row = $db->sql_fetchrow($result) )
				{
					$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
					$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();

					if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
					{
						asort($tracking_forums);
						unset($tracking_forums[key($tracking_forums)]);
					}

					if ( $row['last_post'] > $userdata['user_lastvisit'] )
					{
						$tracking_forums[$forum_id] = time();
						setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
					}
				}
			}
		}
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//START MOD Keep_unread_2
//MOD Keep_unread_2 * deleted
/*
//		if( $userdata['session_logged_in'] )
//		{
//			// get the list of object authorized
//			$keys = array();
//			$keys = get_auth_keys($viewcatkey);
//
//			// mark each forums
//			for ($i=0; $i < count($keys['id']); $i++) if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
//			{
//				$forum_id = $tree['id'][ $keys['idx'][$i] ];
//				$sql = "SELECT MAX(post_time) AS last_post FROM " . POSTS_TABLE . " WHERE forum_id = $forum_id";
//				if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
//				if ( $row = $db->sql_fetchrow($result) )
//				{
//					$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
//					$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
//
//					if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
//					{
//						asort($tracking_forums);
//						unset($tracking_forums[key($tracking_forums)]);
//					}
//
//					if ( $row['last_post'] > $userdata['user_lastvisit'] )
//					{
//						$tracking_forums[$forum_id] = time();
//						setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
//					}
//				}
//			}
//		}
*/
//-- add
		// get the list of object authorized
		$keys = array();
		$keys = get_auth_keys($viewcatkey);

		// mark each forums
		for ($i=0; $i < count($keys['id']); $i++)
		{
			if ($tree['type'][ $keys['idx'][$i] ] == POST_FORUM_URL)
			{
				$forum_id = $tree['id'][ $keys['idx'][$i] ];
				$board_config['tracking_forums'][$forum_id] = time(); //right now
				$list_topics = implode(',', array_keys($board_config['tracking_unreads'])); //all tracking topic_id's
				if ($list_topics)
				{ //Get all the topics that are in this forum
					$sql = "SELECT topic_id
						FROM " . TOPICS_TABLE . "
						WHERE topic_id IN ($list_topics)
						AND forum_id = $forum_id AND topic_moved_id = 0";
					if ( !$result = $db->sql_query($sql) )
					{
						message_die(GENERAL_ERROR, 'Could not access topics', '', __LINE__, __FILE__, $sql);
					}
					while ( $row = $db->sql_fetchrow($result) ) //Clean them
					{
						$id = $row['topic_id'];
						if ( isset($board_config['tracking_unreads'][$id]) )	unset($board_config['tracking_unreads'][$id]);
					}
				}
			}
		}
		write_cookies($userdata); //Save
//END MOD Keep_unread_2
#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_categories_hierarchy.php
#
#-----[ FIND ]------------------------------------------------
#
<?php
#
#-----[ AFTER, ADD ]------------------------------------------
#
//-- mod : Keep_unread_2 -----------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	// read the user cookie
	$tracking_topics	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
	$tracking_forums	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
	$tracking_all		= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) ? intval($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) : -1;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//START MOD Keep_unread_2
//MOD Keep_unread_2 * deleted
/*
	// read the user cookie
	$tracking_topics	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array();
	$tracking_forums	= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array();
	$tracking_all		= ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) ) ? intval($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) : -1;
*/
//END MOD Keep_unread_2
//-- fin mod : keep unread -------------------------------------------------------------------------
#
#-----[ FIND ]------------------------------------------------
#
	// read the last or unread posts
	$user_lastvisit = $userdata['session_logged_in'] ? $userdata['user_lastvisit'] : 99999999999;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
	// read the last or unread posts
//START MOD Keep_unread_2
//MOD Keep_unread_2 * deleted
/*
	// read the last or unread posts
	// 60 days limit
	if ($userdata['user_lastvisit'] < (time() - 5184000))
	{
		$userdata['user_lastvisit'] = time() - 5184000;
	}
	$user_lastvisit = $userdata['session_logged_in'] ? $userdata['user_lastvisit'] : 99999999999;
	$sql = "SELECT p.forum_id, p.topic_id, p.post_time, p.post_username, u.username, u.user_id, t.topic_last_post_id, t.topic_title
				FROM ((" . POSTS_TABLE . " p
					LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = p.topic_id AND t.forum_id = p.forum_id AND t.topic_moved_id = 0)
					LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
				WHERE ( p.post_time > $user_lastvisit $sql_last_posts )
					 AND p.post_id = t.topic_last_post_id";
*/
//	Get new_unreads list and forum_unread flags, save cookies etc.
	$new_unreads = list_new_unreads($forum_unreads);
	$list_unreads = implode(',', array_keys($new_unreads));
	$sql_unreads = empty($list_unreads) ? "" : "p.topic_id IN (" . $list_unreads . ")";
	if (!empty($sql_unreads) && !empty($sql_last_posts)) $sql_unreads .= " OR ";
	if (!empty($sql_unreads) || !empty($sql_last_posts))
	{
		$sql_unreads = " ( " . $sql_unreads;
		$sql_last_posts .= " ) AND ";
	}
	
	$sql = "SELECT p.forum_id, p.topic_id, p.post_time, p.post_username, u.username, u.user_id, t.topic_last_post_id, t.topic_title
				FROM ((" . POSTS_TABLE . " p
					LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = p.topic_id AND t.forum_id = p.forum_id AND t.topic_moved_id = 0)
					LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
				WHERE $sql_unreads $sql_last_posts
					  p.post_id = t.topic_last_post_id";
//END MOD Keep_unread_2
#
#-----[ FIND ]------------------------------------------------
#
		if ( $row['post_time'] > $user_lastvisit )
		{
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//START MOD Keep_unread_2
//MOD Keep_unread_2 * deleted
/*
		if ( $row['post_time'] > $user_lastvisit )
*/
		if ( $row['post_time'] > topic_last_read($row['forum_id'], $row['topic_id']) )
//END MOD Keep_unread_2
#
#-----[ FIND ]------------------------------------------------
#
					if ( empty($tracking_topics[$check_topic_id]) )
					{
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//START MOD Keep_unread_2
//MOD Keep_unread_2 * deleted
/*
					if ( empty($tracking_topics[$check_topic_id]) )
					{
*/
//END MOD Keep_unread_2
#
#-----[ FIND ]------------------------------------------------
#
					}
					else
					{
						if ( $tracking_topics[$check_topic_id] < $check_post_time )
						{
							$unread_topics = true;
							$forum_last_post_time = max($check_post_time, $forum_last_post_time);
						}
					}
				}

				// is there a cookie for this forum ?
				if ( !empty($tracking_forums[$forum_id]) )
				{
					if ( $tracking_forums[$forum_id] > $forum_last_post_time )
					{
						$unread_topics = false;
					}
				}

				// is there a cookie for all forums ?
				if ( $tracking_all > $forum_last_post_time )
				{
					$unread_topics = false;
#
#-----[ REPLACE WITH ]---------------------------------------- 
#
//START MOD Keep_unread_2
//MOD Keep_unread_2 * deleted
/*
					}
					else
					{
						if ( $tracking_topics[$check_topic_id] < $check_post_time )
						{
							$unread_topics = true;
							$forum_last_post_time = max($check_post_time, $forum_last_post_time);
						}
					}
				}

				// is there a cookie for this forum ?
				if ( !empty($tracking_forums[$forum_id]) )
				{
					if ( $tracking_forums[$forum_id] > $forum_last_post_time )
					{
						$unread_topics = false;
					}
				}

				// is there a cookie for all forums ?
				if ( $tracking_all > $forum_last_post_time )
				{
					$unread_topics = false;
*/
//END MOD Keep_unread_2
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM
User avatar
Wicher
Registered User
Posts: 1806
Joined: Wed May 07, 2003 10:33 pm
Location: Netherlands or Holland, your choice..
Contact:

Post by Wicher »

@mickey14:
i think you are talking about Categories Hierarchy (Sub Forums)?
"http://www.phpbbhacks.com/download/978"

Why would you use the simple subforums mod with that mod?
It has the keep unread AND the subforums in one.
User avatar
Wicher
Registered User
Posts: 1806
Joined: Wed May 07, 2003 10:33 pm
Location: Netherlands or Holland, your choice..
Contact:

Post by Wicher »

asinshesq wrote:
Wicher wrote:...I also posted it at the home forum of the subforums mod: http://www.pentapenguin.com/forum/viewtopic.php?t=1416
And submitted it to phpbbhacks.com.
If it on phpbbhacks, i will post a link to it here....

What about the subforums topic on this board here: http://www.phpbb.com/phpBB/viewtopic.php?t=336974
Merlin wrote: ...I suggest that when there are no more bugs and changes, that you create a single update file and send that to asinshesq to add to the zip, that is probably easiest, and then we can also update the first post to say that the simple subforums mod is supported etc.

That would only be true if we formally submitted the mod for validation here and it went through the process. And that would require some tinkering so that the mod is in the right format for official phpbb validated mods. I guess when Wicher is sure he's done he can pm me the code and I'll repackage it so that it looks like an official mod and then I can submit a new version of keep unreads with that as an additional folder in the contrib folder, but it will take about a month or so to get that validated before it appears in the file that you get when you click the link in the first post of this topic.


I also posted this fix to the home forum of the simple subforums mod.
http://www.pentapenguin.com/forum/viewt ... c&start=60
I will also put a link to this post to the topic you mentiond.

I will send you this fix by pm asinshesq, and leave it up to you how you will go from here.
I think it is bug free but i am no php expert, this allready took me weeks to figure out, offcourse i slept a few hours :D , so if you see something in the fix that could be better just go for it.
Maybe you can contact pentapenguin and work make it a joined "project".
Would be nice i think.
User avatar
Ptirhiik
Registered User
Posts: 7411
Joined: Mon Jan 06, 2003 10:36 pm
Contact:

Post by Ptirhiik »

Wicher wrote: @mickey14: i think you are talking about Categories Hierarchy (Sub Forums)?
mickey14 was refering to older versions of CH (prior 2.1.0) which didn't included the keep unread functionality. Though they were compatible with the old Keep Unreads Flag mod, but not the new. This is for compliancy with the older CH plus the new Keep Unread Flag.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Wicher, I've taken the liberty of turning what you posted into a single mod that complies with the usual phpbb mod format with instructions about how to use it depending on whether you start with keep unread and want to add simple subforums or vice versa. I haven't tested any of this (I just accepted the code you wrote) but hopfeully it will work fine. If it works correctly and you agree that this is a little easier to follow, we can either (a) link to this post or (b) have you paste the code into one of your posts in lieu of the earlier code and we can then link to your post (and if you do that I'll go ahead and delete the code here so that we don't repeat all that code twice).

[edit: I've deleted this code since it is superseded by the post here: http://www.phpbb.com/phpBB/viewtopic.ph ... 55#1947755 ]
Last edited by asinshesq on Thu Jan 12, 2006 12:36 pm, edited 2 times in total.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Mickey14 wrote: Hello, on several places, it is made mention to the compatibility of this new Keep Unread MOD with category hierarchy prior to 2.1. So far, I did not see any such compatibility file.

I applied this to my CH 2.0.4 equiped board, and it works with Keep Unread 2.0.3c.

Most of this come from the original "Part4" file from Ptirhiik, I adapted the rest for the new KeepUnread.

Hoping this helps

Thanks for that contribution, Michel!
User avatar
Wicher
Registered User
Posts: 1806
Joined: Wed May 07, 2003 10:33 pm
Location: Netherlands or Holland, your choice..
Contact:

Post by Wicher »

@asinshesq

I edited my post at http://www.phpbb.com/phpBB/viewtopic.ph ... 96#1920396, before i read your post about yours.
I added in the fix also the other way around id the simple subforums mod allready was installed.
Sadly my way looks far more complicated than yours.
I hope you will add that other way arround also to your way, and go with that.
Thanks, Wicher.
I'll pm it to you also now.

[EDIT]Sorry asinshesq, did not read your version very good until now, i saw that you allredy included the otherway arround. THank you very mutch.[END EDIT]

@pitriick, thanks for the explanation.
Last edited by Wicher on Sat Jan 07, 2006 8:12 pm, edited 1 time in total.
Mickey14
Registered User
Posts: 88
Joined: Sat Mar 05, 2005 10:45 am

Post by Mickey14 »

Ptirhiik wrote:
Wicher wrote:@mickey14: i think you are talking about Categories Hierarchy (Sub Forums)?
mickey14 was refering to older versions of CH (prior 2.1.0) which didn't included the keep unread functionality. Though they were compatible with the old Keep Unreads Flag mod, but not the new. This is for compliancy with the older CH plus the new Keep Unread Flag.


Yes, sorry if it was unclear that it was targeted to the version of Category Hierarchy not including the keep unread feature. I posted this because of some requests around pages 23 of this topic I think... :oops:
asinshesq wrote: Thanks for that contribution, Michel!


You are welcome :D
Last edited by Mickey14 on Sat Jan 07, 2006 8:16 pm, edited 1 time in total.
Post Reply

Return to “[2.0.x] MOD Database Releases”