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
BrotherTank
Registered User
Posts: 73
Joined: Sun Jan 11, 2004 1:39 pm
Location: Hamilton, Ontario, Canada
Name: Greg
Contact:

Re: Simple Fix for Function: list_new_unreads

Post by BrotherTank »

Merlin Sythove wrote: "Bug" is a matter of opinion. I think that if you have read permission, you will automatically have view permission. How else can you view your own posts? If another mod changes that assumption and detaches read and view so you can read topics but not view them (where's the logic in that?) then I would hardly call that a bug in my mod :lol:


Ok... lol.. I viewed it the other way. In the permissions, if you go to the advanced mode, you can set the various permissions seperately - ie: View, Read, Post, & Reply. With the case of the Yellow Card mod, a user need only have Read & Post permissions to report the post. Thus a Forum Admin can hide the reported posts area by setting the View permission to Private, Mod, or Admin. In doing this, it does show a hole or bug in your code (as I see it lol..), in that it will list and search for unread posts to which the user has no View permission to the area in which those posts might be stored.

I did it this way as I didn't want the other 150 members (or guests for that matter) being able to view the reports generated when someone reports a post. If say user "reported" sees that user "reportee" has reported them for whatever reason, their could be a backlash against the reportee. It's much better if these types of things have some annonimity - or at least that made sense to me.

So, I needed a way to fix your program, so that it wasn't listing areas to which a user had no view permissions. This was the easiest fix that I could come up with. Now, I say bug or hole.. you say.. not... it's like the old "Potatoe" or "Pah-tah-toe" (phonetically spelled so you get the meaning). Same thing... really.. just 2 differences in perception. I was hoping that by your response, that you might look into it, seeing as one has varying control of the permissions. If you have a solution that uses less system resources - I am very interested in seeing it. And I'm not harping on this because I'm some sort of ass or the like.

So while you can argue the point - I've just given you a good example as to where someone will not have view permission but needs read and post. All I was suggesting is that you might want to either add the code I have given you or come up with your own code that closes a possible problem. I'm sure there are other mods that make use of simple little permission or auth tricks, and this way you will not have anyone questioning why your mod is reporting posts/threads to which a user has no view permissions. I know my users immediately PM'd me saying what is this and why can't I read on it when I click on the link provided (it was returning - Post does not exist - error), which is why I had to come up with the fix in the first place.
Merlin Sythove wrote: Anyway, glad you have solved it. If other people have similar problems I may have a look into it to see if there is a more elegant way of solving the "interference" :D Fornow, your solution seems to work just fine.


I'm glad it's solved too. I try to decipher what the mods do and see if I can come up with a solution before contacting the authors and asking for their help. In this case.. the code may not be the tightest, but for now it solves the problem of my users questioning what is going on, and why they can't read something that lists as unread.

I leave the code and solution in your hands... add it as a contrib - include it in the code - make it more efficient - doesn't matter to me. I just thought I would pass it along and possibly help you with any future problems when someone says why is it listing unread threads that a user has no right to view. Thanks for your responses and a very efficient and usefull mod.

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

Re: Simple Fix for Function: list_new_unreads

Post by asinshesq »

BrotherTank wrote: If you have a solution that uses less system resources - I am very interested in seeing it.

I likewise don';t see this as a bug (I think your application is a clever but counterintuitive use of the permissions system), but I also agree that it doesn't much matter whether it is a bug or not since you need to do something to make the two mods work together.

I'm not sure about this, but you can give this a try:

Code: Select all

		$is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
		if ( count($is_auth_ary) )
		{
			foreach ( $is_auth_ary as $forum_id => $auths )
			{
				if ( $auths['auth_read'] && $auths['auth_view'] )
				{
					$forum_ids[] = $forum_id;
				}
			}
		}
Merlin, does that look right to you?
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: Simple Fix for Function: list_new_unreads

Post by Merlin Sythove »

asinshesq wrote: Merlin, does that look right to you?


Yep, that is exactly how it should be done :D

The auth array requested is larger than the normal, so it will (theoretically) be slower.
Need custom work done? Pimp My Forum!
colin_bb
Registered User
Posts: 104
Joined: Tue Feb 14, 2006 8:40 pm

Post by colin_bb »

I think i have approached this from the other way that the above user has: i have installed keep_unread_posts mod first, and now would like to tweak it slightly to show the last topic that was posted on in that forum. I get the impression the other user had the topics_on_index mod installed first, then tried to install keep_unread mod.

With all the aspects of this mod, i couldn't be happier, but i am getting an earful from users who want to see what the last post was at a glance. :x
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

If it was the same one I had a look at earlier, then it should not be much of a problem .You should be able to install the modifications to the SQL statements at least. Try that first.
Need custom work done? Pimp My Forum!
colin_bb
Registered User
Posts: 104
Joined: Tue Feb 14, 2006 8:40 pm

Post by colin_bb »

I was able to follow the topic_on_index mod instructions up to line 112, so yes i modified one of the sql queries. The next instruction in the mod file is to find:

Code: Select all

//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
(line 114), and thats where the keep_unread_flags mod takes over.
User avatar
BrotherTank
Registered User
Posts: 73
Joined: Sun Jan 11, 2004 1:39 pm
Location: Hamilton, Ontario, Canada
Name: Greg
Contact:

Post by BrotherTank »

Thanks guys....

I still don't know all the options one can select or use when checking the auths - so your way does save time and reduce server thrashing...
I know we probably both still see it differently on the bug/no bug, but I'm glad that you were able to give me something that will allow me (and possibly others using similar setups) the ability to control things via the permissions.

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

Post by asinshesq »

colin_bb wrote: I was able to follow the topic_on_index mod instructions up to line 112, so yes i modified one of the sql queries. The next instruction in the mod file is to find:

Code: Select all

//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
(line 114), and thats where the keep_unread_flags mod takes over.


Maybe I don't understand what you are having problems with. The last topic mod asks you to place some code before

Code: Select all

	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
And you can see that the keep unread mod told you to change that code to

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);
	//END MOD Keep_unread_2
so you should put the code the last topic mod is talking about before

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);
	//END MOD Keep_unread_2
colin_bb
Registered User
Posts: 104
Joined: Tue Feb 14, 2006 8:40 pm

Post by colin_bb »

Your right. I done that, easymod seemed to find no other errors and installed successfully, but when i viewed my index i got this error message:
Could not query forums information

DEBUG MODE

SQL Error : 1066 Not unique table/alias: 't'

SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_id, t.topic_title, t.topic_last_post_id FROM (((( phpbb_forums f LEFT JOIN phpbb_posts p ON p.post_id = f.forum_last_post_id ) LEFT JOIN phpbb_topics t ON t.topic_last_post_id = p.post_id ) LEFT JOIN phpbb_topics t ON t.topic_last_post_id = p.post_id ) LEFT JOIN phpbb_users u ON u.user_id = p.poster_id ) ORDER BY f.cat_id, f.forum_order

Line : 188
File : index.php


That refers to this section in my index.php:

Code: Select all

default:
//-- MOD BEGIN: Last Topic Title on Index -------------------
			$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_id, t.topic_title, t.topic_last_post_id
				FROM (((( " . FORUMS_TABLE . " f
				LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
				LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id )
				LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id )
				LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
				ORDER BY f.cat_id, f.forum_order";
		//-- MOD END: Last Topic Title on Index -------------------
			break;
...and if i edit the offending line (i think), so it reads the following:

Code: Select all

default:
//-- MOD BEGIN: Last Topic Title on Index -------------------
			$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id, t.topic_id, t.topic_title, t.topic_last_post_id, t.topic_id, t.topic_title, t.topic_last_post_id
				FROM (((( " . FORUMS_TABLE . " f
				LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
				LEFT JOIN " . TOPICS_TABLE . " tp ON tp.topic_last_post_id = p.post_id )
				LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_last_post_id = p.post_id )
				LEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )
				ORDER BY f.cat_id, f.forum_order";
		//-- MOD END: Last Topic Title on Index -------------------
			break;
...then the page loads and the latest topic shows, but it's showed twice: there are two 'last post' columns (but just one 'last post' column header) showing the same thing.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

colin_bb wrote: ...when i viewed my index i got this error message...


...and if i edit the offending line (i think), so it reads the following:...

...then the page loads and the latest topic shows, but it's showed twice: there are two 'last post' columns (but just one 'last post' column header) showing the same thing.


How did you get two of those lines in there? You should delete the extra one rather than changing it, but that won't explain why there are two columns.

As for why it is showing two last post columns, that has nothing to do with this mod. Sounds like you did something wrong in the template (maybe put some code in the template twice?).

Are you using subSilver or some other template? If you are using another template, how does it look in subSilver.

You should probably ask this question in the topic for the last topic on index mod rather than here.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

asinshesq wrote:
colin_bb wrote:...when i viewed my index i got this error message...


...and if i edit the offending line (i think), so it reads the following:...

...then the page loads and the latest topic shows, but it's showed twice: there are two 'last post' columns (but just one 'last post' column header) showing the same thing.


How did you get two of those lines in there?...


Actually, it sounds like maybe you installed the mod twice...maybe that would explain why there were two of those lines in there and why in your template you're doubling up on the column?
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Yes, colin_bb, you have an extra parenthesis in there too. You seem to ahve installed that mod twice.

I would suggest you go back to your backup phpbb files (not your backup db, jsut your backup phpbb files) as they existed before you installed the last topic on index mod, and then use easymod to reinstall it.
colin_bb
Registered User
Posts: 104
Joined: Tue Feb 14, 2006 8:40 pm

Post by colin_bb »

Yes your absolutely right, i'm not sure how that happened. I also see that your mod affected it a lot less than i originally thought. In fact, you only need to change one line in the topic_on_index mod.

Find this in topic_on_index_101.mod (approx line 114):

Code: Select all

# 
#-----[ FIND ]----------------------------------------- 
#
	//
	// Obtain a list of topic ids which contain
	// posts made since user last visited
	//
# 
Change to:

Code: Select all

#-----[ FIND ]----------------------------------------- 
#
	//MOD Keep_unread_2 * Get new_unreads list and forum_unread flags, save cookies etc.
#
That is all that you need to change to get both mods working.

Great!

Thanks for your help asinshesq. Now, you're gonna hate me, but....
knightdragon106d
Registered User
Posts: 17
Joined: Sun Feb 08, 2004 11:40 am
Location: Florida
Contact:

Post by knightdragon106d »

does this mod work with phpBB 2.0.20?
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

knightdragon106d wrote: does this mod work with phpBB 2.0.20?

Probably, but you should not be on phpbb2.0.20...you should update to phpbb2.0.22
Post Reply

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