Changeset e83f035 in github


Ignore:
Timestamp:
Aug 29, 2009 2:41:17 PM (4 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
b4fa591
Parents:
0131ec9
Message:
  • Fix LDAP contact update when RDN field is changed (#1485788)
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r0131ec9 re83f035  
    22=========================== 
    33 
     4- Fix LDAP contact update when RDN field is changed (#1485788) 
    45- Fix LDAP attributes case senitivity problems (#1485830) 
    56- Fix LDAP addressbook browsing when only one directory is used (#1486022) 
  • program/include/rcube_ldap.php

    r0131ec9 re83f035  
    481481    } // end foreach 
    482482 
     483    $dn = base64_decode($id); 
     484 
    483485    // Update the entry as required. 
    484     $dn = base64_decode($id); 
    485486    if (!empty($deletedata)) { 
    486487      // Delete the fields. 
    487       $res = ldap_mod_del($this->conn, $dn, $deletedata); 
    488       if ($res === FALSE) { 
     488      if (!ldap_mod_del($this->conn, $dn, $deletedata)) 
    489489        return false; 
     490    } // end if 
     491 
     492    if (!empty($replacedata)) { 
     493      // Handle RDN change 
     494      if ($replacedata[$this->prop['LDAP_rdn']]) { 
     495        $newdn = $this->prop['LDAP_rdn'].'='.$replacedata[$this->prop['LDAP_rdn']].','.$this->prop['base_dn'];  
     496        if ($dn != $newdn) { 
     497          $newrdn = $this->prop['LDAP_rdn'].'='.$replacedata[$this->prop['LDAP_rdn']]; 
     498          unset($replacedata[$this->prop['LDAP_rdn']]); 
     499        } 
     500      } 
     501      // Replace the fields. 
     502      if (!empty($replacedata)) { 
     503        if (!ldap_mod_replace($this->conn, $dn, $replacedata)) 
     504          return false; 
    490505      } // end if 
    491506    } // end if 
    492507 
    493     if (!empty($replacedata)) { 
    494       // Replace the fields. 
    495       $res = ldap_mod_replace($this->conn, $dn, $replacedata); 
    496       if ($res === FALSE) { 
    497         return false; 
    498       } // end if 
    499     } // end if 
    500  
    501508    if (!empty($newdata)) { 
    502509      // Add the fields. 
    503       $res = ldap_mod_add($this->conn, $dn, $newdata); 
    504       if ($res === FALSE) { 
     510      if (!ldap_mod_add($this->conn, $dn, $newdata)) 
    505511        return false; 
    506       } // end if 
    507512    } // end if 
     513 
     514    // Handle RDN change 
     515    if (!empty($newrdn)) { 
     516      if (@ldap_rename($this->conn, $dn, $newrdn, NULL, TRUE)) 
     517        return base64_encode($newdn); 
     518    } 
    508519 
    509520    return true; 
  • program/js/app.js

    re0896df re83f035  
    29272927 
    29282928  // update a contact record in the list 
    2929   this.update_contact_row = function(cid, cols_arr) 
     2929  this.update_contact_row = function(cid, cols_arr, newcid) 
    29302930  { 
    29312931    var row; 
     
    29352935          $(row.cells[c]).html(cols_arr[c]); 
    29362936 
     2937      // cid change 
     2938      if (newcid) { 
     2939        row.id = 'rcmrow' + newcid; 
     2940        this.contact_list.remove_row(cid); 
     2941        this.contact_list.init_row(row); 
     2942        this.contact_list.selection[0] = newcid; 
     2943        row.style.display = ''; 
     2944      } 
     2945 
    29372946      return true; 
    29382947    } 
     
    29402949    return false; 
    29412950  }; 
     2951 
     2952  // add row to contacts list 
     2953  this.add_contact_row = function(cid, cols, select) 
     2954    { 
     2955    if (!this.gui_objects.contactslist || !this.gui_objects.contactslist.tBodies[0]) 
     2956      return false; 
     2957     
     2958    var tbody = this.gui_objects.contactslist.tBodies[0]; 
     2959    var rowcount = tbody.rows.length; 
     2960    var even = rowcount%2; 
     2961     
     2962    var row = document.createElement('tr'); 
     2963    row.id = 'rcmrow'+cid; 
     2964    row.className = 'contact '+(even ? 'even' : 'odd'); 
     2965             
     2966    if (this.contact_list.in_selection(cid)) 
     2967      row.className += ' selected'; 
     2968 
     2969    // add each submitted col 
     2970    for (var c in cols) { 
     2971      col = document.createElement('td'); 
     2972      col.className = String(c).toLowerCase(); 
     2973      col.innerHTML = cols[c]; 
     2974      row.appendChild(col); 
     2975    } 
     2976     
     2977    this.contact_list.insert_row(row); 
     2978     
     2979    this.enable_command('export', (this.contact_list.rowcount > 0)); 
     2980    }; 
    29422981 
    29432982 
     
    29943033    }; 
    29953034 
    2996   // load contact record 
     3035  // load identity record 
    29973036  this.load_identity = function(id, action) 
    29983037    { 
     
    38853924    } 
    38863925 
    3887   // add row to contacts list 
    3888   this.add_contact_row = function(cid, cols, select) 
    3889     { 
    3890     if (!this.gui_objects.contactslist || !this.gui_objects.contactslist.tBodies[0]) 
    3891       return false; 
    3892      
    3893     var tbody = this.gui_objects.contactslist.tBodies[0]; 
    3894     var rowcount = tbody.rows.length; 
    3895     var even = rowcount%2; 
    3896      
    3897     var row = document.createElement('tr'); 
    3898     row.id = 'rcmrow'+cid; 
    3899     row.className = 'contact '+(even ? 'even' : 'odd'); 
    3900              
    3901     if (this.contact_list.in_selection(cid)) 
    3902       row.className += ' selected'; 
    3903  
    3904     // add each submitted col 
    3905     for (var c in cols) { 
    3906       col = document.createElement('td'); 
    3907       col.className = String(c).toLowerCase(); 
    3908       col.innerHTML = cols[c]; 
    3909       row.appendChild(col); 
    3910     } 
    3911      
    3912     this.contact_list.insert_row(row); 
    3913      
    3914     this.enable_command('export', (this.contact_list.rowcount > 0)); 
    3915     }; 
    3916  
    39173926  this.toggle_prefer_html = function(checkbox) 
    39183927    { 
  • program/steps/addressbook/save.inc

    r5499336 re83f035  
    5858  $a_record = $plugin['record']; 
    5959   
    60   if (!$plugin['abort'] && $CONTACTS->update($cid, $a_record)) 
     60  if (!$plugin['abort'] && ($result = $CONTACTS->update($cid, $a_record))) 
    6161  { 
     62    // LDAP DN change 
     63    if (is_string($result) && strlen($result)>1) { 
     64      $newcid = $result; 
     65      // change cid in POST for 'show' action 
     66      $_POST['_cid'] = $newcid; 
     67    } 
     68     
    6269    // define list of cols to be displayed 
    6370    $a_js_cols = array(); 
    64     $record = $CONTACTS->get_record($cid, true); 
     71    $record = $CONTACTS->get_record($newcid ? $newcid : $cid, true); 
    6572 
    6673    foreach (array('name', 'email') as $col) 
     
    6875 
    6976    // update the changed col in list 
    70     $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols); 
     77    $OUTPUT->command('parent.update_contact_row', $cid, $a_js_cols, $newcid); 
    7178       
    7279    // show confirmation 
Note: See TracChangeset for help on using the changeset viewer.