summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-11-28 17:32:33 +0000
committerthomascube <thomas@roundcube.net>2011-11-28 17:32:33 +0000
commitd6aafdce3bfa8c76160e00b36db1ac63abcfab38 (patch)
tree974105104842ba17b47b650fbeafee7ab88b57e6 /program
parentb4b3777c92457cd2caf6a988e530942f70bc4f54 (diff)
Fix saving of composite fields in LDAP
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_ldap.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php
index cc122e706..6a8ddb9bb 100644
--- a/program/include/rcube_ldap.php
+++ b/program/include/rcube_ldap.php
@@ -1051,17 +1051,9 @@ class rcube_ldap extends rcube_addressbook
$replacedata = array();
$deletedata = array();
- // flatten composite fields in $record
- if (is_array($record['address'])) {
- foreach ($record['address'] as $i => $struct) {
- foreach ($struct as $col => $val) {
- $record[$col][$i] = $val;
- }
- }
- }
-
+ $ldap_data = $this->_map_data($save_cols);
foreach ($this->fieldmap as $col => $fld) {
- $val = $save_cols[$col];
+ $val = $ldap_data[$fld];
if ($fld) {
// remove empty array values
if (is_array($val))
@@ -1353,6 +1345,20 @@ class rcube_ldap extends rcube_addressbook
*/
private function _map_data($save_cols)
{
+ // flatten composite fields first
+ foreach ($this->coltypes as $col => $colprop) {
+ if (is_array($colprop['childs']) && ($values = $this->get_col_values($col, $save_cols, false))) {
+ foreach ($values as $subtype => $childs) {
+ $subtype = $subtype ? ':'.$subtype : '';
+ foreach ($childs as $i => $child_values) {
+ foreach ((array)$child_values as $childcol => $value) {
+ $save_cols[$childcol.$subtype][$i] = $value;
+ }
+ }
+ }
+ }
+ }
+
$ldap_data = array();
foreach ($this->fieldmap as $col => $fld) {
$val = $save_cols[$col];