/** * @see Action::execute() */ public function execute() { parent::execute(); // check permissions $boardIDs = Board::getModeratedBoards('canDeletePostCompletely'); if (empty($boardIDs)) { throw new PermissionDeniedException(); } // delete posts $postIDArray = array(); $sql = "SELECT\tpostID\n\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\tWHERE\tisDeleted = 1\n\t\t\t\tAND threadID IN (\n\t\t\t\t\tSELECT\tthreadID\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\t\tWHERE\tboardID IN (" . $boardIDs . ")\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t)"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $postIDArray[] = $row['postID']; } if (count($postIDArray)) { PostEditor::deleteAllCompletely(implode(',', $postIDArray)); } $this->executed(); // forward HeaderUtil::redirect('index.php?page=ModerationDeletedPosts' . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * @see Cronjob::execute() */ public function execute($data) { if (THREAD_ENABLE_RECYCLE_BIN && THREAD_EMPTY_RECYCLE_BIN_CYCLE > 0) { // delete threads first $sql = "SELECT\tthreadID\n\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\tWHERE\tisDeleted = 1\n\t\t\t\t\tAND deleteTime < " . (TIME_NOW - THREAD_EMPTY_RECYCLE_BIN_CYCLE * 86400); $result = WCF::getDB()->sendQuery($sql); if (WCF::getDB()->countRows($result) > 0) { require_once WBB_DIR . 'lib/data/thread/ThreadEditor.class.php'; $threadIDs = ''; while ($row = WCF::getDB()->fetchArray($result)) { if (!empty($threadIDs)) { $threadIDs .= ','; } $threadIDs .= $row['threadID']; } ThreadEditor::deleteAllCompletely($threadIDs); } // delete posts $sql = "SELECT\tpostID\n\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\tWHERE\tisDeleted = 1\n\t\t\t\t\tAND deleteTime < " . (TIME_NOW - THREAD_EMPTY_RECYCLE_BIN_CYCLE * 86400); $result = WCF::getDB()->sendQuery($sql); if (WCF::getDB()->countRows($result) > 0) { require_once WBB_DIR . 'lib/data/post/PostEditor.class.php'; $postIDs = ''; while ($row = WCF::getDB()->fetchArray($result)) { if (!empty($postIDs)) { $postIDs .= ','; } $postIDs .= $row['postID']; } PostEditor::deleteAllCompletely($postIDs); } } if (THREAD_DELETE_LINK_CYCLE > 0) { $sql = "DELETE FROM\twbb" . WBB_N . "_thread\n\t\t\t\tWHERE\t\tmovedTime > 0\n\t\t\t\t\t\tAND movedTime < " . (TIME_NOW - THREAD_DELETE_LINK_CYCLE * 86400); WCF::getDB()->sendQuery($sql); } }
/** * Deletes the threads with the given thread ids completely. */ public static function deleteAllCompletely($threadIDs, $deletePosts = true, $updateUserStats = true) { if (empty($threadIDs)) { return; } // update user posts & activity points if ($updateUserStats) { self::updateUserStats($threadIDs, 'delete'); } // delete posts if ($deletePosts) { PostEditor::deleteAllCompletely(self::getAllPostIDs($threadIDs), true, true, $updateUserStats); } // delete threads self::deleteData($threadIDs); }
/** * @see Form::save() */ public function save() { // build conditions $this->conditions = new ConditionBuilder(); parent::save(); // boardIDs if (count($this->boardIDs)) { $this->conditions->add("threadID IN (SELECT threadID FROM wbb" . WBB_N . "_thread WHERE boardID IN (" . implode(',', $this->boardIDs) . "))"); } // time if ($this->timeAfterDay && $this->timeAfterMonth && $this->timeAfterYear) { $time = @gmmktime(0, 0, 0, $this->timeAfterMonth, $this->timeAfterDay, $this->timeAfterYear); if ($time !== false && $time !== -1) { $this->conditions->add("time > " . $time); } } if ($this->timeBeforeDay && $this->timeBeforeMonth && $this->timeBeforeYear) { $time = @gmmktime(0, 0, 0, $this->timeBeforeMonth, $this->timeBeforeDay, $this->timeBeforeYear); if ($time !== false && $time !== -1) { $this->conditions->add("time < " . $time); } } // username if ($this->createdBy != '') { $users = preg_split('/\\s*,\\s*/', $this->createdBy, -1, PREG_SPLIT_NO_EMPTY); $users = array_map('escapeString', $users); $this->conditions->add("username IN ('" . implode("','", $users) . "')"); } // status if ($this->deleted) { $this->conditions->add("isDeleted = 1"); } if ($this->notDeleted) { $this->conditions->add("isDeleted = 0"); } if ($this->disabled) { $this->conditions->add("isDisabled = 1"); } if ($this->notDisabled) { $this->conditions->add("isDisabled = 0"); } if ($this->closed) { $this->conditions->add("isClosed = 1"); } if ($this->open) { $this->conditions->add("isClosed = 0"); } // execute action $conditions = $this->conditions->get(); switch ($this->action) { case 'delete': $postIDs = ''; $sql = "SELECT\tpostID\n\t\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\t\t" . $conditions; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!empty($postIDs)) { $postIDs .= ','; } $postIDs .= $row['postID']; $this->affectedPosts++; } // get thread ids $threadIDs = PostEditor::getThreadIDs($postIDs); // delete posts PostEditor::deleteAllCompletely($postIDs); // check threads ThreadEditor::checkVisibilityAll($threadIDs); break; case 'trash': case 'restore': $sql = "UPDATE\twbb" . WBB_N . "_post\n\t\t\t\t\tSET\tisDeleted = " . ($this->action == 'trash' ? 1 : 0) . "\n\t\t\t\t\t\t" . ($this->action == 'trash' ? ",deleteTime = " . TIME_NOW . ", deletedBy = '" . escapeString(WCF::getUser()->username) . "', deletedByID = " . WCF::getUser()->userID : '') . "\n\t\t\t\t\t" . $conditions; WCF::getDB()->sendQuery($sql); $this->affectedPosts = WCF::getDB()->getAffectedRows(); break; case 'disable': case 'enable': $sql = "UPDATE\twbb" . WBB_N . "_post\n\t\t\t\t\tSET\tisDisabled = " . ($this->action == 'disable' ? 1 : 0) . "\n\t\t\t\t\t" . $conditions; WCF::getDB()->sendQuery($sql); $this->affectedPosts = WCF::getDB()->getAffectedRows(); break; case 'close': case 'open': $sql = "UPDATE\twbb" . WBB_N . "_post\n\t\t\t\t\tSET\tisClosed = " . ($this->action == 'close' ? 1 : 0) . "\n\t\t\t\t\t" . $conditions; WCF::getDB()->sendQuery($sql); $this->affectedPosts = WCF::getDB()->getAffectedRows(); break; } $this->saved(); WCF::getTPL()->assign('affectedPosts', $this->affectedPosts); }