hosted/js lib/hosted

Torsten Grote grote at kolabsys.com
Wed Jul 4 15:54:09 CEST 2012


 hosted/js/kolab_hosted.js               |    4 -
 lib/hosted/kolab_client_task_signup.php |   80 ++++++++++++++++++++++++++++++--
 2 files changed, 77 insertions(+), 7 deletions(-)

New commits:
commit 35fe6fd428cfa20b2733f216df67322eb3a1a826
Author: Torsten Grote <grote at kolabsys.com>
Date:   Wed Jul 4 13:14:20 2012 +0200

    signing up users works, still needs checks

diff --git a/hosted/js/kolab_hosted.js b/hosted/js/kolab_hosted.js
index 5d98c13..d40bb4c 100644
--- a/hosted/js/kolab_hosted.js
+++ b/hosted/js/kolab_hosted.js
@@ -25,7 +25,7 @@ kadm.check_user_availability = function(userid)
 {
     // get form data and build new email address
     data = kadm.serialize_form('#signup-form');
-    uid = data['alias'] + '@' + data['domain'];
+    uid = data['uid'] + '@' + data['domain'];
     
     if(isValidEmailAddress(uid)) {
         // update future mail form field
@@ -57,7 +57,7 @@ function update_user_info(msg) {
     }
     else {
         // add span area and inform about non-availability
-        $('input[name="alias"]').after(' <span id="availability" style="font-weight:bold;margin-left:1em;color:red;">' + msg + '</span>');
+        $('input[name="uid"]').after(' <span id="availability" style="font-weight:bold;margin-left:1em;color:red;">' + msg + '</span>');
     }
 }
 
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index 3df4795..a853179 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -45,6 +45,7 @@ class kolab_client_task_signup extends kolab_client_task
         // API calls are made in the same session.
         $this->token = $result->get('session_token');
         $this->api->set_session_token($this->token);
+        $_SESSION['user']['token'] = $this->token;
                 
         // Run security checks
         // TODO figure out to reenable this
@@ -103,14 +104,33 @@ class kolab_client_task_signup extends kolab_client_task
            $domain_form_names[$domain] = $domain;
         }
 
+
+        // retrieve user types
+        $user_types = $this->api->get('user_types.list')->get();
+
+        // We're interested in user_type 'kolab' for personal users
+        foreach ($user_types['list'] as $type_id => $type_attrs) {
+            if ($type_attrs['key'] == 'kolab') {
+                $this->type_id = $type_id;
+                
+/*                foreach ($type_attrs['attributes']['form_fields'] as $field_name => $field_attrs) {
+                    // Use the $field_attrs['type'] to see what type the field is, use lookup map in lib/kolab_form.php
+                    if($field_attrs['optional'] != 'yes') {
+                        console($field_name . " type=" . (empty($field_attrs['type']) ? "text" : $field_attrs['type']));
+                    }
+                }
+ */
+            }
+        }
+
         
         // The sign-up form is deliberately kept minimal. All further information can be entered after sign-up.
-
-        $form = new kolab_form(array('id' => 'signup-form'));
+        $form_id = 'signup-form';
+        $form = new kolab_form(array('id' => $form_id));
 
         $form->add_element(array(
             'label'   => 'Username',
-            'name'    => 'alias',
+            'name'    => 'uid',
             'type'    => kolab_form::INPUT_TEXT,
             'value'   => 'john.doe',
             'onchange'=> "kadm.check_user_availability()",
@@ -133,13 +153,62 @@ class kolab_client_task_signup extends kolab_client_task
             'type'    => kolab_form::INPUT_TEXT,
             'readonly'=> true,
         ));
+        // TODO make the following fields optional
+        $form->add_element(array(
+            'name'    => 'type_id',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => $this->type_id,
+        ));
+        $form->add_element(array(
+            'name'    => 'givenname',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'test',
+        ));
+        $form->add_element(array(
+            'name'    => 'sn',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'test',
+        ));
+        $form->add_element(array(
+            'name'    => 'cn',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'test',
+        ));
+        $form->add_element(array(
+            'name'    => 'userpassword',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'test',
+        ));
+        $form->add_element(array(
+            'name'    => 'userpassword2',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'test',
+        ));
+        $form->add_element(array(
+            'name'    => 'ou',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'ou=people,dc=notifytest,dc=tld', // TODO this would need to be updated if kept
+        ));
+        $form->add_element(array(
+            'name'    => 'preferredlanguage',
+            'type'    => kolab_form::INPUT_HIDDEN,
+            'value'   => 'en_US',
+        ));
         $form->add_button(array(
             'value'   => kolab_html::escape('Sign up'),
-            'onclick' => "alert('not working yet')",
+            'onclick' => "kadm.user_save()",
+//            'onclick' => "kadm.command('signup.add_user')",
         ));
 
         // keep session
-        $this->output->set_env('token', $this->token);
+        $this->output->set_env('token', $_SESSION['user']['token']);
+    
+        // add message translations
+        $this->output->add_translation('form.required.empty', 'user.add.success');
+
+        // define form_id and required fields
+        $this->output->set_env('form_id', $form_id);
+        $this->output->set_env('required_fields', Array('uid', 'mail', 'cur_mail', 'domain'));
 
         // assign form output to template variable
         $this->output->assign('form', $form->output());
@@ -147,6 +216,7 @@ class kolab_client_task_signup extends kolab_client_task
     
     public function action_add_user() {
         // TODO actually add user here
+        $this->output->command('display_message', 'Not adding user here, yet', 'notice');
     }
 
 }





More information about the commits mailing list