Firefox PHP

Displaying 'new' on an external page

Posted by DriftN2Forty 
Displaying 'new' on an external page
November 30, 2006 02:58AM
I link to my forum from a main page. I'd like to be able to check (from the main page) if a user is still logged into the forum and display 'new' by the forum link if there are new messages. possible?
Re: Displaying 'new' on an external page
December 01, 2006 04:32PM
Possible, yes. Um, its going to be a lot of code though.

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: Displaying 'new' on an external page
December 01, 2006 09:09PM
Alrighty then. Well if anyone is feeling giddy, go for it. I'm a long way from tackling this stuff on my own. Thanks anyway.
Re: Displaying 'new' on an external page
June 01, 2007 01:32PM
With the use of quick_auth, i managed my goal with the following
require_once("quick_auth-5.1.2.php");

$conn = mysql_connect("localhost", "username", "password") or die(mysql_error());
        mysql_select_db("phorum", $conn) or die(mysql_error());
        
$messageRes = mysql_query("SELECT message_id FROM phorum_messages", $conn) or die ( mysql_error() );

$flagRes = mysql_query("SELECT message_id FROM phorum_user_newflags
                        WHERE user_id = {$USER['user_id']}", $conn) or die ( mysql_error() );

mysql_close($conn);


while($row = mysql_fetch_row($messageRes)) {
  $messageIDs[] = $row[0];
}

while($row = mysql_fetch_row($flagRes)) {
  $flagIDs[] = $row[0];
}

foreach ( $messageIDs as $MID )
{
  $IDPos = array_search( $MID, $flagIDs );
	
  if( $IDPos === FALSE )
    $newFlag = "IMAGE TAG OR TEXT HERE";
}
Re: Displaying 'new' on an external page
June 01, 2007 01:58PM
Please take a look at the core Phorum code to see how newflags work. Or download the new count module, which implements new counting too. Your code now is bugged.

A message is considered new if its id is not in the newflags table AND if its id is higher than the lowest message id in the newflags table for the forum in which the message resides (this is called "min_id" in the code).

This rule is not implemented, so this will probably cause wrong new message flagging.

Furthermore, it's not really good to simply select *all* message ids from the messages table. That might work while the forums do not have a lot of messages, but imagine what happens if the forums grow.

Another bug could be that non accessable forums are also counted by your code. If all your forums are open for the users, then this is not a problem. But others who might want to use this script could miss the functionality of not counting closed forums.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Displaying 'new' on an external page
June 01, 2007 03:39PM
Well that bit of info would have been useful when I first presented the question. I'll run with that to improve what I have done. Like you said though, I only have one forum running so I have a simple situation.

Thanks
Sorry, only registered users may post in this forum.

Click here to login