function moderation_blogs() { global $wpdb, $wp_roles, $current_user, $user_id, $current_site; if (!is_moderator()) { die; } if (isset($_GET['updated'])) { ?> <div id="message" class="updated fade"><p><?php _e(urldecode($_GET['updatedmsg']), 'moderation'); ?> </p></div><?php } echo '<div class="wrap">'; if (!isset($_GET['action'])) { $_GET['action'] = ''; } switch ($_GET['action']) { //---------------------------------------------------// default: ?> <h2><?php _e('Blogs', 'moderation'); ?> </h2> <?php if (isset($_GET['start']) == false) { $start = 0; } else { $start = intval($_GET['start']); } if (isset($_GET['num']) == false) { $num = 30; } else { $num = intval($_GET['num']); } $query = "SELECT * FROM " . $wpdb->base_prefix . "moderation_reports WHERE report_object_type = 'blog' AND report_status = 'new' GROUP BY report_blog_ID, report_object_ID ORDER BY report_stamp DESC"; $query .= " LIMIT " . intval($start) . ", " . intval($num); $reports = $wpdb->get_results($query, ARRAY_A); if (count($reports) < $num) { $next = false; } else { $next = true; } if (count($reports) > 0) { $report_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->base_prefix . "moderation_reports WHERE report_object_type = 'blog' AND report_status = 'new' GROUP BY GROUP BY report_blog_id, report_object_type, report_object_id ORDER BY report_stamp DESC"); if ($report_count > 30) { ?> <br /> <table><td> <fieldset> <?php //$order_sort = "order=" . $_GET[ 'order' ] . "&sortby=" . $_GET[ 'sortby' ]; if ($start == 0) { echo __('Previous Page', 'moderation'); } elseif ($start <= 30) { echo '<a href="admin.php?page=moderation-blogs&start=0&' . $order_sort . ' " style="text-decoration:none;" >' . __('Previous Page', 'moderation') . '</a>'; } else { echo '<a href="admin.php?page=moderation-blogs&start=' . ($start - $num) . '&' . $order_sort . '" style="text-decoration:none;" >' . __('Previous Page', 'moderation') . '</a>'; } if ($next) { echo ' || <a href="admin.php?page=moderation-blogss&start=' . ($start + $num) . '&' . $order_sort . '" style="text-decoration:none;" >' . __('Next Page', 'moderation') . '</a>'; } else { echo ' || ' . __('Next Page', 'moderation'); } ?> </fieldset> </td></table> <?php } echo "<form name='process_reports' method='POST' action='admin.php?page=moderation-blogs&action=process_reports' >"; echo "\n\t\t\t\t<br />\n\t\t\t\t<table cellpadding='3' cellspacing='3' width='100%' class='widefat'>\n\t\t\t\t<thead><tr>\n\t\t\t\t<th scope='col'>" . __('Blog', 'moderation') . "</th>\n\t\t\t\t<th scope='col'>" . __('Report Date/Time', 'moderation') . "</th>\n\t\t\t\t<th scope='col'>" . __('Reason(s)', 'moderation') . "</th>\n\t\t\t\t<th scope='col'>" . __('Action', 'moderation') . "</th>\n\t\t\t\t</tr></thead>\n\t\t\t\t<tbody id='the-list'>\n\t\t\t\t"; //=========================================================// $class = isset($class) && 'alternate' == $class ? '' : 'alternate'; $date_format = get_option('date_format'); $time_format = get_option('time_format'); foreach ($reports as $report) { //=========================================================// echo "<tr class='" . $class . "'>"; unset($blog_details); $blog_details = get_blog_details($report['report_blog_ID']); unset($reasons); $query = $wpdb->prepare("SELECT report_reason, report_note FROM " . $wpdb->base_prefix . "moderation_reports WHERE report_object_type = 'blog' AND report_status = 'new' AND report_blog_ID = %s AND report_object_ID = %s ORDER BY report_stamp DESC", $report['report_blog_ID'], $report['report_object_ID']); $reasons = $wpdb->get_results($query, ARRAY_A); echo "<td valign='top'><a href='" . $blog_details->siteurl . "' rel='permalink' class='edit'>" . stripslashes($blog_details->blogname) . "</a> (" . $blog_details->siteurl . ")</td>"; echo "<td valign='top'>" . date_i18n($date_format . ' ' . $time_format, $report['report_stamp']) . "</td>"; echo "<td valign='top'>"; foreach ($reasons as $reason) { echo stripslashes($reason['report_reason']); if (!empty($reason['report_note'])) { echo " - " . stripslashes($reason['report_note']); } echo "<br />"; } echo "</td>"; echo "<td valign='top'>"; echo "<select name='reports[" . $report['report_ID'] . "-" . $report['report_blog_ID'] . "]'>"; echo "<option value='reject_report'>" . __('Reject Report', 'moderation') . "</option>"; echo "<option value='suspend_blog'>" . __('Suspend Blog', 'moderation') . "</option>"; echo "</select>"; echo "</td>"; echo "</tr>"; $class = 'alternate' == $class ? '' : 'alternate'; //=========================================================// } //=========================================================// ?> </tbody></table> <p class="submit"> <input class="button button-primary" type="submit" name="Submit" value="<?php _e('Process Reports', 'moderation'); ?> " /> </p> </form> <?php } else { ?> <p><?php _e('There currently aren\'t any blogs in the moderation queue.', 'moderation'); ?> </p> <?php } break; //---------------------------------------------------// //---------------------------------------------------// case "process_reports": $reports = $_POST['reports']; if (count($reports) > 0) { foreach ($reports as $report_information => $action) { unset($report_ID); unset($blog_ID); list($report_ID, $blog_ID) = explode("-", $report_information); if ($action == 'reject_report') { $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . "moderation_reports SET report_status = 'rejected' WHERE report_object_type = 'blog' AND report_status = 'new' AND report_blog_ID = %d AND report_object_ID = %d", $blog_ID, $blog_ID)); } if ($action == 'suspend_blog') { $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->base_prefix . "moderation_reports SET report_status = 'suspended' WHERE report_object_type = 'blog' AND report_status = 'new' AND report_blog_ID = %d AND report_object_ID = %d", $blog_ID, $blog_ID)); update_archived($blog_ID, '1'); } } } echo "\n\t\t<SCRIPT LANGUAGE='JavaScript'>\n\t\twindow.location='admin.php?page=moderation-blogs&updated=true&updatedmsg=" . urlencode(__('Reports Processed.', 'moderation')) . "';\n\t\t</script>\n\t\t"; break; //---------------------------------------------------// //---------------------------------------------------// case "process": break; //---------------------------------------------------// } echo '</div>'; }
/** * Updates the archived status of a blog using the update_archived function * the update_archived parameters are: * $id The id of the blog to be updated. * $archived The new archived status value. * * @param array $args Array with username, password and update_archived function parameters * @return integer Returns the new archived status */ function msxmlrpc_update_archived($args) { $parameters = check_arguments($args); if (!is_array($parameters)) { return $parameters; } return update_archived($parameters['id'], $parameters['archived']); }