public function approveTopic($_tid) { $db = \DB::getPDO(); $tid = (int) $_tid; $qry = 'SELECT t.topic_status, t.cat_id, p.imessage FROM ' . PREFIX . 'codo_topics AS t' . ' INNER JOIN ' . PREFIX . 'codo_posts AS p ON p.topic_id=t.topic_id ' . ' WHERE t.topic_id=' . $tid; $res = $db->query($qry); if ($res) { $row = $res->fetch(); $status = $row['topic_status']; $cid = $row['cat_id']; $text = $row['imessage']; $user = \CODOF\User\User::get(); if ($user->can('moderate topics', $cid)) { $qry = 'UPDATE ' . PREFIX . 'codo_topics SET topic_status=' . \CODOF\Forum\Forum::APPROVED . ' WHERE topic_id=' . $tid; $db->query($qry); $topic = new \CODOF\Forum\Topic($db); $topic->incTopicCount($cid); //If a post considered as spam by filter is being approved //it means the filter needs to relearn that it is not spam if ($status == \CODOF\Forum\Forum::MODERATION_BY_FILTER) { $filter = new \CODOF\SpamFilter(); $filter->ham($text); } } } }