OLD CODE:
<?php
/*
Plugin Name: Private Blog by Default
Plugin URI: http://www.miteshashar.com/
Description: A brief description of the plugin.
Version: 0.1
Author: Mitesh B Ashar
Author URI: http://www.miteshashar.com/
*/
?>
<?php
/* Copyright 2007 Mitesh B Ashar (email@miteshashar.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
?>
<?
if($wpdb->get_var("SHOW TABLES LIKE 'wpmu_pubdenial'")!='wpmu_pubdenial')
{
$sql= "CREATE TABLE pubdenial(blog_id int NOT NULL, backup int)";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);
}
function denypuboncreate($blog_id)
{
global $wpdb;
$blogstat=get_blog_status($blog_id,"public");
$wpdb->query("INSERT INTO pubdenial VALUES(".$blog_id.",".$blogstat.")");
if($blogstat)update_blog_status($blog_id,"public",0);
}
add_action('wpmu_activate_blog','denypuboncreate');
function denypubonupdate($old,$new)
{
global $wpdb,$blog_id;
$blogstat=get_blog_status($blog_id,"public");
$wpdb->query("UPDATE pubdenial SET backup='".$blogstat."' WHERE blog_id=".$blog_id);
echo $blogstat;
if($blogstat)update_blog_status($blog_id,"public",0);
}
add_action('update_option_blog_public','denypubonupdate');
function rempubblog($blog_id)
{
global $wpdb;
$wpdb->query("DELETE FROM pubdenial WHERE blog_id=".$blog_id);
}
function approvepub($blog_id)
{
global $wpdb;
$blogstat=$wpdb->get_var("SELECT backup FROM pubdenial WHERE blog_id=$blog_id");
update_blog_status($blog_id,"public",$blogstat);
rempubblog($blog_id);
}
function spampub($blog_id)
{
update_blog_status($blog_id,"spam",1);
rempubblog($blog_id);
}
add_action('admin_menu', 'config_pubdenial');
function config_pubdenial()
{
get_currentuserinfo();
//if (!is_site_admin()) return false;
add_submenu_page('wpmu-admin.php', 'Blogs waiting to go Public', 'Approve New Blogs', 10, basename(__FILE__), 'configpage_pubdenial');
}
function configpage_pubdenial()
{
global $wpdb;
if (!is_site_admin()) die(__('<p>You do not have permission to access this page.</p>'));
if(isset($_POST['submit'])){
if ( !current_user_can('manage_options') )die(__("Sorry, you ain't admin enough to do this"));
else
{
$pubblogs=array();
for($i=0;isset($_POST['pubblog'.$i]);$i++)$pubblogs[$i]=$_POST['pubblog'.$i];
for($i=0;isset($_POST['pubblog'.$i."action"]);$i++)$pubblogsact[$i]=$_POST['pubblog'.$i."action"];
for($i=0;$i<count($pubblogs);$i++)
{
switch($pubblogsact[$i])
{
case 'approve': approvepub($pubblogs[$i]);$appflag=1;break;
case 'spam': spampub($pubblogs[$i]);$spamflag=1;break;
}
}
if($appflag==1) ?> <div id="message" class="updated fade"><p> <?php _e('Selected Blogs approved.') ?> </p></div><?
if($spamflag==1) ?> <div id="message" class="updated fade"><p> <?php _e('Selected Blogs marked as spam.') ?> </p></div> <?
}
}
?>
<div class="wrap">
<h2>Blogs waiting to go public</h2>
<form action="" method="post" id="pubblogs" style="margin: auto;">
<TABLE BORDER=0>
<TR>
<TD>Approve</TD><TD>Spam</TD><TD>Decide later</TD><TD>Blog Name</TD>
</TR>
<?
$pubblogs=$wpdb->get_results("SELECT blog_id from pubdenial",ARRAY_A);
for($i=0;$i<count($pubblogs);$i++)
{
echo "<TR>";
echo '<TD ALIGN=CENTER><INPUT TYPE=radio NAME="pubblog'.$i.'action" VALUE="approve" SELECTED></TD>';
echo '<TD ALIGN=CENTER><INPUT TYPE=radio NAME="pubblog'.$i.'action" VALUE="spam"></TD>';
echo '<TD ALIGN=CENTER><INPUT TYPE=radio NAME="pubblog'.$i.'action" VALUE="later"></TD>';
echo '<TD><INPUT TYPE=hidden NAME="pubblog'.$i.'" VALUE="'.$pubblogs[$i][blog_id].'">';
$currdetails=get_blog_details($pubblogs[$i][blog_id]);
echo '<A HREF="'.$currdetails->siteurl.'">'.$currdetails->blogname.'</A>';
echo '</TD></TR>';
}?>
</TABLE>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Update »'); ?>" /></p>
</form>
<?
}
//*/
?>