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

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

installing with PCP or split topic or topic calendar mods

Post by asinshesq »

To make things easier for people who are trying to install this keep unread mod on a board that has the PCP (profile control panel) mod, the split topic type mod or the topic calendar mod (or any or other mod that includes a file called includes/functions_topic_list.php), I'm repeating niksa's original solution here. In addition to the other changes that the keep unread mod requires you to make, you need to make the following change:

Code: Select all

OPEN
includes/functions_topic_list.php

FIND
		$newest_post_img = '';
			if ( $userdata['session_logged_in'] && ($topic_item_type == POST_TOPIC_URL) )
			{
				if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
				{
					if( !empty($tracking_topics) || !empty($tracking_forums) || !empty($tracking_all) )
					{
						$unread_topics = true;
						if( !empty($tracking_topics[$topic_id]) )
						{
							if( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
							{
								$unread_topics = false;
							}
						}
						if( !empty($tracking_forums[$forum_id]) )
						{
							if( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
							{
								$unread_topics = false;
							}
						}
						if( !empty($tracking_all) )
						{
							if( $tracking_all >= $topic_rowset[$i]['post_time'] )
							{
								$unread_topics = false;
							}
						}
						if ( $unread_topics )
						{
							$folder_image = $folder_new;
							$folder_alt = $lang['New_posts'];
							$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
						}
						else
						{
							$folder_image = $folder;
							$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
							$newest_post_img = '';
						}
					}
					else
					{
						$folder_image = $folder_new;
						$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
						$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
					}
				}
				else 
				{
					$folder_image = $folder;
					$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
					$newest_post_img = '';
				}
			}
			else
			{
				$folder_image = $folder;
				$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
				$newest_post_img = '';
			}

REPLACE WITH
			//START MOD Keep_unread_2
			if( $topic_rowset[$i]['post_time'] > topic_last_read($forum_id, $topic_id) )
			{
				$folder_image = $folder_new;
				$folder_alt = $lang['New_posts'];      
				$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';  
			}
			else
			{
				$folder_image = $folder;
				$folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
				$newest_post_img = '';
			}
			//END MOD Keep_unread_2
kyle1745
Registered User
Posts: 173
Joined: Thu Nov 14, 2002 2:21 am

Post by kyle1745 »

Well Im wondering if he just assumed it was for PCP as that code was not commented out on my board, and it seemed to work perfect with it. Even without the additional code that he had but I added that anyways.

If your building a new version it would be nice to have some pre canned .txt files with the 60day limit and etc. My other suggestion would be a way to turn it on and off so that users could choose if they want the feature or not.

I just happy its working as its a great mod.
asinshesq wrote:
kyle1745 wrote:Ok I got it working. It turns out with PCP you need both sets of code, and not replace the code in Niksas post. Or at least for my board that worked....

Are you saying that you should ignore the first part of niksa's post where he says don't make a certain change on viewforum because (he says) that part is commented out on a pcp board anyway? So the only change you needed to make from the normal script was to do the FIND and REPLACE WITH that he tells you to do in includes/functions_topic_list.php? Thanks for that investigative work.
My next question though is about the SQL optimzation mod. What is considered a HUGE amount of concurrent traffic? 10 users? 50? 1000?


Don't worry about it...I'll be releaseing an upgrade to 2.0.5 soon that will give everyone a sligtly changed version of the more optimized sql so for now hang in there.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

new version: 2.0.5

Post by asinshesq »

I've just finisihed a new version (version 2.0.5). Here's the changelog for the last two versions:

Code: Select all

##   2006-06-01 - Version 2.0.5
##		- Optimized the query in the list_new_unreads function (thanks for the idea, bigwebmaster); and 
##		  changed the code so that list_new_unreads only gets run a single time when the user is on index.php
##		  (before this change, index.php ran list_new_unreads a first time and page_header.php ran it a second time)
##		- Put in code that will allow people to easily add a toggling link ("View your unread posts" versus 
##		  "You have no unread posts") on pages other than index.php (see author's notes for how to add links)
##		- Changed viewtopic.php so that the mod will work regardless of whether viewtopic is set
##		  to display from oldest to newest or newest to oldest
##
##   2006-05-20 - Version 2.0.4
##		- Changes to conform to phpbb2.0.20 changes (only relevant for the mod itself, 
##		  not the upgrade...but if you already have keep unread installed and
##		  are trying to upgrade phpbb from 2.0.19 to 2.0.20 and are stuck because of 
##		  this mod, see http://www.phpbb.com/phpBB/viewtopic.php?p=2082858#2082858 for help)
##		- Fixed bugs that would trigger an error for banned users and that would show 
##		  guests that there are unread posts in forums they are not authorized as guests
##		  to view on boards with mod to the mod to change view unread posts link installed
##		- Optimized the queries for the mod to the mod to change view unread 
##		  posts link so that the code runs fewer queries to get to the same result
##		- Changed basic mod so that the link will now read "View unread posts" if there 
##		  are any and "You have no unread posts" if there aren't any
##		- Changed index_body.tpl to ensure that users would see the mark all forums read 
##		  link even if they are not logged in.
##		- Changed the author's notes to include links to posts showing how
##		  to make this mod compatible with the simple subforums mod, 
##		  the old version of categories hierarchy mod,
##		  the latest topics on index mod and the post sort order mod
##		- Changed author's notes to show how to add the number of topics with unread posts 
##		  to the link, and how to add a link to the page that shows a list of unread posts 
##		  that lets the user mark all posts read
##		- Changed the author's note about adding a text link for marking a post unread so that 
##		  the link appears on the far right in the same font as the 'Back to Top' link that
##		  appears on the far left
If you are still on version 2.0.3c and you want to use the upgrade scripts I've included in the download, you'll need to upgrade first to 2.0.4 and then to 2.0.5. Make sure to read the author's notes in the upgrade scripts because, for example, you'll need to delete part of the script depending on whether you are using the mod to the mod that changes the text of the view unread posts link.

I plan to submit the new version for validation in mid June 2006.
ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Post by ABDev »

Hi asinshesq,
Nice MOD, I like it :)
I have one problem since I updated it in the 2.0.4 version :)
If I modify the permissions of all my forums, and if the Read permissions are for the registered members, when a guest comes on my board, he has this error :?

Code: Select all

Erreur Générale
Could not query new topic information

DEBUGGAGE

Vous avez une erreur de syntaxe dans votre requête SQL. Si vous venez de modifier vos fichiers phpBB (en installant un MOD, FIX ou bien une mise à jour), reprenez les étapes de l'installation de cette modification.

Erreur SQL: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND t.topic_moved_id = 0' at line 5


Requête SQL: 
SELECT t.forum_id, t.topic_id, p.post_time FROM phpbb_topics t, phpbb_posts p WHERE p.post_id = t.topic_last_post_id AND p.post_time > 1149337541 AND t.forum_id IN () AND t.topic_moved_id = 0 


Ligne: 1985
Fichier: /home/www/xxxxxxxxxxx/web/XXXXX/includes/functions.php


Code de l'erreur trouvée: 
Ligne-1975:   $sql = "SELECT t.forum_id, t.topic_id, p.post_time 
Ligne-1976:   FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
Ligne-1977:   WHERE p.post_id = t.topic_last_post_id 
Ligne-1978:   $sql_and[$i] 
Ligne-1979:   $check_auth_sql 
Ligne-1980:   AND t.topic_moved_id = 0"; 
Ligne-1981:   
Ligne-1982:   if ( !($result = $db->sql_query($sql)) ) 
Ligne-1983:   { 
Ligne-1984:   message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql); 
Ligne-1985:   }
I hope you'll have an idea ;)
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

ABDev wrote: Hi asinshesq,
Nice MOD, I like it :)
I have one problem since I updated it in the 2.0.4 version :) ...


Do you mean version 2.0.5?
ABDev
Registered User
Posts: 905
Joined: Sun Aug 21, 2005 9:29 pm
Location: France
Name: Adrien Bonnel

Post by ABDev »

No, 2.0.4 :wink:

Code: Select all

##############################################################
## MOD Title:		keep unread flags
##
## MOD Author: Merlin Sythove < N/A > (N/A) N/A
## MOD Author: asinshesq < N/A > (Alan) N/A
## MOD Author: Ptirhiik < N/A > (Pierre) http://rpgnet.clanmckeen.com
##
## MOD Description:	This mod keeps the unread flags for a topic active until the topic is read.
##			It also activates the new post feature for guests.
##
##			The following are new features as a result of the upgrades in May 2005 and 2006:
##
##			1.	Solves the bugs that sometimes gave a user an unread flag on
##				his or her own posts, sometimes gave a user an unread flag on other posts that
##				he or she had already read and sometimes caused a user to lose all unread flags.
##
##			2.	Keeps unread flags beyond the current page of a topic until
##				the user actually visits that page.
##
##			3. 	Gives the user a new yellow button on each post (right next
##				to the quote button) that allows the user to mark the topic unread
##				again from that post onwards (a sort of bookmark function).
##
##			4.	Changes text of unread post link that appears on index page so that
##				it reads "View your unread posts" or "You have no unread posts"
##				depending on whether or not the user has unread posts.
##
## MOD Version:		2.0.4
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

That doesn't prove it's 2.0.4 since I may have made a mistake in the numbering ;). Take a look at the name of the zip file and see if it's called 2.0.4 or 2.0.5.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

ABDev wrote: No, 2.0.4 :wink:

Code: Select all

##############################################################
## MOD Title:		keep unread flags
##
## MOD Author: Merlin Sythove < N/A > (N/A) N/A
## MOD Author: asinshesq < N/A > (Alan) N/A
## MOD Author: Ptirhiik < N/A > (Pierre) http://rpgnet.clanmckeen.com
##
## MOD Description:	This mod keeps the unread flags for a topic active until the topic is read.
##			It also activates the new post feature for guests.
##
##			The following are new features as a result of the upgrades in May 2005 and 2006:
##
##			1.	Solves the bugs that sometimes gave a user an unread flag on
##				his or her own posts, sometimes gave a user an unread flag on other posts that
##				he or she had already read and sometimes caused a user to lose all unread flags.
##
##			2.	Keeps unread flags beyond the current page of a topic until
##				the user actually visits that page.
##
##			3. 	Gives the user a new yellow button on each post (right next
##				to the quote button) that allows the user to mark the topic unread
##				again from that post onwards (a sort of bookmark function).
##
##			4.	Changes text of unread post link that appears on index page so that
##				it reads "View your unread posts" or "You have no unread posts"
##				depending on whether or not the user has unread posts.
##
## MOD Version:		2.0.4


Something is strange here. You are right that the introductory part you quote is from 2.0.4, but the lines you quote from functions.php are from 2.0.5. Specifically, you quote these lines from your board in your earlier post:

Code: Select all

Code de l'erreur trouvée:
Ligne-1975:   $sql = "SELECT t.forum_id, t.topic_id, p.post_time
Ligne-1976:   FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
Ligne-1977:   WHERE p.post_id = t.topic_last_post_id
Ligne-1978:   $sql_and[$i]
Ligne-1979:   $check_auth_sql
Ligne-1980:   AND t.topic_moved_id = 0";
Ligne-1981:   
Ligne-1982:   if ( !($result = $db->sql_query($sql)) )
Ligne-1983:   {
Ligne-1984:   message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql);
Ligne-1985:   }
and I note that I only introduced the variable $sql_and[$i] that appears in your quote in version 2.0.5. So, please let me know what version we're really talking about.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

ABDev wrote: Hi asinshesq,
Nice MOD, I like it :)
I have one problem since I updated it in the 2.0.4 version :)
If I modify the permissions of all my forums, and if the Read permissions are for the registered members, when a guest comes on my board, he has this error :?

Code: Select all

Erreur Générale
Could not query new topic information

DEBUGGAGE

Vous avez une erreur de syntaxe dans votre requête SQL. Si vous venez de modifier vos fichiers phpBB (en installant un MOD, FIX ou bien une mise à jour), reprenez les étapes de l'installation de cette modification.

Erreur SQL: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND t.topic_moved_id = 0' at line 5


Requête SQL: 
SELECT t.forum_id, t.topic_id, p.post_time FROM phpbb_topics t, phpbb_posts p WHERE p.post_id = t.topic_last_post_id AND p.post_time > 1149337541 AND t.forum_id IN () AND t.topic_moved_id = 0 


Ligne: 1985
Fichier: /home/www/xxxxxxxxxxx/web/XXXXX/includes/functions.php


Code de l'erreur trouvée: 
Ligne-1975:   $sql = "SELECT t.forum_id, t.topic_id, p.post_time 
Ligne-1976:   FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p 
Ligne-1977:   WHERE p.post_id = t.topic_last_post_id 
Ligne-1978:   $sql_and[$i] 
Ligne-1979:   $check_auth_sql 
Ligne-1980:   AND t.topic_moved_id = 0"; 
Ligne-1981:   
Ligne-1982:   if ( !($result = $db->sql_query($sql)) ) 
Ligne-1983:   { 
Ligne-1984:   message_die(GENERAL_ERROR, 'Could not query new topic information', '', __LINE__, __FILE__, $sql); 
Ligne-1985:   }
I hope you'll have an idea ;)


As I look more closely at the error you are showing, it appears to me that (a) you are using 2.0.5 rather than 2.0.4 and (b) you made some mistakes in upgrading the mod. How did you upgarde? Did you start with 2.0.3c and tghen upgard first to 2.0.4 and then to 2.0.5 or did you do something else?

How about posting the entire function called list_new_unreads() that appears in includes/functions.php and we'll take a look.
WebSnail
Registered User
Posts: 524
Joined: Sun Nov 11, 2001 2:20 pm
Location: South Yorkshire, UK
Contact:

Post by WebSnail »

Just a quick mod suggestion for you.

This code change allows your users to see how many unread posts have been posted..

Open: index.php

Find:

Code: Select all

	//MOD Keep_unread_2 * Get new_unreads list and forum_unread flags, save cookies etc.
	$new_unreads = list_new_unreads($forum_unreads, $toggle_unreads_link);
After, Add:

Code: Select all

// MOD View_posts_since_last_visit_number && Keep unread
	if( $userdata['session_logged_in'] ) 
	{ 
		$lang['View_unread_posts'] = $lang['View_unread_posts'] . " (".count($new_unreads).")"; 
	}

// MOD END View_posts_since_last_visit_number && Keep unread
Nothing too fancy but it seems to work pretty well :)
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

WebSnail wrote: Just a quick mod suggestion for you.

This code change allows your users to see how many unread posts have been posted..

Open: index.php

Find:

Code: Select all

	//MOD Keep_unread_2 * Get new_unreads list and forum_unread flags, save cookies etc.
	$new_unreads = list_new_unreads($forum_unreads, $toggle_unreads_link);
After, Add:

Code: Select all

// MOD View_posts_since_last_visit_number && Keep unread
	if( $userdata['session_logged_in'] ) 
	{ 
		$lang['View_unread_posts'] = $lang['View_unread_posts'] . " (".count($new_unreads).")"; 
	}

// MOD END View_posts_since_last_visit_number && Keep unread
Nothing too fancy but it seems to work pretty well :)


Thanks, good suggestion, but keep in mind that doing that will (I think) give you the number of topics that have unread posts in them rather than the number of unread posts. Correct?
cTak
Registered User
Posts: 11
Joined: Tue Mar 28, 2006 9:35 pm

Post by cTak »

I was up to date with 2.0.20 but this morning I saw and updated to 2.0.21.


I have this mod, and the updates to not work with this mod, in search.php.


Anyone have an update for this mod and phpbb 2.0.21?

I had to roll back to my old version of search.php.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

cTak wrote: I was up to date with 2.0.20 but this morning I saw and updated to 2.0.21.


I have this mod, and the updates to not work with this mod, in search.php.


Anyone have an update for this mod and phpbb 2.0.21?

I had to roll back to my old version of search.php.


I'll try to get around to doing that tonight if I have a chance...
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

asinshesq wrote:
cTak wrote:I was up to date with 2.0.20 but this morning I saw and updated to 2.0.21.


I have this mod, and the updates to not work with this mod, in search.php.


Anyone have an update for this mod and phpbb 2.0.21?

I had to roll back to my old version of search.php.


I'll try to get around to doing that tonight if I have a chance...


To be clear, I'll be adjusting themod so that it will cleanly install on phpbb2.0.21, but I wasn't planning on providing a specific path showing how someone who already has the mod installed on phpbb2.0.20 can upgrade to phpbb2.0.21. That effort is straightfoward enough...if you have specific questions feel free to ask.
WebSnail
Registered User
Posts: 524
Joined: Sun Nov 11, 2001 2:20 pm
Location: South Yorkshire, UK
Contact:

Post by WebSnail »

asinshesq wrote: Thanks, good suggestion, but keep in mind that doing that will (I think) give you the number of topics that have unread posts in them rather than the number of unread posts. Correct?

Whoops, so it does...

I guess a little additional editing required :)
Post Reply

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