require_once LIBERTY_PKG_PATH . 'LibertyComment.php'; global $commentsLib, $gBitSmarty, $gBitSystem, $gBitThemes; $postComment = array(); $formfeedback = array('error' => array()); $gBitSmarty->assign_by_ref('formfeedback', $formfeedback); // make sure that we don't feed ajax comments if we don't have javascript enabled if (!$gBitThemes->isJavascriptEnabled()) { $gBitSystem->setConfig('comments_ajax', 'n'); } if (@BitBase::verifyId($_REQUEST['delete_comment_id'])) { $deleteComment = new LibertyComment($_REQUEST['delete_comment_id']); // make sure we're loaded up before we delete $deleteComment->loadComment(); if ($deleteComment->isValid() && $gContent->hasUserPermission('p_liberty_admin_comments')) { // delete entire thread $deleteComment->expunge(); } } if (@BitBase::verifyId($_REQUEST['post_comment_id']) && $gContent->hasUserPermission('p_liberty_post_comments')) { $post_comment_id = $_REQUEST['post_comment_id']; $editComment = new LibertyComment($post_comment_id); //if we are passed a comment id but not going to store it then turn off ajax if (!isset($_REQUEST['post_comment_submit']) && !isset($_REQUEST['post_comment_cancel'])) { //even if ajax is on - we force it off in this case $gBitSmarty->assign('comments_ajax', FALSE); } if ($editComment->mInfo['content_id']) { if ($editComment->userCanUpdate($gContent)) { $postComment['data'] = $editComment->mInfo['data']; $postComment['title'] = $editComment->mInfo['title']; } else {
// Remove a topic } elseif (isset($_REQUEST['remove'])) { // Check permissions to edit this topic if the root object is the board check its perms, otherwise check general comment admin perms if (!($gContent->mInfo['root_id'] == $gContent->mInfo['board_content_id'] && $board->hasAdminPermission() || $gBitUser->hasPermission('p_liberty_admin_comments'))) { $gBitSystem->fatalError(tra('You do not have permission to delete this topic.')); } if (!empty($_REQUEST['cancel'])) { // user cancelled - just continue on, doing nothing } elseif (empty($_REQUEST['confirm'])) { $formHash['remove'] = TRUE; $formHash['t'] = $_REQUEST['t']; $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete this topic?') . ' ' . $gContent->getTitle(), 'error' => tra('This cannot be undone!'))); } else { // @TODO Topic should extend LibertyComment - but until that day we load it up a second time $topicAsComment = new LibertyComment($_REQUEST['t']); if (!$topicAsComment->expunge()) { $gBitSmarty->assignByRef('errors', $topicAsComment->mErrors); } // send us back to the baord - http_referer won't work with confirm process bit_redirect(BOARDS_PKG_URL . 'index.php?b=' . $gContent->mInfo['board_id']); } // User pref options on a topic - not really editing but this simplifies topic related processes putting it here } elseif (isset($_REQUEST['new']) || isset($_REQUEST['notify'])) { // Check permissions to view this topic $gContent->verifyViewPermission(); if (isset($_REQUEST['new']) && is_numeric($_REQUEST['new'])) { $rslt = $gContent->readTopicSet($_REQUEST['new']); } elseif (isset($_REQUEST['notify']) && is_numeric($_REQUEST['notify'])) { $rslt = $gContent->notify($_REQUEST['notify']); } }
function expunge() { global $gBitSystem; $ret = FALSE; if ($this->isValid()) { $this->StartTrans(); $sql = "SELECT `comment_id` FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `parent_id` = ?"; $rows = $this->mDb->getAll($sql, array($this->mContentId)); foreach ($rows as $row) { $comment = new LibertyComment($row['comment_id']); $comment->expunge(); } if ($gBitSystem->isPackageActive('boards')) { // due to foreign key constraints, this has to go in the base class of BitBoardPost $sql = "DELETE FROM `" . BIT_DB_PREFIX . "boards_posts` WHERE `comment_id` = ?"; $rs = $this->mDb->query($sql, array($this->mCommentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "boards_topics` WHERE `parent_id` = ?"; $result = $this->mDb->query($query, array($this->getField('content_id'))); } $sql = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `comment_id` = ?"; $rs = $this->mDb->query($sql, array($this->mCommentId)); /* * TODO: figureout why this is even here. Mime should handle this and it needs to pass in mandatory attachmentId * Slated to delete for now - wjames5 */ /* if (method_exists($this,'expungeMetaData')) { $this->expungeMetaData(); } */ if (LibertyMime::expunge()) { $ret = TRUE; $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * Delete comment entries relating to the content object * * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expungeComments() { require_once LIBERTY_PKG_PATH . 'LibertyComment.php'; // Delete all comments associated with this piece of content $query = "SELECT `comment_id` FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `root_id` = ?"; if ($commentIds = $this->mDb->getCol($query, array($this->mContentId))) { foreach ($commentIds as $commentId) { $tmpComment = new LibertyComment($commentId); $tmpComment->expunge(); } } return parent::expunge(); }
/** * This function removes a single image area tag **/ function expunge_tag($itagId) { $ret = FALSE; $storeComment = new LibertyComment(@BitBase::verifyId($itagId) ? $itagId : NULL); $storeComment->mDb->StartTrans(); if ($storeComment->verifyId($storeComment->mCommentId)) { $storeComment->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "itags_image_areas` WHERE `attachment_id`=? and `comment_id`=?", array($this->mAttachementId, $storeComment->mCommentId)); } $storeComment->expunge(); $storeComment->mDb->CompleteTrans(); $this->load(); return $ret; }
then we check permission to delete boards. if so, we call histlib's method remove_all_versions for all the checked boards. */ if (isset($_REQUEST["submit_mult"]) && isset($_REQUEST["checked"]) && $_REQUEST["submit_mult"] == "remove_boards") { // Now check permissions to remove the selected bitboard $gContent->verifyUserPermission('p_boards_remove'); $gBitUser->verifyTicket(); if (!empty($_REQUEST['cancel'])) { // user cancelled - just continue on, doing nothing } elseif (empty($_REQUEST['confirm'])) { $formHash['b'] = $_REQUEST['b']; $formHash['delete'] = TRUE; $formHash['submit_mult'] = 'remove_boards'; foreach ($_REQUEST["checked"] as $del) { $formHash['input'][] = '<input type="hidden" name="checked[]" value="' . $del . '"/>'; } $gBitSystem->confirmDialog($formHash, array('warning' => tra('Are you sure you want to delete these topics?') . ' (' . tra('Count: ') . count($_REQUEST["checked"]) . ')', 'error' => tra('This cannot be undone!'))); } else { foreach ($_REQUEST["checked"] as $deleteId) { $deleteComment = new LibertyComment($deleteId); if ($deleteComment->isValid() && $gBitUser->hasPermission('p_liberty_admin_comments')) { if (!$deleteComment->expunge()) { $gBitSmarty->assignByRef('errors', $deleteComment->mErrors); } } } if (!empty($errors)) { $gBitSmarty->assignByRef('errors', $errors); } } }
/** * This function removes a bitboard entry **/ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->StartTrans(); // parent actually has deletion of rows in boards for constraint reasons if (parent::expunge()) { $this->CompleteTrans(); $ret = TRUE; } else { $this->mDb->RollbackTrans(); } } return $ret; }