Esempio n. 1
0
 /**
 Delete comments
 
 @param	ids		<b>mixed</b>		Comment(s) ID(s)
 */
 public function delComments($ids)
 {
     if (!$this->core->auth->check('delete,contentadmin', $this->id)) {
         throw new Exception(__('You are not allowed to delete comments'));
     }
     $co_ids = dcUtils::cleanIds($ids);
     if (empty($co_ids)) {
         throw new Exception(__('No such comment ID'));
     }
     # Retrieve posts affected by comments edition
     $affected_posts = array();
     $strReq = 'SELECT post_id ' . 'FROM ' . $this->prefix . 'comment ' . 'WHERE comment_id' . $this->con->in($co_ids) . 'GROUP BY post_id';
     $rs = $this->con->select($strReq);
     while ($rs->fetch()) {
         $affected_posts[] = (int) $rs->post_id;
     }
     $strReq = 'DELETE FROM ' . $this->prefix . 'comment ' . 'WHERE comment_id' . $this->con->in($co_ids) . ' ' . 'AND post_id in (SELECT tp.post_id ' . 'FROM ' . $this->prefix . 'post tp ' . "WHERE tp.blog_id = '" . $this->con->escape($this->id) . "' ";
     #If user can only delete, we need to check the post's owner
     if (!$this->core->auth->check('contentadmin', $this->id)) {
         $strReq .= "AND tp.user_id = '" . $this->con->escape($this->core->auth->userID()) . "' ";
     }
     $strReq .= ")";
     $this->con->execute($strReq);
     $this->triggerComments($co_ids, true, $affected_posts);
     $this->triggerBlog();
 }