More options functionaily
validation, error messages More options git-svn-id: http://svn.automattic.com/wordpress/trunk@223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9f7fc05b29
commit
abfaf6500a
|
@ -1,6 +1,6 @@
|
||||||
1 b2edit.php Post / Edit
|
1 b2edit.php Post / Edit
|
||||||
3 b2team.php Team
|
3 b2team.php Team
|
||||||
4 b2options.php Options
|
4 wp-options.php Options
|
||||||
3 b2categories.php Categories
|
3 b2categories.php Categories
|
||||||
4 b2template.php Template
|
4 b2template.php Template
|
||||||
5 linkmanager.php Manage Links
|
5 linkmanager.php Manage Links
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('../b2config.php');
|
require_once('../wp-config.php');
|
||||||
/**
|
/**
|
||||||
** get_option_widget()
|
** get_option_widget()
|
||||||
** parameters:
|
** parameters:
|
||||||
|
@ -12,54 +12,48 @@ function get_option_widget($option_result, $editable, $between)
|
||||||
global $wpdb, $tableoptionvalues;
|
global $wpdb, $tableoptionvalues;
|
||||||
$disabled = $editable ? '' : 'disabled';
|
$disabled = $editable ? '' : 'disabled';
|
||||||
|
|
||||||
switch ($option_result->option_type)
|
switch ($option_result->option_type) {
|
||||||
{
|
|
||||||
case 1: // integer
|
case 1: // integer
|
||||||
case 3: // string
|
case 3: // string
|
||||||
case 6: // range -- treat same as integer for now!
|
case 6: // range -- treat same as integer for now!
|
||||||
{
|
if (($option_result->option_type == 1) || ($option_result->option_type == 1)) {
|
||||||
if (($option_result->option_type == 1) || ($option_result->option_type == 1))
|
|
||||||
$width = 6;
|
$width = 6;
|
||||||
else
|
} else {
|
||||||
$width = $option_result->option_width;
|
$width = $option_result->option_width;
|
||||||
|
}
|
||||||
return <<<TEXTINPUT
|
return <<<TEXTINPUT
|
||||||
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
||||||
<input type="text" name="$option_result->option_name" size="$width" value="$option_result->option_value" $disabled/>
|
<input type="text" name="$option_result->option_name" size="$width" value="$option_result->option_value" $disabled/>
|
||||||
TEXTINPUT;
|
TEXTINPUT;
|
||||||
//break;
|
//break;
|
||||||
}
|
|
||||||
case 2: // boolean
|
case 2: // boolean
|
||||||
{
|
$true_selected = ($option_result->option_value == '1') ? 'selected' : '';
|
||||||
$true_selected = ($option_result->option_value == 'true') ? 'selected' : '';
|
$false_selected = ($option_result->option_value == '0') ? 'selected' : '';
|
||||||
$false_selected = ($option_result->option_value == 'false') ? 'selected' : '';
|
|
||||||
return <<<BOOLSELECT
|
return <<<BOOLSELECT
|
||||||
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
||||||
<select name="$option_result->option_name" $disabled>
|
<select name="$option_result->option_name" $disabled>
|
||||||
<option $true_selected>true</option>
|
<option value="1" $true_selected>true</option>
|
||||||
<option $false_selected>false</option>
|
<option value="0" $false_selected>false</option>
|
||||||
</select>
|
</select>
|
||||||
BOOLSELECT;
|
BOOLSELECT;
|
||||||
//break;
|
//break;
|
||||||
}
|
|
||||||
case 5: // select
|
case 5: // select
|
||||||
{
|
|
||||||
$ret = <<<SELECT
|
$ret = <<<SELECT
|
||||||
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
||||||
<select name="$option_result->option_name" $disabled>
|
<select name="$option_result->option_name" $disabled>
|
||||||
SELECT;
|
SELECT;
|
||||||
|
|
||||||
$select = $wpdb->get_results("SELECT optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min "
|
$select = $wpdb->get_results("SELECT optionvalue, optionvalue_desc "
|
||||||
."FROM $tableoptionvalues "
|
."FROM $tableoptionvalues "
|
||||||
."WHERE option_id = $option_result->option_id "
|
."WHERE option_id = $option_result->option_id "
|
||||||
."ORDER BY optionvalue_seq");
|
."ORDER BY optionvalue_seq");
|
||||||
if ($select)
|
if ($select) {
|
||||||
{
|
foreach($select as $option) {
|
||||||
foreach($select as $option)
|
|
||||||
{
|
|
||||||
$ret .= '<option value="'.$option->optionvalue.'"';
|
$ret .= '<option value="'.$option->optionvalue.'"';
|
||||||
//error_log("comparing [$option_result->option_value] == [$option->optionvalue]");
|
//error_log("comparing [$option_result->option_value] == [$option->optionvalue]");
|
||||||
if ($option_result->option_value == $option->optionvalue)
|
if ($option_result->option_value == $option->optionvalue) {
|
||||||
{
|
|
||||||
$ret .=' selected';
|
$ret .=' selected';
|
||||||
}
|
}
|
||||||
$ret .= ">$option->optionvalue_desc</option>\n";
|
$ret .= ">$option->optionvalue_desc</option>\n";
|
||||||
|
@ -68,9 +62,56 @@ SELECT;
|
||||||
$ret .= '</select>';
|
$ret .= '</select>';
|
||||||
return $ret;
|
return $ret;
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
|
case 7: // SQL select
|
||||||
|
// first get the sql to run
|
||||||
|
$sql = $wpdb->get_var("SELECT optionvalue FROM $tableoptionvalues WHERE option_id = $option_result->option_id");
|
||||||
|
if (!$sql) {
|
||||||
|
return $option_result->option_name . $editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now we may need to do table name substitution
|
||||||
|
eval("include('../wp-config.php');\$sql = \"$sql\";");
|
||||||
|
|
||||||
|
$ret = <<<SELECT
|
||||||
|
<label for="$option_result->option_name">$option_result->option_name</label>$between
|
||||||
|
<select name="$option_result->option_name" $disabled>
|
||||||
|
SELECT;
|
||||||
|
|
||||||
|
$select = $wpdb->get_results("$sql");
|
||||||
|
if ($select) {
|
||||||
|
foreach($select as $option) {
|
||||||
|
$ret .= '<option value="'.$option->value.'"';
|
||||||
|
//error_log("comparing [$option_result->option_value] == [$option->optionvalue]");
|
||||||
|
if ($option_result->option_value == $option->value) {
|
||||||
|
$ret .=' selected';
|
||||||
|
}
|
||||||
|
$ret .= ">$option->label</option>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ret .= '</select>';
|
||||||
|
return $ret;
|
||||||
|
//break;
|
||||||
|
|
||||||
} // end switch
|
} // end switch
|
||||||
return $option_result->option_name . $editable;
|
return $option_result->option_name . $editable;
|
||||||
} // end function get_option_widget
|
} // end function get_option_widget
|
||||||
|
|
||||||
|
|
||||||
|
function validate_option($option, $name, $val) {
|
||||||
|
global $wpdb, $tableoptionvalues;
|
||||||
|
$msg = '';
|
||||||
|
switch ($option->option_type) {
|
||||||
|
case 6: // range
|
||||||
|
// get range
|
||||||
|
$range = $wpdb->get_row("SELECT optionvalue_max, optionvalue_min FROM $tableoptionvalues WHERE option_id = $option->option_id");
|
||||||
|
if ($range) {
|
||||||
|
if (($val < $range->optionvalue_min) || ($val > $range->optionvalue_max)) {
|
||||||
|
$msg = "$name is outside the valid range ($range->optionvalue_min - $range->optionvalue_max). ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // end switch
|
||||||
|
return $msg;
|
||||||
|
} // end validate_option
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1,6 +1,6 @@
|
||||||
--- temporary file to set up options data before update/install script is written.
|
--- temporary file to set up options data before update/install script is written.
|
||||||
|
|
||||||
-- will also need settings in b2config.php for these tables names
|
-- will also need settings in wp-config.php for these tables names
|
||||||
-- //new option tables
|
-- //new option tables
|
||||||
-- $tableoptions = 'options';
|
-- $tableoptions = 'options';
|
||||||
-- $tableoptiontypes = 'optiontypes';
|
-- $tableoptiontypes = 'optiontypes';
|
||||||
|
@ -21,6 +21,7 @@ INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (3, 'string');
|
||||||
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (4, 'date');
|
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (4, 'date');
|
||||||
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (5, 'select');
|
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (5, 'select');
|
||||||
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (6, 'range');
|
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (6, 'range');
|
||||||
|
INSERT INTO optiontypes (optiontype_id, optiontype_name) VALUES (7, 'sqlselect');
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE options (
|
CREATE TABLE options (
|
||||||
|
@ -40,39 +41,39 @@ INSERT INTO options (option_id, option_name, option_type, option_value, option_d
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(2,'blogfilename', 3, 'index.php', 'blogfilename is the name of the default file for your blog', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(2,'blogfilename', 3, 'index.php', 'blogfilename is the name of the default file for your blog', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(3,'blogname', 3, 'my weblog', 'blogname is the name of your blog', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(3,'blogname', 3, 'my weblog', 'blogname is the name of your blog', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(4,'blogdescription', 3, 'babblings!', 'blogdescription is the description of your blog', 8, 40);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(4,'blogdescription', 3, 'babblings!', 'blogdescription is the description of your blog', 8, 40);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(5,'b2inc', 3, 'b2-include', 'This is the name of the include directory. No "/" allowed.', 8);
|
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(6,'search_engine_friendly_urls', 2, 'false', 'Querystring Configuration ** (don\'t change if you don\'t know what you\'re doing)', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(6,'search_engine_friendly_urls', 2, 'false', 'Querystring Configuration ** (don\'t change if you don\'t know what you\'re doing)', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(7,'new_users_can_blog', 2, 'false', 'whether you want new users to be able to post entries once they have registered', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(7,'new_users_can_blog', 2, '0', 'whether you want new users to be able to post entries once they have registered', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(8,'users_can_register', 2, 'true', 'whether you want to allow users to register on your blog', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(8,'users_can_register', 2, '1', 'whether you want to allow users to register on your blog', 8);
|
||||||
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(54,'admin_email', 3, 'you@example.com', 'Your email (obvious eh?)', 8);
|
||||||
|
|
||||||
--// general blog setup
|
--// general blog setup
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(9 ,'start_of_week', 5, '1', 'day at the start of the week', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(9 ,'start_of_week', 5, '1', 'day at the start of the week', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(10,'use_preview', 2, 'true', 'Do you want to use the \'preview\' function', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(10,'use_preview', 2, '1', 'Do you want to use the \'preview\' function', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(11,'use_bbcode', 2, 'false', 'use BBCode, like [b]bold[/b]', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(11,'use_bbcode', 2, '0', 'use BBCode, like [b]bold[/b]', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(12,'use_gmcode', 2, 'false', 'use GreyMatter-styles: **bold** \\\\italic\\\\ __underline__', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(12,'use_gmcode', 2, '0', 'use GreyMatter-styles: **bold** \\\\italic\\\\ __underline__', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(13,'use_quicktags', 2, 'true', 'buttons for HTML tags (they won\'t work on IE Mac yet)', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(13,'use_quicktags', 2, '1', 'buttons for HTML tags (they won\'t work on IE Mac yet)', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(14,'use_htmltrans', 2, 'true', 'IMPORTANT! set this to false if you are using Chinese, Japanese, Korean, or other double-bytes languages', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(14,'use_htmltrans', 2, '1', 'IMPORTANT! set this to false if you are using Chinese, Japanese, Korean, or other double-bytes languages', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(15,'use_balanceTags', 2, 'true', 'this could help balance your HTML code. if it gives bad results, set it to false', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(15,'use_balanceTags', 2, '1', 'this could help balance your HTML code. if it gives bad results, set it to false', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(16,'use_smilies', 2, 'true', 'set this to 1 to enable smiley conversion in posts (note: this makes smiley conversion in ALL posts)', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(16,'use_smilies', 2, '1', 'set this to 1 to enable smiley conversion in posts (note: this makes smiley conversion in ALL posts)', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(17,'smilies_directory', 3, 'http://mydomain.com/b2-img/smilies', 'the directory where your smilies are (no trailing slash)', 8, 40);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(17,'smilies_directory', 3, 'http://mydomain.com/b2-img/smilies', 'the directory where your smilies are (no trailing slash)', 8, 40);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(18,'require_name_email', 2, 'false', 'set this to true to require e-mail and name, or false to allow comments without e-mail/name', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(18,'require_name_email', 2, '0', 'set this to true to require e-mail and name, or false to allow comments without e-mail/name', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(19,'comment_allowed_tags', 3, '<b><i><strong><em><code><blockquote><p><br><strike><a>', 'here is a list of the tags that are allowed in the comments. You can add tags to the list, just add them in the string, add only the opening tag: for example, only \'<a>\' instead of \'<a href=""></a>\'', 8, 40);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(19,'comment_allowed_tags', 3, '<b><i><strong><em><code><blockquote><p><br><strike><a>', 'here is a list of the tags that are allowed in the comments. You can add tags to the list, just add them in the string, add only the opening tag: for example, only \'<a>\' instead of \'<a href=""></a>\'', 8, 40);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(20,'comments_notify', 2, 'true', 'set this to true to let every author be notified about comments on their posts', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(20,'comments_notify', 2, '1', 'set this to true to let every author be notified about comments on their posts', 8);
|
||||||
|
|
||||||
--//rss/rdf feeds
|
--//rss/rdf feeds
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(21,'posts_per_rss', 1, '10', 'number of last posts to syndicate', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(21,'posts_per_rss', 1, '10', 'number of last posts to syndicate', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(22,'rss_language', 3, 'en', 'the language of your blog ( see this: http://backend.userland.com/stories/storyReader$16 )', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(22,'rss_language', 3, 'en', 'the language of your blog ( see this: http://backend.userland.com/stories/storyReader$16 )', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(23,'rss_encoded_html', 2, 'false', 'for b2rss.php: allow encoded HTML in <description> tag?', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(23,'rss_encoded_html', 2, '0', 'for b2rss.php: allow encoded HTML in <description> tag?', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(24,'rss_excerpt_length', 1, '50', 'length (in words) of excerpts in the RSS feed? 0=unlimited note: in b2rss.php, this will be set to 0 if you use encoded HTML', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(24,'rss_excerpt_length', 1, '50', 'length (in words) of excerpts in the RSS feed? 0=unlimited note: in b2rss.php, this will be set to 0 if you use encoded HTML', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(25,'rss_use_excerpt', 2, 'true', 'use the excerpt field for rss feed.', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(25,'rss_use_excerpt', 2, '1', 'use the excerpt field for rss feed.', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(26,'use_weblogsping', 2, 'false', 'set this to true if you want your site to be listed on http://weblogs.com when you add a new post', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(26,'use_weblogsping', 2, '0', 'set this to true if you want your site to be listed on http://weblogs.com when you add a new post', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(27,'use_blodotgsping', 2, 'false', 'set this to true if you want your site to be listed on http://blo.gs when you add a new post', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(27,'use_blodotgsping', 2, '0', 'set this to true if you want your site to be listed on http://blo.gs when you add a new post', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(28,'blodotgsping_url', 3, 'http://mydomain.com', 'You shouldn\'t need to change this.', 8, 30);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(28,'blodotgsping_url', 3, 'http://mydomain.com', 'You shouldn\'t need to change this.', 8, 30);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(29,'use_trackback', 2, 'true', 'set this to 0 or 1, whether you want to allow your posts to be trackback\'able or not note: setting it to zero would also disable sending trackbacks', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(29,'use_trackback', 2, '1', 'set this to 0 or 1, whether you want to allow your posts to be trackback\'able or not note: setting it to zero would also disable sending trackbacks', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(30,'use_pingback', 2, 'true', 'set this to 0 or 1, whether you want to allow your posts to be pingback\'able or not note: setting it to zero would also disable sending pingbacks', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(30,'use_pingback', 2, '1', 'set this to 0 or 1, whether you want to allow your posts to be pingback\'able or not note: setting it to zero would also disable sending pingbacks', 8);
|
||||||
|
|
||||||
--//file upload
|
--//file upload
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(31,'use_fileupload', 2, 'false', 'set this to false to disable file upload, or true to enable it', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(31,'use_fileupload', 2, '0', 'set this to false to disable file upload, or true to enable it', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(32,'fileupload_realpath', 3, '/home/your/site/wordpress/images', 'enter the real path of the directory where you\'ll upload the pictures \nif you\'re unsure about what your real path is, please ask your host\'s support staff \nnote that the directory must be writable by the webserver (chmod 766) \nnote for windows-servers users: use forwardslashes instead of backslashes', 8, 40);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(32,'fileupload_realpath', 3, '/home/your/site/wordpress/images', 'enter the real path of the directory where you\'ll upload the pictures \nif you\'re unsure about what your real path is, please ask your host\'s support staff \nnote that the directory must be writable by the webserver (chmod 766) \nnote for windows-servers users: use forwardslashes instead of backslashes', 8, 40);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(33,'fileupload_url', 3, 'http://mydomain.com/images', 'enter the URL of that directory (it\'s used to generate the links to the uploded files)', 8, 40);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level, option_width) VALUES(33,'fileupload_url', 3, 'http://mydomain.com/images', 'enter the URL of that directory (it\'s used to generate the links to the uploded files)', 8, 40);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(34,'fileupload_allowedtypes', 3, ' jpg gif png ', 'accepted file types, you can add to that list if you want. note: add a space before and after each file type. example: \' jpg gif png \'', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(34,'fileupload_allowedtypes', 3, ' jpg gif png ', 'accepted file types, you can add to that list if you want. note: add a space before and after each file type. example: \' jpg gif png \'', 8);
|
||||||
|
@ -88,8 +89,8 @@ INSERT INTO options (option_id, option_name, option_type, option_value, option_d
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(42,'default_category', 1, '1', 'by default posts will have this category', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(42,'default_category', 1, '1', 'by default posts will have this category', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(43,'subjectprefix', 3, 'blog:', 'subject prefix', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(43,'subjectprefix', 3, 'blog:', 'subject prefix', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(44,'bodyterminator', 3, '___', 'body terminator string (starting from this string, everything will be ignored, including this string)', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(44,'bodyterminator', 3, '___', 'body terminator string (starting from this string, everything will be ignored, including this string)', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(45,'emailtestonly', 2, 'false', 'set this to true to run in test mode', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(45,'emailtestonly', 2, '0', 'set this to true to run in test mode', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(46,'use_phoneemail', 2, 'false', 'some mobile phone email services will send identical subject & content on the same line if you use such a service, set use_phoneemail to true, and indicate a separator string', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(46,'use_phoneemail', 2, '0', 'some mobile phone email services will send identical subject & content on the same line if you use such a service, set use_phoneemail to true, and indicate a separator string', 8);
|
||||||
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(47,'phoneemail_separator', 3, ':::', 'when you compose your message, you\'ll type your subject then the separator string then you type your login:password, then the separator, then content', 8);
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(47,'phoneemail_separator', 3, ':::', 'when you compose your message, you\'ll type your subject then the separator string then you type your login:password, then the separator, then content', 8);
|
||||||
|
|
||||||
--// original options from options page
|
--// original options from options page
|
||||||
|
@ -177,15 +178,15 @@ INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,1,1);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,2,2);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,2,2);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,3,3);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,3,3);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,4,4);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,4,4);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,5,5);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,6,5);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,6,6);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,7,6);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,7,7);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,8,7);
|
||||||
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,8,8);
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(6,54,8);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE optionvalues (
|
CREATE TABLE optionvalues (
|
||||||
option_id int(11) NOT NULL,
|
option_id int(11) NOT NULL,
|
||||||
optionvalue varchar(64),
|
optionvalue tinytext(64),
|
||||||
optionvalue_desc varchar(255),
|
optionvalue_desc varchar(255),
|
||||||
optionvalue_max int(11),
|
optionvalue_max int(11),
|
||||||
optionvalue_min int(11),
|
optionvalue_min int(11),
|
||||||
|
@ -194,6 +195,7 @@ CREATE TABLE optionvalues (
|
||||||
INDEX (option_id, optionvalue_seq)
|
INDEX (option_id, optionvalue_seq)
|
||||||
) TYPE=MyISAM;
|
) TYPE=MyISAM;
|
||||||
|
|
||||||
|
|
||||||
-- select data for what to show
|
-- select data for what to show
|
||||||
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days', 'days', null,null,1);
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'days', 'days', null,null,1);
|
||||||
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts', null,null,2);
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (49, 'posts', 'posts', null,null,2);
|
||||||
|
@ -210,3 +212,44 @@ INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_
|
||||||
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday', null,null,2);
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '1', 'Monday', null,null,2);
|
||||||
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3);
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (9, '6', 'Saturday', null,null,3);
|
||||||
|
|
||||||
|
|
||||||
|
--// Add in a new page for POST DEFAULTS
|
||||||
|
|
||||||
|
--// default_post_status select one of publish draft private
|
||||||
|
--// default_comment_status select one of open closed
|
||||||
|
--// default_ping_status select one of open closed
|
||||||
|
--// default_pingback_flag select one of checked unchecked
|
||||||
|
--// default_post_category sql_select "SELECT cat_id AS value, cat_name AS label FROM $tablecategories order by cat_name"
|
||||||
|
|
||||||
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(55,'default_post_status', 5, 'publish', 'The default state of each new post', 8);
|
||||||
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(56,'default_comment_status', 5, 'open', 'The default state of comments for each new post', 8);
|
||||||
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(57,'default_ping_status', 5, 'open', 'The default ping state for each new post', 8);
|
||||||
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(58,'default_pingback_flag', 5, '1', 'Whether the \'PingBack the URLs in this post\' checkbox should be checked by default', 8);
|
||||||
|
INSERT INTO options (option_id, option_name, option_type, option_value, option_description, option_admin_level) VALUES(59,'default_post_category', 7, '1', 'The default category for each new post', 8);
|
||||||
|
|
||||||
|
INSERT INTO optiongroups (group_id, group_name, group_desc) VALUES(7, 'Default post options', 'Default settings for new posts.');
|
||||||
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(7,55,1 );
|
||||||
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(7,56,2 );
|
||||||
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(7,57,3 );
|
||||||
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(7,58,4 );
|
||||||
|
INSERT INTO optiongroup_options (group_id, option_id, seq) VALUES(7,59,5 );
|
||||||
|
|
||||||
|
-- select data for post_status
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'publish', 'Publish', null,null,1);
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'draft', 'Draft', null,null,2);
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (55, 'private', 'Private', null,null,3);
|
||||||
|
|
||||||
|
-- select data for comment_status
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'open', 'Open', null,null,1);
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (56, 'closed', 'Closed', null,null,2);
|
||||||
|
|
||||||
|
-- select data for ping_status (aargh duplication!)
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'open', 'Open', null,null,1);
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (57, 'closed', 'Closed', null,null,2);
|
||||||
|
|
||||||
|
-- select data for pingback flag
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '1', 'Checked', null,null,1);
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (58, '0', 'Unchecked', null,null,2);
|
||||||
|
|
||||||
|
-- sql select data for default
|
||||||
|
INSERT INTO optionvalues (option_id, optionvalue, optionvalue_desc, optionvalue_max, optionvalue_min, optionvalue_seq) VALUES (59, 'SELECT cat_id AS value, cat_name AS label FROM $tablecategories order by cat_name', '', null,null,1);
|
||||||
|
|
|
@ -39,14 +39,13 @@ require_once("optionhandler.php");
|
||||||
if ($option_group_id == '') {
|
if ($option_group_id == '') {
|
||||||
$option_group_id = 1;
|
$option_group_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
|
|
||||||
case "update":
|
case "update":
|
||||||
$standalone = 1;
|
$standalone = 1;
|
||||||
include("./b2header.php");
|
include("./b2header.php");
|
||||||
//do something
|
$any_changed = 0;
|
||||||
$message = "Settings saved...";
|
|
||||||
//error_log("got action=update and option_group_id=$option_group_id");
|
|
||||||
|
|
||||||
// iterate through the list of options in this group
|
// iterate through the list of options in this group
|
||||||
// pull the vars from the post
|
// pull the vars from the post
|
||||||
|
@ -57,30 +56,47 @@ case "update":
|
||||||
. "LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id "
|
. "LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id "
|
||||||
. "WHERE group_id = $option_group_id "
|
. "WHERE group_id = $option_group_id "
|
||||||
. "ORDER BY seq");
|
. "ORDER BY seq");
|
||||||
if ($options)
|
if ($options) {
|
||||||
{
|
foreach ($options as $option) {
|
||||||
foreach ($options as $option)
|
// should we even bother checking?
|
||||||
{
|
if ($user_level >= $option->option_admin_level) {
|
||||||
$this_name = $option->option_name;
|
$this_name = $option->option_name;
|
||||||
$old_val = stripslashes($option->option_value);
|
$old_val = stripslashes($option->option_value);
|
||||||
$new_val = $HTTP_POST_VARS[$this_name];
|
$new_val = $HTTP_POST_VARS[$this_name];
|
||||||
// get type and validate
|
|
||||||
|
|
||||||
//error_log("update checking $this_name: $old_val and $new_val");
|
if ($new_val != $old_val) {
|
||||||
if ($new_val != $old_val)
|
// get type and validate
|
||||||
{
|
$msg = validate_option($option, $this_name, $new_val);
|
||||||
//error_log("updating $this_name from $old_val to $new_val");
|
if ($msg == '') {
|
||||||
|
//no error message
|
||||||
$result = $wpdb->query("UPDATE $tableoptions SET option_value = '" . addslashes($new_val) . "' WHERE option_id = $option->option_id");
|
$result = $wpdb->query("UPDATE $tableoptions SET option_value = '" . addslashes($new_val) . "' WHERE option_id = $option->option_id");
|
||||||
if (!$result)
|
if (!$result) {
|
||||||
{
|
$db_errors .= " SQL error while saving $this_name. ";
|
||||||
$message .= "Error while saving $this_name. ";
|
} else {
|
||||||
|
++$any_changed;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$validation_message .= $msg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end foreach
|
} // end foreach
|
||||||
|
unset($cache_settings); // so they will be re-read
|
||||||
|
get_settings('siteurl'); // make it happen now
|
||||||
|
} // end if options
|
||||||
|
|
||||||
|
if ($any_changed) {
|
||||||
|
$message = $any_changed . ' setting(s) saved... ';
|
||||||
}
|
}
|
||||||
//header("Location: $this_file?option_group_id=$option_group_id");
|
|
||||||
//break;
|
if (($dB_errors != '') || ($validation_message != '')) {
|
||||||
//fall through
|
if ($message != '') {
|
||||||
|
$message .= '<br />and ';
|
||||||
|
}
|
||||||
|
$message .= $dB_errors . '<br />' . $validation_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
//break; //fall through
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$standalone = 0;
|
$standalone = 0;
|
||||||
|
@ -93,16 +109,12 @@ default:
|
||||||
<?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");
|
||||||
foreach ($option_groups as $option_group)
|
foreach ($option_groups as $option_group) {
|
||||||
{
|
if ($option_group->group_id == $option_group_id) {
|
||||||
if ($option_group->group_id == $option_group_id)
|
|
||||||
{
|
|
||||||
$current_desc=$option_group->group_desc;
|
$current_desc=$option_group->group_desc;
|
||||||
$current_long_desc = $option_group->group_longdesc;
|
$current_long_desc = $option_group->group_longdesc;
|
||||||
echo(" <li id=\"current2\"><a href=\"$this_file?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></li>\n");
|
echo(" <li id=\"current2\"><a href=\"$this_file?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></li>\n");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
echo(" <li><a href=\"$this_file?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></li>\n");
|
echo(" <li><a href=\"$this_file?option_group_id={$option_group->group_id}\" title=\"{$option_group->group_desc}\">{$option_group->group_name}</a></li>\n");
|
||||||
}
|
}
|
||||||
} // end for each group
|
} // end for each group
|
||||||
|
@ -123,10 +135,8 @@ default:
|
||||||
. "LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id "
|
. "LEFT JOIN $tableoptiongroup_options ON $tableoptions.option_id = $tableoptiongroup_options.option_id "
|
||||||
. "WHERE group_id = $option_group_id "
|
. "WHERE group_id = $option_group_id "
|
||||||
. "ORDER BY seq");
|
. "ORDER BY seq");
|
||||||
if ($options)
|
if ($options) {
|
||||||
{
|
foreach ($options as $option) {
|
||||||
foreach ($options as $option)
|
|
||||||
{
|
|
||||||
echo('<tr><td width="10%" valign="top">'. get_option_widget($option, ($user_level >= $option->option_admin_level), '</td><td width="15%" valign="top" style="border: 1px solid #ccc">'));
|
echo('<tr><td width="10%" valign="top">'. get_option_widget($option, ($user_level >= $option->option_admin_level), '</td><td width="15%" valign="top" style="border: 1px solid #ccc">'));
|
||||||
echo("</td><td valign='top' class='helptext'>$option->option_description</td></tr>\n");
|
echo("</td><td valign='top' class='helptext'>$option->option_description</td></tr>\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue