moodle-tool_sptoolboxmgr/settings.php

119 lines
4.2 KiB
PHP
Raw Permalink Normal View History

2024-03-22 22:10:56 +01:00
<?php
2024-05-12 23:34:48 +02:00
// This file is part of Moodle - http://moodle.org/.
2024-03-22 22:10:56 +01:00
//
2024-05-12 23:34:48 +02:00
// 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.
2024-03-22 22:10:56 +01:00
// (at your option) any later version.
//
2024-05-12 23:34:48 +02:00
// 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.
2024-03-22 22:10:56 +01:00
// GNU General Public License for more details.
//
2024-05-12 23:34:48 +02:00
// You should have received a copy of the GNU General Public License.
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
2024-03-22 22:10:56 +01:00
/**
2024-05-12 23:34:48 +02:00
* Local plugin Settings
*
2024-03-22 22:10:56 +01:00
* @package tool_sptoolboxmgr
2024-05-12 23:34:48 +02:00
* @copyright 2023 P.M. Kuipers
2024-03-22 22:10:56 +01:00
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
2024-05-12 23:34:48 +02:00
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);
}