lwb5-in-2025/scripts/game/main/forums/library/move.inc

30 lines
940 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class main_forums_move {
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($forum, $topic, $dest, $user) {
$this->db->query("SELECT * FROM f_forum WHERE id IN ($forum,$dest) FOR UPDATE");
$q = $this->db->query("SELECT COUNT(*) FROM f_post WHERE forum=$forum AND topic=$topic AND deleted IS NULL");
if (!($q && dbCount($q))) {
return;
}
list($np) = dbFetchArray($q);
$this->db->query("UPDATE f_post SET forum=$dest WHERE topic=$topic AND forum=$forum");
$this->db->query("UPDATE f_topic SET forum=$dest WHERE id=$topic AND forum=$forum");
$this->db->query("UPDATE f_forum SET posts=posts-$np,topics=topics-1 WHERE id=$forum");
$this->db->query("UPDATE f_forum SET posts=posts+$np,topics=topics+1 WHERE id=$dest");
$this->lib->call('markUnread', $topic, $user);
$this->lib->call('updateLast', $forum);
$this->lib->call('updateLast', $dest);
}
}
?>