2 commits - lib/api lib/ext lib/kolab_client_task.php
Aleksander Machniak
machniak at kolabsys.com
Thu Sep 27 14:28:14 CEST 2012
lib/api/kolab_api_service_form_value.php | 58 ++++++++++++++++---------------
lib/ext/Net/LDAP3.php | 4 +-
lib/kolab_client_task.php | 9 +---
3 files changed, 35 insertions(+), 36 deletions(-)
New commits:
commit 3acc45ed3e6e8d96371ecef38770e6521475b52a
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Sep 27 14:26:26 2012 +0200
Use service_bind_dn/service_bind_pw for LDAP connection in init_schema()
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 62eba7d..9fc7763 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -1629,8 +1629,8 @@ class Net_LDAP3
'port' => $port,
'tls' => FALSE,
'version' => 3,
- 'binddn' => $this->config_get('bind_dn'),
- 'bindpw' => $this->config_get('bind_pw')
+ 'binddn' => $this->config_get('service_bind_dn'),
+ 'bindpw' => $this->config_get('service_bind_pw')
);
$_ldap_schema_cache_cfg = array(
commit 04f79b7511090572c98cf352694aec99b23916b4
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Sep 27 14:23:08 2012 +0200
Improved response format of form_value.select_options action.
Now each attribute response contains 'list' element and other
optional elements e.g. 'default', 'required', etc.
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 4b3430f..bff2aa8 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -60,9 +60,7 @@ class kolab_api_service_form_value extends kolab_api_service
public function generate($getdata, $postdata)
{
$attribs = $this->object_type_attributes($postdata['object_type'], $postdata['type_id']);
-
$attributes = (array) $postdata['attributes'];
-
$result = array();
foreach ($attributes as $attr_name) {
@@ -164,12 +162,18 @@ class kolab_api_service_form_value extends kolab_api_service
$method_name = 'select_options_' . strtolower($attr_name);
- if (!method_exists($this, $method_name)) {
- $result[$attr_name] = array();
- continue;
+ if (method_exists($this, $method_name)) {
+ $res = $this->{$method_name}($postdata, $attribs);
+ }
+ else {
+ $res = array();
}
- $result[$attr_name] = $this->{$method_name}($postdata, $attribs);
+ if (!is_array($res['list'])) {
+ $res['list'] = array();
+ }
+
+ $result[$attr_name] = $res;
}
return $result;
@@ -782,7 +786,7 @@ class kolab_api_service_form_value extends kolab_api_service
'top',
);
- return $classes;
+ return array('list' => $classes);
}
private function select_options_attribute($postdata, $attribs = array())
@@ -790,7 +794,10 @@ class kolab_api_service_form_value extends kolab_api_service
$auth = Auth::get_instance();
$list = $auth->ldap_schema_attributes($postdata['classes']);
- return $list;
+ return array(
+ 'list' => $list['may'],
+ 'required' => $list['must']
+ );
}
private function select_options_ou($postdata, $attribs = array())
@@ -809,7 +816,7 @@ class kolab_api_service_form_value extends kolab_api_service
}
if (!empty($postdata['id'])) {
- $subjects = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')')->entries(TRUE);
+ $subjects = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')')->entries(true);
if ($subjects) {
$subject = array_shift($subjects);
@@ -828,27 +835,27 @@ class kolab_api_service_form_value extends kolab_api_service
$default = $base_dn;
}
- $ous = $auth->search($base_dn, '(objectclass=organizationalunit)');
-
+ $ous = $auth->search($base_dn, '(objectclass=organizationalunit)');
$_ous = array();
- foreach ($ous->entries(TRUE) as $ou_dn => $ou_attrs) {
+ foreach ($ous->entries(true) as $ou_dn => $ou_attrs) {
$_ous[] = strtolower($ou_dn);
}
sort($_ous);
- $_ous['default'] = strtolower($default);
-
- return $_ous;
+ return array(
+ 'list' => $_ous,
+ 'default' => strtolower($default),
+ );
}
private function select_options_preferredlanguage($postdata, $attribs = array())
{
$options = $this->_select_options_from_db('preferredlanguage');
-
- $conf = Conf::get_instance();
+ $conf = Conf::get_instance();
$default = $conf->get('default_locale');
+
if (!$default) {
$default = 'en_US';
}
@@ -857,9 +864,10 @@ class kolab_api_service_form_value extends kolab_api_service
$default = $postdata['preferredlanguage'];
}
- $options['default'] = $default;
-
- return $options;
+ return array(
+ 'list' => $options,
+ 'default' => $default,
+ );
}
private function validate_alias($value)
@@ -1069,21 +1077,15 @@ class kolab_api_service_form_value extends kolab_api_service
private function _select_options_from_db($attribute)
{
-
if (empty($attribute)) {
return false;
}
- $db = SQL::get_instance();
+ $db = SQL::get_instance();
$result = $db->fetch_assoc($db->query("SELECT option_values FROM options WHERE attribute = ?", $attribute));
-
$result = json_decode($result['option_values']);
- if (empty($result)) {
- return false;
- } else {
- return $result;
- }
+ return array('list' => $result);
}
private function _validate_email_address($mail_address) {
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 02ca4a5..4326b9a 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -828,14 +828,11 @@ class kolab_client_task
if (!isset($field['values'])) {
$data['attributes'] = array($field['name']);
$resp = $this->api->post('form_value.select_options', null, $data);
-
+ $resp = $resp->get($field['name']);
unset($data['attributes']);
- $field['values'] = $resp->get($field['name']);
- }
- if (!empty($field['values']['default'])) {
- $default = $field['values']['default'];
- unset($field['values']['default']);
+ $default = $resp['default'];
+ $field['values'] = $resp['list'];
}
if (!empty($field['values'])) {
More information about the commits
mailing list