示例#1
0
 /**
  * Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
  * @param string $Page
  * @param int $PageID
  * @return boolean
  */
 public static function delete_page($Page, $PageID)
 {
     $QueryID = G::$DB->get_query_id();
     // get number of pages
     G::$DB->query("\n\t\t\tSELECT\n\t\t\t\tCEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages\n\t\t\tFROM comments\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}\n\t\t\tGROUP BY PageID");
     if (!G::$DB->has_results()) {
         return false;
     }
     list($CommPages) = G::$DB->next_record();
     // Delete comments
     G::$DB->query("\n\t\t\tDELETE FROM comments\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}");
     // Delete quote notifications
     Subscriptions::flush_quote_notifications($Page, $PageID);
     G::$DB->query("\n\t\t\tDELETE FROM users_notify_quoted\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}");
     // Deal with subscriptions
     Subscriptions::move_subscriptions($Page, $PageID, null);
     // Clear cache
     $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
     for ($i = 0; $i <= $LastCatalogue; ++$i) {
         G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
     }
     G::$Cache->delete_value($Page . '_comments_' . $PageID);
     G::$DB->set_query_id($QueryID);
     return true;
 }
示例#2
0
        error(403);
    }
    $DB->query("\n\t\tDELETE FROM forums_posts\n\t\tWHERE TopicID = '{$TopicID}'");
    $DB->query("\n\t\tDELETE FROM forums_topics\n\t\tWHERE ID = '{$TopicID}'");
    $DB->query("\n\t\tSELECT\n\t\t\tt.ID,\n\t\t\tt.LastPostID,\n\t\t\tt.Title,\n\t\t\tp.AuthorID,\n\t\t\tum.Username,\n\t\t\tp.AddedTime,\n\t\t\t(\n\t\t\t\tSELECT COUNT(pp.ID)\n\t\t\t\tFROM forums_posts AS pp\n\t\t\t\t\tJOIN forums_topics AS tt ON pp.TopicID = tt.ID\n\t\t\t\tWHERE tt.ForumID = '{$ForumID}'\n\t\t\t),\n\t\t\tt.IsLocked,\n\t\t\tt.IsSticky\n\t\tFROM forums_topics AS t\n\t\t\tJOIN forums_posts AS p ON p.ID = t.LastPostID\n\t\t\tLEFT JOIN users_main AS um ON um.ID = p.AuthorID\n\t\tWHERE t.ForumID = '{$ForumID}'\n\t\tGROUP BY t.ID\n\t\tORDER BY t.LastPostID DESC\n\t\tLIMIT 1");
    list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts, $NewLocked, $NewSticky) = $DB->next_record(MYSQLI_NUM, false);
    $DB->query("\n\t\tUPDATE forums\n\t\tSET\n\t\t\tNumTopics = NumTopics - 1,\n\t\t\tNumPosts = NumPosts - '{$Posts}',\n\t\t\tLastPostTopicID = '{$NewLastTopic}',\n\t\t\tLastPostID = '{$NewLastPostID}',\n\t\t\tLastPostAuthorID = '{$NewLastAuthorID}',\n\t\t\tLastPostTime = '{$NewLastAddedTime}'\n\t\tWHERE ID = '{$ForumID}'");
    $Cache->delete_value("forums_{$ForumID}");
    $Cache->delete_value("thread_{$TopicID}");
    $Cache->begin_transaction('forums_list');
    $UpdateArray = array('NumPosts' => $NumPosts, 'NumTopics' => '-1', 'LastPostID' => $NewLastPostID, 'LastPostAuthorID' => $NewLastAuthorID, 'LastPostTopicID' => $NewLastTopic, 'LastPostTime' => $NewLastAddedTime, 'Title' => $NewLastTitle, 'IsLocked' => $NewLocked, 'IsSticky' => $NewSticky);
    $Cache->update_row($ForumID, $UpdateArray);
    $Cache->commit_transaction(0);
    $Cache->delete_value("thread_{$TopicID}_info");
    // subscriptions
    Subscriptions::move_subscriptions('forums', $TopicID, null);
    // quote notifications
    Subscriptions::flush_quote_notifications('forums', $TopicID);
    $DB->query("\n\t\tDELETE FROM users_notify_quoted\n\t\tWHERE Page = 'forums'\n\t\t\tAND PageID = '{$TopicID}'");
    header("Location: forums.php?action=viewforum&forumid={$ForumID}");
} else {
    // If we're just editing it
    $Action = 'editing';
    if (isset($_POST['trash'])) {
        $ForumID = TRASH_FORUM_ID;
        $Action = 'trashing';
    }
    $Cache->begin_transaction("thread_{$TopicID}_info");
    $UpdateArray = array('IsSticky' => $Sticky, 'Ranking' => $Ranking, 'IsLocked' => $Locked, 'Title' => Format::cut_string($RawTitle, 150, 1, 0), 'ForumID' => $ForumID);
    $Cache->update_row(false, $UpdateArray);
    $Cache->commit_transaction(0);