Changeset 1803f83 in github


Ignore:
Timestamp:
Nov 28, 2011 12:48:14 PM (18 months ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
50ee4cc
Parents:
d6aafdc
Message:

Improve check of attribute changes when updating a contact

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_ldap.php

    rd6aafdc r1803f83  
    10531053 
    10541054        $ldap_data = $this->_map_data($save_cols); 
     1055        $old_data = $record['_raw_attrib']; 
     1056 
    10551057        foreach ($this->fieldmap as $col => $fld) { 
    10561058            $val = $ldap_data[$fld]; 
     
    10601062                    $val = array_filter($val); 
    10611063                // The field does exist compare it to the ldap record. 
    1062                 if ($record[$col] != $val) { 
     1064                if ($old_data[$fld] != $val) { 
    10631065                    // Changed, but find out how. 
    1064                     if (!isset($record[$col])) { 
     1066                    if (!isset($old_data[$fld])) { 
    10651067                        // Field was not set prior, need to add it. 
    10661068                        $newdata[$fld] = $val; 
    1067                     } // end if 
    1068                     elseif ($val == '') { 
     1069                    } 
     1070                    else if ($val == '') { 
    10691071                        // Field supplied is empty, verify that it is not required. 
    10701072                        if (!in_array($fld, $this->prop['required_fields'])) { 
    10711073                            // It is not, safe to clear. 
    1072                             $deletedata[$fld] = $record[$col]; 
    1073                         } // end if 
     1074                            $deletedata[$fld] = $old_data[$fld]; 
     1075                        } 
    10741076                    } // end elseif 
    10751077                    else { 
    10761078                        // The data was modified, save it out. 
    10771079                        $replacedata[$fld] = $val; 
    1078                     } // end else 
     1080                    } 
    10791081                } // end if 
    10801082            } // end if 
     
    13121314                if (!($value = $rec[$lf][$i])) 
    13131315                    continue; 
     1316 
     1317                $out['_raw_attrib'][$lf][$i] = $value; 
     1318 
    13141319                if ($rf == 'email' && $this->mail_domain && !strpos($value, '@')) 
    13151320                    $out[$rf][] = sprintf('%s@%s', $value, $this->mail_domain); 
     
    13241329            // Make sure name fields aren't arrays (#1488108) 
    13251330            if (is_array($out[$rf]) && in_array($rf, array('name', 'surname', 'firstname', 'middlename', 'nickname'))) { 
    1326                 $out[$rf] = $out[$rf][0]; 
     1331                $out[$rf] = $out['_raw_attrib'][$lf] = $out[$rf][0]; 
    13271332            } 
    13281333        } 
Note: See TracChangeset for help on using the changeset viewer.