first commit

main
root 2 years ago
commit 0d2de82fdc

@ -0,0 +1,3 @@
## Moodle IServ Enrolments ##
This Moodle plugin takes IServ groups and roles and creates Moodle courses and roles based on user configurable LDAP filters and attributes

@ -0,0 +1,81 @@
<?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/>.
/**
* IServ enrolment plugin implementation
*
* This plugin synchronizes courses and their enrolments with an IServ school server.
* Based partially on the OSS plugin by Frank Schütte
*
* @package enrol
* @subpackage iserv
* @author Jonas Lührig based on code by Frank Schütte based on code by Iñaki Arenaza
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2010 Iñaki Arenaza <iarenaza@eps.mondragon.edu>
* @copyright 2020 Frank Schütte <fschuett@gymhim.de>
* @copyright 2023 Gruelag GmbH <buero@gruelag.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace enrol_iserv\task;
defined('MOODLE_INTERNAL') || die;
/**
* Scheduled task to synchronize courses and enrolments
*/
class sync_enrolments_task extends \core\task\scheduled_task {
/**
* Get a descriptive name for this task (shown to admins).
*
* @return string
*/
public function get_name () {
return get_string('sync_task_name', 'enrol_iserv');
}
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute() {
global $CFG;
require_once ("{$CFG->dirroot}/enrol/iserv/lib.php");
// Ensure required plugins are enabled
if (! is_enabled_auth ("ldap")) {
debugging ("[AUTH LDAP] " . get_string ("pluginnotenabled", "auth_ldap"));
die;
}
if (! enrol_is_enabled ("iserv")) {
debugging ("[ENROL IServ] " . get_string ("pluginnotenabled", "enrol_iserv"));
die;
}
// Sync courses
$enrol = enrol_get_plugin ("iserv");
if (! $enrol -> sync_courses ()) {
return false;
};
return true;
}
}

@ -0,0 +1,105 @@
<?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/>.
/**
* CLI sync for full OSS synchronisation.
*
* This script is meant to be called from a cronjob to sync moodle with the OSS
* server to pickup groups as moodle global groups (cohorts).
*
* Sample cron entry:
* # 5 minutes past every full hour
* 5 * * * * $sudo -u www-data /usr/bin/php /var/www/moodle/enrol/oss/cli/sync.php
*
* Notes:
* - it is required to use the web server account when executing PHP CLI scripts
* - you need to change the "www-data" to match the apache user account
* - use "su" if "sudo" not available
* - If you have a large number of users, you may want to raise the memory limits
* by passing -d momory_limit=256M
* - For debugging & better logging, you are encouraged to use in the command line:
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
*
* @package enrol
* @subpackage oss
* @author Frank Schütte - test script
* @copyright 2012 Frank Schütte <fschuett@gymnasium-himmelsthuer.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("CLI_SCRIPT", true);
require (dirname(dirname(dirname(dirname(__FILE__)))) . "/config.php");
require_once ("{$CFG -> libdir}/clilib.php");
// Parse CLI arguments
list ($options, $unrecognized) = cli_get_params (
[
"help" => false,
"user" => false
],
[
"h" => "help",
"u" => "user"
],
);
if ($unrecognized) {
$unrecognized = implode ("\n ", $unrecognized);
cli_error (get_string ("cliunknownoption", "enrol_iserv", $unrecognized));
} else if ($options["help"]) {
$help = <<< EOH
Manually do a sync of IServ groups as courses.
Please ensure to enable and configure the enrol_iserv Plugin beforehand.
Options:
-h, --help Print out this help
Example:
\$sudo -u www-data /usr/bin/php enrol/iserv/cli/sync.php
Notice:
Do not call this file through the system cron scheduler, rather
use the scheduled task within Moodle this plugin provides.
EOH;
echo $help;
die;
}
// Enable debug messages
$CFG -> debug = DEBUG_NORMAL;
// Ensure required plugins are enabled
if (! is_enabled_auth ("ldap")) {
print ("[AUTH LDAP] " . get_string ("pluginnotenabled", "auth_ldap"));
die;
}
if (! enrol_is_enabled ("iserv")) {
print ("[ENROL IServ] " . get_string ("pluginnotenabled", "enrol_iserv"));
die;
}
// Sync courses
$enrol = enrol_get_plugin ("iserv");
if (! $enrol -> sync_courses ($options["user"] ?? "*")) {
cli_error (get_string ("sync_failed", "enrol_iserv"), 1);
};
exit(0);

@ -0,0 +1,24 @@
<?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/>.
defined('MOODLE_INTERNAL') || die();
function xmldb_enrol_iserv_install() {
global $CFG, $DB;
require_once($CFG->libdir . '/accesslib.php');
return true;
}

@ -0,0 +1,37 @@
<?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/>.
/**
* Definition of oss enrolment scheduled tasks.
*
* @package enrol_iserv
* @copyright 2023 Jonas Lührig
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$tasks = array(
array(
'classname' => '\enrol_iserv\task\sync_enrolments_task',
'blocking' => 0,
'minute' => '53',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
),
);

@ -0,0 +1,23 @@
<?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/>.
function xmldb_enrol_iserv_upgrade($oldversion) {
global $CFG, $DB;
require_once($CFG->libdir . '/accesslib.php');
return true;
}

@ -0,0 +1,98 @@
<?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/>.
defined('MOODLE_INTERNAL') || die();
$string['enrolname'] = 'iserv';
$string['pluginname'] = "IServ Einschreibungen";
$string['pluginnotenabled'] = "Plugin {$string['pluginname']} ist nicht aktiviert";
$string['cliunknownoption'] = "Unbekannte CLI Parameter:\n\n{$a}";
$string['sync_failed'] = "Fehler bei der Synchronisation!";
$string['sync_task_name'] = "Kurse und Einschreibungen synchronisieren";
/* Settings translations */
$string['plugin_description'] = "Dieses Plugin synchronisiert IServ Gruppen als Moodle Kurse.";
// Group Settings
$string['group_settings'] = "Gruppeneinstellungen";
$string['group_settings_desc'] = "LDAP Einstellungen zu IServ Gruppen";
$string['group_contexts_key'] = "Gruppenkontexte";
$string['group_contexts_desc'] = "LDAP Kontexte, in denen Gruppen gefunden werden können. Mehrere Kontexte werden mit ; getrennt";
$string['group_object_class_key'] = "Gruppen Objektklasse";
$string['group_object_class_desc'] = "Objektklasse von Gruppen im LDAP Baum";
$string['group_attribute_key'] = "Gruppen ID-Attribut";
$string['group_attribute_desc'] = "LDAP Attribut, welches eine Gruppe identifiziert";
$string['group_fullname_attribute_key'] = "Gruppen Namensattribut";
$string['group_fullname_attribute_desc'] = "LDAP Attribut, welches den vollen Namen einer Gruppe enthält";
$string['group_member_attribute_key'] = "Gruppen Mitgliedsattribut";
$string['group_member_attribute_desc'] = "LDAP Attribut, welches ein Mitglied einer Gruppe darstellt";
$string['group_member_attribute_is_dn_key'] = "Gruppen Mitgliedsattribut ist DN";
$string['group_member_attribute_is_dn_desc'] = "Gibt an, ob das Gruppen Mitgliedsattribut ein DN Wert ist";
$string['group_search_subtree_key'] = "Im gesamten Baum suchen";
$string['group_search_subtree_desc'] = "Gibt an, ob im gesamten Baum unter den Gruppenkontexten nach Gruppen gesucht werden soll";
// Role Settings
$string['role_settings'] = "IServ Rollen-Einstellungen";
$string['role_settings_desc'] = "LDAP Einstellungen zu IServ Rollen";
$string['role_contexts_key'] = "Rollenkontexte";
$string['role_contexts_desc'] = "LDAP Kontexte, in denen Rollen gefunden werden können. Mehrere Kontexte werden mit ; getrennt.";
$string['role_object_class_key'] = "Rollen Objektklasse";
$string['role_object_class_desc'] = "Objektklasse von Rollen im LDAP Baum";
$string['teachers_role_name_key'] = "Rolle Lehrkräfte";
$string['teachers_role_name_desc'] = "Rollenname von Lehrkräften";
$string['students_role_name_key'] = "Rolle Schüler/innen";
$string['students_role_name_desc'] = "Rollenname von Schüler/innen";
$string['role_member_attribute_key'] = "Rollen Mitgliedsattribut";
$string['role_member_attribute_desc'] = "LDAP Attribut, welches ein Mitglied einer Rolle darstellt";
$string['role_member_attribute_is_dn_key'] = "Rollen Mitgliedsattribut ist DN";
$string['role_member_attribute_is_dn_desc'] = "Gibt an, ob das Rollen Mitgliedsattribut ein DN Wert ist";
// Course Mapping
$string['coursemapping'] = "Kurszuweisung";
$string['coursemapping_desc'] = "Einstellungen zur Zuweisung von IServ Gruppen zu Moodle Kursen";
$string['coursemapping_attribute_key'] = "Kurs Attribut";
$string['coursemapping_attribute_desc'] = "LDAP Attribut, wessen Wert eine Gruppe als Kurs markiert";
$string['coursemapping_attribute_value_key'] = "Kurs Attributwert";
$string['coursemapping_attribute_value_desc'] = "Wert des obrigen Kurs Attributes";
$string['coursemapping_use_attribute_key'] = "Kurs Attribut benutzen";
$string['coursemapping_use_attribute_desc'] = "Gibt an, ob das Kurs Attribut verwendet werden soll, um Gruppen Kursen zuzuweisen";
$string['coursemapping_prefixes_key'] = "Kurs CN Präfix";
$string['coursemapping_prefixes_desc'] = "Ein Präfix im CN Gruppen Attribut, welches eine Gruppe als Moodle Kurs markiert. Ein * wird als Platzhalter für den restlichen CN Wert eingesetzt";
$string['coursemapping_use_prefixes_key'] = "Kurs CN Präfix verwenden";
$string['coursemapping_use_prefixes_desc'] = "Gibt an, ob das Kurs CN Präfix verwendet werden soll, um Gruppen Kursen zuzuweisen. Hinweis: Das Kurs Attribut hat Vorrang, wenn beide aktiv sind!";
// Course Settings
$string['courses'] = "Kurseinstellungen";
$string['courses_desc'] = "Einstellungen zu Moodle Kursen";
$string['courses_category_key'] = "Kurskategorie Name";
$string['courses_category_desc'] = "Name der Kurskategorie, in welcher neue Kurse erstellt werden";
$string['courses_category_autocreate_key'] = "Kurskategorie automatisch erstellen";
$string['courses_category_autocreate_desc'] = "Gibt an, ob die Kurskategorie automatisch erstellt werden soll";
$string['courses_autocreate_key'] = "Kurse automatisch erstellen";
$string['courses_autocreate_desc'] = "Gibt an, ob Kurse automatisch erstellt werden sollen";
$string['courses_autoremove_key'] = "Kurse automatisch löschen";
$string['courses_autoremove_desc'] = "Gibt an, ob Kurse automatisch gelöscht werden sollen, wenn diese in IServ nicht mehr existieren oder der Kurs keine Mitglieder mehr besitzt";
$string['courses_template_key'] = "Kurs Vorlage";
$string['courses_template_desc'] = "Vorhandener Kurs, welcher als Vorlage für neue Kurse genutzt werden soll";
$string['course_template_none'] = "Keine Vorlage";
$string['courses_teacher_role_key'] = "Rolle Lehrkräfte";
$string['courses_teacher_role_desc'] = "Rolle, welche Lehrkräften zugeweisen wird";
$string['courses_student_role_key'] = "Rolle Schüler/innen";
$string['courses_student_role_desc'] = "Rolle, welche Schüler/innen zugeweisen wird";
/* Internal strings */
$string['courses_category_description'] = "Kurse von IServ importiert";

@ -0,0 +1,97 @@
<?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/>.
defined('MOODLE_INTERNAL') || die();
$string['enrolname'] = 'iserv';
$string['pluginname'] = "IServ Enrolments";
$string['pluginnotenabled'] = "Plugin {$string['pluginname']} is not enabled";
$string['cliunknownoption'] = "Unknown CLI parameter:\n\n{$a}";
$string['sync_failed'] = "Error during the synchronization process!";
$string['sync_task_name'] = "Synchronize courses and enrolments";
/* Settings translations */
$string['plugin_description'] = "This plugin synchronizes IServ roles via LDAP as Moodle courses";
// Group Settings
$string['group_settings'] = "IServ Group LDAP Settings";
$string['group_settings_desc'] = "Settings related to LDAP groups";
$string['group_contexts_key'] = "Group Contexts";
$string['group_contexts_desc'] = "LDAP contexts in which groups can be found. Multiple contexts are separated by a semi-colon (;)";
$string['group_object_class_key'] = "Group Object Class";
$string['group_object_class_desc'] = "Object class of groups in LDAP tree";
$string['group_attribute_key'] = "Group ID Attribute";
$string['group_attribute_desc'] = "LDAP attribute which identifies a group";
$string['group_fullname_attribute_key'] = "Group Display Name Attribute";
$string['group_fullname_attribute_desc'] = "LDAP attribute which contains the display name of a group";
$string['group_member_attribute_key'] = "Group Member Attribute";
$string['group_member_attribute_desc'] = "LDAP attribute which specifies a group member";
$string['group_member_attribute_is_dn_key'] = "Group Member Attribute is DN";
$string['group_member_attribute_is_dn_desc'] = "Specifies if the group member attribute is a DN value";
$string['group_search_subtree_key'] = "Search Sub-Trees";
$string['group_search_subtree_desc'] = "When true, groups are searched in sub-trees of the group contexts";
// Role Settings
$string['role_settings'] = "IServ Role LDAP Settings";
$string['role_settings_desc'] = "Settings related to IServ roles";
$string['role_contexts_key'] = "Role Contexts";
$string['role_contexts_desc'] = "LDAP contexts in which roles can be found. Multiple contexts are separated by a semi-colon (;).";
$string['role_object_class_key'] = "Role Object Class";
$string['role_object_class_desc'] = "Object class of roles in LDAP tree";
$string['teachers_role_name_key'] = "Teachers Role";
$string['teachers_role_name_desc'] = "Role name of teachers";
$string['students_role_name_key'] = "Students Role";
$string['students_role_name_desc'] = "Role name of students";
$string['role_member_attribute_key'] = "Role Member Attribute";
$string['role_member_attribute_desc'] = "LDAP attribute which specifies a role member";
$string['role_member_attribute_is_dn_key'] = "Role membership attribute is DN";
$string['role_member_attribute_is_dn_desc'] = "Specifies if the role membership attribute is a DN value";
// Course Mapping
$string['coursemapping'] = "Course Mapping";
$string['coursemapping_desc'] = "Settings specifying how IServ groups are mapped to Moodle courses";
$string['coursemapping_attribute_key'] = "Course Attribute";
$string['coursemapping_attribute_desc'] = "LDAP attribute whose value marks IServ groups as Moodle courses";
$string['coursemapping_attribute_value_key'] = "Course Attribute Value";
$string['coursemapping_attribute_value_desc'] = "Value of the course attribute above";
$string['coursemapping_use_attribute_key'] = "Use Course Attribute";
$string['coursemapping_use_attribute_desc'] = "Specifies if the course attribute is used for mapping";
$string['coursemapping_prefixes_key'] = "Course CN Prefix";
$string['coursemapping_prefixes_desc'] = "A prefix in the group CN attribute which marks IServ groups as Moodle courses. An asterisk (*) is used as placeholder for remaining text in the CN attribute";
$string['coursemapping_use_prefixes_key'] = "Use course CN prefix";
$string['coursemapping_use_prefixes_desc'] = "Specifies if the course CN prefix is used for mapping. Notice: The course attribute takes precedence when both are active!";
// Course Settings
$string['courses'] = "Course Settings";
$string['courses_desc'] = "Settings related to Moodle courses";
$string['courses_category_key'] = "Courses category name";
$string['courses_category_desc'] = "Name of the courses category in which any mapped courses will be organized";
$string['courses_category_autocreate_key'] = "Autocreate Courses Category";
$string['courses_category_autocreate_desc'] = "Specifies if the courses category should be auto created";
$string['courses_autocreate_key'] = "Autocreate Courses";
$string['courses_autocreate_desc'] = "Specifies if courses should be auto created";
$string['courses_autoremove_key'] = "Autoremove Courses";
$string['courses_autoremove_desc'] = "Specifies if courses shold be auto removed if the group gets removed from IServ or the group has no members left";
$string['courses_template_key'] = "Course Template";
$string['courses_template_desc'] = "Existing course to use as template for new courses";
$string['course_template_none'] = "No template";
$string['courses_teacher_role_key'] = "Teachers role";
$string['courses_teacher_role_desc'] = "Course role to assign to teachers";
$string['courses_student_role_key'] = "Students role";
$string['courses_student_role_desc'] = "Course role to assign to students";
/* Internal strings */
$string['courses_category_description'] = "Courses imported from IServ";

1344
lib.php

File diff suppressed because it is too large Load Diff

@ -0,0 +1,342 @@
<?php
//
// 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/>.
/**
* IServ enrolment plugin implementation
*
* This plugin synchronizes courses and their enrolments with an IServ school server.
* Based partially on the OSS plugin by Frank Schütte
*
* @package enrol
* @subpackage iserv
* @author Jonas Lührig based on code by Frank Schütte based on code by Iñaki Arenaza
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2010 Iñaki Arenaza <iarenaza@eps.mondragon.edu>
* @copyright 2020 Frank Schütte <fschuett@gymhim.de>
* @copyright 2023 Gruelag GmbH <buero@gruelag.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN -> fulltree) {
global $DB;
// Initializing
require_once ("{$CFG -> dirroot}/enrol/ldap/settingslib.php");
require_once ("{$CFG -> dirroot}/enrol/oss/settings_callbacks.php");
$yesno = array(get_string('no'), get_string('yes'));
// Heading
$settings -> add(
new admin_setting_heading(
'enrol_iserv_settings',
get_string('pluginname','enrol_iserv'),
get_string('plugin_description', 'enrol_iserv')
)
);
// --- GROUP Settings --- //
$settings->add(
new admin_setting_heading(
'enrol_iserv_group_settings',
get_string('group_settings', 'enrol_iserv'),
get_string('group_settings_desc', 'enrol_iserv')
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/group_contexts',
get_string('group_contexts_key', 'enrol_iserv'),
get_string('group_contexts_desc', 'enrol_iserv'),
'ou=groups,dc=mein-iserv,dc=de'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/group_object_class',
get_string('group_object_class_key', 'enrol_iserv'),
get_string('group_object_class_desc', 'enrol_iserv'),
'uuidObject'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/group_attribute',
get_string('group_attribute_key', 'enrol_iserv'),
get_string('group_attribute_desc', 'enrol_iserv'),
'cn'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/group_fullname_attribute',
get_string('group_fullname_attribute_key', 'enrol_iserv'),
get_string('group_fullname_attribute_desc', 'enrol_iserv'),
'description'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/group_member_attribute',
get_string('group_member_attribute_key', 'enrol_iserv'),
get_string('group_member_attribute_desc', 'enrol_iserv'),
"memberUid"
)
);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/group_member_attribute_is_dn',
get_string('group_member_attribute_is_dn_key', 'enrol_iserv'),
get_string('group_member_attribute_is_dn_desc', 'enrol_iserv'),
0,
$yesno
)
);
$settings->add(
new admin_setting_configcheckbox(
'enrol_iserv/group_search_subtree',
get_string('group_search_subtree_key', 'enrol_iserv'),
get_string('group_search_subtree_desc', 'enrol_iserv'),
0
)
);
// --- ROLE Settings --- //
$settings->add(
new admin_setting_heading(
'enrol_iserv_role_settings',
get_string('role_settings', 'enrol_iserv'),
get_string('role_settings_desc', 'enrol_iserv')
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/role_contexts',
get_string('role_contexts_key', 'enrol_iserv'),
get_string('role_contexts_desc', 'enrol_iserv'),
'ou=roles,dc=mein-iserv,dc=de'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/role_object_class',
get_string('role_object_class_key', 'enrol_iserv'),
get_string('role_object_class_desc', 'enrol_iserv'),
'organizationalRole'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/teachers_role_name',
get_string('teachers_role_name_key', 'enrol_iserv'),
get_string('teachers_role_name_desc', 'enrol_iserv'),
'ROLE_TEACHER'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/students_role_name',
get_string('students_role_name_key', 'enrol_iserv'),
get_string('students_role_name_desc', 'enrol_iserv'),
'ROLE_STUDENT'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/role_member_attribute',
get_string('role_member_attribute_key', 'enrol_iserv'),
get_string('role_member_attribute_desc', 'enrol_iserv'),
"roleOccupant"
)
);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/role_member_attribute_is_dn',
get_string('role_member_attribute_is_dn_key', 'enrol_iserv'),
get_string('role_member_attribute_is_dn_desc', 'enrol_iserv'),
1,
$yesno
)
);
// --- GROUP<>COURSE MAPPING Settings --- //
$settings->add(
new admin_setting_heading(
'enrol_iserv_coursemapping_settings',
get_string('coursemapping', 'enrol_iserv'),
get_string('coursemapping_desc', 'enrol_iserv')
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/coursemapping_attribute',
get_string('coursemapping_attribute_key', 'enrol_iserv'),
get_string('coursemapping_attribute_desc', 'enrol_iserv'),
'memberUid'
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/coursemapping_attribute_value',
get_string('coursemapping_attribute_value_key', 'enrol_iserv'),
get_string('coursemapping_attribute_value_desc', 'enrol_iserv'),
"moodlekurs"
)
);
$settings->add(
new admin_setting_configcheckbox(
'enrol_iserv/coursemapping_use_attribute',
get_string('coursemapping_use_attribute_key', 'enrol_iserv'),
get_string('coursemapping_use_attribute_desc', 'enrol_iserv'),
0
)
);
$settings->add(
new admin_setting_configtext_trim_lower(
'enrol_iserv/coursemapping_prefixes',
get_string('coursemapping_prefixes_key', 'enrol_iserv'),
get_string('coursemapping_prefixes_desc', 'enrol_iserv'),
"kurs.*"
)
);
$settings->add(
new admin_setting_configcheckbox(
'enrol_iserv/coursemapping_use_prefixes',
get_string('coursemapping_use_prefixes_key', 'enrol_iserv'),
get_string('coursemapping_use_prefixes_desc', 'enrol_iserv'),
1
)
);
// --- COURSES Settings --- //
$settings->add(
new admin_setting_heading(
'enrol_iserv_courses_settings',
get_string('courses', 'enrol_iserv'),
get_string('courses_desc', 'enrol_iserv')
)
);
$setting = new admin_setting_configtext_trim_lower(
'enrol_iserv/courses_category',
get_string('courses_category_key', 'enrol_iserv'),
get_string('courses_category_desc', 'enrol_iserv'),
"Kurse"
);
$setting -> set_updatedcallback ('enrol_iserv_settings_courses_category_name_updated');
$settings->add($setting);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/courses_autocreate',
get_string('courses_autocreate_key', 'enrol_iserv'),
get_string('courses_autocreate_desc', 'enrol_iserv'),
1,
$yesno
)
);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/courses_autoremove',
get_string('courses_autoremove_key', 'enrol_iserv'),
get_string('courses_autoremove_desc', 'enrol_iserv'),
1,
$yesno
)
);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/courses_category_autocreate',
get_string('courses_category_autocreate_key', 'enrol_iserv'),
get_string('courses_category_autocreate_desc', 'enrol_iserv'),
1,
$yesno
)
);
$enrol_iserv_courses = array();
$enrol_iserv_coursenames = $DB -> get_records_sql('SELECT * FROM {course} ORDER BY fullname');
foreach ($enrol_iserv_coursenames as $key => $coursename) {
$enrol_iserv_courses[$coursename->id] = "{$coursename -> fullname} ({$coursename->id})";
}
$enrol_iserv_courses[0] = get_string('course_template_none','enrol_iserv');
$settings->add(
new admin_setting_configselect(
'enrol_iserv/courses_template',
get_string('courses_template_key', 'enrol_iserv'),
get_string('courses_template_desc', 'enrol_iserv'),
0,
$enrol_iserv_courses
)
);
$options = get_default_enrol_roles (context_system::instance ());
$teacher = get_archetype_roles ('editingteacher');
$teacher = reset ($teacher);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/courses_teacher_role',
get_string('courses_teacher_role_key', 'enrol_iserv'),
get_string('courses_teacher_role_desc', 'enrol_iserv'),
$teacher -> id,
$options
)
);
$options = get_default_enrol_roles (context_system::instance ());
$student = get_archetype_roles ('student');
$student = reset ($student);
$settings->add(
new admin_setting_configselect(
'enrol_iserv/courses_student_role',
get_string('courses_student_role_key', 'enrol_iserv'),
get_string('courses_student_role_desc', 'enrol_iserv'),
$student -> id,
$options
)
);
}

@ -0,0 +1,90 @@
lear<?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/>.
/**
* IServ enrolment plugin implementation
*
* This plugin synchronizes courses and their enrolments with an IServ school server.
* Based partially on the OSS plugin by Frank Schütte
*
* @package enrol
* @subpackage iserv
* @author Jonas Lührig based on code by Frank Schütte based on code by Iñaki Arenaza
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2010 Iñaki Arenaza <iarenaza@eps.mondragon.edu>
* @copyright 2020 Frank Schütte <fschuett@gymhim.de>
* @copyright 2023 Gruelag GmbH <buero@gruelag.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Callback for updating the courses category name on settings update
*
* @uses $CFG
*/
function enrol_iserv_settings_courses_category_name_updated ($value = "") {
global $CFG;
file_put_contents ("/tmp/test.txt", "here {$value}");
require_once "{$CFG -> dirroot}/enrol/iserv/lib.php";
$enrol = enrol_get_plugin('iserv');
$enrol -> rename_courses_category (
get_config ('enrol_iserv') -> courses_category
);
}
/*
function enrol_oss_settings_class_category_updated($full_name) {
global $CFG;
require_once $CFG->dirroot.'/enrol/oss/lib.php';
$config = get_config('enrol_oss');
$classcat = enrol_oss_plugin::get_class_category($config);
if ( $classcat ) {
$classcat->update(array('name' => $config->class_category));
}
}
function enrol_oss_description_updated($groupname, $newvalue) {
global $DB;
$data = new stdClass;
$records = $DB->get_records_sql("SELECT g.id, g.courseid, c.shortname FROM {groups} g JOIN {course} c ON g.courseid = c.id WHERE g.name = ? ", array($groupname));
foreach($records as $group) {
$data->id = $group->id;
$data->description = '<p>'.trim($newvalue).' '.$group->shortname.'</p>';
$DB->update_record('groups', $data);
}
}
function enrol_oss_settings_class_teachers_group_description_updated($full_name) {
$newvalue = get_config('enrol_oss', 'class_teachers_group_description');
enrol_oss_description_updated('teachers', $newvalue);
}
function enrol_oss_settings_class_students_group_description_updated($full_name) {
$newvalue = get_config('enrol_oss', 'class_students_group_description');
enrol_oss_description_updated('students', $newvalue);
}
function enrol_oss_settings_class_parents_group_description_updated($full_name) {
$newvalue = get_config('enrol_oss', 'class_parents_group_description');
enrol_oss_description_updated('parents', $newvalue);
}
*/

@ -0,0 +1,40 @@
<?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/>.
/**
* IServ enrolment plugin implementation
*
* This plugin synchronizes courses and their enrolments with an IServ school server.
* Based partially on the OSS plugin by Frank Schütte
*
* @package enrol
* @subpackage iserv
* @author Jonas Lührig based on code by Frank Schütte based on code by Iñaki Arenaza
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2010 Iñaki Arenaza <iarenaza@eps.mondragon.edu>
* @copyright 2020 Frank Schütte <fschuett@gymhim.de>
* @copyright 2023 Gruelag GmbH <buero@gruelag.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin -> version = 2023102210; // The current plugin version (Date: YYYYMMDDXX).
$plugin -> requires = 2015051100; // Requires Moodle version 2.9
$plugin -> component = 'enrol_iserv'; // Full name of the plugin (used for diagnostics).
$plugin -> maturity = MATURITY_BETA; // Beta, nees testing.
$plugin -> release = '2.3 (Build: 2023081202)';
$plugin -> dependencies = array('auth_ldap' => ANY_VERSION);
Loading…
Cancel
Save