3 commits - doc/kolab_wap-3.0.0.sql doc/sample-insert-hosted-user_types.php lib/hosted

Torsten Grote grote at kolabsys.com
Wed Jul 25 16:56:28 CEST 2012


 doc/kolab_wap-3.0.0.sql                 |    9 +++--
 doc/sample-insert-hosted-user_types.php |    8 ++--
 lib/hosted/kolab_client_task_signup.php |   53 ++++++++++++++++++++++----------
 3 files changed, 46 insertions(+), 24 deletions(-)

New commits:
commit 831f94bba8cbe92c2958d1d6750b6de5a32cab69
Merge: 9a0a48a 5552264
Author: Torsten Grote <grote at kolabsys.com>
Date:   Wed Jul 25 16:56:00 2012 +0200

    Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap



commit 9a0a48a410c9bd21b10b01e52d81db23b4358e33
Author: Torsten Grote <grote at kolabsys.com>
Date:   Wed Jul 25 16:55:16 2012 +0200

    added user_types flag for hosted kolab

diff --git a/doc/kolab_wap-3.0.0.sql b/doc/kolab_wap-3.0.0.sql
index 35a1422..bcfbddf 100644
--- a/doc/kolab_wap-3.0.0.sql
+++ b/doc/kolab_wap-3.0.0.sql
@@ -126,6 +126,7 @@ CREATE TABLE IF NOT EXISTS `user_types` (
   `name` varchar(256) NOT NULL,
   `description` text NOT NULL,
   `attributes` longtext NOT NULL,
+  `used_for` varchar(16),
   PRIMARY KEY (`id`),
   UNIQUE KEY `name` (`name`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
@@ -134,10 +135,10 @@ CREATE TABLE IF NOT EXISTS `user_types` (
 -- Dumping data for table `user_types`
 --
 
-INSERT INTO `user_types` (`id`, `key`, `name`, `description`, `attributes`) VALUES
-(1, 'kolab', 'Kolab User', 'A Kolab User', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"alias":{"data":["givenname","preferredlanguage","sn"],"optional":true},"mailhost":{"optional":true},"uid":{"data":["givenname","preferredlanguage","sn"]},"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"kolabdelegate":{"type":"list","autocomplete":true,"optional":true},"kolabinvitationpolicy":{"type":"select","values":["","ACT_MANUAL","ACT_REJECT"],"optional":true},"kolaballowsmtprecipient":{"type":"list","optional":true},"kolaballowsmtpsender":{"type":"list","optional":true},"l":{"optional":true},"alias":{"type":"list","optional":true},"mailquota":{"optional":true},"mobile":{"optional":true},"nsroledn":{"type":"list","autocomplete":true,"optional":true},"o":{"optional":true},"ou":{"type":"select"},"pager":{"optional":true},"postalcode":{
 "optional":true},"preferredlanguage":{"type":"select"},"sn":[],"street":{"optional":true},"telephonenumber":{"optional":true},"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","kolabinetorgperson","mailrecipient","organizationalperson","person"]}}'),
-(2, 'posix', 'POSIX User', 'A POSIX user (with a home directory and shell access)', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","sn"]},"uid":{"data":["givenname","sn"]},"uidnumber":[],"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"preferredlanguage":{"type":"select","values":["en_US","de_DE","de_CH","en_GB","fi_FI","fr_FR","hu_HU"]},"loginshell":{"type":"select","values":["/bin/bash","/usr/bin/git-shell","/sbin/nologin"]},"ou":{"type":"select"},"sn":[],"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","organizationalperson","person","posixaccount"]}}'),
-(3, 'kolab_posix', 'Mail-enabled POSIX User', 'A mail-enabled POSIX User', '{"auto_form_fields":{"cn":{"data":["givenname","preferredlanguage","sn"]},"displayname":{"data":["givenname","preferredlanguage","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","preferredlanguage","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"alias":{"data":["givenname","preferredlanguage","sn"],"optional":true},"mailhost":{"optional":true},"uid":{"data":["givenname","preferredlanguage","sn"]},"uidnumber":[],"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"kolabdelegate":{"type":"list","autocomplete":true,"optional":true},"kolabinvitationpolicy":{"type":"select","values":["","ACT_MANUAL","ACT_REJECT"],"optional":true},"kolaballowsmtprecipient":{"type":"list","optional":true},"kolaballowsmtpsender":{"type":"list","optional":true},"l":{"optional":true},"loginshell":{"type":"select","values":["/bin/bash","/usr/bin/git-shell","/sbin
 /nologin"]},"alias":{"type":"list","optional":true},"mailquota":{"optional":true},"mobile":{"optional":true},"nsroledn":{"type":"list","autocomplete":true,"optional":true},"o":{"optional":true},"ou":{"type":"select"},"pager":{"optional":true},"postalcode":{"optional":true},"preferredlanguage":{"type":"select"},"sn":[],"street":{"optional":true},"telephonenumber":{"optional":true},"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","kolabinetorgperson","mailrecipient","organizationalperson","person","posixaccount"]}}');
+INSERT INTO `user_types` (`id`, `key`, `name`, `description`, `attributes`, `used_for`) VALUES
+(1, 'kolab', 'Kolab User', 'A Kolab User', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"alias":{"data":["givenname","preferredlanguage","sn"],"optional":true},"mailhost":{"optional":true},"uid":{"data":["givenname","preferredlanguage","sn"]},"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"kolabdelegate":{"type":"list","autocomplete":true,"optional":true},"kolabinvitationpolicy":{"type":"select","values":["","ACT_MANUAL","ACT_REJECT"],"optional":true},"kolaballowsmtprecipient":{"type":"list","optional":true},"kolaballowsmtpsender":{"type":"list","optional":true},"l":{"optional":true},"alias":{"type":"list","optional":true},"mailquota":{"optional":true},"mobile":{"optional":true},"nsroledn":{"type":"list","autocomplete":true,"optional":true},"o":{"optional":true},"ou":{"type":"select"},"pager":{"optional":true},"postalcode":{
 "optional":true},"preferredlanguage":{"type":"select"},"sn":[],"street":{"optional":true},"telephonenumber":{"optional":true},"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","kolabinetorgperson","mailrecipient","organizationalperson","person"]}}', NULL),
+(2, 'posix', 'POSIX User', 'A POSIX user (with a home directory and shell access)', '{"auto_form_fields":{"cn":{"data":["givenname","sn"]},"displayname":{"data":["givenname","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","sn"]},"uid":{"data":["givenname","sn"]},"uidnumber":[],"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"preferredlanguage":{"type":"select","values":["en_US","de_DE","de_CH","en_GB","fi_FI","fr_FR","hu_HU"]},"loginshell":{"type":"select","values":["/bin/bash","/usr/bin/git-shell","/sbin/nologin"]},"ou":{"type":"select"},"sn":[],"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","organizationalperson","person","posixaccount"]}}', NULL),
+(3, 'kolab_posix', 'Mail-enabled POSIX User', 'A mail-enabled POSIX User', '{"auto_form_fields":{"cn":{"data":["givenname","preferredlanguage","sn"]},"displayname":{"data":["givenname","preferredlanguage","sn"]},"gidnumber":[],"homedirectory":{"data":["givenname","preferredlanguage","sn"]},"mail":{"data":["givenname","preferredlanguage","sn"]},"alias":{"data":["givenname","preferredlanguage","sn"],"optional":true},"mailhost":{"optional":true},"uid":{"data":["givenname","preferredlanguage","sn"]},"uidnumber":[],"userpassword":{"optional":true}},"form_fields":{"givenname":[],"initials":{"optional":true},"kolabdelegate":{"type":"list","autocomplete":true,"optional":true},"kolabinvitationpolicy":{"type":"select","values":["","ACT_MANUAL","ACT_REJECT"],"optional":true},"kolaballowsmtprecipient":{"type":"list","optional":true},"kolaballowsmtpsender":{"type":"list","optional":true},"l":{"optional":true},"loginshell":{"type":"select","values":["/bin/bash","/usr/bin/git-shell","/sbin
 /nologin"]},"alias":{"type":"list","optional":true},"mailquota":{"optional":true},"mobile":{"optional":true},"nsroledn":{"type":"list","autocomplete":true,"optional":true},"o":{"optional":true},"ou":{"type":"select"},"pager":{"optional":true},"postalcode":{"optional":true},"preferredlanguage":{"type":"select"},"sn":[],"street":{"optional":true},"telephonenumber":{"optional":true},"title":{"optional":true},"userpassword":{"optional":true}},"fields":{"objectclass":["top","inetorgperson","kolabinetorgperson","mailrecipient","organizationalperson","person","posixaccount"]}}', NULL);
 
 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
diff --git a/doc/sample-insert-hosted-user_types.php b/doc/sample-insert-hosted-user_types.php
index dcb0fa6..31350f2 100644
--- a/doc/sample-insert-hosted-user_types.php
+++ b/doc/sample-insert-hosted-user_types.php
@@ -88,9 +88,9 @@
                 ),
         );
 
-    $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`) " .
+    $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`, `used_for`) " .
                 "VALUES ('personal','Personal', 'A user with a personal hosted plan'," .
-                "'" . json_encode($attributes) . "')");
+                "'" . json_encode($attributes) . "', 'hosted')");
 
     $attributes = Array(
             /*
@@ -173,8 +173,8 @@
                 ),
         );
 
-    $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`) " .
+    $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`, `used_for`) " .
                 "VALUES ('professional','Professional', 'A user with a professional hosted plan'," .
-                "'" . json_encode($attributes) . "')");
+                "'" . json_encode($attributes) . "', 'hosted')");
 
 ?>
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index ed54341..984ea58 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -201,7 +201,9 @@ class kolab_client_task_signup extends kolab_client_task
         // Add user type id selector
         $accttypes = array();
         foreach ($types as $idx => $elem) {
-            $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
+            if($elem['used_for'] == 'hosted') {
+                $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
+            }
         }
 
         $fields['type_id'] = array(


commit 7128020ed784870908ee155512b552e387379a6f
Author: Torsten Grote <grote at kolabsys.com>
Date:   Wed Jul 25 16:53:54 2012 +0200

    introduce and use kolab_hosting section in kolab.conf

diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
index f55cf24..ed54341 100644
--- a/lib/hosted/kolab_client_task_signup.php
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -42,14 +42,29 @@ class kolab_client_task_signup extends kolab_client_task
         
         // Session handling
         $timeout = $this->config_get('session_timeout', 3600);
+
+        // TODO
+        // Do not use the API token for the user browser session.
+        // Use a different token for the user browser session, to verify whether subsequent interactions
+        // belong to the same user nicely progressing through the signup (and not bastardizing the process).
+        //
+        // Do not maintain the API session across hits to this interface.
+        //
+        // So...
+        //
+        // One session token for user browser <-> hosted/index.php
+        // One API session token for a single run/hit of/against hosted/index.php
         if (empty($_SESSION['user']) || empty($_SESSION['user']['token']) || ($timeout && $_SESSION['time'] && $_SESSION['time'] < time() - $timeout)) {
             // 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'), $this->config->get('kolab', 'primary_domain') );
+            // TODO log in with different primary domain
+            $result = $this->api->login($this->config_get('bind_dn'), $this->config_get('bind_pw'), $this->config->get('kolab', 'primary_domain') );
 
             // Set the session token we got in the API client instance, so subsequent
             // API calls are made in the same session.
             $this->token = $result->get('session_token');
             $this->api->set_session_token($this->token);
+
+            // TODO don't expose session to browser
             $_SESSION['user']['token'] = $this->token;
 
             // update session time
@@ -82,7 +97,7 @@ class kolab_client_task_signup extends kolab_client_task
         $form = $this->user_form($data);
 
         // add captcha
-        $publickey = $this->config->get('kolab_wap', 'recaptcha_public_key');
+        $publickey = $this->config_get('recaptcha_public_key');
         // TODO find a less dirty way to add captcha into form
         $form = preg_replace('/<div class="formbuttons">/', '<div id="recaptcha_div"></div><div class="formbuttons">', $form);
 
@@ -110,7 +125,7 @@ class kolab_client_task_signup extends kolab_client_task
 
         // Check for valid CAPTCHA
         $resp = recaptcha_check_answer(
-                    $this->config->get('kolab_wap', 'recaptcha_private_key'),
+                    $this->config_get('recaptcha_private_key'),
                     $_SERVER['REMOTE_ADDR'],
                     $data['recaptcha_challenge_field'],
                     $data['recaptcha_response_field']
@@ -175,12 +190,6 @@ class kolab_client_task_signup extends kolab_client_task
 
         // 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', (array)$data['effective_rights']['entry'])) !== false) {
-            unset($data['effective_rights']['entry'][$key]);
-        }
         
         // Show only required fields
         foreach ($fields as $field_name => $field_attrs) {
@@ -194,6 +203,7 @@ class kolab_client_task_signup extends kolab_client_task
         foreach ($types as $idx => $elem) {
             $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
         }
+
         $fields['type_id'] = array(
             'section'  => 'personal',
             'type'     => kolab_form::INPUT_SELECT,
@@ -273,12 +283,6 @@ class kolab_client_task_signup extends kolab_client_task
                 $domain_name = $domain_attrs[$domain_name_attribute];
             }
 
-            // TODO: Perform a check to see if this domain is available for public registration somehow.
-            // or provide an account that only sees available domains
-            if ($domain_name == $this->config->get('kolab', 'primary_domain')) {
-                continue;
-            }
-
             $domain_names = array_merge($domain_names, $_domain_names);
         }
 
@@ -289,4 +293,19 @@ class kolab_client_task_signup extends kolab_client_task
 
         return $domain_form_names;
     }
+
+    /**
+     * Overrides config_get() from kolab_client_task
+     * Returns configuration option value for hosting.
+     *
+     * @param string $name      Option name
+     * @param mixed  $fallback  Default value
+     *
+     * @return mixed Option value
+     */
+    public function config_get($name, $fallback = null)
+    {
+        $value = $this->config->get('kolab_hosting', $name);
+        return $value !== null ? $value : $fallback;
+    }
 }





More information about the commits mailing list