/** * Delete Comment */ public function delete() { if (!$this->deleteFromTable()) { return false; } // Update comments parent $sql = "UPDATE " . $this->db->prefix("rmc_comments") . " SET parent=" . $this->getVar('parent') . " WHERE parent=" . $this->id(); if (!$this->db->queryF($sql)) { $this->addError($this->db->error()); } // Reduce user posts number $user = new RMCommentUser($this->getVar('user')); if ($user->isNew()) { return true; } if ($user->getVar('xuid') <= 0) { return true; } $sql = "UPDATE " . $this->db->prefix("users") . " SET posts=posts-1 WHERE uid=" . $user->getVar('xuid'); if (!$this->db->queryF($sql)) { $this->addError($this->db->error()); return false; } return true; }