2 commits - plugins/kolab_auth plugins/kolab_delegation

Aleksander Machniak machniak at kolabsys.com
Wed Dec 19 15:32:03 CET 2012


 plugins/kolab_auth/config.inc.php.dist               |    5 +
 plugins/kolab_auth/kolab_auth.php                    |   50 +++++++++++++------
 plugins/kolab_auth/package.xml                       |    4 -
 plugins/kolab_delegation/config.inc.php.dist         |   15 -----
 plugins/kolab_delegation/kolab_delegation_engine.php |   40 ++++++++++-----
 plugins/kolab_delegation/package.xml                 |    4 -
 6 files changed, 71 insertions(+), 47 deletions(-)

New commits:
commit cbd97e52cdefaa87af946c0021db106e93d85e0c
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Wed Dec 19 15:31:14 2012 +0100

    Support Organization field in identities.
    Fix purging identities - use the same email fields as in kolab_auth.

diff --git a/plugins/kolab_delegation/config.inc.php.dist b/plugins/kolab_delegation/config.inc.php.dist
index 56d7bdb..a242ef8 100644
--- a/plugins/kolab_delegation/config.inc.php.dist
+++ b/plugins/kolab_delegation/config.inc.php.dist
@@ -1,25 +1,14 @@
 <?php
 
 // This will overwrite defined LDAP filter
+// Note: LDAP addressbook defined for kolab_auth plugin is used
 $rcmail_config['kolab_delegation_filter'] = '(objectClass=kolabInetOrgPerson)';
 
 // Delegates field (from fieldmap configuration) to get delegates list
 // Note: This is a field name, not LDAP attribute name
+// Note: LDAP addressbook defined for kolab_auth plugin is used
 $rcmail_config['kolab_delegation_delegate_field'] = 'kolabDelegate';
 
-// User authentication ID field (from fieldmap configuration)
-// Note: This is a field name, not LDAP attribute name
-// See kolab_auth plugin config
-$rcmail_config['kolab_delegation_login_field'] = 'email';
-
-// Use this fields (from fieldmap configuration) for identities
-// If the value array contains more than one field, first non-empty will be used
-// Note: These aren't LDAP attributes, but field names in config
-// Note: If there's more than one email address, as many identities will be created
-// See kolab_auth plugin config
-$rcmail_config['kolab_delegation_name_field']  = array('name', 'cn');
-$rcmail_config['kolab_delegation_email_field'] = array('email');
-
 // Remove all user identities which do not match the user's primary or alias
 // addresses and delegator's addresses
 $rcmail_config['kolab_delegation_purge_identities'] = false;
diff --git a/plugins/kolab_delegation/kolab_delegation_engine.php b/plugins/kolab_delegation/kolab_delegation_engine.php
index f056fca..1d01b70 100644
--- a/plugins/kolab_delegation/kolab_delegation_engine.php
+++ b/plugins/kolab_delegation/kolab_delegation_engine.php
@@ -33,6 +33,7 @@ class kolab_delegation_engine
     private $ldap_login_field;
     private $ldap_name_field;
     private $ldap_email_field;
+    private $ldap_org_field;
     private $ldap_dn;
     private $cache = array();
     private $folder_types = array('mail', 'event', 'task');
@@ -46,19 +47,6 @@ class kolab_delegation_engine
     public function __construct()
     {
         $this->rc = rcube::get_instance();
-
-        // Default filter of LDAP queries
-        $this->ldap_filter = $this->rc->config->get('kolab_delegation_filter');
-        // Name of the LDAP field for delegates list
-        $this->ldap_delegate_field = $this->rc->config->get('kolab_delegation_delegate_field');
-        // Name of the LDAP field with authentication ID
-        $this->ldap_login_field = $this->rc->config->get('kolab_delegation_login_field');
-        // Name of the LDAP field with user name used for identities
-        $this->ldap_name_field = $this->rc->config->get('kolab_delegation_name_field');
-        // Name of the LDAP field with email addresses used for identities
-        $this->ldap_email_field = $this->rc->config->get('kolab_delegation_email_field');
-        // Encoded LDAP DN of current user, set on login by kolab_auth plugin
-        $this->ldap_dn = $_SESSION['kolab_dn'];
     }
 
     /**
@@ -234,6 +222,22 @@ class kolab_delegation_engine
             return null;
         }
 
+        // Default filter of LDAP queries
+        $this->ldap_filter = $this->rc->config->get('kolab_delegation_filter');
+        // Name of the LDAP field for delegates list
+        $this->ldap_delegate_field = $this->rc->config->get('kolab_delegation_delegate_field');
+        // Encoded LDAP DN of current user, set on login by kolab_auth plugin
+        $this->ldap_dn = $_SESSION['kolab_dn'];
+
+        // Name of the LDAP field with authentication ID
+        $this->ldap_login_field = $this->rc->config->get('kolab_auth_login');
+        // Name of the LDAP field with user name used for identities
+        $this->ldap_name_field = $this->rc->config->get('kolab_auth_name');
+        // Name of the LDAP field with email addresses used for identities
+        $this->ldap_email_field = $this->rc->config->get('kolab_auth_email');
+        // Name of the LDAP field with organization name for identities
+        $this->ldap_org_field = $this->rc->config->get('kolab_auth_organization');
+
         $ldap->set_filter($this->ldap_filter);
 
         return $ldap;
@@ -470,6 +474,14 @@ class kolab_delegation_engine
             }
         }
 
+        // Organization for identity
+        foreach ((array)$this->ldap_org_field as $field) {
+            $organization = is_array($data[$field]) ? $data[$field][0] : $data[$field];
+            if (!empty($organization)) {
+                break;
+            }
+        }
+
         $realname = $name;
         if ($uid && $name) {
             $name .= ' (' . $uid . ')';
@@ -491,6 +503,7 @@ class kolab_delegation_engine
             'imap_uid' => $imap_uid,
             'email'    => $email,
             'ID'       => $data['ID'],
+            'organization' => $organization,
         );
     }
 
@@ -610,6 +623,7 @@ class kolab_delegation_engine
                 // @TODO: "Delegatorname" or "Username on behalf of Delegatorname"?
                 $default['name']  = $delegator['realname'];
                 $default['email'] = $email;
+                $default['organization'] = $delegator['organization'];
                 $this->rc->user->insert_identity($default);
             }
 
diff --git a/plugins/kolab_delegation/package.xml b/plugins/kolab_delegation/package.xml
index 3901e47..21f3a46 100644
--- a/plugins/kolab_delegation/package.xml
+++ b/plugins/kolab_delegation/package.xml
@@ -15,9 +15,9 @@
 		<email>machniak at kolabsys.com</email>
 		<active>yes</active>
 	</lead>
-	<date>2012-12-04</date>
+	<date>2012-12-19</date>
 	<version>
-		<release>0.1</release>
+		<release>0.2</release>
 		<api>0.1</api>
 	</version>
 	<stability>


commit 035bd6fc3b00c65f2c2771819c9eed42f353745e
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Wed Dec 19 15:20:41 2012 +0100

    Support Organization field in default identity (#1189)

diff --git a/plugins/kolab_auth/config.inc.php.dist b/plugins/kolab_auth/config.inc.php.dist
index 6ddfc63..05c610b 100644
--- a/plugins/kolab_auth/config.inc.php.dist
+++ b/plugins/kolab_auth/config.inc.php.dist
@@ -14,8 +14,9 @@ $rcmail_config['kolab_auth_login'] = 'email';
 // If the value array contains more than one field, first non-empty will be used
 // Note: These aren't LDAP attributes, but field names in config
 // Note: If there's more than one email address, as many identities will be created
-$rcmail_config['kolab_auth_name']  = array('name', 'cn');
-$rcmail_config['kolab_auth_email'] = array('email');
+$rcmail_config['kolab_auth_name']         = array('name', 'cn');
+$rcmail_config['kolab_auth_email']        = array('email');
+$rcmail_config['kolab_auth_organization'] = array('organization');
 
 // Login and password of the admin user. Enables "Login As" feature.
 $rcmail_config['kolab_auth_admin_login']    = '';
diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php
index c25e694..fc0158b 100644
--- a/plugins/kolab_auth/kolab_auth.php
+++ b/plugins/kolab_auth/kolab_auth.php
@@ -208,7 +208,19 @@ class kolab_auth extends rcube_plugin
         if (!empty($this->data['user_email'])) {
             // addresses list is supported
             if (array_key_exists('email_list', $args)) {
-                $args['email_list'] = array_unique($this->data['user_email']);
+                $email_list = array_unique($this->data['user_email']);
+
+                // add organization to the list
+                if (!empty($this->data['user_organization'])) {
+                    foreach ($email_list as $idx => $email) {
+                        $email_list[$idx] = array(
+                            'organization' => $this->data['user_organization'],
+                            'email'        => $email,
+                        );
+                    }
+                }
+
+                $args['email_list'] = $email_list;
             }
             else {
                 $args['user_email'] = $this->data['user_email'][0];
@@ -256,19 +268,6 @@ class kolab_auth extends rcube_plugin
      */
     public function authenticate($args)
     {
-        $ldap = self::ldap();
-        if (!$ldap || !$ldap->ready) {
-            $args['abort'] = true;
-            return $args;
-        }
-
-        $rcmail      = rcube::get_instance();
-        $admin_login = $rcmail->config->get('kolab_auth_admin_login');
-        $admin_pass  = $rcmail->config->get('kolab_auth_admin_password');
-        $login_attr  = $rcmail->config->get('kolab_auth_login');
-        $name_attr   = $rcmail->config->get('kolab_auth_name');
-        $email_attr  = $rcmail->config->get('kolab_auth_email');
-
         // get username and host
         $host    = $args['host'];
         $user    = $args['user'];
@@ -280,6 +279,12 @@ class kolab_auth extends rcube_plugin
             return $args;
         }
 
+        $ldap = self::ldap();
+        if (!$ldap || !$ldap->ready) {
+            $args['abort'] = true;
+            return $args;
+        }
+
         // Find user record in LDAP
         $record = $this->get_user_record($user, $host);
 
@@ -288,7 +293,14 @@ class kolab_auth extends rcube_plugin
             return $args;
         }
 
-        $role_attr = $rcmail->config->get('kolab_auth_role');
+        $rcmail      = rcube::get_instance();
+        $admin_login = $rcmail->config->get('kolab_auth_admin_login');
+        $admin_pass  = $rcmail->config->get('kolab_auth_admin_password');
+        $login_attr  = $rcmail->config->get('kolab_auth_login');
+        $name_attr   = $rcmail->config->get('kolab_auth_name');
+        $email_attr  = $rcmail->config->get('kolab_auth_email');
+        $org_attr    = $rcmail->config->get('kolab_auth_organization');
+        $role_attr   = $rcmail->config->get('kolab_auth_role');
 
         if (!empty($role_attr) && !empty($record[$role_attr])) {
             $_SESSION['user_roledns'] = (array)($record[$role_attr]);
@@ -389,6 +401,14 @@ class kolab_auth extends rcube_plugin
                 $this->data['user_email'] = array_merge((array)$this->data['user_email'], (array)$email);
             }
         }
+        // Organization name for identity (first log in)
+        foreach ((array)$org_attr as $field) {
+            $organization = is_array($record[$field]) ? $record[$field][0] : $record[$field];
+            if (!empty($organization)) {
+                $this->data['user_organization'] = $organization;
+                break;
+            }
+        }
 
         // Log "Login As" usage
         if (!empty($origname)) {
diff --git a/plugins/kolab_auth/package.xml b/plugins/kolab_auth/package.xml
index b32d3cf..2d75d83 100644
--- a/plugins/kolab_auth/package.xml
+++ b/plugins/kolab_auth/package.xml
@@ -18,9 +18,9 @@
 		<email>machniak at kolabsys.com</email>
 		<active>yes</active>
 	</lead>
-	<date>2012-12-04</date>
+	<date>2012-12-19</date>
 	<version>
-		<release>0.5</release>
+		<release>0.6</release>
 		<api>0.1</api>
 	</version>
 	<stability>





More information about the commits mailing list