MDL-43008 calendar: Allow calendar plugins to display setting pages.

This commit is contained in:
Adrian Greeve
2013-11-26 15:44:57 +08:00
parent f7434db109
commit b404b1f41c
4 changed files with 42 additions and 0 deletions
+10
View File
@@ -485,6 +485,16 @@ if ($hassiteconfig) {
}
}
// Add Calendar type settings.
if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
foreach (core_component::get_plugin_list_with_file('calendartype', 'settings.php') as $plugin => $settingspath) {
$settings = new admin_settingpage('calendartype_' . $plugin . '_settings', new lang_string('pluginname', 'calendartype_' . $plugin), 'moodle/site:config');
include($settingspath);
$ADMIN->add('calendartype', $settings);
}
}
/// Add all local plugins - must be always last!
if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
+1
View File
@@ -30,6 +30,7 @@ $string['annually'] = 'Annually';
$string['calendar'] = 'Calendar';
$string['calendarheading'] = '{$a} Calendar';
$string['calendarpreferences'] = 'Calendar preferences';
$string['calendartypes'] = 'Calendar types';
$string['calendarurl'] = 'Calendar URL: {$a}';
$string['clickhide'] = 'click to hide';
$string['clickshow'] = 'click to show';
+29
View File
@@ -40,4 +40,33 @@ class calendartype extends base {
return false;
}
public function get_settings_section_name() {
return 'calendartype_' . $this->name . '_settings';
}
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
global $CFG, $USER, $DB, $OUTPUT, $PAGE; // In case settings.php wants to refer to them.
$ADMIN = $adminroot; // May be used in settings.php.
$plugininfo = $this; // Also can be used inside settings.php.
$qtype = $this; // Also can be used inside settings.php.
if (!$this->is_installed_and_upgraded()) {
return;
}
$section = $this->get_settings_section_name();
$settings = null;
$systemcontext = \context_system::instance();
if (($hassiteconfig) &&
file_exists($this->full_path('settings.php'))) {
$settings = new admin_settingpage($section, $this->displayname,
'moodle/site:config', $this->is_enabled() === false);
include($this->full_path('settings.php')); // This may also set $settings to null.
}
if ($settings) {
$ADMIN->add($parentnodename, $settings);
}
}
}
+2
View File
@@ -59,6 +59,8 @@ information provided here is intended especially for developers.
* The library to interact with Box.net (class boxclient) is only compatible with their APIv1 which
reaches its end of life on the 14th of Dec. You should migrate your scripts to make usage of the
new class boxnet_client(). Note that the method names and return values have changed.
* Settings pages are now possible for Calendar type plugins. Calendar type plugins that require a settings page to
work properly will need to set their requires version to a number that is equal to or grater than the 2.6.1 release version.
DEPRECATIONS:
Various previously deprecated functions have now been altered to throw DEBUG_DEVELOPER debugging notices