Changeset 4357 in subversion


Ignore:
Timestamp:
Dec 22, 2010 8:29:42 AM (2 years ago)
Author:
thomasb
Message:

Extend field mapping of LDAP address books; samml bugfixes

Location:
branches/devel-addressbook
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-addressbook/config/main.inc.php.dist

    r4342 r4357  
    458458  'search_fields' => array('mail', 'cn'),  // fields to search in 
    459459  'fieldmap' => array(      // mapping of contact fields to directory attributes 
    460     // roundcube  => ldap 
     460    // Roundcube  => LDAP 
    461461    'name'        => 'cn', 
    462462    'surname'     => 'sn', 
    463463    'firstname'   => 'givenName', 
    464     'phone'       => 'telephoneNumber', 
    465464    'email'       => 'mail', 
     465    'phone:home'  => 'homePhone', 
     466    'phone:work'  => 'telephoneNumber', 
     467    'phone:mobile' => 'mobile', 
    466468    'street'      => 'street', 
    467469    'zipcode'     => 'postalCode', 
  • branches/devel-addressbook/program/include/rcube_ldap.php

    r4341 r4357  
    6161    if (is_array($p['fieldmap'])) { 
    6262      foreach ($p['fieldmap'] as $rf => $lf) 
    63           $this->fieldmap[$rf] = $this->_attr_name(strtolower($lf)); 
     63        $this->fieldmap[$rf] = $this->_attr_name(strtolower($lf)); 
    6464    } 
    6565    else { 
     
    7171     
    7272    // use fieldmap to advertise supported coltypes to the application 
    73     $this->coltypes = array_keys($this->fieldmap); 
     73    foreach ($this->fieldmap as $col => $lf) { 
     74      list($col, $type) = explode(':', $col); 
     75      if (!is_array($this->coltypes[$col])) 
     76        $this->coltypes[$col] = array('limit' => 1, 'subtypes' => array($type)); 
     77      else if ($type) { 
     78        $this->coltypes[$col]['subtypes'][] = $type; 
     79        $this->coltypes[$col]['limit']++; 
     80      } 
     81      if ($type && !$this->fieldmap[$col]) 
     82        $this->fieldmap[$col] = $lf; 
     83    } 
     84     
    7485    if ($this->fieldmap['street'] && $this->fieldmap['locality']) 
    75       $this->coltypes[] = 'address'; 
     86      $this->coltypes['address'] = array('limit' => 1); 
     87    else if ($this->coltypes['address']) 
     88      $this->coltypes['address'] = array('type' => 'textarea', 'childs' => null, 'limit' => 1); 
    7689 
    7790    // make sure 'required_fields' is an array 
     
    547560    $replacedata = array(); 
    548561    $deletedata = array(); 
    549     foreach ($save_cols as $col => $val) { 
    550       $fld = $this->_map_field($col); 
     562    foreach ($this->fieldmap as $col => $fld) { 
     563      $val = $save_cols[$col]; 
    551564      if ($fld) { 
    552565        // The field does exist compare it to the ldap record. 
     
    589602      if ($replacedata[$this->prop['LDAP_rdn']]) { 
    590603        $newdn = $this->prop['LDAP_rdn'].'=' 
    591           .rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true) 
    592           .','.$this->prop['base_dn'];  
     604          .rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true) 
     605          .','.$this->prop['base_dn']; 
    593606        if ($dn != $newdn) { 
    594607          $newrdn = $this->prop['LDAP_rdn'].'=' 
    595             .rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true); 
     608            .rcube_ldap::quote_string($replacedata[$this->prop['LDAP_rdn']], true); 
    596609          unset($replacedata[$this->prop['LDAP_rdn']]); 
    597610        } 
     
    603616          $this->_debug("S: ".ldap_error($this->conn)); 
    604617          return false; 
    605         } 
     618        } 
    606619        $this->_debug("S: OK"); 
    607620      } // end if 
  • branches/devel-addressbook/program/js/app.js

    r4342 r4357  
    40834083      else 
    40844084        option = $('<option>').attr('value', col).html(colprop.label).appendTo(addmenu); 
    4085     } 
    4086     else 
    4087       alert('addmennu not found') 
     4085      addmenu.show(); 
     4086    } 
    40884087  }; 
    40894088 
  • branches/devel-addressbook/program/steps/addressbook/func.inc

    r4356 r4357  
    126126        $id = strval($source['id'] ? $source['id'] : $j); 
    127127        $js_id = JQ($id); 
    128         $dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id); 
     128        $dom_id = preg_replace('/[^a-z0-9\-_]/i', '_', $id); 
    129129        $out .= sprintf($line_templ, $dom_id, ($current === $id ? 'selected' : ''), 
    130130            Q(rcmail_url(null, array('_source' => $id))), 
     
    500500 
    501501            // also render add-field selector 
    502             if ($edit_mode && $select_add->_count) 
    503                 $content .= html::p('addfield', $select_add->show(null)); 
     502            if ($edit_mode) 
     503                $content .= html::p('addfield', $select_add->show(null, array('style' => $select_add->_count ? null : 'display:none'))); 
    504504 
    505505            $content = html::div(array('id' => 'contactsection' . $section), $content); 
Note: See TracChangeset for help on using the changeset viewer.