mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-09-01 18:48:17 +00:00
Rather than fixing in drivers_ldap, fix properly in Principal class.
This fixes a bug in the Principal class when updating where fields are set on the principal, but are not being updated and end up getting set to NULL as a result.
This commit is contained in:
parent
bc36ff60a3
commit
df3a901c91
@ -485,12 +485,18 @@ class Principal {
|
||||
private function Write( $field_values, $inserting=true ) {
|
||||
if ( is_array($field_values) ) $field_values = (object) $field_values;
|
||||
|
||||
if ( !isset($field_values->{'user_active'}) && isset($field_values->{'active'}) )
|
||||
$field_values->{'user_active'} = $field_values->{'active'};
|
||||
if ( !isset($field_values->{'user_active'}) ) {
|
||||
if ( isset($field_values->{'active'}) )
|
||||
$field_values->{'user_active'} = $field_values->{'active'};
|
||||
else if ( $inserting )
|
||||
$field_values->{'user_active'} = true;
|
||||
}
|
||||
if ( !isset($field_values->{'modified'}) && isset($field_values->{'updated'}) )
|
||||
$field_values->{'modified'} = $field_values->{'updated'};
|
||||
if ( !isset($field_values->{'type_id'}) )
|
||||
if ( !isset($field_values->{'type_id'}) && $inserting )
|
||||
$field_values->{'type_id'} = 1; // Default to 'person'
|
||||
if ( !isset($field_values->{'default_privileges'}) && $inserting )
|
||||
$field_values->{'default_privileges'} = decbin(privilege_to_bits($c->default_privileges));
|
||||
|
||||
|
||||
$sql = '';
|
||||
@ -511,7 +517,7 @@ class Principal {
|
||||
else {
|
||||
$update_list[] = $k.'=:'.$k;
|
||||
}
|
||||
$sql_params[':'.$k] = $field_values->{$k};
|
||||
$sql_params[':'.$k] = (isset($field_values->{$k}) ? $field_values->{$k} : $this->{$k});
|
||||
}
|
||||
|
||||
if ( $inserting && isset(self::$db_mandatory_fields) ) {
|
||||
|
||||
@ -261,11 +261,7 @@ function sync_user_from_LDAP( Principal &$principal, $mapping, $ldap_values ) {
|
||||
|
||||
dbg_error_log( "LDAP", "Going to sync the user from LDAP" );
|
||||
|
||||
$fields_to_set = array(
|
||||
'username' => $principal->username(),
|
||||
'active' => true,
|
||||
'default_privileges' => decbin(privilege_to_bits($c->default_privileges))
|
||||
);
|
||||
$fields_to_set = array();
|
||||
$updateable_fields = Principal::updateableFields();
|
||||
$updateable_fields[] = 'active'; // Backward compatibility: now 'user_exists'
|
||||
$updateable_fields[] = 'updated'; // Backward compatibility: now 'modified'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user