More options improvements.

git-svn-id: http://svn.automattic.com/wordpress/trunk@969 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-03-11 08:51:50 +00:00
parent 74638831a4
commit 75c8c3a72e
7 changed files with 160 additions and 26 deletions

View File

@ -46,6 +46,7 @@ if ($user_level <= 3) {
<ul id="adminmenu2"> <ul id="adminmenu2">
<li><a href="options-general.php">General</a></li> <li><a href="options-general.php">General</a></li>
<li><a href="options-writing.php">Writing</a></li> <li><a href="options-writing.php">Writing</a></li>
<li><a href="options-reading.php">Reading</a></li>
<li><a class="current">Discussion</a></li> <li><a class="current">Discussion</a></li>
<?php <?php
//we need to iterate through the available option groups. //we need to iterate through the available option groups.
@ -67,7 +68,7 @@ if ($user_level <= 3) {
<h2>Discussion Options</h2> <h2>Discussion Options</h2>
<form name="form1" method="post" action="options.php"> <form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" /> <input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','use_smilies','comments_notify','moderation_notify','comment_moderation','moderation_keys'" /> <input type="hidden" name="page_options" value="'default_pingback_flag','default_ping_status','default_comment_status','comments_notify','moderation_notify','comment_moderation','moderation_keys'" />
<p>Usual settings for an article: <em>(These settings may be overidden for individual articles.)</em></p> <p>Usual settings for an article: <em>(These settings may be overidden for individual articles.)</em></p>
<ul> <ul>
<li> <li>
@ -82,7 +83,7 @@ if ($user_level <= 3) {
</li> </li>
<li> <li>
<label for="default_comment_status"> <label for="default_comment_status">
<input name="default_comment_status" type="checkbox" id="default_comment_status" value="1" <?php checked('1', get_settings('default_comment_status')); ?> /> <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_settings('default_comment_status')); ?> />
Allow people to post comments on the article</label> Allow people to post comments on the article</label>
</li> </li>
</ul> </ul>
@ -106,6 +107,10 @@ if ($user_level <= 3) {
<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_settings('comment_moderation')); ?> /> <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_settings('comment_moderation')); ?> />
An administrator must approve the comment (regardless of any matches below) </label> An administrator must approve the comment (regardless of any matches below) </label>
</li> </li>
<li>
<input type="checkbox" name="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> />
User must fill out name and email
</li>
</ul> </ul>
<p>When a comment contains any of these words in its content, name, URI, or email, hold it in the moderation queue: (Seperate multiple words with new lines.)</p> <p>When a comment contains any of these words in its content, name, URI, or email, hold it in the moderation queue: (Seperate multiple words with new lines.)</p>
<p> <p>

View File

@ -46,6 +46,7 @@ if ($user_level <= 3) {
<ul id="adminmenu2"> <ul id="adminmenu2">
<li><a class="current">General</a></li> <li><a class="current">General</a></li>
<li><a href="options-writing.php">Writing</a></li> <li><a href="options-writing.php">Writing</a></li>
<li><a href="options-reading.php">Reading</a></li>
<li><a href="options-discussion.php">Discussion</a></li> <li><a href="options-discussion.php">Discussion</a></li>
<?php <?php
//we need to iterate through the available option groups. //we need to iterate through the available option groups.

View File

@ -55,6 +55,10 @@ default:
} }
?> ?>
<ul id="adminmenu2"> <ul id="adminmenu2">
<li><a href="options-general.php">General</a></li>
<li><a href="options-writing.php">Writing</a></li>
<li><a href="options-reading.php">Reading</a></li>
<li><a href="options-discussion.php">Discussion</a></li>
<?php <?php
//we need to iterate through the available option groups. //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"); $option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $tableoptiongroups ORDER BY group_id");
@ -68,7 +72,7 @@ default:
} }
} // end for each group } // end for each group
?> ?>
<li class="last"><a href="options-permalink.php">Permalinks</a></li> <li class="last"><a class="current">Permalinks</a></li>
</ul> </ul>
<br clear="all" /> <br clear="all" />
<div class="wrap"> <div class="wrap">

View File

@ -0,0 +1,124 @@
<?php
$title = 'Discussion 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 do not have sufficient permissions to edit the options for this blog.");
}
?>
<ul id="adminmenu2">
<li><a href="options-general.php">General</a></li>
<li><a href="options-writing.php">Writing</a></li>
<li><a class="current">Reading</a></li>
<li><a href="options-discussion.php">Discussion</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>Reading Options</h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="'posts_per_page','what_to_show','rss_use_excerpt','blog_charset','gzipcompression' " />
<fieldset>
<legend>Front Page</legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row">Show the most recent:</th>
<td><input name="posts_per_page" type="text" id="posts_per_page" value="<?php echo get_settings('posts_per_page'); ?>" size="3" />
<select name="what_to_show" id="what_to_show" >
<option value="days" <?php selected('days', get_settings('what_to_show')); ?>>days</option>
<option value="posts" <?php selected('posts', get_settings('what_to_show')); ?>>posts</option>
<option value="paged" <?php selected('paged', get_settings('what_to_show')); ?>>posts paged</option>
</select> </td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Syndication Feeds</legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row">Show the most recent:</th>
<td><input name="posts_per_rss" type="text" id="posts_per_rss" value="<?php echo get_settings('posts_per_rss'); ?>" size="3" />
posts </td>
</tr>
<tr valign="top">
<th scope="row"> For each article, show: </th>
<td><label>
<input name="rss_use_excerpt" type="radio" value="0" <?php checked(0, get_settings('rss_use_excerpt')); ?> />
full text</label> <br>
<label>
<input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_settings('rss_use_excerpt')); ?> />
summary</label> </td>
</tr>
</table>
</fieldset>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row"> Encoding for pages and feeds:</th>
<td><input name="blog_charset" type="text" id="blog_charset" value="<?php echo get_settings('blog_charset'); ?>" size="20" class="code" />
<br />
The character encoding you write your blog in (UTF-8 recommended<a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html"></a>)</td>
</tr>
</table>
<p>
<label>
<input type="checkbox" name="gzipcompression" value="1" <?php checked('1', get_settings('gzipcompression')); ?> />
WordPress should compress articles (gzip) if browsers ask for them</label>
</p>
<p style="text-align: right;">
<input type="submit" name="Submit" value="Update Options" />
</p>
</form>
</div>
<?php include("admin-footer.php") ?>

View File

@ -1,5 +1,5 @@
<?php <?php
$title = 'Writing Options'; $title = 'Reading Options';
function add_magic_quotes($array) { function add_magic_quotes($array) {
foreach ($array as $k => $v) { foreach ($array as $k => $v) {
@ -46,6 +46,7 @@ if ($user_level <= 3) {
<ul id="adminmenu2"> <ul id="adminmenu2">
<li><a href="options-general.php">General</a></li> <li><a href="options-general.php">General</a></li>
<li><a class="current">Writing</a></li> <li><a class="current">Writing</a></li>
<li><a href="options-reading.php">Reading</a></li>
<li><a href="options-discussion.php">Discussion</a></li> <li><a href="options-discussion.php">Discussion</a></li>
<?php <?php
//we need to iterate through the available option groups. //we need to iterate through the available option groups.
@ -94,12 +95,6 @@ Advanced controls</label>
<input name="use_balanceTags" type="checkbox" id="label2" value="1" <?php checked('1', get_settings('use_balanceTags')); ?> /> <input name="use_balanceTags" type="checkbox" id="label2" value="1" <?php checked('1', get_settings('use_balanceTags')); ?> />
WordPress should correct invalidly nested XHTML automatically</label></td> WordPress should correct invalidly nested XHTML automatically</label></td>
</tr> </tr>
<tr valign="top">
<th scope="row">Character Encoding: </th>
<td><input name="blog_charset" type="text" id="blog_charset" value="<?php echo get_settings('blog_charset'); ?>" size="20" class="code" />
<br />
The character encoding you write your blog in (UTF-8 recommended<a href="http://developer.apple.com/documentation/macos8/TextIntlSvcs/TextEncodingConversionManager/TEC1.5/TEC.b0.html"></a>)</td>
</tr>
</table> </table>
<fieldset> <fieldset>
<legend>Update Services</legend> <legend>Update Services</legend>

View File

@ -64,6 +64,10 @@ case 'update':
$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)"); $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)");
// die(var_dump($options)); // die(var_dump($options));
// HACK
// Options that if not there have 0 value but need to be something like "closed"
$nonbools = array('default_ping_status', 'default_comment_status');
if ($options) { if ($options) {
foreach ($options as $option) { foreach ($options as $option) {
// should we even bother checking? // should we even bother checking?
@ -71,21 +75,16 @@ case 'update':
$old_val = stripslashes($option->option_value); $old_val = stripslashes($option->option_value);
$new_val = $_POST[$option->option_name]; $new_val = $_POST[$option->option_name];
if (!$new_val) $new_val = 0; if (!$new_val) $new_val = 0;
if( in_array($option->option_name, $nonbools) && $new_val == 0 ) $new_value = 'closed';
if ($new_val != $old_val) { if ($new_val !== $old_val) {
// get type and validate $query = "UPDATE $tableoptions SET option_value = '$new_val' WHERE option_id = $option->option_id";
$msg = validate_option($option, $this_name, $new_val); $result = $wpdb->query($query);
if ($msg == '') { //if( in_array($option->option_name, $nonbools)) die('boo'.$query);
//no error message
$result = $wpdb->query("UPDATE $tableoptions SET option_value = '$new_val' WHERE option_id = $option->option_id");
if (!$result) { if (!$result) {
$db_errors .= " SQL error while saving $this_name. "; $db_errors .= " SQL error while saving $this_name. ";
} else { } else {
++$any_changed; ++$any_changed;
} }
} else {
$validation_message .= $msg;
}
} }
} }
} // end foreach } // end foreach
@ -142,6 +141,9 @@ if ($non_was_selected) { // no group pre-selected, display opening page
?> ?>
<ul id="adminmenu2"> <ul id="adminmenu2">
<li><a href="options-general.php">General</a></li> <li><a href="options-general.php">General</a></li>
<li><a href="options-writing.php">Writing</a></li>
<li><a href="options-reading.php">Reading</a></li>
<li><a href="options-discussion.php">Discussion</a></li>
<?php <?php
//Iterate through the available option groups. //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"); $option_groups = $wpdb->get_results("SELECT group_id, group_name, group_desc, group_longdesc FROM $tableoptiongroups ORDER BY group_id");

View File

@ -704,6 +704,9 @@ function upgrade_110() {
} }
} }
$wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 1");
$wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 2");
$wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 3");
$wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 6"); $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 6");
$wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 7"); $wpdb->query("DELETE FROM $tableoptiongroups WHERE group_id = 7");