2016-01-10 11:01:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class main_forums_deletePost {
|
|
|
|
|
2024-12-31 10:42:58 +01:00
|
|
|
function __construct($lib) {
|
2016-01-10 11:01:49 +01:00
|
|
|
$this->lib = $lib;
|
|
|
|
$this->db = $this->lib->game->db;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function run($postId) {
|
|
|
|
$q = $this->db->query("SELECT forum,topic,reply_to FROM f_post WHERE id=$postId AND deleted IS NULL");
|
|
|
|
if (!($q && dbCount($q))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
list($fid,$tid,$rtid) = dbFetchArray($q);
|
|
|
|
$this->db->query("UPDATE f_post SET reply_to=$rtid WHERE reply_to=$postId");
|
|
|
|
$this->db->query("UPDATE f_forum SET posts=posts-1 WHERE id=$fid");
|
|
|
|
$this->db->query("UPDATE f_post SET deleted=" . time() . " WHERE id=$postId");
|
|
|
|
$q = $this->db->query("SELECT id FROM f_post WHERE topic=$tid AND deleted IS NULL ORDER BY moment DESC LIMIT 1");
|
|
|
|
list($lastid) = dbFetchArray($q);
|
|
|
|
$this->db->query("UPDATE f_topic SET last_post=$lastid WHERE id=$tid");
|
|
|
|
$this->lib->call('updateLast', $fid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|