<?php
|
|
/**
|
|
* @package uForum
|
|
* @file includes/classes/class_pms.php
|
|
* @version $Id$
|
|
* @copyright 2009(c) PioDer <[email protected]>
|
|
* @link http://pioder.gim2przemysl.int.pl/
|
|
* @license GNU GPL v3
|
|
**/
|
|
if ( !defined('IN_uF') )
|
|
{
|
|
die('Hacking attempt');
|
|
}
|
|
class Pms
|
|
{
|
|
function PMCnt($uid = -1)
|
|
{
|
|
$uid = ($uid==-1) ? $_SESSION['uid'] : $uid;
|
|
//private messages in inbox
|
|
$sql = "SELECT COUNT(*) AS `cnt` FROM `".PM_INBOX_TABLE."` WHERE `u_id`='".$uid."'";
|
|
$result = DataBase::sql_query($sql, GENERAL, 'Could not obtain count of pms in inbox');
|
|
$row = DataBase::fetch($result);
|
|
|
|
//private messages in sentbox
|
|
$sql = "SELECT COUNT(*) AS `cnt` FROM `".PM_SENTBOX_TABLE."` WHERE `u_id`='".$uid."'";
|
|
$result = DataBase::sql_query($sql, GENERAL, 'Could not obtain count of pms in sentbox');
|
|
$row2 = DataBase::fetch($result);
|
|
|
|
return array($row['cnt'], $row2['cnt']);
|
|
}
|
|
|
|
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 '<font color="'.$forum_config['color_mod'].'"><b>'.$nick.'</b></font>';
|
|
break;
|
|
}
|
|
case '2':
|
|
{
|
|
return '<font color="'.$forum_config['color_admin'].'"><b>'.$nick.'</b></font>';
|
|
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');
|
|
}
|
|
}
|
|
?>
|