lib/client lib/kolab_client_task.php

Aleksander Machniak machniak at kolabsys.com
Fri Apr 6 20:48:24 CEST 2012


 lib/client/kolab_client_task_user.php |   18 ++++++++++++------
 lib/kolab_client_task.php             |    9 +++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit b2c1741863127d6a5537100335ef93fa718cdfd8
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Fri Apr 6 20:48:01 2012 +0200

    More list widget fixes (#682)

diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index fa94be7..bf92ee0 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -313,12 +313,18 @@ class kolab_client_task_user extends kolab_client_task
             );
 
             // Roles (extract role names)
-            if (!empty($fields['nsrole']) && !empty($data['nsrole'])) {
-                $data['nsrole'] = array_combine($data['nsrole'], $data['nsrole']);
-                foreach ($data['nsrole'] as $dn => $val) {
-                    // @TODO: maybe ldap_explode_dn() would be better?
-                    if (preg_match('/^cn=([^,]+)/i', $val, $m)) {
-                        $data['nsrole'][$dn] = $m[1];
+            $role_attrs = array('nsrole', 'nsroledn');
+            foreach ($role_attrs as $ra) {
+                if (!empty($fields[$ra]) && !empty($data[$ra])) {
+                    if (!is_array($data[$ra])) {
+                        $data[$ra] = (array) $data[$ra];
+                    }
+                    $data[$ra] = array_combine($data[$ra], $data[$ra]);
+                    foreach ($data[$ra] as $dn => $val) {
+                        // @TODO: maybe ldap_explode_dn() would be better?
+                        if (preg_match('/^cn=([^,]+)/i', $val, $m)) {
+                            $data[$ra][$dn] = $m[1];
+                        }
                     }
                 }
             }
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index c1ba15f..797e153 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -1015,6 +1015,15 @@ class kolab_client_task
 
                     // Convert data for the list field with autocompletion
                     if ($field['data-type'] == kolab_form::TYPE_LIST) {
+                        if (!is_array($data[$idx])) {
+                            if (!empty($field['data-autocomplete'])) {
+                                $data[$idx] = array($data[$idx] => $data[$idx]);
+                            }
+                            else {
+                                $data[$idx] = (array) $data[$idx];
+                            }
+                        }
+
                         $field['value'] = !empty($field['data-autocomplete']) ? array_keys($data[$idx]) : array_values($data[$idx]);
                     }
 





More information about the commits mailing list