* @link http://pioder.gim2przemysl.int.pl/
* @license GNU GPL v3
**/
if ( !defined('IN_uF') )
{
die('Hacking attempt');
}
class Pms
{
function UserName($uid)
{
global $user;
global $forum_config;
$nick = $user[$uid]['nick'];
$rank = $user[$uid]['rank'];
switch($rank)
{
case '0':
{
return $nick;
break;
}
case '1':
{
return ''.$nick.'';
break;
}
case '2':
{
return ''.$nick.'';
break;
}
}
}
function SendMessage($text, $name, $nick)
{
//general variables
$u_n_id = $_SESSION['uid'];
$uid = User::UserIdByNick($nick);
//For work!
NewMessage::AddToInbox($text, $name, $u_n_id, $uid);
NewMessage::AddToSentbox($text, $name, $u_n_id, $uid);
}
function DeleteMsgUser($mid)
{
$sql = "DELETE FROM `".PM_INBOX_TABLE."` WHERE `m_id`='$mid'";
DataBase::sql_query($sql,GENERAL,'Could not delete message in inbox');
}
function DeleteMsgAuthor($mid)
{
$sql = "DELETE FROM `".PM_SENTBOX_TABLE."` WHERE `m_id`='$mid'";
DataBase::sql_query($sql,GENERAL,'Could not delete message in sentbox');
}
}
class NewMessage
{
function AddToInbox($text, $name, $unid, $uid)
{
$last = DataBase::new_id(PM_INBOX_TABLE);
$time = time();
$sql = "INSERT INTO `".PM_INBOX_TABLE."` VALUES ('$last', '$uid', '$name', '$text', '$time', '$unid','0')";
DataBase::sql_query($sql,GENERAL,'Could not add new message at inbox');
}
function AddToSentbox($text, $name, $unid, $uid)
{
$last=DataBase::new_id(PM_SENTBOX_TABLE);
$time = time();
$sql = "INSERT INTO `".PM_SENTBOX_TABLE."` VALUES ('$last', '$uid', '$name', '$text', '$time', '$unid')";
DataBase::sql_query($sql,GENERAL,'Could not add new message at inbox');
}
}
?>