MDL-35661 Loading of plugin settings for modules (plugininfo_mod)
This commit is contained in:
@@ -9,23 +9,12 @@ if ($hassiteconfig) {
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
|
||||
$ADMIN->add('modules', new admin_page_pluginsoverview());
|
||||
|
||||
// activity modules
|
||||
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
|
||||
$ADMIN->add('modsettings', new admin_page_managemods());
|
||||
$modules = $DB->get_records('modules', array(), "name ASC");
|
||||
foreach ($modules as $module) {
|
||||
$modulename = $module->name;
|
||||
if (!file_exists("$CFG->dirroot/mod/$modulename/lib.php")) {
|
||||
continue;
|
||||
}
|
||||
$strmodulename = new lang_string('modulename', 'mod_'.$modulename);
|
||||
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);
|
||||
include($CFG->dirroot.'/mod/'.$modulename.'/settings.php');
|
||||
if ($settings) {
|
||||
$ADMIN->add('modsettings', $settings);
|
||||
}
|
||||
}
|
||||
foreach ($allplugins['mod'] as $module) {
|
||||
$module->load_settings($ADMIN, 'modsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// hidden script for converting journals to online assignments (or something like that) linked from elsewhere
|
||||
|
||||
+34
-5
@@ -2200,6 +2200,23 @@ class plugininfo_mod extends plugininfo_base {
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic method getter, redirects to read only values.
|
||||
*
|
||||
* For module plugins we pretend the object has 'visible' property for compatibility
|
||||
* with plugins developed for Moodle version below 2.4
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name) {
|
||||
if ($name === 'visible') {
|
||||
debugging('This is now an instance of plugininfo_mod, please use $module->is_enabled() instead of $module->visible', DEBUG_DEVELOPER);
|
||||
return ($this->is_enabled() !== false);
|
||||
}
|
||||
return parent::__get($name);
|
||||
}
|
||||
|
||||
public function init_display_name() {
|
||||
if (get_string_manager()->string_exists('pluginname', $this->component)) {
|
||||
$this->displayname = get_string('pluginname', $this->component);
|
||||
@@ -2245,12 +2262,24 @@ class plugininfo_mod extends plugininfo_base {
|
||||
}
|
||||
}
|
||||
|
||||
public function get_settings_url() {
|
||||
public function get_settings_section_name() {
|
||||
return 'modsetting' . $this->name;
|
||||
}
|
||||
|
||||
if (file_exists($this->full_path('settings.php')) or file_exists($this->full_path('settingstree.php'))) {
|
||||
return new moodle_url('/admin/settings.php', array('section' => 'modsetting' . $this->name));
|
||||
} else {
|
||||
return parent::get_settings_url();
|
||||
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
|
||||
$module = $this; // also can be used inside settings.php
|
||||
$section = $this->get_settings_section_name();
|
||||
|
||||
$settings = null;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -447,10 +447,10 @@ class assign_plugin_manager {
|
||||
* @param string $subtype - The type of plugin (submission or feedback)
|
||||
* @param part_of_admin_tree $admin - The handle to the admin menu
|
||||
* @param admin_settingpage $settings - The handle to current node in the navigation tree
|
||||
* @param stdClass $module - The handle to the current module
|
||||
* @param stdClass|plugininfo_mod $module - The handle to the current module
|
||||
* @return None
|
||||
*/
|
||||
static function add_admin_assign_plugin_settings($subtype, part_of_admin_tree $admin, admin_settingpage $settings, stdClass $module) {
|
||||
static function add_admin_assign_plugin_settings($subtype, part_of_admin_tree $admin, admin_settingpage $settings, $module) {
|
||||
global $CFG;
|
||||
|
||||
$plugins = get_plugin_list_with_file($subtype, 'settings.php', false);
|
||||
@@ -463,7 +463,7 @@ class assign_plugin_manager {
|
||||
|
||||
foreach ($pluginsbyname as $pluginname => $plugin) {
|
||||
$settings = new admin_settingpage($subtype . '_'.$plugin,
|
||||
$pluginname, 'moodle/site:config', !$module->visible);
|
||||
$pluginname, 'moodle/site:config', $module->is_enabled() === false);
|
||||
if ($admin->fulltree) {
|
||||
$shortsubtype = substr($subtype, strlen('assign'));
|
||||
include($CFG->dirroot . "/mod/assign/$shortsubtype/$plugin/settings.php");
|
||||
|
||||
@@ -27,12 +27,12 @@ defined('MOODLE_INTERNAL') || die;
|
||||
require_once($CFG->dirroot . '/mod/assign/adminlib.php');
|
||||
|
||||
$ADMIN->add('modules', new admin_category('assignmentplugins',
|
||||
new lang_string('assignmentplugins', 'assign'), !$module->visible));
|
||||
new lang_string('assignmentplugins', 'assign'), $module->is_enabled() === false));
|
||||
$ADMIN->add('assignmentplugins', new admin_category('assignsubmissionplugins',
|
||||
new lang_string('submissionplugins', 'assign'), !$module->visible));
|
||||
new lang_string('submissionplugins', 'assign'), $module->is_enabled() === false));
|
||||
$ADMIN->add('assignsubmissionplugins', new assign_admin_page_manage_assign_plugins('assignsubmission'));
|
||||
$ADMIN->add('assignmentplugins', new admin_category('assignfeedbackplugins',
|
||||
new lang_string('feedbackplugins', 'assign'), !$module->visible));
|
||||
new lang_string('feedbackplugins', 'assign'), $module->is_enabled() === false));
|
||||
$ADMIN->add('assignfeedbackplugins', new assign_admin_page_manage_assign_plugins('assignfeedback'));
|
||||
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ if (empty($reportsbyname)) {
|
||||
$ADMIN->add('modsettings', $quizsettings);
|
||||
} else {
|
||||
$ADMIN->add('modsettings', new admin_category('modsettingsquizcat',
|
||||
get_string('modulename', 'quiz'), !$module->visible));
|
||||
get_string('modulename', 'quiz'), $module->is_enabled() === false));
|
||||
$ADMIN->add('modsettingsquizcat', $quizsettings);
|
||||
|
||||
// Add the report pages for the settings.php files in sub directories of mod/quiz/report.
|
||||
@@ -207,7 +207,7 @@ if (empty($reportsbyname)) {
|
||||
$reportname = $report;
|
||||
|
||||
$settings = new admin_settingpage('modsettingsquizcat'.$reportname,
|
||||
$strreportname, 'moodle/site:config', !$module->visible);
|
||||
$strreportname, 'moodle/site:config', $module->is_enabled() === false);
|
||||
if ($ADMIN->fulltree) {
|
||||
include($CFG->dirroot . "/mod/quiz/report/$reportname/settings.php");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user