MDL-17074 - backport ability of admin settings to use the config_plugins table
This commit is contained in:
+28
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user