119 lines
4.2 KiB
PHP
Executable File
119 lines
4.2 KiB
PHP
Executable File
<?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/>.
|
|
|
|
/**
|
|
* Local plugin Settings
|
|
*
|
|
* @package tool_sptoolboxmgr
|
|
* @copyright 2023 P.M. Kuipers
|
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
use \local_treestudyplan\debug;
|
|
|
|
if ($hassiteconfig) {
|
|
|
|
/**************************************
|
|
*
|
|
* Main studyplan settings
|
|
*
|
|
*************************************/
|
|
|
|
// Create admin settings category.
|
|
$ADMIN->add('courses', new admin_category('tool_sptoolboxmgr',
|
|
get_string('pluginname', 'tool_sptoolboxmgr', null, true)));
|
|
|
|
// Settings page: Root nodes.
|
|
$page = new admin_settingpage('tool_sptoolboxmgr_settings',
|
|
get_string('settingspage', 'tool_sptoolboxmgr', null, true));
|
|
|
|
|
|
$categories = array_map('format_string', $DB->get_records_menu('user_info_category', null, 'sortorder ASC', 'id, name'));
|
|
$profilefields = [ 0 => get_string('none', 'core')];
|
|
|
|
foreach ($categories as $catid => $catname) {
|
|
$catfields = [];
|
|
if ($fields = $DB->get_records('user_info_field', ['categoryid' => $catid], 'sortorder ASC')) {
|
|
foreach ($fields as $field) {
|
|
$fieldname = format_string($field->name);
|
|
$component = 'profilefield_' . $field->datatype;
|
|
$classname = "\\$component\\helper";
|
|
if (class_exists($classname) && method_exists($classname, 'get_fieldname')) {
|
|
$fieldname = $classname::get_fieldname($field->name);
|
|
}
|
|
$profilefields[$field->id] = "{$catname} / {$fieldname}";
|
|
}
|
|
}
|
|
}
|
|
debug::dump($profilefields);
|
|
|
|
$page->add(new admin_setting_configselect('tool_sptoolboxmgr/enrolfield',
|
|
get_string('setting_enrolfield', 'tool_sptoolboxmgr'),
|
|
get_string('settingdesc_enrolfield', 'tool_sptoolboxmgr'),
|
|
0,
|
|
$profilefields
|
|
));
|
|
|
|
|
|
$page->add(new admin_setting_configtext('tool_sptoolboxmgr/enrolvalue',
|
|
get_string('setting_enrolvalue', 'tool_sptoolboxmgr'),
|
|
get_string('settingdesc_enrolvalue', 'tool_sptoolboxmgr'),
|
|
"",
|
|
PARAM_RAW
|
|
));
|
|
|
|
|
|
$page->add(new admin_setting_configselect('tool_sptoolboxmgr/trackfield',
|
|
get_string('setting_trackfield', 'tool_sptoolboxmgr'),
|
|
get_string('settingdesc_trackfield', 'tool_sptoolboxmgr'),
|
|
0,
|
|
$profilefields
|
|
));
|
|
|
|
$studyplanfields = ["shortname" => get_string("studyplan_shortname","local_treestudyplan"),
|
|
"idnumber" => get_string("studyplan_idnumber","local_treestudyplan"),
|
|
"name" => get_string("studyplan_name","local_treestudyplan"), ];
|
|
$page->add(new admin_setting_configselect('tool_sptoolboxmgr/trackmapping',
|
|
get_string('setting_trackmapping', 'tool_sptoolboxmgr'),
|
|
get_string('settingdesc_trackmapping', 'tool_sptoolboxmgr'),
|
|
"shortname",
|
|
$studyplanfields
|
|
));
|
|
|
|
|
|
$page->add(new admin_setting_configcheckbox('tool_sptoolboxmgr/trackautofill',
|
|
get_string('setting_trackautofill', 'tool_sptoolboxmgr'),
|
|
get_string('settingdesc_trackautofill', 'tool_sptoolboxmgr'),
|
|
false
|
|
));
|
|
|
|
|
|
|
|
$page->add(new admin_setting_configselect('tool_sptoolboxmgr/coachfield',
|
|
get_string('setting_coachfield', 'tool_sptoolboxmgr'),
|
|
get_string('settingdesc_coachfield', 'tool_sptoolboxmgr'),
|
|
"",
|
|
$profilefields
|
|
));
|
|
|
|
|
|
|
|
// Add settings page to the admin settings category.
|
|
$ADMIN->add('tool_sptoolboxmgr', $page);
|
|
|
|
}
|