Abstraction of a admin functions, new custom options page for general options, improved style.

git-svn-id: https://develop.svn.wordpress.org/trunk@869 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Matt Mullenweg 2004-02-13 09:59:47 +00:00
parent 2a85f5b103
commit 1213208d71
8 changed files with 152 additions and 27 deletions

View File

@ -1,5 +1,13 @@
<?php
function selected($selected, $current) {
if ($selected == $current) echo ' selected="selected"';
}
function checked($checked, $current) {
if ($checked == $current) echo ' checked="checked"';
}
function get_nested_categories($default = 0) {
global $post, $tablecategories, $tablepost2cat, $mode, $wpdb;

View File

@ -4,15 +4,6 @@
$allowed_users = explode(" ", trim($fileupload_allowedusers));
function selected($selected, $current) {
if ($selected == $current) echo ' selected="selected"';
}
function checked($checked, $current) {
if ($checked == $current) echo ' checked="checked"';
}
$submitbutton_text = 'Save';
$toprow_title = 'Editing Post #' . $postdata['ID'];
$form_action = 'editpost';

View File

@ -4,14 +4,6 @@
$allowed_users = explode(" ", trim($fileupload_allowedusers));
function selected($selected, $current) {
if ($selected == $current) echo ' selected="selected"';
}
function checked($checked, $current) {
if ($checked == $current) echo ' checked="checked"';
}
$submitbutton_text = 'Blog this!';
$toprow_title = 'New Post';
$form_action = 'post';

View File

@ -3,7 +3,7 @@
3 categories.php Categories
5 link-manager.php Links
3 users.php Users
4 options.php Options
4 options-general.php Options
4 templates.php Templates
5 upload.php Upload
0 profile.php My Profile

View File

@ -0,0 +1,122 @@
<?php
$title = 'General Options';
function add_magic_quotes($array) {
foreach ($array as $k => $v) {
if (is_array($v)) {
$array[$k] = add_magic_quotes($v);
} else {
$array[$k] = addslashes($v);
}
}
return $array;
}
if (!get_magic_quotes_gpc()) {
$HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS);
$HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS);
$HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
}
$wpvarstoreset = array('action','standalone', 'option_group_id');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) {
if (empty($HTTP_POST_VARS["$wpvar"])) {
if (empty($HTTP_GET_VARS["$wpvar"])) {
$$wpvar = '';
} else {
$$wpvar = $HTTP_GET_VARS["$wpvar"];
}
} else {
$$wpvar = $HTTP_POST_VARS["$wpvar"];
}
}
}
require_once('optionhandler.php');
$standalone = 0;
include_once('admin-header.php');
if ($user_level <= 3) {
die("You have no right to edit the options for this blog.<br />Ask for a promotion to your <a href=\"mailto:$admin_email\">blog admin</a> :)");
}
?>
<ul id="adminmenu2">
<li><a href="options-general.php" class="current">General</a></li>
<?php
//we need to iterate through the available option groups.
$option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $tableoptiongroups ORDER BY group_id");
foreach ($option_groups as $option_group) {
if ($option_group->group_id == $option_group_id) {
$current_desc=$option_group->group_desc;
$current_long_desc = $option_group->group_longdesc;
echo(" <li><a id=\"current2\" href=\"options.php?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></li>\n");
} else {
echo(" <li><a href=\"options.php?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></li>\n");
}
} // end for each group
?>
<li class="last"><a href="options-permalink.php">Permalinks</a></li>
</ul>
<br clear="all" />
<div class="wrap">
<h2>General Options</h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row">Weblog title: </th>
<td><input name="blogname" type="text" id="blogname" value="<?php echo get_settings('blogname'); ?>" size="40" /></td>
</tr>
<tr valign="top">
<th scope="row">Tagline:</th>
<td><input name="blogdescription" type="text" id="blogdescription" style="width: 95%" value="<?php echo get_settings('blogdescription'); ?>" size="45" />
<br />
In a few words, explain what this weblog is about.</td>
</tr>
<tr valign="top">
<th scope="row">Web address (URI): </th>
<td><input name="siteurl" type="text" id="siteurl" value="<?php echo get_settings('siteurl'); ?>" size="40" class="code" /></td>
</tr>
<tr valign="top">
<th scope="row">E-mail address: </th>
<td><input name="admin_email" type="text" id="admin_email" value="<?php echo get_settings('admin_email'); ?>" size="40" class="code" />
<br />
This address is used only for admin purposes. </td>
</tr>
<tr valign="top">
<th scope="row">Membership:</th>
<td> <label for="users_can_register">
<input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_settings('users_can_register')); ?> />
Anyone can register</label>
<br />
<label for="new_users_can_blog">
<input name="new_users_can_blog" type="checkbox" id="new_users_can_blog" value="1" <?php checked('1', get_settings('new_users_can_blog')); ?> />
Any registered member can publish articles </label></td>
</tr>
</table>
<fieldset class="options">
<legend>Time</legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr>
<th scope="row" width="33%">The servers current time is: </th>
<td><code><?php echo date('Y-m-d g:i:s a'); ?></code></td>
</tr>
<tr>
<th scope="row"> Times in the weblog should differ by: </th>
<td><input name="time_difference" type="text" id="time_difference" size="2" value="<?php echo get_settings('time_difference'); ?>" />
hours </td>
</tr>
</table>
</fieldset>
<p style="text-align: right;">
<input type="submit" name="Submit" value="Update Options" />
</p>
</form>
</div>
<?php
include("admin-footer.php") ?>

View File

@ -53,18 +53,19 @@ case "update":
// pull the vars from the post
// validate ranges etc.
// update the values
$options = $wpdb->get_results("SELECT $tableoptions.option_id, option_name, option_type, option_value, option_admin_level "
. "FROM $tableoptions "
. "LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id "
. "WHERE group_id = $option_group_id "
. "ORDER BY seq");
foreach ($_POST as $key => $value) {
$option_names[] = "'$key'";
}
$option_names = implode(',', $option_names);
$options = $wpdb->get_results("SELECT $tableoptions.option_id, option_name, option_type, option_value, option_admin_level FROM $tableoptions WHERE option_name IN ($option_names)");
if ($options) {
foreach ($options as $option) {
// should we even bother checking?
if ($user_level >= $option->option_admin_level) {
$this_name = $option->option_name;
$old_val = stripslashes($option->option_value);
$new_val = $HTTP_POST_VARS[$this_name];
$new_val = $_POST[$this_name];
if ($new_val != $old_val) {
// get type and validate
@ -97,8 +98,8 @@ case "update":
}
$message .= $dB_errors . '<br />' . $validation_message;
}
//break; //fall through
header('Location: ' . $_SERVER['HTTP_REFERER']);
break;
default:
$standalone = 0;
@ -135,6 +136,7 @@ if ($non_was_selected) { // no group pre-selected, display opening page
?>
<ul id="adminmenu2">
<li><a href="options-general.php">General</a></li>
<?php
//Iterate through the available option groups.
$option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $tableoptiongroups ORDER BY group_id");

View File

@ -673,7 +673,7 @@ function upgrade_101() {
}
function upgrade_110() {
global $wpdb, $tableusers, $tablecomments, $tableposts;
global $wpdb, $tableusers, $tablecomments, $tableposts, $tableoptiongroups;
maybe_add_column($tablecomments, 'user_id', "ALTER TABLE `$tablecomments` ADD `user_id` INT DEFAULT '0' NOT NULL ;");
maybe_add_column($tableusers, 'user_activation_key', "ALTER TABLE `$tableusers` ADD `user_activation_key` VARCHAR( 60 ) NOT NULL ;");
@ -704,6 +704,8 @@ function upgrade_110() {
$wpdb->query('UPDATE '.$tableusers.' SET user_pass = MD5(\''.$row->user_pass.'\') WHERE ID = \''.$row->ID.'\'');
}
}
$wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 6");
}
?>

View File

@ -123,6 +123,14 @@ textarea, input, select {
padding: 0;
}
.editform th {
text-align: right;
}
.code {
font-family: "Courier New", Courier, mono;
}
.post-categories {
display: inline;
margin: 0;