コード例 #1
0
 public function delete($id)
 {
     //post id
     $tid = (int) $id;
     $topic = new \CODOF\Forum\Topic($this->db);
     $topic_info = $topic->get_topic_info($tid);
     $cid = $topic_info['cat_id'];
     $tuid = $topic_info['uid'];
     if ($topic->canViewTopic($tuid, $cid, $tid) && $topic->canDeleteTopic($tuid, $cid, $tid)) {
         $isSpam = $_POST['isSpam'];
         if ($isSpam == 'yes') {
             $text = \DB::table(PREFIX . 'codo_posts AS p')->join(PREFIX . 'codo_topics AS t', 'p.topic_id', '=', 't.topic_id')->where('t.topic_id', '=', $tid)->pluck('p.imessage');
             $filter = new \CODOF\SpamFilter();
             $filter->spam($text);
         }
         //Set topic as deleted
         $topic->delete($cid, $tid);
         //update all posts linked with this topic as deleted
         $post = new \CODOF\Forum\Post($this->db);
         $post->deleteOfTopic($cid, $tid);
         echo 'success';
     } else {
         exit('access denied');
     }
 }
コード例 #2
0
 public function deleteReply($_tid)
 {
     $db = \DB::getPDO();
     $pid = (int) $_tid;
     $qry = 'SELECT p.post_status, p.cat_id, p.topic_id,p.uid, p.imessage FROM ' . PREFIX . 'codo_posts AS p' . ' WHERE p.post_id=' . $pid;
     $res = $db->query($qry);
     if ($res) {
         $row = $res->fetch();
         $status = $row['post_status'];
         $cid = $row['cat_id'];
         $text = $row['imessage'];
         $user = \CODOF\User\User::get();
         if ($user->can('moderate posts', $cid)) {
             $qry = 'UPDATE ' . PREFIX . 'codo_posts SET post_status=' . \CODOF\Forum\Forum::DELETED . ' WHERE post_id=' . $pid;
             $db->query($qry);
             if ($status == \CODOF\Forum\Forum::PRE_MODERATION) {
                 $filter = new \CODOF\SpamFilter();
                 $filter->spam($text);
             }
         }
     }
 }