2 commits - lib/api
Aleksander Machniak
machniak at kolabsys.com
Fri Mar 16 11:21:50 CET 2012
lib/api/kolab_api_service_form_value.php | 63 +++++++++++++++++++++++--------
1 file changed, 48 insertions(+), 15 deletions(-)
New commits:
commit 867572bdc6476d4fdbfcfc5eb2beddf0f71b909a
Merge: 5fcbdd3 2014254
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Fri Mar 16 11:21:05 2012 +0100
Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap
Change form_value.list_options to form_value.select_options
Conflicts:
lib/api/kolab_api_service_form_value.php
diff --cc lib/api/kolab_api_service_form_value.php
index 061d343,2b8f70d..c8bf051
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@@ -362,14 -330,11 +362,12 @@@ class kolab_api_service_form_value exte
}
}
- private function list_options_preferredlanguage()
+ private function select_options_preferredlanguage($postdata, $attribs = array())
{
- return array(
- 'en_US',
- 'de_DE',
- 'de_CH',
- 'en_GB',
- 'fr_FR',
- );
- $db = SQL::get_instance();
- $attribute = $db->fetch_assoc($db->query("SELECT option_values FROM options WHERE attribute = 'preferredlanguage'"));
++ $db = SQL::get_instance();
++ $query = $db->query("SELECT option_values FROM options WHERE attribute = 'preferredlanguage'")
++ $attribute = $db->fetch_assoc($query);
++
+ return json_decode($attribute['option_values']);
}
-
}
commit 5fcbdd3d9ab8befc8b7b9f97855b2664b6f969a3
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Thu Mar 15 14:38:03 2012 +0100
Implement form_value.select_options
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 7232768..061d343 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -122,6 +122,49 @@ class kolab_api_service_form_value extends kolab_api_service
return $result;
}
+ /**
+ * Generation of values for fields of type SELECT.
+ *
+ * @param array $getdata GET parameters
+ * @param array $postdata POST parameters. Required parameters:
+ * - attributes: list of attribute names
+ * - user_type_id or group_type_id: Type identifier
+ *
+ * @return array Response with attribute name as a key
+ */
+ public function select_options($getdata, $postdata)
+ {
+ if (isset($postdata['user_type_id'])) {
+ $attribs = $this->user_type_attributes($postdata['user_type_id']);
+ }
+ else if (isset($postdata['group_type_id'])) {
+ $attribs = $this->group_type_attributes($postdata['group_type_id']);
+ }
+ else {
+ $attribs = array();
+ }
+
+ $attributes = (array) $postdata['attributes'];
+ $result = array();
+
+ foreach ($attributes as $attr_name) {
+ if (empty($attr_name)) {
+ continue;
+ }
+
+ $method_name = 'select_options_' . strtolower($attr_name);
+
+ if (!method_exists($this, $method_name)) {
+ $result[$attr_name] = array();
+ continue;
+ }
+
+ $result[$attr_name] = $this->{$method_name}($postdata, $attribs);
+ }
+
+ return $result;
+ }
+
private function generate_alias($postdata, $attribs = array())
{
return $this->generate_secondary_mail($postdata, $attribs);
@@ -319,4 +362,14 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
+ private function select_options_preferredlanguage($postdata, $attribs = array())
+ {
+ return array(
+ 'en_US',
+ 'de_DE',
+ 'de_CH',
+ 'en_GB',
+ 'fr_FR',
+ );
+ }
}
More information about the commits
mailing list