/**************************************
electrifiedForum
Version 0.99rc3 - November 2, 2001
Copyright 2001- electrifiedpenguin.com
This is free software, please leave all
copyright notices intact, thanks!
This is the messaging functions file
MAKE NO CHANGES TO THIS FILE
Customizing options are in the realm files!!!
***************************************/
/**************************************
Data Structure For Private Messaging
1 Table: pmessages
id: smallint, auto-increment
mto: varchar(20)
mfrom: varchar(20)
status: smallint [this is an 'options' style field]
subject: varchar(120)
message: text
***************************************/
function new_messages($username)
{
/* Return true if there are unread messages */
global $config;
if (db_numrows($config[pmtable],"mto='$username' AND status='0'")>0)
return TRUE;
else
return FALSE;
}
function list_messages($username)
{
/* Display list of messages in a users messagebox */
global $realm,$config,$forumsess;
if ($forumsess[$realm][username])
{
if (db_numrows($config[pmtable],"mto='$username'")>0)
{
$result = db_select("SELECT * FROM $config[pmtable] WHERE mto='$username' ORDER BY id DESC");
$i = 0;
print "
";
print "
Subject |
Sender |
Date Time | ";
while($row = db_getarray($result))
{
$i = $i + 1;
if ($i % 2) $bgcolor = $config['color_b'];
else $bgcolor = $config['color_a'];
if ($row[senttime])
{
if ($config['24hour'])
$format = "m-d-y H:i";
else
$format = "m-d-y h:i a";
$datetext = date($format,sql_to_unix_time($row[senttime]));
}
else
{
$datetext = FALSE;
}
if ($row[status] == '0')
$titletext = "".$row[subject]."";
else
$titletext = $row[subject];
print "$titletext | $row[mfrom] | $datetext | ";
}
print " |
";
}
else
{
print "You have no messages in your Messagebox
";
}
}
else
{
print "You are not logged in. You must log in before viewing your inbox.
";
}
}
function read_message($username,$id)
{
/* Read the selected message */
global $config,$realm,$forumsess;
if (!$config[icondir])
$config[icondir] = "art/icons";
$result = db_select("SELECT p.id AS id, p.message AS message, p.senttime AS senttime, p.status AS status, u.username AS mfrom, u.options AS useropts, u.gender AS gender, u.birthday AS birthday, u.sig AS sig, u.votes AS votes, u.rank AS rank, u.location AS location, p.subject AS subject, u.email AS email, u.homepage AS homepage, u.aim AS aim, u.yahoo AS yahoo, u.icq AS icq FROM $config[pmtable] p, $config[utable] u WHERE p.id='$id' AND u.username=p.mfrom");
$i = 0;
print "Sender | Message | ";
while($row = db_getarray($result))
{
$i = $i + 1;
$options = $row[useropts];
if ($i % 2)
$bgcolor = $config['color_b'];
else
$bgcolor = $config['color_a'];
if ($row[status] == 0)
{
$columns = array("status");
$values = array('1');
db_update($config[pmtable],"id='$id'",$columns,$values);
}
if (($row[rank])&&($row[votes]))
{
$score = $row[rank]/$row[votes];
$rank = round($score, 0);
$score = round($score, 2);
}
else
{
$rank = FALSE;
}
if ($config['24hour'])
$format = "l, F j Y H:i";
else
$format = "l, F j Y h:i A";
$datetext = date($format,sql_to_unix_time($row[senttime]));
?>
|
|