MDL-35661 Loading of plugin settings for repositories plugins (plugininfo_repository)

This commit is contained in:
Marina Glancy 2012-09-27 10:39:33 +08:00
parent eb30df1e5f
commit c517dd68f7
2 changed files with 14 additions and 16 deletions

View File

@ -239,17 +239,8 @@ if ($hassiteconfig) {
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
'', $url);
foreach (repository::get_types() as $repositorytype) {
//display setup page for plugins with: general options or multiple instances (e.g. has instance config)
$typeoptionnames = repository::static_function($repositorytype->get_typename(), 'get_type_option_names');
$instanceoptionnames = repository::static_function($repositorytype->get_typename(), 'get_instance_option_names');
if (!empty($typeoptionnames) || !empty($instanceoptionnames)) {
$params = array('action'=>'edit', 'sesskey'=>sesskey(), 'repos'=>$repositorytype->get_typename());
$settingsurl = new moodle_url("/$CFG->admin/repository.php", $params);
$repositoryexternalpage = new admin_externalpage('repositorysettings'.$repositorytype->get_typename(), $repositorytype->get_readablename(), $settingsurl);
$ADMIN->add('repositorysettings', $repositoryexternalpage);
}
foreach ($allplugins['repository'] as $repositorytype) {
$repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
}
}

View File

@ -2575,12 +2575,19 @@ class plugininfo_repository extends plugininfo_base {
return isset($enabled[$this->name]);
}
public function get_settings_url() {
public function get_settings_section_name() {
return 'repositorysettings'.$this->name;
}
if ($this->is_enabled()) {
return new moodle_url('/admin/repository.php', array('sesskey' => sesskey(), 'action' => 'edit', 'repos' => $this->name));
} else {
return parent::get_settings_url();
public function load_settings(part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
if ($hassiteconfig && $this->is_enabled()) {
// completely no access to repository setting when it is not enabled
$sectionname = $this->get_settings_section_name();
$settingsurl = new moodle_url('/admin/repository.php',
array('sesskey' => sesskey(), 'action' => 'edit', 'repos' => $this->name));
$settings = new admin_externalpage($sectionname, $this->displayname,
$settingsurl, 'moodle/site:config', false);
$adminroot->add($parentnodename, $settings);
}
}