UBB.Dev
Posted By: Charles How to use new PM JS on website? - 02/26/2004 9:26 PM
I reused the ubb cookie for the website's login system and it works great but I am not sure what to do to get the new PM messages too on all pages of the website.

thanks if you have any clue wink
Posted By: Ian Spence Re: How to use new PM JS on website? - 02/26/2004 11:54 PM
I just did this on my main page, here's what you have to do.

First, install Allen\'s CP style hack .

Then, go into cp_style_php.cgi.

FIND:
Code
my @needs_escape = qw( " ); # you can add any character after "
ADD AFTER:

Code
$pleh = $show_logout;
$teh = qq~echo checkUserPMs()~;
$eh = qq!blahblah!;


$pleh =~ s/<?php echo checkUserPMs(); ?>/$eh/eisg;
then

FIND:

Code
$var .= sprintf qq($TableBottom 	= "%s";n), esc($TBB);
ADD AFTER:

Code
$var .= sprintf qq($thisShowLogout    	= "%s";n), esc($pleh);
In your (PHP) webpage add the following...

From ultimatebb.php, the following functions:
getuserid ()
checkUserPMs ()
find_environmental ()

After those in your PHP code, add

Code
	$monkey = checkUserPMs();

$thisShowLogout = preg_replace("/blahblah/", $monkey, $thisShowLogout);
where you wish to add the

"Hello, Ian
You have 1 unread private messages."

put this into your code...

$thisShowLogout

This only works with PHP pages, but it does work smile
Posted By: Ron M Re: How to use new PM JS on website? - 02/27/2004 11:49 PM
Or you can do a quick function in your PHP page to get the info yourself:

Code
$gen_pm1msg      = " New Message";
$gen_pmmulti = " New Messages";
$mbrfile = $ubbnotifypath . $ubbmemberid . ".cgi";

if (file_exists($mbrfile)){
$newpm = "TRUE";
$pmfile = file($mbrfile);
$numpm = $pmfile[0];
} else {
$newpm = "FALSE";
}
if ($numpm > 1)
$newpm_msg = $gen_pmmulti;
else
$newpm_msg = $gen_pm1msg;

if ($newpm == "TRUE") {
echo "<font size="1">
<a href="/cgi-bin/ultimatebb.cgi?ubb=my_profile">$numpm $newpm_msg</a></font>
";
}
That's the basics. You can adapt that to say the full "You have XX new Private Messages" or whatever you like.

That's the basic code to accomplish that.

(Yes, I know that some of the code can be cleaned up, but that's just lazyness on my part as the code does work)
© UBB.Developers