hosted/api hosted/index.php hosted/js hosted/skins lib/functions.php lib/hosted lib/kolab_client_api.php lib/kolab_client_task.php public_html/skins

Torsten Grote grote at kolabsys.com
Thu Jun 28 17:58:32 CEST 2012


 hosted/api                                      |    1 
 hosted/index.php                                |   42 ++++++
 hosted/js                                       |    1 
 hosted/skins                                    |    1 
 lib/functions.php                               |    1 
 lib/hosted/kolab_client_task_signup.php         |  152 ++++++++++++++++++++++++
 lib/kolab_client_api.php                        |    1 
 lib/kolab_client_task.php                       |    2 
 public_html/skins/default/templates/signup.html |   42 ++++++
 9 files changed, 242 insertions(+), 1 deletion(-)

New commits:
commit 580f3da14989d9771f792c474bd28c2681116705
Author: Torsten Grote <grote at kolabsys.com>
Date:   Thu Jun 28 15:57:32 2012 +0200

    beginning of hosted functionality

diff --git a/hosted/api b/hosted/api
new file mode 120000
index 0000000..4000823
--- /dev/null
+++ b/hosted/api
@@ -0,0 +1 @@
+../public_html/api/
\ No newline at end of file
diff --git a/hosted/index.php b/hosted/index.php
new file mode 100644
index 0000000..867a6e1
--- /dev/null
+++ b/hosted/index.php
@@ -0,0 +1,42 @@
+<?php
+/*
+ +--------------------------------------------------------------------------+
+ | This file is part of the Kolab Web Admin Panel                           |
+ |                                                                          |
+ | Copyright (C) 2011-2012, Kolab Systems AG                                |
+ |                                                                          |
+ | This program is free software: you can redistribute it and/or modify     |
+ | it under the terms of the GNU Affero General Public License as published |
+ | by the Free Software Foundation, either version 3 of the License, or     |
+ | (at your option) any later version.                                      |
+ |                                                                          |
+ | This program is distributed in the hope that it will be useful,          |
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             |
+ | GNU Affero General Public License for more details.                      |
+ |                                                                          |
+ | You should have received a copy of the GNU Affero General Public License |
+ | along with this program. If not, see <http://www.gnu.org/licenses/>      |
+ +--------------------------------------------------------------------------+
+ | Author: Aleksander Machniak <machniak at kolabsys.com>                      |
+ | Author: Jeroen van Meeuwen <vanmeeuwen at kolabsys.com>                     |
+ +--------------------------------------------------------------------------+
+*/
+
+// environment initialization
+require_once '../lib/functions.php';
+
+// starting task
+$task = kolab_utils::get_input('task', kolab_utils::REQUEST_GET);
+
+if (!$task) {
+    $task = 'signup';
+}
+
+$class = "kolab_client_task_$task";
+
+$KADM = new $class;
+
+// run actions and send output
+$KADM->run();
+$KADM->send();
diff --git a/hosted/js b/hosted/js
new file mode 120000
index 0000000..0723f3a
--- /dev/null
+++ b/hosted/js
@@ -0,0 +1 @@
+../public_html/js/
\ No newline at end of file
diff --git a/hosted/skins b/hosted/skins
new file mode 120000
index 0000000..536cdba
--- /dev/null
+++ b/hosted/skins
@@ -0,0 +1 @@
+../public_html/skins/
\ No newline at end of file
diff --git a/lib/functions.php b/lib/functions.php
index 9761358..8c74cf7 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -47,6 +47,7 @@ $include_path = INSTALL_PATH . PATH_SEPARATOR;
 $include_path .= INSTALL_PATH . '/client' . PATH_SEPARATOR;
 $include_path .= INSTALL_PATH . '/api' . PATH_SEPARATOR;
 $include_path .= INSTALL_PATH . '/ext' . PATH_SEPARATOR;
+$include_path .= INSTALL_PATH . '/hosted' . PATH_SEPARATOR;
 $include_path .= ini_get('include_path');
 
 if (set_include_path($include_path) === false) {
diff --git a/lib/hosted/kolab_client_task_signup.php b/lib/hosted/kolab_client_task_signup.php
new file mode 100644
index 0000000..91dce2f
--- /dev/null
+++ b/lib/hosted/kolab_client_task_signup.php
@@ -0,0 +1,152 @@
+<?php
+/*
+ +--------------------------------------------------------------------------+
+ | This file is part of the Kolab Web Admin Panel                           |
+ |                                                                          |
+ | Copyright (C) 2011-2012, Kolab Systems AG                                |
+ |                                                                          |
+ | This program is free software: you can redistribute it and/or modify     |
+ | it under the terms of the GNU Affero General Public License as published |
+ | by the Free Software Foundation, either version 3 of the License, or     |
+ | (at your option) any later version.                                      |
+ |                                                                          |
+ | This program is distributed in the hope that it will be useful,          |
+ | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             |
+ | GNU Affero General Public License for more details.                      |
+ |                                                                          |
+ | You should have received a copy of the GNU Affero General Public License |
+ | along with this program. If not, see <http://www.gnu.org/licenses/>      |
+ +--------------------------------------------------------------------------+
+ | Author: Aleksander Machniak <machniak at kolabsys.com>                      |
+ | Author: Torsten Grote <grote at kolabsys.com>                               |
+ +--------------------------------------------------------------------------+
+*/
+
+class kolab_client_task_signup extends kolab_client_task
+{
+    protected $ajax_only = true;
+
+    /**
+     * Overwrite Main execution.
+     */
+    public function run()
+    {
+        // Initialize locales
+        $this->locale_init();
+
+        // Assign self to template variable
+        $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');
+
+        // Set the session token we got in the API client instance, so subsequent
+        // API calls are made in the same session.
+        $token = $result->get('session_token');
+        $this->api->set_session_token($token);
+                
+        // Run security checks
+        // TODO figure out to reenable this
+//        $this->input_checks();
+
+        $action = $this->get_input('action', 'GET');
+
+        if ($action) {
+            $method = 'action_' . $action;
+            if (method_exists($this, $method)) {
+                $this->$method();
+            }
+        }
+        else if (method_exists($this, 'action_default')) {
+            $this->action_default();
+        }
+    }
+
+    public function action_default()
+    {
+        // Get a list of domains ($domains again is a kolab_client_api_result instance)
+        $domains = $this->api->get('domains.list')->get();
+
+        // The domain name attribute (the name of the LDAP attribute that holds the actual domain name space)
+        // is configurable as well. Provide a fallback.
+        $domain_name_attribute = $this->config->get('ldap','domain_name_attribute');
+        if (empty($domain_name_attribute)) {
+            $domain_name_attribute = 'associateddomain';
+        }
+
+        // Placeholder for the domain names in this deployment
+        $domain_names = array();
+
+        foreach ($domains['list'] as $domain_dn => $domain_attrs) {
+            // If $domain_attrs[$domain_name_attribute] is an array, the primary domain name space
+            // is the first value in the array.
+            if (is_array($domain_attrs[$domain_name_attribute])) {
+                $_domain_names = $domain_attrs[$domain_name_attribute];
+                $domain_name = array_shift($domain_attrs[$domain_name_attribute]);
+            } else {
+                $_domain_names = (array)($domain_attrs[$domain_name_attribute]);
+                $domain_name = $domain_attrs[$domain_name_attribute];
+            }
+
+            // TODO: Perform a check to see if this domain is available for public registration somehow.
+            // Lacking business support, everything but 'kolab.net' (the primary domain) is available.
+            if ($domain_name == $this->config->get('kolab', 'primary_domain')) {
+                continue;
+            }
+
+            $domain_names = array_merge($domain_names, $_domain_names);
+        }
+
+        // prepare array with proper key ids for form building
+        foreach ($domain_names as $domain) {
+           $domain_form_names[$domain] = $domain;
+        }
+
+        
+        // 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->add_element(array(
+            'label'   => 'Username',
+            'name'    => 'alias',
+            'type'    => kolab_form::INPUT_TEXT,
+//            'onchange'=> "kadm.command('signup.update_mail', 'test')",
+//            'onchange'=> "kadm.form_value_change(['mail'])",
+        ));
+        $form->add_element(array(
+            'label'   => 'Domain',
+            'name'    => 'domain',
+            'type'    => kolab_form::INPUT_SELECT,
+            'options' => $domain_form_names,
+//            'onchange'=> "kadm.command('signup.update_mail', 'test')",
+        ));
+        $form->add_element(array(
+            'label'   => 'Current Email Address',
+            'name'    => 'cur_mail',
+            'type'    => kolab_form::INPUT_TEXT,
+        ));
+        $form->add_element(array(
+            'label'   => 'Future Email Address',
+            'name'    => 'mail',
+            'type'    => kolab_form::INPUT_TEXT,
+            'readonly'=> true,
+        ));
+        $form->add_button(array(
+            'value'   => kolab_html::escape('Sign up'),
+//            'onclick' => "kadm.command('signup.check', 'test')",
+        ));
+
+        $this->output->assign('form', $form->output());
+    }
+    
+    public function action_update_mail() {
+        $this->output->set_object('test', 'TEST UPDATE');
+    }
+
+    public function action_check() {
+        $this->output->set_object('test', 'TEST CHECK');
+    }
+
+}
diff --git a/lib/kolab_client_api.php b/lib/kolab_client_api.php
index dd70677..cf2f946 100644
--- a/lib/kolab_client_api.php
+++ b/lib/kolab_client_api.php
@@ -225,6 +225,7 @@ class kolab_client_api
             return new kolab_client_api_result(null,
                 self::ERROR_INTERNAL, $e->getMessage());
         }
+        //console($body);
 
         $body     = @json_decode($body, true);
         $err_code = null;
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index e93aa40..3ded522 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -67,7 +67,7 @@ class kolab_client_task
     /**
      * Localization initialization.
      */
-    private function locale_init()
+    protected function locale_init()
     {
         $language = $this->get_language();
         $LANG     = array();
diff --git a/public_html/skins/default/templates/signup.html b/public_html/skins/default/templates/signup.html
new file mode 100644
index 0000000..2370577
--- /dev/null
+++ b/public_html/skins/default/templates/signup.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8" />
+    <title>Sign Up For Hosted Kolab</title>
+    <link rel="stylesheet" href="{$skin_path}style.css" />
+    <link rel="shortcut icon" type="image/png" href="{$skin_path}images/favicon.png" />
+    <script src="js/jquery.min.js"></script>
+    <script src="js/kolab_admin.js"></script>
+    <script src="{$skin_path}ui.js"></script>
+</head>
+<body>
+    <div id="logo"></div>
+    <div id="topmenu"></div>
+    <div id="navigation"></div>
+    <div id="task_navigation"></div>
+    <div id="content">
+
+
+    <div id="task_content" class="signup">
+    
+    <h1>Sign Up For Hosted Kolab</h1>
+    <p>
+        Having an account on a Kolab server is way better than just simple Email. It also provides you with full groupware functionality including shared adressbooks, calendars, tasks and journal.
+    </p>
+    <p>
+        You can sign up now for a personal account at no cost.
+    </p>
+    
+    {$form}
+
+    </div>
+    
+    <div id="test"></div>
+
+    </div>
+    <div id="footer">
+        {include file="footer.html"}
+    </div>
+</body>
+{$script}
+</html>





More information about the commits mailing list