Merge branch 'MDL-39376-master' of git://github.com/FMCorz/moodle

This commit is contained in:
Dan Poltawski 2014-11-11 17:21:09 +00:00
commit 20ac3aa5e5
4 changed files with 72 additions and 7 deletions

View File

@ -111,9 +111,9 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configtext('enrol_database/newcoursecategory', get_string('newcoursecategory', 'enrol_database'), '', ''));
if (!during_initial_install()) {
$settings->add(new admin_setting_configselect('enrol_database/defaultcategory', get_string('defaultcategory', 'enrol_database'), get_string('defaultcategory_desc', 'enrol_database'), 1, make_categories_options()));
}
require_once($CFG->dirroot.'/enrol/database/settingslib.php');
$settings->add(new enrol_database_admin_setting_category('enrol_database/defaultcategory', get_string('defaultcategory', 'enrol_database'), get_string('defaultcategory_desc', 'enrol_database')));
$settings->add(new admin_setting_configtext('enrol_database/templatecourse', get_string('templatecourse', 'enrol_database'), get_string('templatecourse_desc', 'enrol_database'), ''));
}

View File

@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Database enrolment plugin custom settings.
*
* @package enrol_database
* @copyright 2013 Darko Miletic
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Class implements new specialized setting for course categories that are loaded
* only when required
* @author Darko Miletic
*
*/
class enrol_database_admin_setting_category extends admin_setting_configselect {
public function __construct($name, $visiblename, $description) {
parent::__construct($name, $visiblename, $description, 1, null);
}
public function load_choices() {
if (is_array($this->choices)) {
return true;
}
$this->choices = make_categories_options();
return true;
}
}

View File

@ -94,10 +94,7 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('enrol_ldap_autocreation_settings', get_string('autocreation_settings', 'enrol_ldap'), ''));
$options = $yesno;
$settings->add(new admin_setting_configselect('enrol_ldap/autocreate', get_string('autocreate_key', 'enrol_ldap'), get_string('autocreate', 'enrol_ldap'), 0, $options));
if (!during_initial_install()) {
$options = make_categories_options();
$settings->add(new admin_setting_configselect('enrol_ldap/category', get_string('category_key', 'enrol_ldap'), get_string('category', 'enrol_ldap'), key($options), $options));
}
$settings->add(new enrol_ldap_admin_setting_category('enrol_ldap/category', get_string('category_key', 'enrol_ldap'), get_string('category', 'enrol_ldap')));
$settings->add(new admin_setting_configtext_trim_lower('enrol_ldap/template', get_string('template_key', 'enrol_ldap'), get_string('template', 'enrol_ldap'), ''));
//--- course update settings ---

View File

@ -193,3 +193,25 @@ class admin_setting_ldap_rolemapping extends admin_setting {
$this->description, true, '', '', $query);
}
}
/**
* Class implements new specialized setting for course categories that are loaded
* only when required
* @author Darko Miletic
*
*/
class enrol_ldap_admin_setting_category extends admin_setting_configselect {
public function __construct($name, $visiblename, $description) {
parent::__construct($name, $visiblename, $description, null, null);
}
public function load_choices() {
if (is_array($this->choices)) {
return true;
}
$this->choices = make_categories_options();
$this->defaultsetting = key($this->choices);
return true;
}
}