Commit dbf9e4ba authored by Petr Skoda's avatar Petr Skoda
Browse files

MDL-23234 finally standardised use of settings.php across all plugins - the...

MDL-23234 finally standardised use of settings.php across all plugins - the only partial exceptions now are report and local plugins
parent bf36ee9b
<?php
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('reports', new admin_externalpage('reportbackups', get_string('backups', 'admin'), "$CFG->wwwroot/$CFG->admin/report/backups/index.php",'moodle/backup:backupcourse'));
<?php
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('roles', new admin_externalpage('reportcapability', get_string('capability', 'report_capability'), "$CFG->wwwroot/$CFG->admin/report/capability/index.php",'moodle/role:manage'));
<?php
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('reports', new admin_externalpage('reportconfiglog', get_string('configlog', 'report_configlog'), "$CFG->wwwroot/$CFG->admin/report/configlog/index.php"));
<?php
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('reports', new admin_externalpage('reportcourseoverview', get_string('courseoverview', 'admin'), "$CFG->wwwroot/$CFG->admin/report/courseoverview/index.php",'report/courseoverview:view'));
<?php
defined('MOODLE_INTERNAL') || die;
// just a link to course report
$ADMIN->add('reports', new admin_externalpage('reportlog', get_string('log', 'admin'), "$CFG->wwwroot/course/report/log/index.php?id=".SITEID, 'coursereport/log:view'));
$ADMIN->add('reports', new admin_externalpage('reportloglive', get_string('loglive', 'coursereport_log'), "$CFG->wwwroot/course/report/log/indexlive.php?id=".SITEID, 'coursereport/log:viewlive'));
<?php
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('reports', new admin_externalpage('reportquestioninstances', get_string('questioninstances', 'report_questioninstances'), "$CFG->wwwroot/$CFG->admin/report/questioninstances/index.php", 'report/questioninstances:view'));
<?php
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('reports', new admin_externalpage('reportsecurity', get_string('reportsecurity', 'report_security'), "$CFG->wwwroot/$CFG->admin/report/security/index.php",'report/security:view'));
<?php
defined('MOODLE_INTERNAL') || die;
// spam cleaner
$ADMIN->add('reports', new admin_externalpage('reportspamcleaner', get_string('spamcleaner', 'report_spamcleaner'), "$CFG->wwwroot/$CFG->admin/report/spamcleaner/index.php", 'moodle/site:config'));
<?php
defined('MOODLE_INTERNAL') || die;
// just a link to course report
$ADMIN->add('reports', new admin_externalpage('reportstats', get_string('stats', 'admin'), "$CFG->wwwroot/course/report/stats/index.php", 'coursereport/stats:view'));
<?php
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
$ADMIN->add('development', new admin_externalpage('reportsimpletest', get_string('simpletest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/index.php",'report/unittest:view'));
$ADMIN->add('development', new admin_externalpage('reportdbtest', get_string('dbtest', 'admin'), "$CFG->wwwroot/$CFG->admin/report/unittest/dbtest.php",'report/unittest:view'));
......
......@@ -26,7 +26,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
foreach (get_plugin_list('theme') as $theme => $themedir) {
$settings_path = "$themedir/settings.php";
if (file_exists($settings_path)) {
$settings = new admin_settingpage('themesetting'.$theme, get_string('pluginname', 'theme_'.$theme));
include($settings_path);
if ($settings) {
$ADMIN->add('themes', $settings);
}
}
}
......
......@@ -176,10 +176,10 @@ if (has_capability('moodle/grade:manage', $systemcontext)
// Include all the settings commands for this plugin if there are any
if (file_exists($plugindir.'/settings.php')) {
$settings = new admin_settingpage('gradereport'.$plugin, get_string('pluginname', 'gradereport_'.$plugin), 'moodle/grade:manage');
if ($ADMIN->fulltree) {
include($plugindir.'/settings.php');
include($plugindir.'/settings.php');
if ($settings) {
$ADMIN->add('gradereports', $settings);
}
$ADMIN->add('gradereports', $settings);
}
}
......@@ -190,10 +190,10 @@ if (has_capability('moodle/grade:manage', $systemcontext)
// Include all the settings commands for this plugin if there are any
if (file_exists($plugindir.'/settings.php')) {
$settings = new admin_settingpage('gradeimport'.$plugin, get_string('pluginname', 'gradeimport_'.$plugin), 'moodle/grade:manage');
if ($ADMIN->fulltree) {
include($plugindir.'/settings.php');
include($plugindir.'/settings.php');
if ($settings) {
$ADMIN->add('gradeimports', $settings);
}
$ADMIN->add('gradeimports', $settings);
}
}
......@@ -204,10 +204,10 @@ if (has_capability('moodle/grade:manage', $systemcontext)
// Include all the settings commands for this plugin if there are any
if (file_exists($plugindir.'/settings.php')) {
$settings = new admin_settingpage('gradeexport'.$plugin, get_string('pluginname', 'gradeexport_'.$plugin), 'moodle/grade:manage');
if ($ADMIN->fulltree) {
include($plugindir.'/settings.php');
include($plugindir.'/settings.php');
if ($settings) {
$ADMIN->add('gradeexports', $settings);
}
$ADMIN->add('gradeexports', $settings);
}
}
......
......@@ -14,15 +14,13 @@ if ($hassiteconfig) {
continue;
}
$strmodulename = get_string('modulename', 'mod_'.$modulename);
if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php')) {
include($CFG->dirroot.'/mod/'.$modulename.'/settingstree.php');
} else if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) {
if (file_exists($CFG->dirroot.'/mod/'.$modulename.'/settings.php')) {
// do not show disabled modules in tree, keep only settings link on manage page
$settings = new admin_settingpage('modsetting'.$modulename, $strmodulename, 'moodle/site:config', !$module->visible);
if ($ADMIN->fulltree) {
include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
if ($settings) {
$ADMIN->add('modsettings', $settings);
}
$ADMIN->add('modsettings', $settings);
}
}
......@@ -40,13 +38,10 @@ if ($hassiteconfig) {
$strblockname = get_string('pluginname', 'block_'.$blockname);
if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/settings.php')) {
$settings = new admin_settingpage('blocksetting'.$blockname, $strblockname, 'moodle/site:config', !$block->visible);
if ($ADMIN->fulltree) {
include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
include($CFG->dirroot.'/blocks/'.$blockname.'/settings.php');
if ($settings) {
$ADMIN->add('blocksettings', $settings);
}
$ADMIN->add('blocksettings', $settings);
} else if (file_exists($CFG->dirroot.'/blocks/'.$blockname.'/config_global.html')) {
$ADMIN->add('blocksettings', new admin_externalpage('blocksetting'.$blockname, $strblockname, "$CFG->wwwroot/$CFG->admin/block.php?block=$block->id", 'moodle/site:config', !$block->visible));
}
}
......@@ -74,29 +69,22 @@ if ($hassiteconfig) {
$ADMIN->add('authsettings', $temp);
if ($auths = get_plugin_list('auth')) {
$authsenabled = get_enabled_auth_plugins();
$authbyname = array();
foreach ($auths as $auth => $authdir) {
$strauthname = get_string('pluginname', "auth_{$auth}");
$authbyname[$strauthname] = $auth;
}
ksort($authbyname);
foreach ($authbyname as $strauthname=>$authname) {
if (file_exists($authdir.'/settings.php')) {
// do not show disabled auths in tree, keep only settings link on manage page
$settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !in_array($authname, $authsenabled));
if ($ADMIN->fulltree) {
include($authdir.'/settings.php');
}
// TODO: finish implementation of common settings - locking, etc.
$auths = get_plugin_list('auth');
$authsenabled = get_enabled_auth_plugins();
foreach ($auths as $authname => $authdir) {
$strauthname = get_string('pluginname', "auth_{$authname}");
// do not show disabled auths in tree, keep only settings link on manage page
$enabled = in_array($authname, $authsenabled);
if (file_exists($authdir.'/settings.php')) {
// TODO: finish implementation of common settings - locking, etc.
$settings = new admin_settingpage('authsetting'.$authname, $strauthname, 'moodle/site:config', !$enabled);
include($authdir.'/settings.php');
if ($settings) {
$ADMIN->add('authsettings', $settings);
} else {
$ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !in_array($authname, $authsenabled)));
}
} else {
$ADMIN->add('authsettings', new admin_externalpage('authsetting'.$authname, $strauthname, "$CFG->wwwroot/$CFG->admin/auth_config.php?auth=$authname", 'moodle/site:config', !$enabled));
}
}
......@@ -212,10 +200,10 @@ if ($hassiteconfig) {
if (file_exists("$CFG->dirroot/$filterpath/filtersettings.php")) {
$settings = new admin_settingpage('filtersetting'.str_replace('/', '', $filterpath),
$strfiltername, 'moodle/site:config', !isset($activefilters[$filterpath]));
if ($ADMIN->fulltree) {
include("$CFG->dirroot/$filterpath/filtersettings.php");
include("$CFG->dirroot/$filterpath/filtersettings.php");
if ($settings) {
$ADMIN->add('filtersettings', $settings);
}
$ADMIN->add('filtersettings', $settings);
}
}
......@@ -353,10 +341,10 @@ if ($hassiteconfig) {
if (file_exists("$location/settings.php")) {
$name = get_string('pluginname', 'webservice_'.$webservice);
$settings = new admin_settingpage('webservicesetting'.$webservice, $name, 'moodle/site:config', !in_array($webservice, $active_webservices) or empty($CFG->enablewebservices));
if ($ADMIN->fulltree) {
include("$location/settings.php");
include("$location/settings.php");
if ($settings) {
$ADMIN->add('webservicesettings', $settings);
}
$ADMIN->add('webservicesettings', $settings);
}
}
/// manage token page link
......@@ -380,10 +368,10 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
if (file_exists($settingsfile)) {
$settings = new admin_settingpage('qtypesetting' . $qtype->name(),
$qtype->local_name(), 'moodle/question:config');
if ($ADMIN->fulltree) {
include($settingsfile);
include($settingsfile);
if ($settings) {
$ADMIN->add('qtypesettings', $settings);
}
$ADMIN->add('qtypesettings', $settings);
}
}
}
......
<?php
defined('MOODLE_INTERNAL') || die;
$options = array('all'=>get_string('allcourses', 'block_course_list'), 'own'=>get_string('owncourses', 'block_course_list'));
if ($ADMIN->fulltree) {
$options = array('all'=>get_string('allcourses', 'block_course_list'), 'own'=>get_string('owncourses', 'block_course_list'));
$settings->add(new admin_setting_configselect('block_course_list_adminview', get_string('adminview', 'block_course_list'),
get_string('configadminview', 'block_course_list'), 'all', $options));
$settings->add(new admin_setting_configcheckbox('block_course_list_hideallcourseslink', get_string('hideallcourseslink', 'block_course_list'),
get_string('confighideallcourseslink', 'block_course_list'), 0));
$settings->add(new admin_setting_configselect('block_course_list_adminview', get_string('adminview', 'block_course_list'),
get_string('configadminview', 'block_course_list'), 'all', $options));
$settings->add(new admin_setting_configcheckbox('block_course_list_hideallcourseslink', get_string('hideallcourseslink', 'block_course_list'),
get_string('confighideallcourseslink', 'block_course_list'), 0));
}
<?php
$settings->add(new admin_setting_configtext('block_online_users_timetosee', get_string('timetosee', 'block_online_users'),
get_string('configtimetosee', 'block_online_users'), 5, PARAM_INT));
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext('block_online_users_timetosee', get_string('timetosee', 'block_online_users'),
get_string('configtimetosee', 'block_online_users'), 5, PARAM_INT));
}
<?php
$settings->add(new admin_setting_configtext('block_rss_client_num_entries', get_string('numentries', 'block_rss_client'),
get_string('clientnumentries', 'block_rss_client'), 5, PARAM_INT));
defined('MOODLE_INTERNAL') || die;
$settings->add(new admin_setting_configtext('block_rss_client_timeout', get_string('timeout2', 'block_rss_client'),
get_string('timeout', 'block_rss_client'), 30, PARAM_INT));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext('block_rss_client_num_entries', get_string('numentries', 'block_rss_client'),
get_string('clientnumentries', 'block_rss_client'), 5, PARAM_INT));
$link ='<a href="'.$CFG->wwwroot.'/blocks/rss_client/managefeeds.php">'.get_string('feedsaddedit', 'block_rss_client').'</a>';
$settings->add(new admin_setting_heading('block_rss_addheading', '', $link));
$settings->add(new admin_setting_configtext('block_rss_client_timeout', get_string('timeout2', 'block_rss_client'),
get_string('timeout', 'block_rss_client'), 30, PARAM_INT));
$link ='<a href="'.$CFG->wwwroot.'/blocks/rss_client/managefeeds.php">'.get_string('feedsaddedit', 'block_rss_client').'</a>';
$settings->add(new admin_setting_heading('block_rss_addheading', '', $link));
}
\ No newline at end of file
......@@ -21,33 +21,38 @@
* @package moodlecore
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$configs = array();
$numberofsections = array();
defined('MOODLE_INTERNAL') || die;
for ($i = 1; $i < 53; $i++){
$numberofsections[$i] = $i;
}
$increments = array();
if ($ADMIN->fulltree) {
$configs = array();
for ($i = 1; $i < 11; $i++){
$increments[$i] = $i;
}
$numberofsections = array();
$selected = array(1 => array(22,2),
2 => array(40,5));
for ($i = 1; $i < 53; $i++){
$numberofsections[$i] = $i;
}
$increments = array();
for($i = 1; $i < 3; $i++){
$configs[] = new admin_setting_configselect('numsections'.$i, get_string('numsections'.$i, 'block_section_links'),
get_string('numsectionsdesc'.$i, 'block_section_links'),
$selected[$i][0], $numberofsections);
for ($i = 1; $i < 11; $i++){
$increments[$i] = $i;
}
$configs[] = new admin_setting_configselect('incby'.$i, get_string('incby'.$i, 'block_section_links'),
get_string('incbydesc'.$i, 'block_section_links'),
$selected[$i][1], $increments);
}
$selected = array(1 => array(22,2),
2 => array(40,5));
foreach ($configs as $config) {
$config->plugin = 'blocks/section_links';
$settings->add($config);
}
for($i = 1; $i < 3; $i++){
$configs[] = new admin_setting_configselect('numsections'.$i, get_string('numsections'.$i, 'block_section_links'),
get_string('numsectionsdesc'.$i, 'block_section_links'),
$selected[$i][0], $numberofsections);
$configs[] = new admin_setting_configselect('incby'.$i, get_string('incby'.$i, 'block_section_links'),
get_string('incbydesc'.$i, 'block_section_links'),
$selected[$i][1], $increments);
}
foreach ($configs as $config) {
$config->plugin = 'blocks/section_links';
$settings->add($config);
}
}
\ No newline at end of file
<?php
$settings->add(new admin_setting_configcheckbox('block_tags_showcoursetags', get_string('showcoursetags', 'block_tags'),
get_string('showcoursetagsdef', 'block_tags'), 0));
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('block_tags_showcoursetags', get_string('showcoursetags', 'block_tags'),
get_string('showcoursetagsdef', 'block_tags'), 0));
}
......@@ -17,6 +17,7 @@ required changes in code:
* remove '_utf8' from language pack names, use new {$a} syntax in language packs
* use 'pluginname' lang pack identifier instead of 'blockname'
* move cron and version number into standard version.php
* removed support for old config_global.html, use settings.php
optional - no changes needed in older code:
*
......
<?php
$settings->add(new admin_setting_configtextarea('filter_censor_badwords', get_string('badwordslist','admin'),
get_string('badwordsconfig', 'admin').'<br />'.get_string('badwordsdefault', 'admin'), ''));
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtextarea('filter_censor_badwords', get_string('badwordslist','admin'),
get_string('badwordsconfig', 'admin').'<br />'.get_string('badwordsdefault', 'admin'), ''));
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment