2 commits - lib/api lib/client

Aleksander Machniak machniak at kolabsys.com
Thu Mar 15 10:06:10 CET 2012


 lib/api/kolab_api_service_form_value.php |   46 ++++++++++++++++++++++++++++++-
 lib/client/kolab_client_task_user.php    |    2 -
 2 files changed, 46 insertions(+), 2 deletions(-)

New commits:
commit 786081ba39c1f986606ce37da5281d40a890b5df
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Thu Mar 15 10:04:41 2012 +0100

    Add form_value.validate

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index fa7ee28..d6d67f9 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -41,7 +41,7 @@ class kolab_api_service_form_value extends kolab_api_service
      *
      * @param array $getdata   GET parameters
      * @param array $postdata  POST parameters. Required parameters:
-     *                         - attribute: attribute name
+     *                         - attributes: list of attribute names
      *                         - user_type_id or group_type_id: Type identifier
      *
      * @return array Response with attribute name as a key
@@ -78,6 +78,50 @@ class kolab_api_service_form_value extends kolab_api_service
         return $result;
     }
 
+    /**
+     * Validation of field values.
+     *
+     * @param array $getdata   GET parameters
+     * @param array $postdata  POST parameters. Required parameters:
+     *                         - user_type_id or group_type_id: Type identifier
+     *
+     * @return array Response with attribute name as a key
+     */
+    public function validate($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();
+        }
+
+        $result = array();
+
+        foreach ((array)$postdata as $attr_name => $attr_value) {
+            if (empty($attr_name)) {
+                continue;
+            }
+            if (preg_match('/^[a-z]+_type_id$/i', $attr_name)) {
+                continue;
+            }
+
+            $method_name = 'validate_' . strtolower($attr_name);
+
+            if (!method_exists($this, $method_name)) {
+                $result[$attr_name] = 'OK';
+                continue;
+            }
+
+            $result[$attr_name] = $this->{$method_name}($attr_value);
+        }
+
+        return $result;
+    }
+
 
     private function generate_cn($postdata, $attribs = array())
     {


commit 0b07708d33175270b8b64f189490e36fe94680d9
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Thu Mar 15 10:04:14 2012 +0100

    Fix fieldset selection on type change

diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 51ced0c..cf19dce 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -530,7 +530,7 @@ class kolab_client_task_user extends kolab_client_task
             'section'  => 'personal',
             'type'     => kolab_form::INPUT_SELECT,
             'options'  => $accttypes,
-            'onchange' => "kadm.user_save(true, 'system')",
+            'onchange' => "kadm.user_save(true, 'personal')",
         );
 
         // Add password confirmation





More information about the commits mailing list