Branch 'kolab-webadmin-3.1' - 4 commits - lib/api lib/Auth lib/kolab_client_task.php
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Mon Feb 10 12:11:49 CET 2014
lib/Auth/LDAP.php | 1 +
lib/api/kolab_api_service_user.php | 26 ++++++++++++++++++++------
lib/kolab_client_task.php | 30 ++++++++++--------------------
3 files changed, 31 insertions(+), 26 deletions(-)
New commits:
commit 68e6c59f5f8af54c85953ef21fa2a53d6fc11fe9
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Feb 10 10:38:18 2014 +0100
Zero results is OK, one result is OK, multiple results is not OK
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index 1d46a75..202510d 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -209,8 +209,12 @@ class kolab_api_service_user extends kolab_api_service
// find user(s)
$users = $auth->list_users(null, $attributes, $search, $params);
- if (empty($users) || empty($users['list']) || $users['count'] > 1) {
- return false;
+ if (empty($users) || empty($users['list'])) {
+ return Array();
+ }
+
+ if ($users['count'] > 1) {
+ raise Exception, "More than a single entry found.";
}
// get user data
commit 96f40a7dc9964f635c54df6ff951e831aaf1ff73
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Feb 10 12:09:15 2014 +0100
If the options are being lower-cased, but the actual LDAP attribute value is not, make sure that the default (current) is still selected
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 20c4bc0..7e7ab58 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -926,7 +926,7 @@ class kolab_client_task
$resp = $resp->get($field['name']);
unset($data['attributes']);
- $default = $resp['default'];
+ $default = empty($data[$field['name']]) ? $resp['default'] : $data[$field['name']];
$field['values'] = $resp['list'];
}
@@ -946,6 +946,14 @@ class kolab_client_task
}
}
+ if (!empty($default)) {
+ foreach ($options as $key => $value) {
+ if (strtolower($default) == $key) {
+ $default = strtolower($default);
+ }
+ }
+ }
+
return array(
'options' => $options,
'default' => $default,
@@ -990,9 +998,7 @@ class kolab_client_task
// Mark automatically generated fields as read-only, etc.
foreach ($auto_fields as $idx => $field) {
- //console("\$field value for \$auto_fields[\$idx] (idx: $idx)", $auto_fields[$idx]);
if (!is_array($field)) {
- //console("not an array... unsetting");
unset($auto_fields[$idx]);
continue;
}
@@ -1161,7 +1167,6 @@ class kolab_client_task
$data[$fname] = (array) $data[$fname];
}
- //console("The data for field $fname at this point is", $data[$fname]);
// request parameters
$post = array(
'list' => $data[$fname],
@@ -1175,7 +1180,6 @@ class kolab_client_task
$result = $result->get('list');
$data[$fname] = $result;
- //console("Set \$data['$fname'] to", $result);
}
}
@@ -1206,19 +1210,14 @@ class kolab_client_task
*/
protected function form_create($name, $attribs, $sections, $fields, $fields_map, $data, $add_mode)
{
- //console("Creating form for $name with data", $data);
-
- //console("Assign fields to sections", $fields);
// Assign sections to fields
foreach ($fields as $idx => $field) {
if (!$field['section']) {
$fields[$idx]['section'] = isset($fields_map[$idx]) ? $fields_map[$idx] : 'other';
- //console("Assigned field $idx to section " . $fields[$idx]['section']);
+ Log::trace("Assigned field $idx to section " . $fields[$idx]['section']);
}
}
- //console("Using fields_map", $fields_map);
-
// Sort
foreach ($fields_map as $idx => $val) {
if (array_key_exists($idx, $fields)) {
@@ -1233,8 +1232,6 @@ class kolab_client_task
$fields_map = array_merge($fields_map, $fields);
}
- //console("Using attribs", $attribs);
-
$form = new kolab_form($attribs);
$assoc_fields = array();
$req_fields = array();
@@ -1242,10 +1239,6 @@ class kolab_client_task
$auto_fields = $this->output->get_env('auto_fields');
- //console("form_create() \$attribs", $attribs);
- //console("form_create() \$auto_fields", $auto_fields);
- //console("Going to walk through sections", $sections);
-
// Parse elements and add them to the form object
foreach ($sections as $section_idx => $section) {
$form->add_section($section_idx, kolab_html::escape($this->translate($section)));
@@ -1264,7 +1257,6 @@ class kolab_client_task
$field['section'] = $section_idx;
if (empty($field['value']) && !empty($data[$idx])) {
- //console("Using data value", $data[$idx], "for value of field $idx");
$value = $data[$idx];
// Convert data for the list field with autocompletion
@@ -1341,8 +1333,6 @@ class kolab_client_task
}
}
- //console("Adding field to form", $field);
-
$form->add_element($field);
}
}
commit a648e82ceea6bba8826a48e86e59525c7e6df92e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Feb 10 12:08:22 2014 +0100
Make sure the 'ou' "attribute" is set to the parent DN, not the ou attribute value, if no value is set
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index 7b6bd0e..1d46a75 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -79,11 +79,11 @@ class kolab_api_service_user extends kolab_api_service
*/
public function user_add($getdata, $postdata)
{
- //console("user_add()", $postdata);
+ Log::trace("user_add()", $postdata);
$user_attributes = $this->parse_input_attributes('user', $postdata);
- //console("user_add()", $user_attributes);
+ Log::trace("user_add()", $user_attributes);
$auth = Auth::get_instance();
$result = $auth->user_add($user_attributes, $postdata['type_id']);
@@ -123,12 +123,12 @@ class kolab_api_service_user extends kolab_api_service
public function user_edit($getdata, $postdata)
{
- //console("\$postdata to user_edit()", $postdata);
+ Log::trace("\$postdata to user_edit()", $postdata);
$user_attributes = $this->parse_input_attributes('user', $postdata);
$user = $postdata['id'];
- //console("\$user_attributes as result from parse_input_attributes", $user_attributes);
+ Log::trace("\$user_attributes as result from parse_input_attributes", $user_attributes);
$auth = Auth::get_instance();
$result = $auth->user_edit($user, $user_attributes, $postdata['type_id']);
@@ -166,10 +166,20 @@ class kolab_api_service_user extends kolab_api_service
$auth = Auth::get_instance();
$result = $auth->user_info($getdata['id']);
+ $result_dn = key($result);
+
Log::trace("user.info on " . $getdata['id'] . " result: " . var_export($result, TRUE));
// normalize result
$result = $this->parse_result_attributes('user', $result);
+ if (empty($result['ou'])) {
+ $_dn = ldap_explode_dn($result_dn, 0);
+ // pop the count and rdn
+ unset($_dn['count']);
+ unset($_dn[0]);
+ $result['ou'] = implode(',', $_dn);
+ }
+
Log::trace("user.info on " . $getdata['id'] . " parsed result: " . var_export($result, TRUE));
if ($result) {
commit 5ea191bb16e862304a255bd6d51f116b918cf4c2
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Feb 10 12:07:40 2014 +0100
Make sure the 'ou' attribute value does not make it back on to user entries
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 0075166..d4b0fd9 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -936,6 +936,7 @@ class LDAP extends Net_LDAP3 {
if (!empty($attrs['ou'])) {
$base_dn = $attrs['ou'];
+ unset($attrs['ou']);
}
// TODO: The rdn is configurable as well.
More information about the commits
mailing list