if ($_REQUEST['do'] == 'posts') { // fetch threads and posts to be moderated from the moderation table // this saves a index on visible and a query with about 3 inner joins $threadids = array(); $postids = array(); $hasdelperm = array(); $moderated = $db->query_read("\r\n\t\tSELECT *\r\n\t\tFROM " . TABLE_PREFIX . "moderation\r\n\t\tWHERE type IN ('thread', 'reply')\r\n\t"); while ($moderate = $db->fetch_array($moderated)) { if ($moderate['type'] == 'thread') { $threadids[] = $moderate['primaryid']; } else { $postids[] = $moderate['primaryid']; } } $db->free_result($moderated); $sql = fetch_moderator_forum_list_sql('canmoderateposts'); print_form_header('moderate', 'doposts', 0, 1, 'threads'); print_table_header($vbphrase['threads_awaiting_moderation']); if (!empty($threadids) and $sql) { $threadids = implode(',', $threadids); $threads = $db->query_read("\r\n\t\t\tSELECT thread.threadid, thread.title AS title, thread.notes AS notes,\r\n\t\t\t\tthread.forumid AS forumid, thread.postuserid AS userid,\r\n\t\t\t\tthread.postusername AS username, thread.dateline, thread.firstpostid, pagetext\r\n\t\t\tFROM " . TABLE_PREFIX . "thread AS thread\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "post AS post ON(thread.firstpostid = post.postid)\r\n\t\t\tWHERE {$sql} AND thread.threadid IN ({$threadids})\r\n\t\t\tORDER BY thread.lastpost\r\n\t\t"); $havethreads = false; while ($thread = $db->fetch_array($threads)) { if ($thread['firstpostid'] == 0) { // eek potential for disaster $post_text = $db->query_first("SELECT pagetext FROM " . TABLE_PREFIX . "post WHERE threadid = {$thread['threadid']} ORDER BY dateline ASC"); $thread['pagetext'] = $post_text['pagetext']; } if ($havethreads) { print_description_row('<span class="smallfont"> </span>', 0, 2, 'thead'); } else {
if (!empty($updatethread)) { foreach ($updatethread as $threadid => $null) { build_thread_counters($threadid); } } if (!empty($updateforum)) { foreach ($updateforum as $forumid => $null) { build_forum_counters($forumid); } } define('CP_REDIRECT', 'moderate.php?do=posts'); print_stop_message('moderated_posts_successfully'); } // ###################### Start attachment moderation ####################### if ($_REQUEST['do'] == 'attachments') { $sql = fetch_moderator_forum_list_sql('canmoderateattachments'); print_form_header('moderate', 'doattachments'); print_table_header($vbphrase['attachments_awaiting_moderation']); $done = false; if ($sql) { $attachments = $db->query_read("\n\t\t\tSELECT user.username, post.username AS postusername, attachment.filename, attachment.postid, thread.forumid, thread.threadid, attachment.thumbnail_dateline,\n\t\t\t\tattachment.attachmentid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize, attachment.filesize, attachment.dateline\n\t\t\tFROM " . TABLE_PREFIX . "attachment AS attachment\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "post AS post ON (attachment.postid = post.postid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "thread AS thread ON (post.threadid = thread.threadid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "user AS user ON (attachment.userid = user.userid)\n\t\t\tWHERE {$sql} AND attachment.visible = 0 AND attachment.postid <> 0\n\t\t"); while ($attachment = $db->fetch_array($attachments)) { if ($done) { print_description_row('<span class="smallfont"> </span>', 0, 2, 'thead'); } else { print_description_row(' <input type="button" value="' . $vbphrase['validate'] . '" onclick="js_check_all_option(this.form, 1);" class="button" title="' . $vbphrase['validate'] . '" /> <input type="button" value="' . $vbphrase['delete'] . '" onclick="js_check_all_option(this.form, -1);" class="button" title="' . $vbphrase['delete'] . '" /> <input type="button" value="' . $vbphrase['ignore'] . '" onclick="js_check_all_option(this.form, 0);" class="button" title="' . $vbphrase['ignore'] . '" /> ', 0, 2, 'thead', 'center'); }
print_select_row($vbphrase['order'], 'order', array($vbphrase['ascending'], $vbphrase['descending'])); print_submit_row($vbphrase['submit']); } // ###################### Do View ########################## if ($_POST['do'] == 'doview') { $vbulletin->input->clean_array_gpc('p', array('view' => TYPE_INT, 'orderby' => TYPE_INT, 'order' => TYPE_INT)); if (!$vbulletin->GPC['forumid']) { print_stop_message('please_complete_required_fields'); } else { if ($vbulletin->GPC['forumid'] != -1 and !can_moderate($vbulletin->GPC['forumid'])) { print_stop_message('no_permission'); } } // gather forums that this person is a moderator of if ($vbulletin->GPC['forumid'] == -1) { $forumids = fetch_moderator_forum_list_sql(); } else { $forumids = " OR thread.forumid = " . $vbulletin->GPC['forumid']; } switch ($vbulletin->GPC['orderby']) { case 0: $vbulletin->GPC['orderby'] = 'postdateline'; break; case 1: $vbulletin->GPC['orderby'] = 'postusername, postdateline'; break; case 2: $vbulletin->GPC['orderby'] = 'forumid, postdateline'; break; default: $vbulletin->GPC['orderby'] = 'postdateline';