Branch 'dev/edit-existing-entries' - 2 commits - lib/Auth public_html/js

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Sat Mar 31 12:48:25 CEST 2012


 lib/Auth/LDAP.php             |   31 ++++++++++++------
 public_html/js/kolab_admin.js |   70 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 88 insertions(+), 13 deletions(-)

New commits:
commit cf23f6dfe62ab042331dd754b304d1968a568e66
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat Mar 31 12:47:29 2012 +0200

    Be a little more intelligent about where to add groups of a certain type using standard configuration section/item resolving mechanisms
    Lowercase special attributes such as 'objectclass' so we get to know whether anything submitted is actually different

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index a75323d..bd5f6a2 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -522,15 +522,10 @@ class LDAP
         }
 
         // Check if the user_type has a specific base DN specified.
-        $base_dn = $this->conf->get($this->domain, $type_str . "_group_base_dn");
+        $base_dn = $this->conf->get($type_str . "_group_base_dn");
         // If not, take the regular user_base_dn
         if (!$base_dn)
-            $base_dn = $this->conf->get($this->domain, "group_base_dn");
-
-        // If no user_base_dn either, take the user type specific from the parent
-        // configuration
-        if (!$base_dn)
-            $base_dn = $this->conf->get('ldap', $type_str . "_group_base_dn");
+            $base_dn = $this->conf->get("group_base_dn");
 
         // TODO: The rdn is configurable as well.
         // Use [$type_str . "_"]user_rdn_attr
@@ -722,7 +717,14 @@ class LDAP
             for ($y = 0; $y < $__result[$x]["count"]; $y++) {
                 $attr = $__result[$x][$y];
                 if ($__result[$x][$attr]["count"] == 1) {
-                    $result[$dn][$attr] = $__result[$x][$attr][0];
+                    switch ($attr) {
+                        case "objectclass":
+                            $result[$dn][$attr] = strtolower($__result[$x][$attr][0]);
+                            break;
+                        default:
+                            $result[$dn][$attr] = $__result[$x][$attr][0];
+                            break;
+                    }
                 }
                 else {
                     $result[$dn][$attr] = array();
@@ -732,7 +734,14 @@ class LDAP
                             $result[$dn]['primary_domain'] = $__result[$x][$attr][$z];
                         }
 
-                        $result[$dn][$attr][] = $__result[$x][$attr][$z];
+                        switch ($attr) {
+                            case "objectclass":
+                                $result[$dn][$attr][] = strtolower($__result[$x][$attr][$z]);
+                                break;
+                            default:
+                                $result[$dn][$attr][] = $__result[$x][$attr][$z];
+                                break;
+                        }
                     }
                 }
             }
@@ -875,8 +884,8 @@ class LDAP
         // Always bind with the session credentials
         $this->_bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
 
-//        console("Entry DN", $entry_dn);
-//        console("Attributes", $attributes);
+        //console("Entry DN", $entry_dn);
+        //console("Attributes", $attributes);
 
         foreach ($attributes as $attr_name => $attr_value) {
             if (empty($attr_value)) {


commit a8cb5e9802720d8d1b5931154f25f3afd3b96d5d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat Mar 31 12:44:48 2012 +0200

    Update kolab_admin.js to realize the difference between selecting to add a user, and submitting a form to add a user
    Same for groups

diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 8279b0c..fe398f8 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1024,6 +1024,72 @@ function kolab_admin()
     this.command('user.list', {page: page});
   };
 
+  this.user_add = function(reload, section)
+  {
+    var data = this.serialize_form('#'+this.env.form_id);
+
+    if (reload || reload == '') {
+      // TODO: Not needed?
+      data.section = section;
+
+      this.http_post('user.add');
+      return;
+    }
+
+    this.form_error_clear();
+
+    // check password
+    if (data.userpassword != data.userpassword2) {
+      this.display_message('user.password.mismatch', 'error');
+      this.form_value_error('userpassword2');
+      return;
+    }
+
+    this.set_busy(true, 'saving');
+    this.api_post('user.add', data, 'user_add_response');
+  };
+
+  this.user_add_response = function(response)
+  {
+    if (!this.api_response(response))
+      return;
+
+    this.display_message('user.add.success');
+    this.command('user.list', {page: this.env.list_page});
+  };
+
+  this.user_edit = function(reload, section)
+  {
+    var data = this.serialize_form('#'+this.env.form_id);
+
+    if (reload) {
+      data.section = section;
+      this.http_post('user.edit', {data: data});
+      return;
+    }
+
+    this.form_error_clear();
+
+    // check password
+    if (data.userpassword != data.userpassword2) {
+      this.display_message('user.password.mismatch', 'error');
+      this.form_value_error('userpassword2');
+      return;
+    }
+
+    this.set_busy(true, 'saving');
+    this.api_post('user.edit', data, 'user_edit_response');
+  };
+
+  this.user_edit_response = function(response)
+  {
+    if (!this.api_response(response))
+      return;
+
+    this.display_message('user.edit.success');
+    this.command('user.list', {page: this.env.list_page});
+  };
+
   this.user_save = function(reload, section)
   {
     var data = this.serialize_form('#'+this.env.form_id);
@@ -1097,9 +1163,9 @@ function kolab_admin()
   {
     var data = this.serialize_form('#'+this.env.form_id);
 
-    if (reload) {
+    if (reload || reload == '') {
       data.section = section;
-      this.http_post('group.add', {data: data});
+      this.http_post('group.add');
       return;
     }
 





More information about the commits mailing list