|
|
- <?php
- /**
- * @package uForum
- * @file includes/classes/class_mod.php
- * @version $Id: classes/class_mod.php 15 2009-05-01 17:06:40Z pioder $
- * @copyright 2009(c) PioDer <pioder@wp.pl>
- * @link http://pioder.gim2przemysl.int.pl/
- * @license GNU GPL v3
- **/
- if ( !defined('IN_uF') )
- {
- die('Hacking attempt');
- }
- class Mod
- {
- function MoveTopic($tid, $fid)
- {
- $sql = "UPDATE `".TOPICS_TABLE."` SET `f_id`='$fid' WHERE `t_id`='$tid'";
- DataBase::sql_query($sql,'GENERAL','Could not update topic');
- $sql = "UPDATE `".POSTS_TABLE."` SET `f_id`='$fid' WHERE `t_id`='$tid'";
- DataBase::sql_query($sql,'GENERAL','Could not update post');
- }
-
- function TopicLocked($tid)
- {
- global $default_skin;
- global $default_lang;
- $lock = Topic::TopicInformation($tid,'lock');
- if ($lock=='1')
- {
- return '<a href="moderate.php?action=unlock&id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/unlock.gif" width="20" height="20" alt="unlock">';
- }
- else
- {
- return '<a href="moderate.php?action=lock&id='.$tid.'"><img border="0" src="skins/'.$default_skin.'/images/lock.gif" width="20" height="20" alt="lock"></a>';
- }
- }
-
- function DeleteTopic($topicid)
- {
- $sql="SELECT * FROM ".POSTS_TABLE." WHERE `t_id`='$topicid'";
- $query = DataBase::sql_query($sql,'GENERAL','Could not obtain post information');
- while($item = DataBase::fetch($query))
- {
- $uid = Topic::PostInformation($item['p_id'],'u_id');
- $posts = User::UserInformation($uid,'posts');
- $posts = $posts -1;
- $sql = "UPDATE `".USERS_TABLE."` SET `posts`='$posts' WHERE `u_id`='$uid'";
- DataBase::sql_query($sql,'GENERAL','Could not update user amout of posts');
- }
- $sql = "DELETE FROM ".POSTS_TABLE." WHERE t_id='$topicid';";
- DataBase::sql_query($sql,'GENERAL','Could not delete topic posts.');
- $sql = "DELETE FROM ".TOPICS_TABLE." WHERE t_id='$topicid';";
- DataBase::sql_query($sql,'GENERAL','Could not delete topic posts.');
- }
-
- function LockTopic($topicid)
- {
- $sql = "UPDATE `".TOPICS_TABLE."` SET `lock` = '1' WHERE `t_id` =$topicid;";
- DataBase::sql_query($sql,'GENERAL','Could not lock topic.');
- }
-
- function StickTopic($topicid, $mode)
- {
- $sql = "UPDATE `".TOPICS_TABLE."` SET `sticky` = '$mode' WHERE `t_id` =$topicid;";
- DataBase::sql_query($sql,'GENERAL','Could not stick topic.');
- }
-
- function UnlockTopic($topicid)
- {
- $sql = "UPDATE `".TOPICS_TABLE."` SET `lock` = '0' WHERE `t_id` =$topicid;";
- DataBase::sql_query($sql,'GENERAL','Could not unlock topic.');
- }
-
- function DeletePost($postid)
- {
- $uid = Topic::PostInformation($postid,'u_id');
- $tid = Topic::PostInformation($postid,'t_id');
- $posts = User::UserInformation($uid,'posts');
- $posts = $posts -1;
- $sql = "UPDATE `".USERS_TABLE."` SET `posts`='$posts' WHERE `u_id`='$uid'";
- DataBase::sql_query($sql,'GENERAL','Could not update user amout of posts');
- $sql2 = "DELETE FROM ".POSTS_TABLE." WHERE p_id='$postid';";
- DataBase::sql_query($sql2,'GENERAL','Could not delete post.');
- $sql = "SELECT * FROM ".POSTS_TABLE." WHERE p_id>'$postid' AND `t_id`='$tid';";
- $query = DataBase::sql_query($sql,'GENERAL','Could not obtain post information.');
- while($item=DataBase::fetch($query))
- {
- $number = $item['tp_id'];
- $number = $number-1;
- $number2 = $item['p_id'];
- $sql3 = "UPDATE `".POSTS_TABLE."` SET `tp_id` = '$number' WHERE `p_id` =$number2;";
- DataBase::sql_query($sql3,'GENERAL','Could not update post.');
- }
- }
-
- function AcceptPost($postid)
- {
- $sql = "UPDATE `".POSTS_TABLE."` SET `moderated`='0' WHERE `p_id`='$postid'";
- DataBase::sql_query($sql, 'GENERAL', 'Could not accept post');
- }
- }
- ?>
|