Chris@76: 'ApproveMessage', Chris@76: 'attachments' => 'UnapprovedAttachments', Chris@76: 'replies' => 'UnapprovedPosts', Chris@76: 'topics' => 'UnapprovedPosts', Chris@76: ); Chris@76: Chris@76: // Pick something valid... Chris@76: if (!isset($_REQUEST['sa']) || !isset($subactions[$_REQUEST['sa']])) Chris@76: $_REQUEST['sa'] = 'replies'; Chris@76: Chris@76: $subactions[$_REQUEST['sa']](); Chris@76: } Chris@76: Chris@76: // View all unapproved posts. Chris@76: function UnapprovedPosts() Chris@76: { Chris@76: global $txt, $scripturl, $context, $user_info, $sourcedir, $smcFunc; Chris@76: Chris@76: $context['current_view'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? 'topics' : 'replies'; Chris@76: $context['page_title'] = $txt['mc_unapproved_posts']; Chris@76: Chris@76: // Work out what boards we can work in! Chris@76: $approve_boards = boardsAllowedTo('approve_posts'); Chris@76: Chris@76: // If we filtered by board remove ones outside of this board. Chris@76: //!!! Put a message saying we're filtered? Chris@76: if (isset($_REQUEST['brd'])) Chris@76: { Chris@76: $filter_board = array((int) $_REQUEST['brd']); Chris@76: $approve_boards = $approve_boards == array(0) ? $filter_board : array_intersect($approve_boards, $filter_board); Chris@76: } Chris@76: Chris@76: if ($approve_boards == array(0)) Chris@76: $approve_query = ''; Chris@76: elseif (!empty($approve_boards)) Chris@76: $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; Chris@76: // Nada, zip, etc... Chris@76: else Chris@76: $approve_query = ' AND 0'; Chris@76: Chris@76: // We also need to know where we can delete topics and/or replies to. Chris@76: if ($context['current_view'] == 'topics') Chris@76: { Chris@76: $delete_own_boards = boardsAllowedTo('remove_own'); Chris@76: $delete_any_boards = boardsAllowedTo('remove_any'); Chris@76: $delete_own_replies = array(); Chris@76: } Chris@76: else Chris@76: { Chris@76: $delete_own_boards = boardsAllowedTo('delete_own'); Chris@76: $delete_any_boards = boardsAllowedTo('delete_any'); Chris@76: $delete_own_replies = boardsAllowedTo('delete_own_replies'); Chris@76: } Chris@76: Chris@76: $toAction = array(); Chris@76: // Check if we have something to do? Chris@76: if (isset($_GET['approve'])) Chris@76: $toAction[] = (int) $_GET['approve']; Chris@76: // Just a deletion? Chris@76: elseif (isset($_GET['delete'])) Chris@76: $toAction[] = (int) $_GET['delete']; Chris@76: // Lots of approvals? Chris@76: elseif (isset($_POST['item'])) Chris@76: foreach ($_POST['item'] as $item) Chris@76: $toAction[] = (int) $item; Chris@76: Chris@76: // What are we actually doing. Chris@76: if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) Chris@76: $curAction = 'approve'; Chris@76: elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) Chris@76: $curAction = 'delete'; Chris@76: Chris@76: // Right, so we have something to do? Chris@76: if (!empty($toAction) && isset($curAction)) Chris@76: { Chris@76: checkSession('request'); Chris@76: Chris@76: // Handy shortcut. Chris@76: $any_array = $curAction == 'approve' ? $approve_boards : $delete_any_boards; Chris@76: Chris@76: // Now for each message work out whether it's actually a topic, and what board it's on. Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT m.id_msg, m.id_member, m.id_board, m.subject, t.id_topic, t.id_first_msg, t.id_member_started Chris@76: FROM {db_prefix}messages AS m Chris@76: INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) Chris@76: LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board) Chris@76: WHERE m.id_msg IN ({array_int:message_list}) Chris@76: AND m.approved = {int:not_approved} Chris@76: AND {query_see_board}', Chris@76: array( Chris@76: 'message_list' => $toAction, Chris@76: 'not_approved' => 0, Chris@76: ) Chris@76: ); Chris@76: $toAction = array(); Chris@76: $details = array(); Chris@76: while ($row = $smcFunc['db_fetch_assoc']($request)) Chris@76: { Chris@76: // If it's not within what our view is ignore it... Chris@76: if (($row['id_msg'] == $row['id_first_msg'] && $context['current_view'] != 'topics') || ($row['id_msg'] != $row['id_first_msg'] && $context['current_view'] != 'replies')) Chris@76: continue; Chris@76: Chris@76: $can_add = false; Chris@76: // If we're approving this is simple. Chris@76: if ($curAction == 'approve' && ($any_array == array(0) || in_array($row['id_board'], $any_array))) Chris@76: { Chris@76: $can_add = true; Chris@76: } Chris@76: // Delete requires more permission checks... Chris@76: elseif ($curAction == 'delete') Chris@76: { Chris@76: // Own post is easy! Chris@76: if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) Chris@76: $can_add = true; Chris@76: // Is it a reply to their own topic? Chris@76: elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) Chris@76: $can_add = true; Chris@76: // Someone elses? Chris@76: elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) Chris@76: $can_add = true; Chris@76: } Chris@76: Chris@76: if ($can_add) Chris@76: $anItem = $context['current_view'] == 'topics' ? $row['id_topic'] : $row['id_msg']; Chris@76: $toAction[] = $anItem; Chris@76: Chris@76: // All clear. What have we got now, what, what? Chris@76: $details[$anItem] = array(); Chris@76: $details[$anItem]["subject"] = $row['subject']; Chris@76: $details[$anItem]["topic"] = $row['id_topic']; Chris@76: $details[$anItem]["member"] = ($context['current_view'] == 'topics') ? $row['id_member_started'] : $row['id_member']; Chris@76: $details[$anItem]["board"] = $row['id_board']; Chris@76: } Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: // If we have anything left we can actually do the approving (etc). Chris@76: if (!empty($toAction)) Chris@76: { Chris@76: if ($curAction == 'approve') Chris@76: { Chris@76: approveMessages ($toAction, $details, $context['current_view']); Chris@76: } Chris@76: else Chris@76: { Chris@76: removeMessages ($toAction, $details, $context['current_view']); Chris@76: } Chris@76: } Chris@76: } Chris@76: Chris@76: // How many unapproved posts are there? Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT COUNT(*) Chris@76: FROM {db_prefix}messages AS m Chris@76: INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic AND t.id_first_msg != m.id_msg) Chris@76: INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) Chris@76: WHERE m.approved = {int:not_approved} Chris@76: AND {query_see_board} Chris@76: ' . $approve_query, Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: ) Chris@76: ); Chris@76: list ($context['total_unapproved_posts']) = $smcFunc['db_fetch_row']($request); Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: // What about topics? Normally we'd use the table alias t for topics but lets use m so we don't have to redo our approve query. Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT COUNT(m.id_topic) Chris@76: FROM {db_prefix}topics AS m Chris@76: INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) Chris@76: WHERE m.approved = {int:not_approved} Chris@76: AND {query_see_board} Chris@76: ' . $approve_query, Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: ) Chris@76: ); Chris@76: list ($context['total_unapproved_topics']) = $smcFunc['db_fetch_row']($request); Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: $context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=postmod;sa=' . $context['current_view'] . (isset($_REQUEST['brd']) ? ';brd=' . (int) $_REQUEST['brd'] : ''), $_GET['start'], $context['current_view'] == 'topics' ? $context['total_unapproved_topics'] : $context['total_unapproved_posts'], 10); Chris@76: $context['start'] = $_GET['start']; Chris@76: Chris@76: // We have enough to make some pretty tabs! Chris@76: $context[$context['moderation_menu_name']]['tab_data'] = array( Chris@76: 'title' => $txt['mc_unapproved_posts'], Chris@76: 'help' => 'postmod', Chris@76: 'description' => $txt['mc_unapproved_posts_desc'], Chris@76: ); Chris@76: Chris@76: // Update the tabs with the correct number of posts. Chris@76: $context['menu_data_' . $context['moderation_menu_id']]['sections']['posts']['areas']['postmod']['subsections']['posts']['label'] .= ' (' . $context['total_unapproved_posts'] . ')'; Chris@76: $context['menu_data_' . $context['moderation_menu_id']]['sections']['posts']['areas']['postmod']['subsections']['topics']['label'] .= ' (' . $context['total_unapproved_topics'] . ')'; Chris@76: Chris@76: // If we are filtering some boards out then make sure to send that along with the links. Chris@76: if (isset($_REQUEST['brd'])) Chris@76: { Chris@76: $context['menu_data_' . $context['moderation_menu_id']]['sections']['posts']['areas']['postmod']['subsections']['posts']['add_params'] = ';brd=' . (int) $_REQUEST['brd']; Chris@76: $context['menu_data_' . $context['moderation_menu_id']]['sections']['posts']['areas']['postmod']['subsections']['topics']['add_params'] = ';brd=' . (int) $_REQUEST['brd']; Chris@76: } Chris@76: Chris@76: // Get all unapproved posts. Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT m.id_msg, m.id_topic, m.id_board, m.subject, m.body, m.id_member, Chris@76: IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.smileys_enabled, Chris@76: t.id_member_started, t.id_first_msg, b.name AS board_name, c.id_cat, c.name AS cat_name Chris@76: FROM {db_prefix}messages AS m Chris@76: INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) Chris@76: INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) Chris@76: LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) Chris@76: LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat) Chris@76: WHERE m.approved = {int:not_approved} Chris@76: AND t.id_first_msg ' . ($context['current_view'] == 'topics' ? '=' : '!=') . ' m.id_msg Chris@76: AND {query_see_board} Chris@76: ' . $approve_query . ' Chris@76: LIMIT ' . $context['start'] . ', 10', Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: ) Chris@76: ); Chris@76: $context['unapproved_items'] = array(); Chris@76: for ($i = 1; $row = $smcFunc['db_fetch_assoc']($request); $i++) Chris@76: { Chris@76: // Can delete is complicated, let's solve it first... is it their own post? Chris@76: if ($row['id_member'] == $user_info['id'] && ($delete_own_boards == array(0) || in_array($row['id_board'], $delete_own_boards))) Chris@76: $can_delete = true; Chris@76: // Is it a reply to their own topic? Chris@76: elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($delete_own_replies == array(0) || in_array($row['id_board'], $delete_own_replies))) Chris@76: $can_delete = true; Chris@76: // Someone elses? Chris@76: elseif ($row['id_member'] != $user_info['id'] && ($delete_any_boards == array(0) || in_array($row['id_board'], $delete_any_boards))) Chris@76: $can_delete = true; Chris@76: else Chris@76: $can_delete = false; Chris@76: Chris@76: $context['unapproved_items'][] = array( Chris@76: 'id' => $row['id_msg'], Chris@76: 'alternate' => $i % 2, Chris@76: 'counter' => $context['start'] + $i, Chris@76: 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], Chris@76: 'subject' => $row['subject'], Chris@76: 'body' => parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), Chris@76: 'time' => timeformat($row['poster_time']), Chris@76: 'poster' => array( Chris@76: 'id' => $row['id_member'], Chris@76: 'name' => $row['poster_name'], Chris@76: 'link' => $row['id_member'] ? '' . $row['poster_name'] . '' : $row['poster_name'], Chris@76: 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], Chris@76: ), Chris@76: 'topic' => array( Chris@76: 'id' => $row['id_topic'], Chris@76: ), Chris@76: 'board' => array( Chris@76: 'id' => $row['id_board'], Chris@76: 'name' => $row['board_name'], Chris@76: ), Chris@76: 'category' => array( Chris@76: 'id' => $row['id_cat'], Chris@76: 'name' => $row['cat_name'], Chris@76: ), Chris@76: 'can_delete' => $can_delete, Chris@76: ); Chris@76: } Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: $context['sub_template'] = 'unapproved_posts'; Chris@76: } Chris@76: Chris@76: // View all unapproved attachments. Chris@76: function UnapprovedAttachments() Chris@76: { Chris@76: global $txt, $scripturl, $context, $user_info, $sourcedir, $smcFunc; Chris@76: Chris@76: $context['page_title'] = $txt['mc_unapproved_attachments']; Chris@76: Chris@76: // Once again, permissions are king! Chris@76: $approve_boards = boardsAllowedTo('approve_posts'); Chris@76: Chris@76: if ($approve_boards == array(0)) Chris@76: $approve_query = ''; Chris@76: elseif (!empty($approve_boards)) Chris@76: $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; Chris@76: else Chris@76: $approve_query = ' AND 0'; Chris@76: Chris@76: // Get together the array of things to act on, if any. Chris@76: $attachments = array(); Chris@76: if (isset($_GET['approve'])) Chris@76: $attachments[] = (int) $_GET['approve']; Chris@76: elseif (isset($_GET['delete'])) Chris@76: $attachments[] = (int) $_GET['delete']; Chris@76: elseif (isset($_POST['item'])) Chris@76: foreach ($_POST['item'] as $item) Chris@76: $attachments[] = (int) $item; Chris@76: Chris@76: // Are we approving or deleting? Chris@76: if (isset($_GET['approve']) || (isset($_POST['do']) && $_POST['do'] == 'approve')) Chris@76: $curAction = 'approve'; Chris@76: elseif (isset($_GET['delete']) || (isset($_POST['do']) && $_POST['do'] == 'delete')) Chris@76: $curAction = 'delete'; Chris@76: Chris@76: // Something to do, let's do it! Chris@76: if (!empty($attachments) && isset($curAction)) Chris@76: { Chris@76: checkSession('request'); Chris@76: Chris@76: // This will be handy. Chris@76: require_once($sourcedir . '/ManageAttachments.php'); Chris@76: Chris@76: // Confirm the attachments are eligible for changing! Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT a.id_attach Chris@76: FROM {db_prefix}attachments AS a Chris@76: INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) Chris@76: LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board) Chris@76: WHERE a.id_attach IN ({array_int:attachments}) Chris@76: AND a.approved = {int:not_approved} Chris@76: AND a.attachment_type = {int:attachment_type} Chris@76: AND {query_see_board} Chris@76: ' . $approve_query, Chris@76: array( Chris@76: 'attachments' => $attachments, Chris@76: 'not_approved' => 0, Chris@76: 'attachment_type' => 0, Chris@76: ) Chris@76: ); Chris@76: $attachments = array(); Chris@76: while ($row = $smcFunc['db_fetch_assoc']($request)) Chris@76: $attachments[] = $row['id_attach']; Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: // Assuming it wasn't all like, proper illegal, we can do the approving. Chris@76: if (!empty($attachments)) Chris@76: { Chris@76: if ($curAction == 'approve') Chris@76: ApproveAttachments($attachments); Chris@76: else Chris@76: removeAttachments(array('id_attach' => $attachments)); Chris@76: } Chris@76: } Chris@76: Chris@76: // How many unapproved attachments in total? Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT COUNT(*) Chris@76: FROM {db_prefix}attachments AS a Chris@76: INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) Chris@76: INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) Chris@76: WHERE a.approved = {int:not_approved} Chris@76: AND a.attachment_type = {int:attachment_type} Chris@76: AND {query_see_board} Chris@76: ' . $approve_query, Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: 'attachment_type' => 0, Chris@76: ) Chris@76: ); Chris@76: list ($context['total_unapproved_attachments']) = $smcFunc['db_fetch_row']($request); Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: $context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=attachmod;sa=attachments', $_GET['start'], $context['total_unapproved_attachments'], 10); Chris@76: $context['start'] = $_GET['start']; Chris@76: Chris@76: // Get all unapproved attachments. Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT a.id_attach, a.filename, a.size, m.id_msg, m.id_topic, m.id_board, m.subject, m.body, m.id_member, Chris@76: IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, Chris@76: t.id_member_started, t.id_first_msg, b.name AS board_name, c.id_cat, c.name AS cat_name Chris@76: FROM {db_prefix}attachments AS a Chris@76: INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) Chris@76: INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) Chris@76: INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board) Chris@76: LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member) Chris@76: LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat) Chris@76: WHERE a.approved = {int:not_approved} Chris@76: AND a.attachment_type = {int:attachment_type} Chris@76: AND {query_see_board} Chris@76: ' . $approve_query . ' Chris@76: LIMIT ' . $context['start'] . ', 10', Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: 'attachment_type' => 0, Chris@76: ) Chris@76: ); Chris@76: $context['unapproved_items'] = array(); Chris@76: for ($i = 1; $row = $smcFunc['db_fetch_assoc']($request); $i++) Chris@76: { Chris@76: $context['unapproved_items'][] = array( Chris@76: 'id' => $row['id_attach'], Chris@76: 'alternate' => $i % 2, Chris@76: 'filename' => $row['filename'], Chris@76: 'size' => round($row['size'] / 1024, 2), Chris@76: 'time' => timeformat($row['poster_time']), Chris@76: 'poster' => array( Chris@76: 'id' => $row['id_member'], Chris@76: 'name' => $row['poster_name'], Chris@76: 'link' => $row['id_member'] ? '' . $row['poster_name'] . '' : $row['poster_name'], Chris@76: 'href' => $scripturl . '?action=profile;u=' . $row['id_member'], Chris@76: ), Chris@76: 'message' => array( Chris@76: 'id' => $row['id_msg'], Chris@76: 'subject' => $row['subject'], Chris@76: 'body' => parse_bbc($row['body']), Chris@76: 'time' => timeformat($row['poster_time']), Chris@76: 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], Chris@76: ), Chris@76: 'topic' => array( Chris@76: 'id' => $row['id_topic'], Chris@76: ), Chris@76: 'board' => array( Chris@76: 'id' => $row['id_board'], Chris@76: 'name' => $row['board_name'], Chris@76: ), Chris@76: 'category' => array( Chris@76: 'id' => $row['id_cat'], Chris@76: 'name' => $row['cat_name'], Chris@76: ), Chris@76: ); Chris@76: } Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: $context['sub_template'] = 'unapproved_attachments'; Chris@76: } Chris@76: Chris@76: // Approve a post, just the one. Chris@76: function ApproveMessage() Chris@76: { Chris@76: global $user_info, $topic, $board, $sourcedir, $smcFunc; Chris@76: Chris@76: checkSession('get'); Chris@76: Chris@76: $_REQUEST['msg'] = (int) $_REQUEST['msg']; Chris@76: Chris@76: require_once($sourcedir . '/Subs-Post.php'); Chris@76: Chris@76: isAllowedTo('approve_posts'); Chris@76: Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT t.id_member_started, t.id_first_msg, m.id_member, m.subject, m.approved Chris@76: FROM {db_prefix}messages AS m Chris@76: INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic}) Chris@76: WHERE m.id_msg = {int:id_msg} Chris@76: AND m.id_topic = {int:current_topic} Chris@76: LIMIT 1', Chris@76: array( Chris@76: 'current_topic' => $topic, Chris@76: 'id_msg' => $_REQUEST['msg'], Chris@76: ) Chris@76: ); Chris@76: list ($starter, $first_msg, $poster, $subject, $approved) = $smcFunc['db_fetch_row']($request); Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: // If it's the first in a topic then the whole topic gets approved! Chris@76: if ($first_msg == $_REQUEST['msg']) Chris@76: { Chris@76: approveTopics($topic, !$approved); Chris@76: Chris@76: if ($starter != $user_info['id']) Chris@76: logAction('approve_topic', array('topic' => $topic, 'subject' => $subject, 'member' => $starter, 'board' => $board)); Chris@76: } Chris@76: else Chris@76: { Chris@76: approvePosts($_REQUEST['msg'], !$approved); Chris@76: Chris@76: if ($poster != $user_info['id']) Chris@76: logAction('approve', array('topic' => $topic, 'subject' => $subject, 'member' => $poster, 'board' => $board)); Chris@76: } Chris@76: Chris@76: redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg']. '#msg' . $_REQUEST['msg']); Chris@76: } Chris@76: Chris@76: // Approve a batch of posts (or topics in their own right) Chris@76: function approveMessages($messages, $messageDetails, $current_view = 'replies') Chris@76: { Chris@76: global $sourcedir; Chris@76: Chris@76: require_once($sourcedir . '/Subs-Post.php'); Chris@76: if ($current_view == 'topics') Chris@76: { Chris@76: approveTopics($messages); Chris@76: // and tell the world about it Chris@76: foreach ($messages as $topic) Chris@76: { Chris@76: logAction('approve_topic', array('topic' => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board'])); Chris@76: } Chris@76: } Chris@76: else Chris@76: { Chris@76: approvePosts($messages); Chris@76: // and tell the world about it again Chris@76: foreach ($messages as $post) Chris@76: { Chris@76: logAction('approve', array('topic' => $messageDetails[$post]['topic'], 'subject' => $messageDetails[$post]['subject'], 'member' => $messageDetails[$post]['member'], 'board' => $messageDetails[$post]['board'])); Chris@76: } Chris@76: } Chris@76: } Chris@76: Chris@76: // This is a helper function - basically approve everything! Chris@76: function approveAllData() Chris@76: { Chris@76: global $smcFunc, $sourcedir; Chris@76: Chris@76: // Start with messages and topics. Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT id_msg Chris@76: FROM {db_prefix}messages Chris@76: WHERE approved = {int:not_approved}', Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: ) Chris@76: ); Chris@76: $msgs = array(); Chris@76: while ($row = $smcFunc['db_fetch_row']($request)) Chris@76: $msgs[] = $row[0]; Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: if (!empty($msgs)) Chris@76: { Chris@76: require_once($sourcedir . '/Subs-Post.php'); Chris@76: approvePosts($msgs); Chris@76: } Chris@76: Chris@76: // Now do attachments Chris@76: $request = $smcFunc['db_query']('', ' Chris@76: SELECT id_attach Chris@76: FROM {db_prefix}attachments Chris@76: WHERE approved = {int:not_approved}', Chris@76: array( Chris@76: 'not_approved' => 0, Chris@76: ) Chris@76: ); Chris@76: $attaches = array(); Chris@76: while ($row = $smcFunc['db_fetch_row']($request)) Chris@76: $attaches[] = $row[0]; Chris@76: $smcFunc['db_free_result']($request); Chris@76: Chris@76: if (!empty($attaches)) Chris@76: { Chris@76: require_once($sourcedir . '/ManageAttachments.php'); Chris@76: ApproveAttachments($attaches); Chris@76: } Chris@76: } Chris@76: Chris@76: // remove a batch of messages (or topics) Chris@76: function removeMessages($messages, $messageDetails, $current_view = 'replies') Chris@76: { Chris@76: global $sourcedir, $modSettings; Chris@76: require_once($sourcedir . '/RemoveTopic.php'); Chris@76: if ($current_view == 'topics') Chris@76: { Chris@76: removeTopics($messages); Chris@76: // and tell the world about it Chris@76: foreach ($messages as $topic) Chris@76: // Note, only log topic ID in native form if it's not gone forever. Chris@76: logAction('remove', array( Chris@76: (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$topic]['board'] ? 'topic' : 'old_topic_id') => $topic, 'subject' => $messageDetails[$topic]['subject'], 'member' => $messageDetails[$topic]['member'], 'board' => $messageDetails[$topic]['board'])); Chris@76: } Chris@76: else Chris@76: { Chris@76: foreach ($messages as $post) Chris@76: { Chris@76: removeMessage($post); Chris@76: logAction('delete', array( Chris@76: (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $messageDetails[$post]['board'] ? 'topic' : 'old_topic_id') => $messageDetails[$post]['topic'], 'subject' => $messageDetails[$post]['subject'], 'member' => $messageDetails[$post]['member'], 'board' => $messageDetails[$post]['board'])); Chris@76: } Chris@76: } Chris@76: } Chris@76: ?>