MDL-23151 new ext sync option and minor refactoring
This commit is contained in:
@@ -70,8 +70,3 @@ $string['settingsheadernewcourses'] = 'Creation of new courses';
|
||||
$string['remoteuserfield_desc'] = 'The name of the field in the remote table that we are using to match entries in the user table.';
|
||||
$string['templatecourse'] = 'New course template';
|
||||
$string['templatecourse_desc'] = 'Optional: auto-created courses can copy their settings from a template course. Type here the shortname of the template course.';
|
||||
$string['unenrolaction'] = 'External unenrol action';
|
||||
$string['unenrolaction_desc'] = 'Select action to carry our when user enrolment disappears from external enrolment table. Please note that some user data and settings are purged from course during course unenrolment.';
|
||||
$string['unenrolactiondisable'] = 'Disable course enrolment';
|
||||
$string['unenrolactionkeep'] = 'Keep user enrolled';
|
||||
$string['unenrolactionunenrol'] = 'Unenrol user from course';
|
||||
|
||||
@@ -255,7 +255,7 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
}
|
||||
|
||||
// deal with enrolments removed from external table
|
||||
if ($unenrolaction == 0) {
|
||||
if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) {
|
||||
// unenrol
|
||||
if (!empty($requested_roles)) {
|
||||
// we might get some error or connection problem, better not unenrol everybody
|
||||
@@ -267,10 +267,10 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($unenrolaction == 1) {
|
||||
} else if ($unenrolaction == ENROL_EXT_REMOVED_KEEP) {
|
||||
// keep - only adding enrolments
|
||||
|
||||
} else if ($unenrolaction == 2) {
|
||||
} else if ($unenrolaction == ENROL_EXT_REMOVED_SUSPEND or $unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
|
||||
// disable
|
||||
foreach ($current_status as $userid=>$status) {
|
||||
if (isset($requested_roles[$userid])) {
|
||||
@@ -279,6 +279,9 @@ class enrol_database_plugin extends enrol_plugin {
|
||||
if ($status != ENROL_USER_SUSPENDED) {
|
||||
$DB->set_field('user_enrolments', 'status', ENROL_USER_SUSPENDED, array('enrolid'=>$instance->id, 'userid'=>$userid));
|
||||
}
|
||||
if ($unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
|
||||
role_unassign_all(array('contextid'=>$context->id, 'userid'=>$userid, 'component'=>'enrol_database', 'itemid'=>$instance->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,11 @@ if ($ADMIN->fulltree) {
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_database/ignorehiddencourses', get_string('ignorehiddencourses', 'enrol_database'), get_string('ignorehiddencourses_desc', 'enrol_database'), 0));
|
||||
|
||||
$options = array(0=>get_string('unenrolactionunenrol', 'enrol_database'), 1=>get_string('unenrolactionkeep', 'enrol_database'), 2=>get_string('unenrolactiondisable', 'enrol_database'));
|
||||
$settings->add(new admin_setting_configselect('enrol_database/unenrolaction', get_string('unenrolaction', 'enrol_database'), get_string('unenrolaction_desc', 'enrol_database'), 0, $options));
|
||||
$options = array(ENROL_EXT_REMOVED_UNENROL => get_string('extremovedunenrol', 'enrol'),
|
||||
ENROL_EXT_REMOVED_KEEP => get_string('extremovedkeep', 'enrol'),
|
||||
ENROL_EXT_REMOVED_SUSPEND => get_string('extremovedsuspend', 'enrol'),
|
||||
ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol'));
|
||||
$settings->add(new admin_setting_configselect('enrol_database/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_UNENROL, $options));
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,5 +23,5 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$plugin->version = 2010061500;
|
||||
$plugin->version = 2010070800;
|
||||
//TODO: should we add cron sync?
|
||||
+7
-1
@@ -72,5 +72,11 @@ $string['unenrolme'] = 'Unenrol me from {$a}';
|
||||
$string['unenrolroleusers'] = 'Unenrol users';
|
||||
$string['uninstallconfirm'] = 'You are about to completely delete the enrol plugin \'{$a}\'. This will completely delete everything in the database associated with this enrolment type. Are you SURE you want to continue?';
|
||||
$string['uninstalldeletefiles'] = 'All data associated with the enrol plugin \'{$a->plugin}\' has been deleted from the database. To complete the deletion (and prevent the plugin re-installing itself), you should now delete this directory from your server: {$a->directory}';
|
||||
$string['unlimitedduration'] = 'Unlmited';
|
||||
$string['unlimitedduration'] = 'Unlimited';
|
||||
$string['usersearch'] = 'Search ';
|
||||
$string['extremovedaction'] = 'External unenrol action';
|
||||
$string['extremovedaction_help'] = 'Select action to carry our when user enrolment disappears from external enrolment source. Please note that some user data and settings are purged from course during course unenrolment.';
|
||||
$string['extremovedsuspend'] = 'Disable course enrolment';
|
||||
$string['extremovedsuspendnoroles'] = 'Disable course enrolment and remove roles';
|
||||
$string['extremovedkeep'] = 'Keep user enrolled';
|
||||
$string['extremovedunenrol'] = 'Unenrol user from course';
|
||||
|
||||
@@ -40,6 +40,25 @@ define('ENROL_USER_SUSPENDED', 1);
|
||||
/** Enrol info is cached for this number of seconds in require_login() */
|
||||
define('ENROL_REQUIRE_LOGIN_CACHE_PERIOD', 1800);
|
||||
|
||||
/** When user disappears from external source, the enrolment is completely removed */
|
||||
define('ENROL_EXT_REMOVED_UNENROL', 0);
|
||||
|
||||
/** When user disappears from external source, the enrolment is kept as is - one way sync */
|
||||
define('ENROL_EXT_REMOVED_KEEP', 1);
|
||||
|
||||
/**
|
||||
* When user disappears from external source, user enrolment is suspended, roles are kept as is.
|
||||
* In some cases user needs a role with some capability to be visible in UI - suc has in gradebook,
|
||||
* assignments, etc.
|
||||
*/
|
||||
define('ENROL_EXT_REMOVED_SUSPEND', 2);
|
||||
|
||||
/**
|
||||
* When user disappears from external source, the enrolment is suspended and roles assigned
|
||||
* by enrol instance are removed. Please note that user may "disappear" from gradebook and other areas.
|
||||
* */
|
||||
define('ENROL_EXT_REMOVED_SUSPENDNOROLES', 3);
|
||||
|
||||
/**
|
||||
* Returns instances of enrol plugins
|
||||
* @param bool $enable return enabled only
|
||||
|
||||
Reference in New Issue
Block a user