Skip to content

Commit

Permalink
MDL-23234 finally standardised use of settings.php across all plugins…
Browse files Browse the repository at this point in the history
… - the only partial exceptions now are report and local plugins
  • Loading branch information
skodak committed Jul 13, 2010
1 parent bf36ee9 commit dbf9e4b
Show file tree
Hide file tree
Showing 47 changed files with 753 additions and 660 deletions.
2 changes: 2 additions & 0 deletions admin/report/backups/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/capability/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/configlog/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?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"));
2 changes: 2 additions & 0 deletions admin/report/courseoverview/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/log/settings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/questioninstances/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/security/settings.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/spamcleaner/settings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?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'));

2 changes: 2 additions & 0 deletions admin/report/stats/settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?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'));
2 changes: 2 additions & 0 deletions admin/report/unittest/settings.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?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'));
Expand Down
4 changes: 4 additions & 0 deletions admin/settings/appearance.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
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);
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions admin/settings/grades.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@
// 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);
}
}

Expand All @@ -190,10 +190,10 @@
// 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);
}
}

Expand All @@ -204,10 +204,10 @@
// 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);
}
}

Expand Down
72 changes: 30 additions & 42 deletions admin/settings/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
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);
}
}

Expand All @@ -40,13 +38,10 @@
$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));
}
}

Expand Down Expand Up @@ -74,29 +69,22 @@
$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));
}
}

Expand Down Expand Up @@ -212,10 +200,10 @@
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);
}
}

Expand Down Expand Up @@ -353,10 +341,10 @@
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
Expand All @@ -380,10 +368,10 @@
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);
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions blocks/course_list/settings.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?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));
}


7 changes: 5 additions & 2 deletions blocks/online_users/settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?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));
}

16 changes: 10 additions & 6 deletions blocks/rss_client/settings.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?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));
}
51 changes: 28 additions & 23 deletions blocks/section_links/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 5 additions & 2 deletions blocks/tags/settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?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));
}

1 change: 1 addition & 0 deletions blocks/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down
7 changes: 5 additions & 2 deletions filter/censor/filtersettings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?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'), ''));
}
Loading

0 comments on commit dbf9e4b

Please sign in to comment.