summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-admin/wpmu-blogs.php
blob: 1caa46fc7868307b892e8f568e3051632085052f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?php
require_once('admin.php');

$title = __('WPMU Admin');
$parent_file = 'wpmu-admin.php';
require_once('admin-header.php');
if( $wpblog != 'main' || $user_level < 10) {
    die( __('<p>You do not have permission to access this page.</p>') );
}
if (isset($_GET['updated'])) {
    ?><div class="updated"><p><strong><?php _e('Options saved.') ?></strong></p></div><?php
}
print '<div class="wrap">';
switch( $_GET[ 'action' ] ) {
    case "editblog":
    $options_table_name = $wpmuBaseTablePrefix . $_GET[ 'id' ] ."_options";
    $query = "SELECT *
              FROM   ".$options_table_name."
	      WHERE  option_name NOT LIKE 'rss%'";
    $options = $wpdb->get_results( $query, ARRAY_A );
    $query = "SELECT * 
	      FROM ".$wpdb->blogs." 
              WHERE blog_id = '".$_GET[ 'id' ]."'";
    $details = $wpdb->get_row( $query, ARRAY_A );
    $is_archived = get_settings( "is_archived" );
    if( $is_archived == '' )
	$is_archived = 'no';

    print "<h2>Edit Blog</h2>";
    ?>
    <form name="form1" method="post" action="wpmu-edit.php?action=updateblog"> 
    <input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" /> 
    <table><td valign='top'>
    <table width="100%" border='0' cellspacing="2" cellpadding="5" class="editform"> 
	<tr valign="top"> 
	<th scope="row">Blogname</th> 
	<td><input name="blog[blogname]" type="text" id="blog_name" value="<?php echo $details[ 'blogname' ] ?>" size="20" />.<?php echo $domain; ?></td> 
	</tr> 
	<tr valign="top"> 
	<th scope="row">Registered</th> 
	<td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo $details[ 'registered' ] ?>" size="40" /></td> 
	</tr> 
	<tr valign="top"> 
	<th scope="row">Last Updated</th> 
	<td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo $details[ 'last_updated' ] ?>" size="40" /></td> 
	</tr> 
	<tr valign="top"> 
	<th scope="row">Public</th> 
	<td><input type='radio' name='blog[is_public]' value='yes'<?php if( $details[ 'is_public' ] == 'yes' ) echo " checked"?>> Yes&nbsp;&nbsp;
	    <input type='radio' name='blog[is_public]' value='no'<?php if( $details[ 'is_public' ] == 'no' ) echo " checked"?>> No &nbsp;&nbsp;
	    </td> 
	</tr> 
	<tr valign="top"> 
	<th scope="row">Archived</th> 
	<td><input type='radio' name='option[is_archived]' value='yes'<?php if( $is_archived == 'yes' ) echo " checked"?>> Yes&nbsp;&nbsp;
	    <input type='radio' name='option[is_archived]' value='no'<?php if( $is_archived == 'no' ) echo " checked"?>> No &nbsp;&nbsp;
	    </td> 
	</tr> 
    <tr><td colspan='2'>
    <p class="submit">
      <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
    </p>
    <br />
    <br />
    </td></tr>
    <?php
    while( list( $key, $val ) = each( $options ) ) { 
    ?>
	<tr valign="top"> 
	<th scope="row"><?php echo ucwords( str_replace( "_", " ", $val[ 'option_name' ] ) ) ?></th> 
	<td><input name="option[<?php echo $val[ 'option_name' ] ?>]" type="text" id="<?php echo $val[ 'option_name' ] ?>" value="<?php echo $val[ 'option_value' ] ?>" size="40" /></td> 
	</tr> 
    <?php
    }
    ?>
    </table>
    <p class="submit">
      <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
    </p>
    </td>
    <td valign='top'>
    <?php
    $themes = get_themes();
    $query = "SELECT option_value
              FROM   ".$options_table_name."
	      WHERE  option_name = 'allowed_themes'";
    $blog_allowed_themes = $wpdb->get_var( $query );
    if( $blog_allowed_themes != false )
	$blog_allowed_themes = unserialize( $blog_allowed_themes );
    $allowed_themes = get_site_settings( "allowed_themes" );
    if( $allowed_themes == false ) {
	$allowed_themes = array_keys( $themes );
    }
    $out = '';
    while( list( $key, $val ) = each( $themes ) ) { 
	if( isset( $allowed_themes[ $key ] ) == false ) {
	    if( isset( $blog_allowed_themes[ $key ] ) == true ) {
		$checked = 'checked ';
	    } else {
		$checked = '';
	    }

	    $out .= '
		<tr valign="top"> 
		<th title="'.$val[ "Description" ].'" scope="row">'.$key.'</th> 
		<td><input name="theme['.$key.']" type="checkbox" id="'.$key.'" value="on" '.$checked.'/></td> 
		</tr> ';
	}
    }
    if( $out != '' ) {
	print "<h3>Blog Themes</h3>";
	print '<table width="100%" border="0" cellspacing="2" cellpadding="5" class="editform">';
	print '<tr><th>Theme</th><th>Enable</th></tr>';
	print $out;
	print "</table>";
    }
    ?>
    </td>
    </table>
    <?php
    break;
    default:
	$query = "SELECT * 
	          FROM ".$wpdb->blogs." 
		  WHERE site_id = '".$wpdb->siteid."'";
	if( $_GET[ 's' ] != '' ) {
	    $query = "SELECT * 
	              FROM ".$wpdb->blogs.", ".$wpdb->site." 
		      WHERE site_id = '".$wpdb->siteid."'
		      AND   ".$wpdb->blogs.".site_id = ".$wpdb->site.".id
		      AND   blogname like '%".$_GET[ 's' ]."%'";
	}
	$blog_list = $wpdb->get_results( $query, ARRAY_A );
?>
<h2>Blogs</h2>
<form name="searchform" action="wpmu-blogs.php" method="get" style="float: left; width: 16em; margin-right: 3em;"> 
  <fieldset> 
  <legend><?php _e('Search Blogs&hellip;') ?></legend> 
  <input type='hidden' name='action' value='blogs'>
  <input type="text" name="s" value="<?php if (isset($_GET[ 's' ])) echo wp_specialchars($_GET[ 's' ], 1); ?>" size="17" /> 
  <input type="submit" name="submit" value="<?php _e('Search') ?>"  /> 
  </fieldset>
</form>

<br style="clear:both;" />

<?php

// define the columns to display, the syntax is 'internal name' => 'display name'
$posts_columns = array(
  'id'           => __('ID'),
  'blogname'     => __('Blog Name'),
  'last_updated' => __('Last Updated'),
  'registered'   => __('Registered')
);
$posts_columns = apply_filters('manage_posts_columns', $posts_columns);

// you can not edit these at the moment
$posts_columns['control_view']      = '';
$posts_columns['control_edit']      = '';
$posts_columns['control_backend']   = '';
$posts_columns['control_delete']    = '';

?>

<table width="100%" cellpadding="3" cellspacing="3"> 
	<tr>

<?php foreach($posts_columns as $column_display_name) { ?>
	<th scope="col"><?php echo $column_display_name; ?></th>
<?php } ?>

	</tr>
<?php
if ($blog_list) {
$bgcolor = '';
foreach ($blog_list as $blog) { 
$class = ('alternate' == $class) ? '' : 'alternate';
?> 
	<tr class='<?php echo $class; ?>'>

<?php

foreach($posts_columns as $column_name=>$column_display_name) {

	switch($column_name) {
	
	case 'id':
		?>
		<th scope="row"><?php echo $blog[ 'blog_id' ] ?></th>
		<?php
		break;

	case 'blogname':
		?>
		<td><?php echo $blog[ 'blogname' ] ?>
		</td>
		<?php
		break;

	case 'last_updated':
		?>
		<td><?php echo $blog[ 'last_updated' ] ?></td>
		<?php
		break;

	case 'registered':
		?>
		<td><?php echo $blog[ 'registered' ] ?></td>
		<?php
		break;

	case 'control_view':
		?>
		<td><a href="<?php echo get_blogaddress_by_name( $blog[ 'blogname' ] ); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
		<?php
		break;

	case 'control_edit':
		?>
		<td><?php echo "<a href='wpmu-blogs.php?action=editblog&amp;id=".$blog[ 'blog_id' ]."' class='edit'>" . __('Edit') . "</a>"; ?></td>
		<?php
		break;

	case 'control_backend':
		?>
		<td><?php echo "<a href='".get_blogaddress_by_name( $blog[ 'blogname' ] )."wp-admin/' class='edit'>" . __('Backend') . "</a>"; ?></td>
		<?php
		break;

	case 'control_delete':
		?>
		<td><?php echo "<a href='wpmu-edit.php?action=deleteblog&amp;id=".$blog[ 'blog_id' ]."' class='delete' onclick=\"return confirm('" . sprintf(__("You are about to delete this blog?\\n  \'OK\' to delete, \'Cancel\' to stop.") ) . "')\">" . __('Delete') . "</a>"; ?></td>
		<?php
		break;

	default:
		?>
		<td><?php do_action('manage_posts_custom_column', $column_name, $id); ?></td>
		<?php
		break;
	}
}
?>
	</tr> 
<?php
}
print "</table>";
} else {
?>
  <tr style='background-color: <?php echo $bgcolor; ?>'> 
    <td colspan="8"><?php _e('No blogs found.') ?></td> 
  </tr> 
<?php
} // end if ($blogs)

    $themes = get_themes();
    $allowed_themes = get_site_settings( "allowed_themes" );
    if( $allowed_themes == false ) {
	$allowed_themes = array_keys( $themes );
    }

    print "<br />";
    print "<form action='wpmu-edit.php?action=updatethemes' method='POST'>";
    print "<h3>Site Themes</h3>";
    print '<table border="0" cellspacing="2" cellpadding="5" class="editform">';
    print "<caption>Disable themes site-wide. You can enable themes on a blog by blog basis.</caption>";
    print '<tr><th>Theme</th><th>Description</th><th>Disabled</th></tr>';
    while( list( $key, $val ) = each( $themes ) ) { 
	$enabled = '';
	$disabled = '';
	if( isset( $allowed_themes[ $key ] ) == true ) {
	    $enabled = 'checked ';
	} else {
	    $disabled = 'checked ';
	}
    ?>
	<tr valign="top"> 
	<th scope="row"><?php echo $key ?></th> 
	<td><?php echo $val[ 'Description' ] ?></td>
	<td>
	<input name="theme[<?php echo $key ?>]" type="radio" id="<?php echo $key ?>" value="disabled" <?php echo $disabled ?>/> Yes
	&nbsp;&nbsp;&nbsp; 
	<input name="theme[<?php echo $key ?>]" type="radio" id="<?php echo $key ?>" value="enabled" <?php echo $enabled ?>/> No
	</td> 
	</tr> 
    <?php
    }
    ?>
    </table>
    <input type='submit' value='Update Themes'>
    </form>
    <?php
break;
} // end switch( $action )
?> 

<div class="navigation">
<div class="alignleft"><?php //next_posts_link(__('&laquo; Previous Entries')) ?></div>
<div class="alignright"><?php //previous_posts_link(__('Next Entries &raquo;')) ?></div>
</div>

</div>
<?php include('admin-footer.php'); ?>