Page 20 of 42

Re: View or mark unread posts

Posted: Mon Nov 24, 2008 9:32 pm
by asinshesq
franktombino wrote:I've see that there are the update package for the Seo on 3.0.2 to 3.0.3.

Tomorrow i do the changes and I will says you if work correctly.
Right. It appears that your problem is not due to this mod but rather to the SEO mod. My guess is that SEO 'simplifies' the link so that the hash doesn't appear, and as a result it breaks the mark all forums read (or mark all topics read) functionality (since the update to phpbb3.0.3 now looks for a hash code before it will mark forums or topics as read).

Re: View or mark unread posts

Posted: Tue Nov 25, 2008 6:01 pm
by franktombino
Today Update... :cry:

I try with the automatic update by the Seo, but the forum doesn't work finally. I don't have only this mod, and with the changes, they don't work properly.

I try with manually modify all files changes by Seo, and the result is white page on index and forum don't view.

I'm disappointed, and I don't know what to make.

PS: I'm not a developer of php, but maybe was better not update...

Regards.

Re: View or mark unread posts

Posted: Tue Nov 25, 2008 6:10 pm
by asinshesq
franktombino wrote:Today Update... :cry:

I try with the automatic update by the Seo, but the forum doesn't work finally. I don't have only this mod, and with the changes, they don't work properly.

I try with manually modify all files changes by Seo, and the result is white page on index and forum don't view.

I'm disappointed, and I don't know what to make.

PS: I'm not a developer of php, but maybe was better not update...

Regards.
Sorry to hear that, but the problem has nothing to do with this mod. I suggest you use the support forum here or at the phpbb seo site. They will want to know the error message that is triggering the white screen, so take a look at your php error log. (If you don't know what I mean, feel free to pm me.)

Re: View or mark unread posts

Posted: Wed Nov 26, 2008 7:57 am
by Eelke
Just one friendly piece of advice. I don't know what this SEO mod does, but phpBB3 is already quite well optimized for search engines. I can imagine that the mod adds friendly URLs. Notice how I don't say Search Engine Friendly URLs, because ironically, most search engines, including Google, are perfectly happy with "unfriendly" URLs, it's mostly useful for your human users. If this SEO mod is causing trouble for you, consider if you really need it.

I don't mean to turn this topic into a debate about SEO, there are other areas for that. I just wanted to give you this to consider. Ask further elsewhere on the board (search for SEO) if you have further questions.

Re: View or mark unread posts

Posted: Wed Nov 26, 2008 9:44 am
by franktombino
Hi Eelke...

I'm not expert of web designer, and my site is only for hobby. For the SEO, the functions seem me very interesting, but I don't know that the modify are profits.

However, I have resolved!!!

I've re-installed the automatic update package of SEO, maintaining the new files where was conflicts, and after I re-apply the modifications of this mod (ver. 1.0.4).

Now, it workly very well. Try to believe!

Thanks a lot asinshesq and Tazmanian for support! ;)

Re: View or mark unread posts

Posted: Sun Nov 30, 2008 3:26 pm
by asinshesq
IPB_Refugee wrote:...I have a brand new board and wrote the first post. It is the only post in the board. Then I clicked the link "Mark post as unread" but on the index page it tells me "You have no unread posts".
Finally sat down to trouble shoot this. The problem will happen whenever the post you mark unread is the latest post in the forum. I think this should fix it (please let me know):

Code: Select all

OPEN
includes/functions_view_or_mark_unread_posts.php

FIND
	// next, check to see if the post being marked unread has a post_time before $forum_tracking _info
	if ($post_time < $forum_tracking_info )

REPLACE WITH
	// next, check to see if the post being marked unread has a post_time at or before $forum_tracking_info
	if ($post_time <= $forum_tracking_info)
And thanks for pointing it out.

Re: View or mark unread posts

Posted: Sun Nov 30, 2008 7:52 pm
by asinshesq
asinshesq wrote:
MartectX wrote:You can also put the code into this if-clause (it's a few lines after your proposal):

Code: Select all

				// If one subforum is unread the forum gets unread too...
				if ($subforum_unread)
				{
					$forum_unread = true;
					$exists_unreads = 1;
				}
Yes, that would have been a more sensible way for me to have coded this to begin with (saves an extra if). When the mod to modx converter is finalized so that I can easily to another version, I'll pick that change up too (if I remember it ;) ).
Your suggestion helpfully saves one if clause, but now that I'm looking at this again, I see that an even cleaner solution is to move the $exists_unread line down further so that the mod makes one fewer chagnes to functions_display.php and the same if statement sets the flag for regular forum unreads and for subforum unreads. Here's what will be in the new version when I get around to submitting it (which won't happen until the mod to modx text converter at phpbb.com is properly working):

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_display.php

#
#-----[ FIND ]------------------------------------------
#
		// start mod view or mark unread posts
		if ($forum_unread)
		{
			// if there are any unread topics, set $exists_unreads flag to 1 so that
			// when check_unreads_flag() is called in the future it can skip the sql query
			// and give the answer that there are unread posts'
			$exists_unreads = 1;
		}
		// end mod view or mark unread posts

		$folder_image = $folder_alt = $l_subforums = '';

#
#-----[ REPLACE WITH ]------------------------------------------
#
		$folder_image = $folder_alt = $l_subforums = '';

#
#-----[ FIND ]------------------------------------------
#
				// start mod view or mark unread posts
				if ($subforum_unread)
				{
					// if there are any unread topics, set $exists_unreads flag to 1 so that
					// when check_unreads_flag() is called in the future it can skip the sql query
					// and give the answer that there are unread posts'
					$exists_unreads = 1;
				}
				// end mod view or mark unread posts

				if ($subforum_row['display'] && $subforum_row['name'])

#
#-----[ REPLACE WITH ]------------------------------------------
#
				if ($subforum_row['display'] && $subforum_row['name'])

#
#-----[ FIND ]------------------------------------------
#
		// Which folder should we display?

#
#-----[ BEFORE, ADD ]------------------------------------------
#
		// start mod view or mark unread posts
		if ($forum_unread)
		{
			// if there are any unread topics, set $exists_unreads flag to 1 so that
			// when check_unreads_flag() is called in the future it can skip the sql query
			// and give the answer that there are unread posts'
			$exists_unreads = 1;
		}
		// end mod view or mark unread posts

Re: View or mark unread posts

Posted: Mon Dec 01, 2008 4:44 pm
by IPB_Refugee
Hello Alan,

my testboard at localhost is no longer a fresh one but has a copy of my real board's database in the meanwhile.
asinshesq wrote:The problem will happen whenever the post you mark unread is the latest post in the forum.
I cannot confirm this as I have not been able to reproduce the bug. (When I write a new post in my testboard and mark it as unread, the link on index.php tells me "View unread posts" now.)

Should I ever be able to reproduce the bug, I will let you know.

Thanks for your work!
Wolfgang

EDIT: The bug appeared again. And Alan's fix seems to work - thank you! (Alan has already been notified about this.)

Re: View or mark unread posts

Posted: Mon Dec 01, 2008 4:46 pm
by cyba
Discovered the issues and made these fixes.

Don't fully understand why it decides to add an extra '-' at the end of the link, but hey, heres how to get rid of it.
Open includes/functions_seo.php

Find:

Code: Select all

return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . $params . ((!$session_id) ? '' : $amp_delim . 'sid=' . $session_id);
Replace With:

Code: Select all

return trim($url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . $params . ((!$session_id) ? '' : $amp_delim . 'sid=' . $session_id), '-');
A hash has been added (for security) when marking topics read, here is a fix for the "mark topics read bug":

Open viewforum.php:

Find:

Code: Select all

'U_MARK_TOPICS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? format_url($forum_name, "f$forum_id", 0, 'mark=topics') : '',
Replace With:

Code: Select all

'U_MARK_TOPICS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? format_url($forum_name, "f$forum_id", 0, 'mark=topics&hash=' . generate_link_hash('global')) : '',
Problem solved!
The official developers of the mod may not be happy with these fixes, so please check back to see what they say.

Re: View or mark unread posts

Posted: Mon Dec 01, 2008 5:04 pm
by asinshesq
cyba wrote:Discovered the issues and made these fixes...
Just to avoid confusion for others who may not have been following things: your fixes are just for people with the seo mod (you are specifying changes to fix that mod, not this one).

Re: View or mark unread posts

Posted: Mon Dec 01, 2008 5:10 pm
by IPB_Refugee
Hello Alan,

there is indeed something I noticed:

Whenever I am in a category or in a forum that has subforums, the link tells me "no unread posts" which is incorrect (my style is based on subsilver2).

index.php: "view unread posts" (correct)
viewtopic.php: "view unread posts" (correct)
viewforum in a forum without subforums: "view unread posts" (correct)
viewforum in a forum with subforums: "no unread posts" (not correct)
viewforum in a forum which is a category: "no unread posts" (not correct)

Here is the beginning of my function check_unread_posts:

Code: Select all

function check_unread_posts()
{
	//return true; // spart ein Query; dafür steht nicht Ungelesene Beiträge / keine ungelesenen Beiträge
	global $db, $user, $auth, $exists_unreads;

	if ($exists_unreads == 1)
	{
		// functions_display() has already been called (user is on index) and there are unreads
		return true;
	}

	if ($exists_unreads == -1)
	{
		// functions_display has already been called (user is on index) but there are no unreads
		return false;
	}

	// Note that the code below is adapted from code that appears in display_forums()
I think it should be okay this way (?)

Regards
Wolfgang

Re: View or mark unread posts

Posted: Mon Dec 01, 2008 11:50 pm
by asinshesq
IPB_Refugee wrote:...there is indeed something I noticed:

Whenever I am in a category or in a forum that has subforums, the link tells me "no unread posts" which is incorrect (my style is based on subsilver2).

index.php: "view unread posts" (correct)
viewtopic.php: "view unread posts" (correct)
viewforum in a forum without subforums: "view unread posts" (correct)
viewforum in a forum with subforums: "no unread posts" (not correct)
viewforum in a forum which is a category: "no unread posts" (not correct)
Thanks, you're absolutely correct. Here's the reason and a fix:

Regular unmodded phpbb3 checks for unread posts whenever it runs the function display_forums() (which appears in includes/functions_display.php). That function gets called from the index and, in some cases, from viewforum.

When I wrote the mod, I was worried about weighing down big boards so I set things up in my check_unread_posts() function to skip the query and loop that checks for unread posts if the script had already checked for unread posts in display_forums(). (That's why the basic mod adds code to display_forums() that sets a flag called $exist_unreads whenever display_forums() runs.)

That works great on the index page, since the index page needs to figure out if there are any unreads in order to know which forums to show as including unreads. That also works great on viewforum for any category or forum that has unreads. But if you go to viewforum for a category or forum that has no unreads at a time when another forum somewhere else has unreads and viewforum calls display_forums() (which basically happens whenever the category or forum has a subforum), display_forums() will only check posts in the category or forum you are at and its subforums (rather than all forums) and for that reason it may set the flag $exists_unreads as false even if there are unreads elsewhere on the board. In another words, the flag gives a 'false negative' in that case. The fix is to skip the flag (and therefore have the code in check_unreads() run the query and loop to check for unreads) whenever display_forums() is called from viewforum.

Here's the fix:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_display.php

#
#-----[ FIND ]------------------------------------------
#
	// start mod view or mark unread post
	// initialize the flag $exists_unread to signal that we have already checked unreads in functions_display()
	// so that when check_unread_posts() is called in the future it can skip the sql query and give the
	// answer that there are none (this gets reset to '1' later on in functions_display() if there are unreads)
	global $exists_unreads;
	$exists_unreads = -1;
	// end mod view or mark unread posts

#
#-----[ REPLACE WITH ]------------------------------------------
#
	// start mod view or mark unread post
	// initialize the flag $exists_unread to signal that we have already checked unreads in functions_display()
	// so that when check_unread_posts() is called in the future it can skip the sql query and give the
	// answer that there are none (this gets reset to '1' later on in functions_display() if there are unreads),
	// but do NOT initialize if the user is on viewforum since the test for unreads may give false negatives in that context
	if (!$sql_where)
	{
		global $exists_unreads;
		$exists_unreads = -1;
	}
	// end mod view or mark unread posts

Re: View or mark unread posts

Posted: Fri Dec 05, 2008 11:31 am
by ChriZathens
I guess that this fix is not needed when you have omitted the query to check whether there are unread posts and change "view unread posts" to "no unread posts", correct?

Re: View or mark unread posts

Posted: Fri Dec 05, 2008 12:08 pm
by asinshesq
ChriZathens wrote:I guess that this fix is not needed when you have omitted the query to check whether there are unread posts and change "view unread posts" to "no unread posts", correct?
Right, you won't need the last change I posted (the one fixing the little bug where the link didn't toggle for certain categories and forums with subforums under them). But you still should make the prior change (the one changing '<' to '<=').

Re: View or mark unread posts

Posted: Fri Dec 05, 2008 2:33 pm
by ChriZathens
OK, Alan, thanks a lot!!!
Are you going to submit the latest fixes for a new release?