diff --git a/lib/adminlib.php b/lib/adminlib.php
index b361cdadfeb..9fbe1d9bc2c 100644
--- a/lib/adminlib.php
+++ b/lib/adminlib.php
@@ -1237,18 +1237,22 @@ class admin_setting_configtext extends admin_setting {
parent::admin_setting($name, $visiblename, $description, $defaultsetting);
}
+ // returns a string or NULL
function get_setting() {
global $CFG;
return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
}
+ // $data is a string
function write_setting($data) {
if (is_string($this->paramtype)) {
if (!$this->validate($data)) {
return get_string('validateerror', 'admin') . $this->visiblename . '
';
}
} else {
- $data = clean_param($data, $this->paramtype);
+ if ($data != clean_param($data, $this->paramtype)) {
+ return get_string('validateerror', 'admin') . $this->visiblename . '
';
+ }
}
return (set_config($this->name,$data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '
');
}
@@ -1349,7 +1353,6 @@ class admin_setting_configtime extends admin_setting {
var $name2;
var $choices;
var $choices2;
- var $defaultsetting2;
function admin_setting_configtime($hoursname, $minutesname, $visiblename, $description, $defaultsetting) {
$this->name2 = $minutesname;
@@ -1366,7 +1369,7 @@ class admin_setting_configtime extends admin_setting {
function get_setting() {
global $CFG;
- return (isset($CFG->{$this->name}) && isset($CFG->{$this->name2}) ? array($CFG->{$this->name}, $CFG->{$this->name2}) : NULL);
+ return (isset($CFG->{$this->name}) && isset($CFG->{$this->name2}) ? array('h' => $CFG->{$this->name}, 'm' => $CFG->{$this->name2}) : NULL);
}
function write_setting($data) {
@@ -1379,18 +1382,18 @@ class admin_setting_configtime extends admin_setting {
}
function output_html() {
- //TO DO: fix handling of default values here!
- $setvalue = $this->get_setting();
- if (!is_array($setvalue)) {
- $setvalue = array(0,0);
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
}
$return = '
| ' . $this->visiblename . ' | |
| | ' . $this->description . ' |
';
return $return;
@@ -1420,10 +1423,10 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
}
function output_html() {
- //TO DO: fix handling of default values here!
- $currentsetting = $this->get_setting();
- if (!is_array($currentsetting)) {
- $currentsetting = array();
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
}
$return = '| ' . $this->visiblename . ' | |
| | ' . $this->description . ' |
';
return $return;
-
-
}
}
@@ -1630,13 +1630,19 @@ class admin_setting_special_frontpagedesc extends admin_setting {
function output_html() {
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
+ }
+
$usehtmleditor = can_use_html_editor();
$return = '| ' . $this->visiblename . ' | ' .
'';
ob_start(); // double-check the number of columns below... might overrun some screen resolutions
- print_textarea($usehtmleditor, 20, 40, 0, 0, 's_' . $this->name, $this->get_setting());
+ print_textarea($usehtmleditor, 20, 40, 0, 0, 's_' . $this->name, $currentsetting);
if ($usehtmleditor) {
use_html_editor();
@@ -1681,17 +1687,6 @@ class admin_setting_special_editorfontlist extends admin_setting {
$name = 'editorfontlist';
$visiblename = get_string('editorfontlist', 'admin');
$description = get_string('configeditorfontlist', 'admin');
- if (isset($CFG->editorfontlist)) {
- $items = explode(';', $CFG->editorfontlist);
- $this->items = array();
- foreach ($items as $item) {
- $item = explode(':', $item);
- $this->items[$item[0]] = $item[1];
- }
- } else {
- $items = NULL;
- }
- unset($defaults);
$defaults = array('k0' => 'Trebuchet',
'v0' => 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif',
'k1' => 'Arial',
@@ -1714,7 +1709,21 @@ class admin_setting_special_editorfontlist extends admin_setting {
}
function get_setting() {
- return $this->items;
+ global $CFG;
+ if (isset($CFG->editorfontlist)) {
+ $i = 0;
+ $currentsetting = array();
+ $items = explode(';', $CFG->editorfontlist);
+ foreach ($items as $item) {
+ $item = explode(':', $item);
+ $currentsetting['k' . $i] = $item[0];
+ $currentsetting['v' . $i] = $item[1];
+ $i++;
+ }
+ return $currentsetting;
+ } else {
+ return NULL;
+ }
}
function write_setting($data) {
@@ -1747,24 +1756,25 @@ class admin_setting_special_editorfontlist extends admin_setting {
}
function output_html() {
+
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
+ }
+
$return = ' |
| ' . $this->visiblename . ' | ';
- $count = 0;
- $currentsetting = $this->items;
- if (!is_array($currentsetting)) {
- $currentsetting = NULL;
- }
- foreach ($currentsetting as $key => $value) {
- $return .= '';
+ for ($i = 0; $i < count($currentsetting) / 2; $i++) {
+ $return .= '';
$return .= ' ';
- $return .= ' ';
- $count++;
+ $return .= ' ';
}
- $return .= '';
+ $return .= '';
$return .= ' ';
- $return .= ' ';
- $return .= '';
+ $return .= ' ';
+ $return .= '';
$return .= ' ';
- $return .= '';
+ $return .= '';
$return .= ' |
| | ' . $this->description . ' |
';
return $return;
}
@@ -1924,9 +1934,10 @@ class admin_setting_special_editorhidebuttons extends admin_setting {
// checkboxes with input name="$this->name[$key]" value="1"
// we do 15 fields per column
- $currentsetting = $this->get_setting();
- if (!is_array($currentsetting)) {
- $currentsetting = array();
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
}
$return = '| ' . $this->visiblename . ' | ';
@@ -2064,16 +2075,32 @@ class admin_setting_special_backupdays extends admin_setting {
function get_setting() {
$backup_config = backup_get_config();
- return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
+ if (isset($backup_config->{$this->name})) {
+ $currentsetting = $backup_config->{$this->name};
+ return array('u' => substr($currentsetting, 0, 1),
+ 'm' => substr($currentsetting, 1, 1),
+ 't' => substr($currentsetting, 2, 1),
+ 'w' => substr($currentsetting, 3, 1),
+ 'r' => substr($currentsetting, 4, 1),
+ 'f' => substr($currentsetting, 5, 1),
+ 's' => substr($currentsetting, 6, 1));
+ } else {
+ return NULL;
+ }
}
function output_html() {
- $currentsetting = $this->get_setting();
- if ($currentsetting === NULL) {
- $currentsetting = '0000000';
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
}
+ // rewrite for simplicity
+ $currentsetting = $currentsetting['u'] . $currentsetting['m'] . $currentsetting['t'] . $currentsetting['w'] .
+ $currentsetting['r'] . $currentsetting['f'] . $currentsetting['s'];
+
return ' |
| ' . $this->visiblename . ' | ' .
' ' . get_string('sunday', 'calendar') . ' | ' .
get_string('monday', 'calendar') . ' | ' . get_string('tuesday', 'calendar') . ' | ' .
@@ -2125,13 +2152,17 @@ class admin_setting_special_debug extends admin_setting_configselect {
function get_setting() {
global $CFG;
- if ($CFG->debug == 7) { // Old values
- return 1;
+ if (isset($CFG->debug)) {
+ if ($CFG->debug == 7) { // Old values
+ return 1;
+ }
+ if ($CFG->debug == 15) { // Old values
+ return 16;
+ }
+ return $CFG->debug;
+ } else {
+ return NULL;
}
- if ($CFG->debug == 15) { // Old values
- return 16;
- }
- return $CFG->debug;
}
function write_setting($data) {
@@ -2173,10 +2204,12 @@ class admin_setting_special_calendar_weekend extends admin_setting {
function output_html() {
- $currentsetting = $this->get_setting();
- if (!is_array($currentsetting)) {
- $currentsetting = array('u' => 0, 'm' => 0, 't' => 0, 'w' => 0, 'r' => 0, 'f' => 0, 's' => 0);
+ if ($this->get_setting() === NULL) {
+ $currentsetting = $this->defaultsetting;
+ } else {
+ $currentsetting = $this->get_setting();
}
+
return ' | ' . $this->visiblename . ' | ' .
' | |
|