Almost there with config_plugins work!

* More solid checking for auth GET/POST var.
 * print_auth_lock_options() now handles user field mapping options for LDAP and similar modules
 * user mapping options have moved to config_plugins table
 * LDAP module has migrated to using new field mapping vars -- simplified config.html a lot
 * strings are mostly resolved
 * a bit of work pending on CAS and DB modules
 * need an upgrade path for field-mapping config entries -- limited to LDAP only
This commit is contained in:
martinlanghoff
2005-06-01 04:44:17 +00:00
parent 6b64601101
commit b50eee807b
3 changed files with 81 additions and 437 deletions
+55 -16
View File
@@ -67,7 +67,7 @@
$options[$module] = get_string("auth_$module"."title", "auth");
}
asort($options);
if (isset($_GET['auth'])) {
if (isset($_GET['auth']) && in_array($_GET['auth'], $modules)) {
$auth = $_GET['auth'];
} else {
$auth = $config->auth;
@@ -88,13 +88,6 @@
}
$user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
foreach ($user_fields as $user_field) {
$user_field = "auth_user_$user_field";
if (! isset($config->$user_field)) {
$config->$user_field = "";
}
}
if (empty($focus)) {
$focus = "";
}
@@ -219,24 +212,70 @@ function validate_form(&$form, &$err) {
// but some may want a custom one if they are offering
// other options
// Note: pluginconfig_ fields have special handling.
function print_auth_lock_options ($auth, $user_fields, $helptext='', $refreshopts, $updateopts) {
function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
echo '<tr><td colspan="3">';
print_heading(get_string('auth_fieldlocks', 'auth'));
if ($retrieveopts) {
print_heading(get_string('auth_data_mapping', 'auth'));
} else {
print_heading(get_string('auth_fieldlocks', 'auth'));
}
echo '<td/></tr>';
$lockoptions = array ('unlocked' => get_string('auth_unlocked', 'auth'),
'unlockedifempty' => get_string('auth_unlockedifempty', 'auth'),
'locked' => get_string('auth_locked', 'auth'));
$lockoptions = array ('unlocked' => get_string('unlocked', 'auth'),
'unlockedifempty' => get_string('unlockedifempty', 'auth'),
'locked' => get_string('locked', 'auth'));
$updatelocaloptions = array('oncreate' => get_string('update_oncreate', 'auth'),
'onlogin' => get_string('update_onogin', 'auth'));
$updateextoptions = array('0' => get_string('update_never', 'auth'),
'1' => get_string('update_onupdate', 'auth'));
$pluginconfig = get_config("auth/$auth");
// helptext is on a field with rowspan
if (empty($helptext)) {
$helptext = '&nbsp;';
}
foreach ($user_fields as $field) {
echo '<tr valign="top"><td align="right">';
echo get_string($field);
echo '</td><td>';
choose_from_menu($lockoptions, "pluginconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
echo "</td><td>$helptext</td></tr>";
$helptext = '&nbsp;';
// Define some vars we'll work with
optional_variable($pluginconfig->{"field_map_$field"}, '');
optional_variable($pluginconfig->{"field_updatelocal_$field"}, '');
optional_variable($pluginconfig->{"field_updateremote_$field"}, '');
optional_variable($pluginconfig->{"field_lock_$field"}, '');
if ($retrieveopts) {
$varname = 'field_map_' . $field;
echo "<input name=\"pluginconfig_{$varname}\" type=\"text\" size=\"30\" value=\"{$pluginconfig->$varname}\">";
echo '<div align="right">';
echo get_string('auth_updatelocal', 'auth') . '&nbsp;&nbsp;';
choose_from_menu($updatelocaloptions, "pluginconfig_field_updatelocal_{$field}", $pluginconfig->{"field_updatelocal_$field"}, "");
echo '<br />';
if ($updateopts) {
echo get_string('auth_updateremote', 'auth') . '&nbsp;&nbsp;';
'&nbsp;&nbsp;';
choose_from_menu($updateextoptions, "pluginconfig_field_updateremote_{$field}", $pluginconfig->{"field_updateremote_$field"}, "");
echo '<br />';
}
echo get_string('auth_fieldlock', 'auth') . '&nbsp;&nbsp;';
choose_from_menu($lockoptions, "pluginconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
echo '</div>';
} else {
choose_from_menu($lockoptions, "pluginconfig_field_lock_{$field}", $pluginconfig->{"field_lock_$field"}, "");
}
echo '</td>';
if (!empty($helptext)) {
echo '<td rowspan="' . count($user_fields) . '">' . $helptext . '</td>';
$helptext = '';
}
echo '</tr>';
}
}
+12 -413
View File
@@ -1,4 +1,4 @@
<?PHP
<?php
// Initialize vars
optional_variable($config->ldap_host_url, "");
optional_variable($config->ldap_contexts, "");
@@ -20,45 +20,8 @@
optional_variable($config->ldap_graceattr, "");
optional_variable($config->auth_user_create, "");
optional_variable($config->auth_user_create, "");
optional_variable($config->auth_ldap_forcepasswordchange, "");
optional_variable($config->auth_ldap_forcechangepassword, "");
optional_variable($config->auth_user_firstname_updatelocal, "1");
optional_variable($config->auth_user_firstname_editlock, "1");
optional_variable($config->auth_user_firstname_updateremote, "");
optional_variable($config->auth_user_lastname_updatelocal, "1");
optional_variable($config->auth_user_lastname_editlock, "1");
optional_variable($config->auth_user_lastname_updateremote, "");
optional_variable($config->auth_user_email_updatelocal, "1");
optional_variable($config->auth_user_email_editlock, "1");
optional_variable($config->auth_user_email_updateremote, "");
optional_variable($config->auth_user_phone1_updatelocal, "");
optional_variable($config->auth_user_phone1_editlock, "");
optional_variable($config->auth_user_phone1_updateremote, "");
optional_variable($config->auth_user_phone2_updatelocal, "");
optional_variable($config->auth_user_phone2_editlock, "");
optional_variable($config->auth_user_phone2_updateremote, "");
optional_variable($config->auth_user_department_updatelocal, "");
optional_variable($config->auth_user_department_editlock, "");
optional_variable($config->auth_user_department_updateremote, "");
optional_variable($config->auth_user_address_updatelocal, "");
optional_variable($config->auth_user_address_editlock, "");
optional_variable($config->auth_user_address_updateremote, "");
optional_variable($config->auth_user_city_updatelocal, "");
optional_variable($config->auth_user_city_editlock, "");
optional_variable($config->auth_user_city_updateremote, "");
optional_variable($config->auth_user_country_updatelocal, "");
optional_variable($config->auth_user_country_editlock, "");
optional_variable($config->auth_user_country_updateremote, "");
optional_variable($config->auth_user_description_updatelocal, "");
optional_variable($config->auth_user_description_editlock, "");
optional_variable($config->auth_user_description_updateremote, "");
optional_variable($config->auth_user_lang_updatelocal, "");
optional_variable($config->auth_user_lang_editlock, "");
optional_variable($config->auth_user_lang_updateremote, "");
optional_variable($config->auth_user_idnumber_updatelocal, "");
optional_variable($config->auth_user_idnumber_editlock, "");
optional_variable($config->auth_user_idnumber_updateremote, "");
optional_variable($config->auth_ldap_stdchangepassword, false);
if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
@@ -368,382 +331,17 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
</td>
</tr>
<?php
<tr>
<td colspan="2">
<h4><?php print_string("auth_data_mapping", "auth") ?> </h4>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("firstname") ?>:</td>
<td>
<input name="auth_user_firstname" type="text" size="30" value="<?php echo $config->auth_user_firstname?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_firstname_updatelocal">
<option value="0" <?php echo ($config->auth_user_firstname_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_firstname_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_firstname_editlock">
<option value="0" <?php echo ($config->auth_user_firstname_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_firstname_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_firstname_updateremote">
<option value="0" <?php echo ($config->auth_user_firstname_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_firstname_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
<td rowspan=12 valign="top">
<?php print_string("auth_ldapextrafields","auth") ?>
<?php print_string("auth_updatelocal_expl","auth") ?>
<?php print_string("auth_editlock_expl","auth") ?>
<?php print_string("auth_updateremote_expl","auth") ?>
<hr>
<?php print_string("auth_updateremote_ldap","auth") ?>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("lastname") ?>:</td>
<td>
<input name="auth_user_lastname" type="text" size="30" value="<?php echo $config->auth_user_lastname?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_lastname_updatelocal">
<option value="0" <?php echo ($config->auth_user_lastname_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_lastname_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock","auth") ?>
<select name="auth_user_lastname_editlock">
<option value="0" <?php echo ($config->auth_user_lastname_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_lastname_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_lastname_updateremote">
<option value="0" <?php echo ($config->auth_user_lastname_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_lastname_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("email") ?>:</td>
<td>
<input name="auth_user_email" type="text" size="30" value="<?php echo $config->auth_user_email?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_email_updatelocal">
<option value="0" <?php echo ($config->auth_user_email_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_email_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_email_editlock">
<option value="0" <?php echo ($config->auth_user_email_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_email_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_email_updateremote">
<option value="0" <?php echo ($config->auth_user_email_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_email_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("phone") ?> 1:</td>
<td>
<input name="auth_user_phone1" type="text" size="30" value="<?php echo $config->auth_user_phone1?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_phone1_updatelocal">
<option value="0" <?php echo ($config->auth_user_phone1_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_phone1_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_phone1_editlock">
<option value="0" <?php echo ($config->auth_user_phone1_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_phone1_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_phone1_updateremote">
<option value="0" <?php echo ($config->auth_user_phone1_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_phone1_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("phone") ?> 2:</td>
<td>
<input name="auth_user_phone2" type="text" size="30" value="<?php echo $config->auth_user_phone2?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_phone2_updatelocal">
<option value="0" <?php echo ($config->auth_user_phone2_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_phone2_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_phone2_editlock">
<option value="0" <?php echo ($config->auth_user_phone2_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_phone2_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_phone2_updateremote">
<option value="0" <?php echo ($config->auth_user_phone2_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_phone2_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("department") ?>:</td>
<td>
<input name="auth_user_department" type="text" size="30" value="<?php echo $config->auth_user_department?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_department_updatelocal">
<option value="0" <?php echo ($config->auth_user_department_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_department_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_department_editlock">
<option value="0" <?php echo ($config->auth_user_department_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_department_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_department_updateremote">
<option value="0" <?php echo ($config->auth_user_department_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_department_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("address") ?>:</td>
<td>
<input name="auth_user_address" type="text" size="30" value="<?php echo $config->auth_user_address?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_address_updatelocal">
<option value="0" <?php echo ($config->auth_user_address_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_address_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_address_editlock">
<option value="0" <?php echo ($config->auth_user_address_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_address_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_address_updateremote">
<option value="0" <?php echo ($config->auth_user_address_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_address_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("city") ?>:</td>
<td>
<input name="auth_user_city" type="text" size="30" value="<?php echo $config->auth_user_city?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_city_updatelocal">
<option value="0" <?php echo ($config->auth_user_city_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_city_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_city_editlock">
<option value="0" <?php echo ($config->auth_user_city_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_city_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_city_updateremote">
<option value="0" <?php echo ($config->auth_user_city_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_city_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("country") ?>:</td>
<td>
<input name="auth_user_country" type="text" size="30" value="<?php echo $config->auth_user_country?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_country_updatelocal">
<option value="0" <?php echo ($config->auth_user_country_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_country_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_country_editlock">
<option value="0" <?php echo ($config->auth_user_country_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_country_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_country_updateremote">
<option value="0" <?php echo ($config->auth_user_country_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_country_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("description") ?>:</td>
<td>
<input name="auth_user_description" type="text" size="30" value="<?php echo $config->auth_user_description?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_description_updatelocal">
<option value="0" <?php echo ($config->auth_user_description_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_description_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_description_editlock">
<option value="0" <?php echo ($config->auth_user_description_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_description_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_description_updateremote">
<option value="0" <?php echo ($config->auth_user_description_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_description_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("idnumber") ?>:</td>
<td>
<input name="auth_user_idnumber" type="text" size="30" value="<?php echo $config->auth_user_idnumber?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_idnumber_updatelocal">
<option value="0" <?php echo ($config->auth_user_idnumber_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_idnumber_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_idnumber_editlock">
<option value="0" <?php echo ($config->auth_user_idnumber_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_idnumber_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_idnumber_updateremote">
<option value="0" <?php echo ($config->auth_user_idnumber_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_idnumber_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
<tr valign="top" class="required">
<td align="right"><?php print_string("language") ?>:</td>
<td>
<input name="auth_user_lang" type="text" size="30" value="<?php echo $config->auth_user_lang?>">
<div align="right">
<?php print_string("auth_updatelocal", "auth") ?>
<select name="auth_user_lang_updatelocal">
<option value="0" <?php echo ($config->auth_user_lang_updatelocal ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_lang_updatelocal ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_editlock", "auth") ?>
<select name="auth_user_lang_editlock">
<option value="0" <?php echo ($config->auth_user_lang_editlock ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_lang_editlock ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
<?php print_string("auth_updateremote", "auth") ?>
<select name="auth_user_lang_updateremote">
<option value="0" <?php echo ($config->auth_user_lang_updateremote ? '' : 'selected="yes"') ?> >
<?php print_string("no") ?></option>
<option value="1" <?php echo ($config->auth_user_lang_updateremote ? 'selected="yes"' : '') ?> >
<?php print_string("yes") ?></option>
</select><br>
</div>
</td>
</tr>
$help = get_string("auth_ldapextrafields","auth");
$help .= get_string("auth_updatelocal_expl","auth");
$help .= get_string("auth_fieldlock_expl","auth");
$help .= get_string("auth_updateremote_expl","auth");
$help .= '<hr />';
$help .= get_string("auth_updateremote_ldap","auth");
print_auth_lock_options($auth, $user_fields, $help, true, true);
?>
<tr valign="top" class="required">
<td align="right"><?php print_string("instructions", "auth") ?>:</td>
@@ -751,6 +349,7 @@ if (!function_exists('ldap_connect')){ // Is php4-ldap really there?
<textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
</td>
<td>
<?php print_string("authinstructions","auth") ?>
<?php helpbutton("text", get_string("helptext")) ?>
</td>
+14 -8
View File
@@ -372,6 +372,7 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
global $CFG ;
$pcfg = get_config('auth/ldap');
// configure a temp table
print "Configuring temp table\n";
@@ -503,11 +504,11 @@ function auth_sync_users ($bulk_insert_records = 1000, $do_updates=1) {
////
if ($do_updates) {
// narrow down what fields we need to update
$all_keys = array_keys(get_object_vars($CFG));
$all_keys = array_keys(get_object_vars($pcfg));
$updatekeys = array();
foreach ($all_keys as $key) {
if (preg_match('/^auth_user_(.+)_updatelocal$/',$key, $match)) {
if ($CFG->{$match[0]}) { // if it has a true value
if (preg_match('/^field_updatelocal_(.+)$/',$key, $match)) {
if ($pcfg->{$match[0]}) { // if it has a true value
array_push($updatekeys, $match[1]); // the actual key name
}
}
@@ -637,6 +638,8 @@ function auth_ldap_update_user_record($username, $updatekeys=false) {
global $CFG;
$pcfg = get_config('auth/ldap');
//just in case check text case
$username = trim(moodle_strtolower($username));
@@ -663,8 +666,7 @@ function auth_ldap_update_user_record($username, $updatekeys=false) {
} else {
$value = '';
}
if(isset($CFG->{'auth_user_' . $key. '_updatelocal'})
&& $CFG->{'auth_user_' . $key. '_updatelocal'}){
if (!empty($pcfg->{'field_updatelocal_' . $key})) {
if ($user->{$key} != $value) { // only update if it's changed
set_field('user', $key, $value, 'username', $username);
}
@@ -782,6 +784,8 @@ function auth_iscreator($username=0) {
function auth_user_update($olduser, $newuser) {
global $USER , $CFG;
$pcfg = get_config('auth/ldap');
$ldapconnection = auth_ldap_connect();
@@ -810,7 +814,7 @@ function auth_user_update($olduser, $newuser) {
//error_log(var_export($user_entry) . 'fpp' );
foreach ($attrmap as $key=>$ldapkeys){
if (isset($CFG->{'auth_user_'. $key.'_updateremote'}) && $CFG->{'auth_user_'. $key.'_updateremote'}){
if (!empty($pcfg->{'field_updateremote_'. $key})) {
// for ldap values that could be in more than one
// ldap key, we will do our best to match
@@ -1355,10 +1359,12 @@ function auth_ldap_attributes (){
"department", "address", "city", "country", "description",
"idnumber", "lang" );
$pcfg = get_config('auth/ldap');
$moodleattributes = array();
foreach ($fields as $field) {
if (!empty($config["auth_user_$field"])) {
$moodleattributes[$field] = $config["auth_user_$field"];
if (!empty($pcfg->{"field_map_$field"})) {
$moodleattributes[$field] = $pcfg->{"field_map_$field"};
if (preg_match('/,/',$moodleattributes[$field])) {
$moodleattributes[$field] = explode(',', $moodleattributes[$field]); // split ?
}