Skip to content

Commit

Permalink
update enrol/ldap to work with roles.
Browse files Browse the repository at this point in the history
Credit: Alastair Pharo <alastair@catalyst.net.nz>

1) Some config settings have changed (ones that related specifically to
teachers and students).  There is a check in place however to migrate
old configurations to new ones.

2) Perviously two syncs happened - one for students, one for teachers.
Now sync gets called the same number of times as there are roles.
Those roles that have config settings associated with them then run
through all the records.  This means syncing takes longer the more
roles you configure (which is expected anyway I suppose).
  • Loading branch information
mjollnir_ committed Sep 26, 2006
1 parent 7ccf89f commit 87c7590
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 192 deletions.
54 changes: 40 additions & 14 deletions enrol/ldap/config.html
Expand Up @@ -16,19 +16,6 @@
if (!isset ($frm->enrol_ldap_search_sub)) {
$frm->enrol_ldap_search_sub = '0';
}
// student & teacher enrol
if (!isset ($frm->enrol_ldap_student_contexts)) {
$frm->enrol_ldap_student_contexts = '';
}
if (!isset ($frm->enrol_ldap_student_memberattribute)) {
$frm->enrol_ldap_student_memberattribute = '';
}
if (!isset ($frm->enrol_ldap_teacher_contexts)) {
$frm->enrol_ldap_teacher_contexts = '';
}
if (!isset ($frm->enrol_ldap_teacher_memberattribute)) {
$frm->enrol_ldap_teacher_memberattribute = '';
}
if (!isset ($frm->enrol_ldap_objectclass)) {
$frm->enrol_ldap_objectclass = '';
}
Expand Down Expand Up @@ -56,7 +43,7 @@
}
if (!isset ($frm->enrol_ldap_course_shortname)) {
$frm->enrol_ldap_course_shortname = '';
}
}
if (!isset ($frm->enrol_ldap_course_shortname_updatelocal)) {
$frm->enrol_ldap_course_shortname_updatelocal = false;
}
Expand All @@ -72,6 +59,19 @@
if (!isset ($frm->enrol_ldap_course_summary_editlock)) {
$frm->enrol_ldap_course_summary_editlock = false;
}

// Roles
$roles = get_records('role');
foreach($roles as $role) {
if (!isset($frm->{'enrol_ldap_contexts_role'.$role->id})) {
$frm->{'enrol_ldap_contexts_role'.$role->id} = '';
}

if (!isset($frm->{'enrol_ldap_memberattribute_role'.$role->id})) {
$frm->{'enrol_ldap_memberattribute_role'.$role->id} = '';
}
}

// autocreate
optional_variable($frm->enrol_ldap_autocreate, false);
optional_variable($frm->enrol_ldap_category, 1);
Expand Down Expand Up @@ -145,6 +145,7 @@ <h4><?php print_string("enrol_ldap_server_settings", "enrol_ldap") ?> </h4>
</td>
</tr>

<?php /*
<tr>
<td colspan="2">
<h4><?php print_string("enrol_ldap_student_settings", "enrol_ldap") ?> </h4>
Expand Down Expand Up @@ -194,6 +195,31 @@ <h4><?php print_string("enrol_ldap_teacher_settings", "enrol_ldap") ?> </h4>
<?php print_string("enrol_ldap_teacher_memberattribute","enrol_ldap") ?>
</td>
</tr>
*/ ?>

<tr>
<td colspan="2">
<h4><?php print_string('enrol_ldap_roles', 'enrol_ldap'); ?></h4>
</td>
</tr>
<tr>
<td colspan="3">
<table>
<tr>
<th><?php print_string('role_name', 'enrol_ldap'); ?></th>
<th><?php print_string('enrol_ldap_contexts', 'enrol_ldap'); ?></th>
<th><?php print_string('enrol_ldap_memberattribute', 'enrol_ldap'); ?></th>
</tr>
<?php foreach ($roles as $role): ?>
<tr>
<td><?php echo htmlspecialchars($role->name, ENT_COMPAT, 'UTF-8'); ?></td>
<td><input type="text" size="30" name="enrol_ldap_contexts_role<?php echo $role->id; ?>" value="<?php echo htmlspecialchars($frm->{'enrol_ldap_contexts_role'.$role->id}); ?>" /></td>
<td><input type="text" size="30" name="enrol_ldap_memberattribute_role<?php echo $role->id; ?>" value="<?php echo htmlspecialchars($frm->{'enrol_ldap_memberattribute_role'.$role->id}); ?>" /></td>
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>

<tr>
<td colspan="2">
Expand Down

0 comments on commit 87c7590

Please sign in to comment.