MDL-17074 - backport ability of admin settings to use the config_plugins table

This commit is contained in:
stronk7
2009-02-11 17:51:34 +00:00
parent 50537ba778
commit d2aa927a0a
2 changed files with 29 additions and 1 deletions
+1
View File
@@ -51,6 +51,7 @@ $string['groupunknown'] = 'Group $a not associated to specified course';
$string['guestnoeditprofile'] = 'The guest user cannot edit their profile';
$string['guestnoeditprofileother'] = 'The guest user profile cannot be edited';
$string['guestsarenotallowed'] = 'The guest user is not allowed to do this';
$string['invalidadminsettingname'] = 'Invalid admin setting ($a)';
$string['invalidcontext'] = 'Invalid context';
$string['invalidcourse'] = 'Invalid course';
$string['invalidcourseid'] = 'You are trying to use an invalid course ID ($a)';
+28 -1
View File
@@ -1616,12 +1616,39 @@ class admin_setting {
* @param mixed $defaultsetting string or array depending on implementation
*/
function admin_setting($name, $visiblename, $description, $defaultsetting) {
$this->name = $name;
$this->parse_setting_name($name);
$this->visiblename = $visiblename;
$this->description = $description;
$this->defaultsetting = $defaultsetting;
}
/**
* Set up $this->name and possibly $this->plugin based on whether $name looks
* like 'settingname' or 'plugin/settingname'. Also, do some sanity checking
* on the names, that is, output a developer debug warning if the name
* contains anything other than [a-zA-Z0-9_]+.
*
* @param string $name the setting name passed in to the constructor.
*/
function parse_setting_name($name) {
$bits = explode('/', $name);
if (count($bits) > 2) {
print_error('invalidadminsettingname', '', '', $name);
}
$this->name = array_pop($bits);
if (!preg_match('/^[a-zA-Z0-9_]+$/', $this->name)) {
print_error('invalidadminsettingname', '', '', $name);
}
if (!empty($bits)) {
$this->plugin = array_pop($bits);
if ($this->plugin === 'moodle') {
$this->plugin = null;
} else if (!preg_match('/^[a-zA-Z0-9_]+$/', $this->plugin)) {
print_error('invalidadminsettingname', '', '', $name);
}
}
}
function get_full_name() {
return 's_'.$this->plugin.'_'.$this->name;
}