2 commits - hosted/js lib/Auth lib/hosted

Torsten Grote grote at kolabsys.com
Tue Jul 10 11:48:01 CEST 2012


 hosted/js/kolab_hosted.js               |   24 +++++-------------------
 lib/Auth/LDAP.php                       |    3 +++
 lib/hosted/kolab_client_task_signup.php |   32 +++++++++++++++++++++-----------
 3 files changed, 29 insertions(+), 30 deletions(-)

New commits:
commit 5110eac83b18e8110f135ec1e84be7d81089e7ce
Author: Torsten Grote <grote at kolabsys.com>
Date:   Tue Jul 10 09:47:27 2012 +0200

    enable availability checking and reorder signup form fields

diff --git a/hosted/js/kolab_hosted.js b/hosted/js/kolab_hosted.js
index db5bd8e..577aa5c 100644
--- a/hosted/js/kolab_hosted.js
+++ b/hosted/js/kolab_hosted.js
@@ -24,15 +24,15 @@
 kadm.check_user_availability = function()
 {
     // get form data and build new email address
-    data = kadm.serialize_form('#signup-form');
-    uid = data['uid'] + '@' + data['domain'];
+    var data = kadm.serialize_form('#signup-form');
+    var mail = data['uid'] + '@' + data['domain'];
     
-    if(isValidEmailAddress(uid)) {
+    if(isValidEmailAddress(mail)) {
         // update future mail form field
-        $('input[name="mail"]').val(uid);
+        $('input[name="mail"]').val(mail);
         
         // check if user with that email address already exists
-        kadm.api_post('users.list', {'search': {'mail': {'value': uid} } }, 'check_user_availability_response');
+        kadm.api_post('users.list', {'search': {'mail': {'value': mail} } }, 'check_user_availability_response');
     } else {
         update_user_info('This will not produce a valid email address!');
     }
@@ -60,15 +60,6 @@ kadm.user_signup = function()
 }
 
 
-function update_ou()
-{
-    // update ou string from domain field
-    $('input[name="ou"]').val("ou=people,dc=" + $('select[name="domain"]').val().split(".").join(",dc="));
-
-    // also update user name availability
-    kadm.check_user_availability();
-}
-
 function update_user_info(msg)
 {
     // display message next to form field
@@ -87,11 +78,6 @@ function update_user_info(msg)
     } else {
         $('input[type="button"]').attr("disabled", "disabled");
     }
-
-    // update givenname and cn
-    // TODO remove when no longer needed
-    $('input[name="givenname"]').val($('input[name="uid"]').val());
-    $('input[name="cn"]').val($('input[name="uid"]').val());
 }
 
 function isValidEmailAddress(emailAddress) {
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index 36617a7..1b9d2ce 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -39,7 +39,7 @@ class kolab_client_task_signup extends kolab_client_task
         $this->output->assign('engine', $this);
         
         // Login ($result is a kolab_client_api_result instance))
-        $result = $this->api->login($this->config->get('ldap', 'bind_dn'), $this->config->get('ldap', 'bind_pw'), 'notifytest.tld');
+        $result = $this->api->login($this->config->get('ldap', 'bind_dn'), $this->config->get('ldap', 'bind_pw'), 'hostedtest.tld');
 
         // Set the session token we got in the API client instance, so subsequent
         // API calls are made in the same session.
@@ -79,19 +79,32 @@ class kolab_client_task_signup extends kolab_client_task
 
     private function user_form($data = array()) {
         $attribs['id'] = 'signup-form';
-        $show_fields = array('mailalternateaddress');
+
+        $fields_map = array(
+            'givenname'                 => 'other',
+            'sn'                        => 'other',
+            'cn'                        => 'other',
+            'mailalternateaddress'      => 'other',
+            'uid'                       => 'other',
+            'domain'                    => 'other',
+            'userpassword'              => 'other',
+            'userpassword2'             => 'other',
+            'mail'                      => 'other',
+            'alias'                     => 'other',
+        );
 
         // Prepare fields
         list($fields, $types, $type) = $this->form_prepare('user', $data, array('userpassword2')); 
 
         // Remove delete button
+        // TODO adapt effective rights and then remove
         if(($key = array_search('delete', $data['effective_rights']['entry'])) !== false) {
             unset($data['effective_rights']['entry'][$key]);
         }
         
         // Show only required fields
         foreach ($fields as $field_name => $field_attrs) {
-            if((!array_key_exists('required', $field_attrs) or $field_attrs['required'] != 'true') and !in_array($field_name, $show_fields)) {
+            if(!array_key_exists('required', $field_attrs) or $field_attrs['required'] != 'true') {
                 unset($fields[$field_name]);
             }
         }
@@ -102,7 +115,7 @@ class kolab_client_task_signup extends kolab_client_task
             'value'    => $type,
         );
         
-        // Add object type
+        // Add object type field
         $fields['object_type'] = array(
             'type'     => kolab_form::INPUT_HIDDEN,
             'value'    => 'user',
@@ -112,14 +125,12 @@ class kolab_client_task_signup extends kolab_client_task
         $fields['domain'] = array(
             'type'     => kolab_form::INPUT_SELECT,
             'options'  => $this->get_domains(),
-            'onchange' => 'kadm.form_value_change(["mail"])',
+            'onchange' => 'kadm.check_user_availability()',
         );
-        // TODO get domain into auto-fields
 
+        // Check for user availability
+        $fields['uid']['onchange'] = 'kadm.check_user_availability()';
 
-        // Require mail alternate address
-        $fields['mailalternateaddress']['required'] = 'true';
-    
         // Hide cn field
         if (isset($fields['cn'])) {
             $fields['cn']['type'] = kolab_form::INPUT_HIDDEN;
@@ -137,7 +148,6 @@ class kolab_client_task_signup extends kolab_client_task
                 ));
             }
         }
-
         
         // Change field labels for hosted case
         // TODO make translatable
@@ -147,7 +157,7 @@ class kolab_client_task_signup extends kolab_client_task
         $fields['domain']['label'] = "Domain";
 
         // Create form object and populate with fields
-        $form = $this->form_create('user', $attribs, array('other'), $fields, array(), $data, true);
+        $form = $this->form_create('user', $attribs, array('other'), $fields, $fields_map, $data, true);
 
         $form->set_title(kolab_html::escape('Sign up'));
 


commit f0baf6fb7391850ac74eda782c914b1167680a23
Author: Torsten Grote <grote at kolabsys.com>
Date:   Tue Jul 10 09:43:27 2012 +0200

    make sure base_dn is not empty when adding users

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 5574457..d701758 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -866,6 +866,9 @@ class LDAP
         if (empty($base_dn))
             $base_dn = $this->conf->get('ldap', $type_str . "_user_base_dn");
 
+        if (empty($base_dn))
+            $base_dn = $this->conf->get('ldap', "user_base_dn");
+
         // If still no base dn to add the user to... use the toplevel dn
         if (empty($base_dn))
             $base_dn = $this->conf->get($this->domain, "base_dn");





More information about the commits mailing list