View or mark unread posts

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

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
ulong
Registered User
Posts: 59
Joined: Fri Nov 14, 2008 12:22 pm

Re: View or mark unread posts

Post by ulong » Thu Jan 15, 2009 10:44 am

I know, that is not this thread mod, but i installed counting like your tutorial and...
my functions.php looks like (just a part, with whole file there is a problem in this forum):

Code: Select all

		'S_ENABLE_FEEDS_FORUM'		=> ($config['rss_forum']  && $f_rss != 0) ? true : false,
		'S_ENABLE_FEEDS_THREAD'		=> ($config['rss_thread'] && $t_rss != 0) ? true : false,
// MOD : MSSTI RSS Feeds (V1.0.4) - End
		'SITE_LOGO_IMG'			=> $user->img('site_logo'))
	);

	// application/xhtml+xml not used because of IE
	header('Content-type: text/html; charset=UTF-8');

	header('Cache-Control: private, no-cache="set-cookie"');
	header('Expires: 0');
	header('Pragma: no-cache');

	return;
}

/**
* Generate page footer
*/
function page_footer($run_cron = true)
{
	global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;

	// Output page creation time
	if (defined('DEBUG'))
	{
		$mtime = explode(' ', microtime());
		$totaltime = $mtime[0] + $mtime[1] - $starttime;

		if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
		{
			$db->sql_report('display');
		}

		$debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);

		if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
		{
			if (function_exists('memory_get_usage'))
			{
				if ($memory_usage = memory_get_usage())
				{
					global $base_memory_usage;
					$memory_usage -= $base_memory_usage;
					$memory_usage = get_formatted_filesize($memory_usage);

					$debug_output .= ' | Memory Usage: ' . $memory_usage;
				}
			}

			$debug_output .= ' | <a href="' . build_url() . '&explain=1">Explain</a>';
		}
	}

	$template->assign_vars(array(
		'DEBUG_OUTPUT'			=> (defined('DEBUG')) ? $debug_output : '',
		'TRANSLATION_INFO'		=> (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',

		'U_ACP' => ($auth->acl_get('a_') && $user->data['is_registered']) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '')
	);

	// Call cron-type script
	if (!defined('IN_CRON') && $run_cron && !$config['board_disable'])
	{
		$cron_type = '';

		if (time() - $config['queue_interval'] > $config['last_queue_run'] && !defined('IN_ADMIN') && file_exists($phpbb_root_path . 'cache/queue.' . $phpEx))
		{
			// Process email queue
			$cron_type = 'queue';
		}
		else if (method_exists($cache, 'tidy') && time() - $config['cache_gc'] > $config['cache_last_gc'])
		{
			// Tidy the cache
			$cron_type = 'tidy_cache';
		}
		else if (time() - $config['warnings_gc'] > $config['warnings_last_gc'])
		{
			$cron_type = 'tidy_warnings';
		}
		else if (time() - $config['database_gc'] > $config['database_last_gc'])
		{
			// Tidy the database
			$cron_type = 'tidy_database';
		}
		else if (time() - $config['search_gc'] > $config['search_last_gc'])
		{
			// Tidy the search
			$cron_type = 'tidy_search';
		}
		else if (time() - $config['session_gc'] > $config['session_last_gc'])
		{
			$cron_type = 'tidy_sessions';
		}

		if ($cron_type)
		{
			$template->assign_var('RUN_CRON_TASK', '<img src="' . append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $cron_type) . '" width="1" height="1" alt="cron" />');
		}
	}

	$template->display('body');

	garbage_collection();
	exit_handler();
}

/**
* Closing the cache object and the database
* Cool function name, eh? We might want to add operations to it later
*/
function garbage_collection()
{
	global $cache, $db;

	// Unload cache, must be done before the DB connection if closed
	if (!empty($cache))
	{
		$cache->unload();
	}

	// Close our DB connection.
	if (!empty($db))
	{
		$db->sql_close();
	}
}

/**
* Handler for exit calls in phpBB.
* This function supports hooks.
*
* Note: This function is called after the template has been outputted.
*/
function exit_handler()
{
	global $phpbb_hook, $config;

	if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__))
	{
		if ($phpbb_hook->hook_return(__FUNCTION__))
		{
			return $phpbb_hook->hook_return_result(__FUNCTION__);
		}
	}

	// As a pre-caution... some setups display a blank page if the flush() is not there.
	(!$config['gzip_compress']) ? @flush() : @ob_flush();

	exit;
}

/**
* Handler for init calls in phpBB. This function is called in user::setup();
* This function supports hooks.
*/
function phpbb_user_session_handler()
{
	global $phpbb_hook;

	if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__))
	{
		if ($phpbb_hook->hook_return(__FUNCTION__))
		{
			return $phpbb_hook->hook_return_result(__FUNCTION__);
		}
	}

	return;
}

/**
* checks and returns the number of posts the user has not read.
* Takes a single parameter, which is an array of forum_ids identifying the forums in which the
* function will check for unreads.  If no parameter is passed to the forum, checks
* in all forums as well as in forum_id 0 (globals).
*/
function check_post_unread_count($forum_ids = array())
{
   global $db, $auth, $user;

   if (!$forum_ids)
   {
      // $forum_ids was not passed to the function, so include forum_id 0 (globals)
      // in the list and then look up and include all other forums the user is authorized to read
      $forum_ids[] = 0;

      $sql = 'SELECT forum_id
         FROM ' . FORUMS_TABLE;
      $result = $db->sql_query($sql);
      while ($row = $db->sql_fetchrow($result))
      {
         if ($auth->acl_get('f_read', $row['forum_id']))
         {
            $forum_ids[] = $row['forum_id'];
         }
      }
      $db->sql_freeresult($result);
   }

   // now count the posts with post time after each of the relevant times
   $sql = 'SELECT COUNT(p.post_id) as count
      FROM ' . POSTS_TABLE . ' p
      LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (p.forum_id = ft.forum_id AND ft.user_id = ' . $user->data['user_id'] . ')
      LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (p.topic_id = tt.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')
      WHERE
      (
         p.post_time > tt.mark_time
         OR (tt.mark_time IS NULL AND p.post_time > ft.mark_time)
         OR (ft.mark_time IS NULL AND p.post_time > ' . $user->data['user_lastmark'] . ')
      )
         AND ' . $db->sql_in_set('p.forum_id', $forum_ids);

   $result = $db->sql_query($sql);
   $unread_post_count = $db->sql_fetchfield('count', false, $result);
   $db->sql_freeresult($result);

   return $unread_post_count;
}


/**
* checks and returns the number of topics that include posts the user has not read.
* Takes a single parameter, which is an array of forum_ids identifying the forums in which the
* function will check for unreads.  If no parameter is passed to the function, checks
* in all forums as well as in forum_id 0 (globals).
*/
function check_topic_unread_count($forum_ids = array())
{
   global $db, $auth, $user;

   if (!$forum_ids)
   {
      // $forum_ids was not passed to the function, so include forum_id 0 (globals)
      // in the list and then look up and include all other forums the user is authorized to read
      $forum_ids[] = 0;

      $sql = 'SELECT forum_id
         FROM ' . FORUMS_TABLE;
      $result = $db->sql_query($sql);
      while ($row = $db->sql_fetchrow($result))
      {
         if ($auth->acl_get('f_read', $row['forum_id']))
         {
            $forum_ids[] = $row['forum_id'];
         }
      }
      $db->sql_freeresult($result);
   }

   // now count the topics with topic_last_post_time after each of the relevant times
   $sql = 'SELECT COUNT(t.topic_id) as count
      FROM ' . TOPICS_TABLE . ' t
      LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (t.forum_id = ft.forum_id AND ft.user_id = ' . $user->data['user_id'] . ')
      LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (t.topic_id = tt.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')
      WHERE
      (
         t.topic_last_post_time > tt.mark_time
         OR (tt.mark_time IS NULL AND t.topic_last_post_time > ft.mark_time)
         OR (ft.mark_time IS NULL AND t.topic_last_post_time > ' . $user->data['user_lastmark'] . ')
      )
         AND ' . $db->sql_in_set('t.forum_id', $forum_ids);

   $result = $db->sql_query($sql);
   $unread_topic_count = $db->sql_fetchfield('count', false, $result);
   $db->sql_freeresult($result);

   return $unread_topic_count;
}


?>
And there is error:

Code: Select all

Parse error: syntax error, unexpected $end in /home/platne/niejedzie/public_html/forum2/includes/functions.php on line 3708
This is phpbb 3.0.2

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

Re: View or mark unread posts

Post by asinshesq » Thu Jan 15, 2009 11:23 am

ulong wrote:I know, that is not this thread mod, but i installed counting like your tutorial and...
my functions.php looks like (just a part, with whole file there is a problem in this forum):...
And there is error:

Code: Select all

Parse error: syntax error, unexpected $end in /home/platne/niejedzie/public_html/forum2/includes/functions.php on line 3708
This is phpbb 3.0.2
I just copied those last two functions (the count functions you mentioned) onto my functions file and they do not cause a parse error, so your problem is somewhere earlier on in functions (a part that comes from another mod). If you pm the full functions file to me I can take a look at some point to see what else you have in the file that is wrong.

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

Re: View or mark unread posts

Post by asinshesq » Thu Jan 15, 2009 11:34 am

ulong wrote:I know, that is not this thread mod, but i installed counting like your tutorial and...
my functions.php looks like (just a part, with whole file there is a problem in this forum):...
And there is error:

Code: Select all

Parse error: syntax error, unexpected $end in /home/platne/niejedzie/public_html/forum2/includes/functions.php on line 3708
This is phpbb 3.0.2
Just comparing the regular functions.php to what you have, you seem to be missing a line and, more importantly, a close parenthesis at the bottom of function page_header() (nothing to do with this mod...looks like you messed up in installing the rss feed mod?)

Try this and see if it helps:

Code: Select all

OPEN
includes/functions.php

FIND
          'SITE_LOGO_IMG'         => $user->img('site_logo'))
       );

REPLACE WITH
		'SITE_LOGO_IMG'			=> $user->img('site_logo'),

		'A_COOKIE_SETTINGS'		=> addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')),
	));

ulong
Registered User
Posts: 59
Joined: Fri Nov 14, 2008 12:22 pm

Re: View or mark unread posts

Post by ulong » Thu Jan 15, 2009 4:53 pm

asinshesq wrote:
ulong wrote:I know, that is not this thread mod, but i installed counting like your tutorial and...
my functions.php looks like (just a part, with whole file there is a problem in this forum):...
And there is error:

Code: Select all

Parse error: syntax error, unexpected $end in /home/platne/niejedzie/public_html/forum2/includes/functions.php on line 3708
This is phpbb 3.0.2
Just comparing the regular functions.php to what you have, you seem to be missing a line and, more importantly, a close parenthesis at the bottom of function page_header() (nothing to do with this mod...looks like you messed up in installing the rss feed mod?)

Try this and see if it helps:

Code: Select all

OPEN
includes/functions.php

FIND
          'SITE_LOGO_IMG'         => $user->img('site_logo'))
       );

REPLACE WITH
		'SITE_LOGO_IMG'			=> $user->img('site_logo'),

		'A_COOKIE_SETTINGS'		=> addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')),
	));
yes, i have installed rss feed 2 ;)
I did this code, and now its working correctly!

Thank you!
You are one of the most helpfull people in this board ;)

wobo
Registered User
Posts: 128
Joined: Tue May 04, 2004 4:28 am

Re: View or mark unread posts

Post by wobo » Wed Jan 21, 2009 3:33 pm

A long while ago I used phpbb2 and we had the Unread-MOD installed. Now, with a detour through punBB I am coming back to phpBB in version 3.0.4. From former times I remember the discussion about one functionality of this MOD: how does it deal with sessions?

I mean, I login in the morning, I see 40 unread posts. I start reading, after I read 10 posts I have to leave. I come back in the afternoon and login again - will those other unread 30 posts still show up as unread?

In short: will the unread tag be kept when the session is terminated and a new session is opened? This can (and does) also happen when the internet connection goes down during a session.

I haven't found an answer to this in this thread and I'd like to know before I take the time to install the MOD.

wobo
Parents: Talk to your kids about Linux!
Before someone else does it!

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

Re: View or mark unread posts

Post by asinshesq » Wed Jan 21, 2009 3:45 pm

Wobo, this mod does not change phpbb3's behavior in keeping track of unread posts. Phpbb3 - unlike phpbb2 - keeps track via the database (unless you disable db tracking via the ACP) so sessions have nothing to do with anything (except for guests).

wobo
Registered User
Posts: 128
Joined: Tue May 04, 2004 4:28 am

Re: View or mark unread posts

Post by wobo » Wed Jan 21, 2009 4:04 pm

That's great, this issue was yet unclear when we had those discussions (phpbb3 was in Alpha stage back then).

wobo
Parents: Talk to your kids about Linux!
Before someone else does it!

wobo
Registered User
Posts: 128
Joined: Tue May 04, 2004 4:28 am

Re: View or mark unread posts

Post by wobo » Wed Jan 21, 2009 4:19 pm

Ah, I just realized it is not so great. phpbb3 does care for the session state.

1. I login as user A and write a posting. I log out.
2. I log in as User B and klick on "new postings" - the system shows the post from user A as new.
3. I log out and log in again as user B - no new postings.

This shows that "new postings" actually means "new postings since your last logout". Will this be different with the unread MOD? I mean, will that posting stay "unread" until I actually read it or do something like "Mark all forums read"?
Parents: Talk to your kids about Linux!
Before someone else does it!

wobo
Registered User
Posts: 128
Joined: Tue May 04, 2004 4:28 am

Re: View or mark unread posts

Post by wobo » Wed Jan 21, 2009 4:38 pm

I just read the technical notes of this MOD. Unfortunately it is not what I am looking for. In the technical notes it says that phpbb3 checks the forum_last_post_time against the mark_time entry for the user. In other words, it only marks those posts as "new" or "unread" which are younger than the user's last login.

That's what I said in my earlier post - it depends on the session marks.

wobo
Parents: Talk to your kids about Linux!
Before someone else does it!

wolfman24
Registered User
Posts: 387
Joined: Tue Mar 07, 2006 12:07 pm

Re: View or mark unread posts

Post by wolfman24 » Wed Jan 21, 2009 4:59 pm

There is a difference between new posts and unread posts. However, if I log out and log in again there are no new posts anymore, but the post are still unread. This is the way it works for me.

wobo
Registered User
Posts: 128
Joined: Tue May 04, 2004 4:28 am

Re: View or mark unread posts

Post by wobo » Wed Jan 21, 2009 5:17 pm

Thx! That was the info I was looking for. Installing now....

wobo
Parents: Talk to your kids about Linux!
Before someone else does it!

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

Re: View or mark unread posts

Post by asinshesq » Wed Jan 21, 2009 5:32 pm

wobo wrote:Ah, I just realized it is not so great. phpbb3 does care for the session state.

1. I login as user A and write a posting. I log out.
2. I log in as User B and klick on "new postings" - the system shows the post from user A as new.
3. I log out and log in again as user B - no new postings.

This shows that "new postings" actually means "new postings since your last logout". Will this be different with the unread MOD? I mean, will that posting stay "unread" until I actually read it or do something like "Mark all forums read"?
Right, new posts have nothing to do with unread posts.

Phpbb3 keeps track of unread posts in the db and shows unread posts by a different icon for the forum or topic they are in, but for some reason the developers decided to tell you in the header the number of new posts rather than the number of unread posts. This mod changes that by giving you a note in the header showing whether or not there are unread posts (and allowing you to see a list of unread posts if there are any).

On my own board, I have gotten rid of the new posts link altogether because I think it confuses people.

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

Re: View or mark unread posts

Post by asinshesq » Wed Jan 21, 2009 5:38 pm

wobo wrote:In the technical notes it says that phpbb3 checks the forum_last_post_time against the mark_time entry for the user. In other words, it only marks those posts as "new" or "unread" which are younger than the user's last login.

That's what I said in my earlier post - it depends on the session marks.
The note you are tlaking about is correct, but it's way more complicated than you are assuming (for example, mark_time has nothing to do with session or login times but instead is tied to the last time that all topics in the forum were marked read or were in fact read). The phpbb3 approach to unreads does work correctly (except for its treatment of unread global announcments, which I correct in another mod) and does not depend on session marks (assuming the admin does not disable tracking by db via the acp). The approach the developers take was not intuitive to me, but it turns out to be a very very clever way to keep track of unreads without weighing down a big board with extra queries. I have tried as much as possible to avoid extra queries as well (and I have included in my author's notes thoughts on features you can turn off if you have a really really big board and are concerned about any extra queries).

wobo
Registered User
Posts: 128
Joined: Tue May 04, 2004 4:28 am

Re: View or mark unread posts

Post by wobo » Wed Jan 21, 2009 6:34 pm

Thanks a lot for this insightful post. Again i learned something.
Finished installing - it works! And I agree, the "new posts" besides the "unread posts" may be a bit confusing for the unwashed masses. :)

Hopefully my users are satisfied with this solution although I know they will miss the "Show new posts of last 24 hours" function.

wobo
Parents: Talk to your kids about Linux!
Before someone else does it!

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

Re: View or mark unread posts

Post by asinshesq » Tue Jan 27, 2009 12:37 am

asinshesq wrote:If anyone wants to test out my [beta] bug fix for phpbb3 properly dealing with global announcements (nothing directly do with this mod but I will incorporate that fix in a future version of this mod), here it is: http://www.phpbb.com/community/viewtopi ... &t=1357705
My mod that fixes phpbb3's global announcement unread flag bug has now been validated. See http://www.phpbb.com/community/viewtopi ... &t=1430485
If you install that mod, you should read the authors notes to this mod and make the changes to this mod that the notes tell you to make when you install that bug fix. (Again, the bug that mod fixes is not a bug caused by this mod.)

Locked

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