Don't save 'internal' or empty serialized values

pull/82/head
Thomas Bruederli 12 years ago
parent a0e86dcdeb
commit 49cb6984ed

@ -38,7 +38,7 @@ class rcube_ldap extends rcube_addressbook
/** private properties */ /** private properties */
protected $ldap; protected $ldap;
protected $prop = array(); protected $prop = array();
protected $fieldmap = array('_objclass' => 'objectclass'); protected $fieldmap = array();
protected $sub_filter; protected $sub_filter;
protected $filter = ''; protected $filter = '';
protected $result = null; protected $result = null;
@ -63,6 +63,8 @@ class rcube_ldap extends rcube_addressbook
{ {
$this->prop = $p; $this->prop = $p;
$fetch_attributes = array('objectClass');
if (isset($p['searchonly'])) if (isset($p['searchonly']))
$this->searchonly = $p['searchonly']; $this->searchonly = $p['searchonly'];
@ -80,8 +82,8 @@ class rcube_ldap extends rcube_addressbook
if (empty($this->prop['groups']['scope'])) if (empty($this->prop['groups']['scope']))
$this->prop['groups']['scope'] = 'sub'; $this->prop['groups']['scope'] = 'sub';
// add group name attrib to fieldmap in order to have it fetched // add group name attrib to the list of attributes to be fetched
$this->fieldmap['_groupname'] = $this->prop['groups']['name_attr']; $fetch_attributes[] = $this->prop['groups']['name_attr'];
} }
else if (is_array($p['group_filters']) && count($p['group_filters'])) { else if (is_array($p['group_filters']) && count($p['group_filters'])) {
$this->groups = true; $this->groups = true;
@ -192,7 +194,7 @@ class rcube_ldap extends rcube_addressbook
$this->cache = $rcube->get_cache('LDAP.' . asciiwords($this->prop['name']), 'db', 600); $this->cache = $rcube->get_cache('LDAP.' . asciiwords($this->prop['name']), 'db', 600);
// initialize ldap wrapper object // initialize ldap wrapper object
$this->prop['attributes'] = array_values($this->fieldmap); $this->prop['attributes'] = array_unique(array_merge(array_values($this->fieldmap), $fetch_attributes));
$this->ldap = new rcube_ldap_generic($this->prop, true); $this->ldap = new rcube_ldap_generic($this->prop, true);
$this->ldap->set_cache($this->cache); $this->ldap->set_cache($this->cache);
@ -565,8 +567,7 @@ class rcube_ldap extends rcube_addressbook
return $group_members; return $group_members;
// read these attributes for all members // read these attributes for all members
$attrib = $count ? array('dn') : array_values($this->fieldmap); $attrib = $count ? array('dn') : $this->prop['attributes'];
$attrib[] = 'objectClass';
$attrib[] = 'member'; $attrib[] = 'member';
$attrib[] = 'uniqueMember'; $attrib[] = 'uniqueMember';
$attrib[] = 'memberURL'; $attrib[] = 'memberURL';
@ -1288,7 +1289,7 @@ class rcube_ldap extends rcube_addressbook
if (array_intersect(array('groupofuniquenames','kolabgroupofuniquenames'), array_map('strtolower', (array)$rec['objectclass']))) { if (array_intersect(array('groupofuniquenames','kolabgroupofuniquenames'), array_map('strtolower', (array)$rec['objectclass']))) {
$out['_type'] = 'group'; $out['_type'] = 'group';
$out['readonly'] = true; $out['readonly'] = true;
$fieldmap['name'] = $fieldmap['_groupname']; $fieldmap['name'] = $this->prop['groups']['name_attr'];
} }
foreach ($fieldmap as $rf => $lf) foreach ($fieldmap as $rf => $lf)
@ -1353,8 +1354,10 @@ class rcube_ldap extends rcube_addressbook
if (is_array($colprop['serialized'])) { if (is_array($colprop['serialized'])) {
foreach ($colprop['serialized'] as $subtype => $delim) { foreach ($colprop['serialized'] as $subtype => $delim) {
$key = $col.':'.$subtype; $key = $col.':'.$subtype;
foreach ((array)$save_cols[$key] as $i => $val) foreach ((array)$save_cols[$key] as $i => $val) {
$save_cols[$key][$i] = join($delim, array($val['street'], $val['locality'], $val['zipcode'], $val['country'])); $values = array($val['street'], $val['locality'], $val['zipcode'], $val['country']);
$save_cols[$key][$i] = count(array_filter($values)) ? join($delim, $values) : null;
}
} }
} }
} }

Loading…
Cancel
Save