4 commits - lib/api lib/Auth lib/Auth.php lib/client lib/kolab_api_controller.php lib/kolab_api_service.php lib/kolab_client_api.php lib/locale public_html/js public_html/skins

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Mon May 14 13:13:34 CEST 2012


 lib/Auth.php                                    |   10 
 lib/Auth/LDAP.php                               |   72 ++++-
 lib/api/kolab_api_service_domain.php            |   66 ++++
 lib/api/kolab_api_service_domains.php           |    1 
 lib/api/kolab_api_service_user.php              |    4 
 lib/client/kolab_client_task_domain.php         |  339 ++++++++++++++++++++++++
 lib/client/kolab_client_task_group.php          |    2 
 lib/client/kolab_client_task_main.php           |    8 
 lib/client/kolab_client_task_role.php           |  339 ++++++++++++++++++++++++
 lib/kolab_api_controller.php                    |    4 
 lib/kolab_api_service.php                       |   33 ++
 lib/kolab_client_api.php                        |    4 
 lib/locale/en_US.php                            |  163 +++++------
 public_html/js/kolab_admin.js                   |    5 
 public_html/skins/default/style.css             |    3 
 public_html/skins/default/templates/domain.html |   17 +
 public_html/skins/default/templates/role.html   |   17 +
 17 files changed, 985 insertions(+), 102 deletions(-)

New commits:
commit 52407d7fe56a1c888449902339f2e8cd704f73ff
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon May 14 12:13:21 2012 +0100

    Add additional tasks and templates

diff --git a/lib/client/kolab_client_task_domain.php b/lib/client/kolab_client_task_domain.php
new file mode 100644
index 0000000..8fa605c
--- /dev/null
+++ b/lib/client/kolab_client_task_domain.php
@@ -0,0 +1,339 @@
+<?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>                      |
+ +--------------------------------------------------------------------------+
+*/
+
+class kolab_client_task_domain extends kolab_client_task
+{
+    protected $ajax_only = true;
+
+    protected $menu = array(
+        'add'  => 'domain.add',
+    );
+
+    /**
+     * Default action.
+     */
+    public function action_default()
+    {
+        $this->output->set_object('content', 'domain', true);
+        $this->output->set_object('task_navigation', $this->menu());
+
+        $this->action_list();
+    }
+
+    /**
+     * Groups list action.
+     */
+    public function action_list()
+    {
+        $page_size = 20;
+        $page      = (int) self::get_input('page', 'POST');
+        if (!$page || $page < 1) {
+            $page = 1;
+        }
+
+        // request parameters
+        $post = array(
+            'attributes' => array('associateddomain'),
+//            'sort_order' => 'ASC',
+            'sort_by'    => 'associateddomain',
+            'page_size'  => $page_size,
+            'page'       => $page,
+        );
+
+        // search parameters
+        if (!empty($_POST['search'])) {
+            $search = self::get_input('search', 'POST', true);
+            $field  = self::get_input('field',  'POST');
+            $method = self::get_input('method', 'POST');
+
+            $search_request = array(
+                $field => array(
+                    'value' => $search,
+                    'type'  => $method,
+                ),
+            );
+        }
+        else if (!empty($_POST['search_request'])) {
+            $search_request = self::get_input('search_request', 'POST');
+            $search_request = @unserialize(base64_decode($search_request));
+        }
+
+        if (!empty($search_request)) {
+            $post['search']          = $search_request;
+            $post['search_operator'] = 'OR';
+        }
+
+        // get domains list
+        $result = $this->api->post('domains.list', null, $post);
+        $count  = (int) $result->get('count');
+        $result = (array) $result->get('list');
+
+        // calculate records
+        if ($count) {
+            $start = 1 + max(0, $page - 1) * $page_size;
+            $end   = min($start + $page_size - 1, $count);
+        }
+
+        $rows = $head = $foot = array();
+        $cols = array('name');
+        $i    = 0;
+
+        // table header
+        $head[0]['cells'][] = array('class' => 'name', 'body' => $this->translate('domain.list'));
+
+        // table footer (navigation)
+        if ($count) {
+            $pages = ceil($count / $page_size);
+            $prev  = max(0, $page - 1);
+            $next  = $page < $pages ? $page + 1 : 0;
+
+            $count_str = kolab_html::span(array(
+                'content' => $this->translate('domain.list.records', $start, $end, $count)), true);
+            $prev = kolab_html::a(array(
+                'class' => 'prev' . ($prev ? '' : ' disabled'),
+                'href'  => '#',
+                'onclick' => $prev ? "kadm.command('domain.list', {page: $prev})" : "return false",
+            ));
+            $next = kolab_html::a(array(
+                'class' => 'next' . ($next ? '' : ' disabled'),
+                'href'  => '#',
+                'onclick' => $next ? "kadm.command('domain.list', {page: $next})" : "return false",
+            ));
+
+            $foot_body = kolab_html::span(array('content' => $prev . $count_str . $next));
+        }
+        $foot[0]['cells'][] = array('class' => 'listnav', 'body' => $foot_body);
+
+        // table body
+        if (!empty($result)) {
+            foreach ($result as $idx => $item) {
+                console($idx);
+                if (!is_array($item) || empty($item['associateddomain'])) {
+                    continue;
+                }
+
+                $i++;
+                $cells = array();
+                $cells[] = array('class' => 'name', 'body' => kolab_html::escape($item['associateddomain']),
+                    'onclick' => "kadm.command('domain.info', '$idx')");
+                $rows[] = array('id' => $i, 'class' => 'selectable', 'cells' => $cells);
+            }
+        }
+        else {
+            $rows[] = array('cells' => array(
+                0 => array('class' => 'empty-body', 'body' => $this->translate('domain.norecords')
+            )));
+        }
+
+        $table = kolab_html::table(array(
+            'id'    => 'domainlist',
+            'class' => 'list',
+            'head'  => $head,
+            'body'  => $rows,
+            'foot'  => $foot,
+        ));
+
+        $this->output->set_env('search_request', $search_request ? base64_encode(serialize($search_request)) : null);
+        $this->output->set_env('list_page', $page);
+        $this->output->set_env('list_count', $count);
+
+        $this->watermark('taskcontent');
+        $this->output->set_object('domainlist', $table);
+    }
+
+    /**
+     * Group information (form) action.
+     */
+    public function action_info()
+    {
+        $id     = $this->get_input('id', 'POST');
+        console("action_info() on", $id);
+        $result = $this->api->get('domain.info', array('domain' => $id));
+        $domain  = $result->get();
+        $output = $this->domain_form(null, $domain);
+
+        $this->output->set_object('taskcontent', $output);
+    }
+
+    /**
+     * Groups adding (form) action.
+     */
+    public function action_add()
+    {
+        $data   = $this->get_input('data', 'POST');
+        $output = $this->domain_form(null, $data, true);
+
+        $this->output->set_object('taskcontent', $output);
+    }
+
+    /**
+     * Group edit/add form.
+     */
+    private function domain_form($attribs, $data = array())
+    {
+        if (empty($attribs['id'])) {
+            $attribs['id'] = 'domain-form';
+        }
+
+        // Form sections
+        $sections = array(
+            'system'   => 'domain.system',
+            'other'    => 'domain.other',
+        );
+
+        // field-to-section map and fields order
+        $fields_map = array(
+            'type_id'           => 'system',
+            'type_id_name'      => 'system',
+            'associateddomain'  => 'system',
+        );
+
+        // Prepare fields
+        list($fields, $types, $type) = $this->form_prepare('domain', $data);
+
+        $add_mode  = empty($data['id']);
+        $accttypes = array();
+
+        foreach ($types as $idx => $elem) {
+            $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
+        }
+
+        // Add user type id selector
+        $fields['type_id'] = array(
+            'section'  => 'system',
+            'type'     => kolab_form::INPUT_SELECT,
+            'options'  => $accttypes,
+            'onchange' => "kadm.domain_save(true, 'system')",
+        );
+
+        // Hide account type selector if there's only one type
+        if (count($accttypes) < 2 || !$add_mode) {
+            $fields['type_id']['type'] = kolab_form::INPUT_HIDDEN;
+        }
+
+        // Create mode
+        if ($add_mode) {
+            // Page title
+            $title = $this->translate('domain.add');
+        }
+        // Edit mode
+        else {
+            $title = $data['cn'];
+
+            // Add user type name
+            $fields['type_id_name'] = array(
+                'label'    => 'domain.type_id',
+                'section'  => 'system',
+                'value'    => $accttypes[$type]['content'],
+            );
+        }
+
+        // Create form object and populate with fields
+        $form = $this->form_create('domain', $attribs, $sections, $fields, $fields_map, $data, $add_mode);
+
+        $form->set_title(kolab_html::escape($title));
+
+        $this->output->add_translation('domain.add.success', 'domain.edit.success', 'domain.delete.success');
+
+        return $form->output();
+    }
+
+    private function parse_members($list)
+    {
+        // convert to key=>value array, see kolab_api_service_form_value::list_options_uniquemember()
+        foreach ($list as $idx => $value) {
+            if (!empty($value['displayname'])) {
+                $list[$idx] = $value['displayname'];
+            } elseif (!empty($value['cn'])) {
+                $list[$idx] = $value['cn'];
+            } else {
+                console("No display name or cn for $idx");
+            }
+
+            if (!empty($value['mail'])) {
+                $list[$idx] .= ' <' . $value['mail'] . '>';
+            }
+        }
+
+        return $list;
+    }
+
+    /**
+     * Returns list of domain types.
+     *
+     * @return array List of domain types
+     */
+    public function domain_types()
+    {
+        return array(
+                array(
+                        'key' => 'standard',
+                        'name' => 'standard domain name space',
+                        'description' => 'A standard domain name space',
+                        'attributes' => array(
+                                'associateddomain' => array(),
+                                'inetdomainbasedn' => array(
+                                        'optional' => true
+                                    )
+                            )
+                    )
+            );
+    }
+
+    /**
+     * Users search form.
+     *
+     * @return string HTML output of the form
+     */
+    public function search_form()
+    {
+        $form = new kolab_form(array('id' => 'search-form'));
+
+        $form->add_section('criteria', kolab_html::escape($this->translate('search.criteria')));
+        $form->add_element(array(
+            'section' => 'criteria',
+            'label'   => $this->translate('search.field'),
+            'name'    => 'field',
+            'type'    => kolab_form::INPUT_SELECT,
+            'options' => array(
+                'cn'   => kolab_html::escape($this->translate('search.name')),
+                'mail' => kolab_html::escape($this->translate('search.email')),
+            ),
+        ));
+        $form->add_element(array(
+            'section' => 'criteria',
+            'label'   => $this->translate('search.method'),
+            'name'    => 'method',
+            'type'    => kolab_form::INPUT_SELECT,
+            'options' => array(
+                'both'   => kolab_html::escape($this->translate('search.contains')),
+                'exact'  => kolab_html::escape($this->translate('search.is')),
+                'prefix' => kolab_html::escape($this->translate('search.prefix')),
+            ),
+        ));
+
+        return $form->output();
+    }
+
+}
diff --git a/lib/client/kolab_client_task_role.php b/lib/client/kolab_client_task_role.php
new file mode 100644
index 0000000..431d9e0
--- /dev/null
+++ b/lib/client/kolab_client_task_role.php
@@ -0,0 +1,339 @@
+<?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>                      |
+ +--------------------------------------------------------------------------+
+*/
+
+class kolab_client_task_role extends kolab_client_task
+{
+    protected $ajax_only = true;
+
+    protected $menu = array(
+        'add'  => 'role.add',
+    );
+
+    /**
+     * Default action.
+     */
+    public function action_default()
+    {
+        $this->output->set_object('content', 'role', true);
+        $this->output->set_object('task_navigation', $this->menu());
+
+        $this->action_list();
+    }
+
+    /**
+     * Groups list action.
+     */
+    public function action_list()
+    {
+        $page_size = 20;
+        $page      = (int) self::get_input('page', 'POST');
+        if (!$page || $page < 1) {
+            $page = 1;
+        }
+
+        // request parameters
+        $post = array(
+            'attributes' => array('cn'),
+//            'sort_order' => 'ASC',
+            'sort_by'    => 'cn',
+            'page_size'  => $page_size,
+            'page'       => $page,
+        );
+
+        // search parameters
+        if (!empty($_POST['search'])) {
+            $search = self::get_input('search', 'POST', true);
+            $field  = self::get_input('field',  'POST');
+            $method = self::get_input('method', 'POST');
+
+            $search_request = array(
+                $field => array(
+                    'value' => $search,
+                    'type'  => $method,
+                ),
+            );
+        }
+        else if (!empty($_POST['search_request'])) {
+            $search_request = self::get_input('search_request', 'POST');
+            $search_request = @unserialize(base64_decode($search_request));
+        }
+
+        if (!empty($search_request)) {
+            $post['search']          = $search_request;
+            $post['search_operator'] = 'OR';
+        }
+
+        // get roles list
+        $result = $this->api->post('roles.list', null, $post);
+        $count  = (int) $result->get('count');
+        $result = (array) $result->get('list');
+
+        // calculate records
+        if ($count) {
+            $start = 1 + max(0, $page - 1) * $page_size;
+            $end   = min($start + $page_size - 1, $count);
+        }
+
+        $rows = $head = $foot = array();
+        $cols = array('name');
+        $i    = 0;
+
+        // table header
+        $head[0]['cells'][] = array('class' => 'name', 'body' => $this->translate('role.list'));
+
+        // table footer (navigation)
+        if ($count) {
+            $pages = ceil($count / $page_size);
+            $prev  = max(0, $page - 1);
+            $next  = $page < $pages ? $page + 1 : 0;
+
+            $count_str = kolab_html::span(array(
+                'content' => $this->translate('role.list.records', $start, $end, $count)), true);
+            $prev = kolab_html::a(array(
+                'class' => 'prev' . ($prev ? '' : ' disabled'),
+                'href'  => '#',
+                'onclick' => $prev ? "kadm.command('role.list', {page: $prev})" : "return false",
+            ));
+            $next = kolab_html::a(array(
+                'class' => 'next' . ($next ? '' : ' disabled'),
+                'href'  => '#',
+                'onclick' => $next ? "kadm.command('role.list', {page: $next})" : "return false",
+            ));
+
+            $foot_body = kolab_html::span(array('content' => $prev . $count_str . $next));
+        }
+        $foot[0]['cells'][] = array('class' => 'listnav', 'body' => $foot_body);
+
+        // table body
+        if (!empty($result)) {
+            foreach ($result as $idx => $item) {
+                if (!is_array($item) || empty($item['cn'])) {
+                    continue;
+                }
+
+                $i++;
+                $cells = array();
+                $cells[] = array('class' => 'name', 'body' => kolab_html::escape($item['cn']),
+                    'onclick' => "kadm.command('role.info', '$idx')");
+                $rows[] = array('id' => $i, 'class' => 'selectable', 'cells' => $cells);
+            }
+        }
+        else {
+            $rows[] = array('cells' => array(
+                0 => array('class' => 'empty-body', 'body' => $this->translate('role.norecords')
+            )));
+        }
+
+        $table = kolab_html::table(array(
+            'id'    => 'rolelist',
+            'class' => 'list',
+            'head'  => $head,
+            'body'  => $rows,
+            'foot'  => $foot,
+        ));
+
+        $this->output->set_env('search_request', $search_request ? base64_encode(serialize($search_request)) : null);
+        $this->output->set_env('list_page', $page);
+        $this->output->set_env('list_count', $count);
+
+        $this->watermark('taskcontent');
+        $this->output->set_object('rolelist', $table);
+    }
+
+    /**
+     * Group information (form) action.
+     */
+    public function action_info()
+    {
+        $id     = $this->get_input('id', 'POST');
+        $result = $this->api->get('role.info', array('role' => $id));
+        $role  = $result->get();
+        $output = $this->role_form(null, $role);
+
+        $this->output->set_object('taskcontent', $output);
+    }
+
+    /**
+     * Groups adding (form) action.
+     */
+    public function action_add()
+    {
+        $data   = $this->get_input('data', 'POST');
+        $output = $this->role_form(null, $data, true);
+
+        $this->output->set_object('taskcontent', $output);
+    }
+
+    /**
+     * Group edit/add form.
+     */
+    private function role_form($attribs, $data = array())
+    {
+        if (empty($attribs['id'])) {
+            $attribs['id'] = 'role-form';
+        }
+
+        // Form sections
+        $sections = array(
+            'system'   => 'role.system',
+            'other'    => 'role.other',
+        );
+
+        // field-to-section map and fields order
+        $fields_map = array(
+            'type_id'       => 'system',
+            'type_id_name'  => 'system',
+            'cn'            => 'system',
+            'gidnumber'     => 'system',
+            'mail'          => 'system',
+            'member'        => 'system',
+            'uniquemember'  => 'system',
+            'memberurl'     => 'system',
+        );
+
+        // Prepare fields
+        list($fields, $types, $type) = $this->form_prepare('role', $data);
+
+        $add_mode  = empty($data['id']);
+        $accttypes = array();
+
+        foreach ($types as $idx => $elem) {
+            $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
+        }
+
+        // Add user type id selector
+        $fields['type_id'] = array(
+            'section'  => 'system',
+            'type'     => kolab_form::INPUT_SELECT,
+            'options'  => $accttypes,
+            'onchange' => "kadm.role_save(true, 'system')",
+        );
+
+        // Hide account type selector if there's only one type
+        if (count($accttypes) < 2 || !$add_mode) {
+            $fields['type_id']['type'] = kolab_form::INPUT_HIDDEN;
+        }
+
+        // Create mode
+        if ($add_mode) {
+            // Page title
+            $title = $this->translate('role.add');
+        }
+        // Edit mode
+        else {
+            $title = $data['cn'];
+
+            // Add user type name
+            $fields['type_id_name'] = array(
+                'label'    => 'role.type_id',
+                'section'  => 'system',
+                'value'    => $accttypes[$type]['content'],
+            );
+        }
+
+        // Create form object and populate with fields
+        $form = $this->form_create('role', $attribs, $sections, $fields, $fields_map, $data, $add_mode);
+
+        $form->set_title(kolab_html::escape($title));
+
+        $this->output->add_translation('role.add.success', 'role.edit.success', 'role.delete.success');
+
+        return $form->output();
+    }
+
+    private function parse_members($list)
+    {
+        // convert to key=>value array, see kolab_api_service_form_value::list_options_uniquemember()
+        foreach ($list as $idx => $value) {
+            if (!empty($value['displayname'])) {
+                $list[$idx] = $value['displayname'];
+            } elseif (!empty($value['cn'])) {
+                $list[$idx] = $value['cn'];
+            } else {
+                console("No display name or cn for $idx");
+            }
+
+            if (!empty($value['mail'])) {
+                $list[$idx] .= ' <' . $value['mail'] . '>';
+            }
+        }
+
+        return $list;
+    }
+
+    /**
+     * Returns list of role types.
+     *
+     * @return array List of role types
+     */
+    public function role_types()
+    {
+        if (!isset($_SESSION['role_types'])) {
+            $result = $this->api->post('role_types.list');
+            $list   = $result->get('list');
+
+            if (is_array($list)) {
+                $_SESSION['role_types'] = $list;
+            }
+        }
+
+        return $_SESSION['role_types'];
+    }
+
+    /**
+     * Users search form.
+     *
+     * @return string HTML output of the form
+     */
+    public function search_form()
+    {
+        $form = new kolab_form(array('id' => 'search-form'));
+
+        $form->add_section('criteria', kolab_html::escape($this->translate('search.criteria')));
+        $form->add_element(array(
+            'section' => 'criteria',
+            'label'   => $this->translate('search.field'),
+            'name'    => 'field',
+            'type'    => kolab_form::INPUT_SELECT,
+            'options' => array(
+                'cn'   => kolab_html::escape($this->translate('search.name')),
+                'mail' => kolab_html::escape($this->translate('search.email')),
+            ),
+        ));
+        $form->add_element(array(
+            'section' => 'criteria',
+            'label'   => $this->translate('search.method'),
+            'name'    => 'method',
+            'type'    => kolab_form::INPUT_SELECT,
+            'options' => array(
+                'both'   => kolab_html::escape($this->translate('search.contains')),
+                'exact'  => kolab_html::escape($this->translate('search.is')),
+                'prefix' => kolab_html::escape($this->translate('search.prefix')),
+            ),
+        ));
+
+        return $form->output();
+    }
+
+}
diff --git a/public_html/skins/default/templates/domain.html b/public_html/skins/default/templates/domain.html
new file mode 100644
index 0000000..e658427
--- /dev/null
+++ b/public_html/skins/default/templates/domain.html
@@ -0,0 +1,17 @@
+<div id="toc" class="domain">
+    <div id="search">
+        <div class="searchinput">
+            <input type="text" id="searchinput" name="search" value="{$engine->translate('search')}" />
+            <script type="text/javascript">search_init('domain')</script>
+            <span class="searchactions">
+                <span id="search-details" title="{$engine->translate('search.criteria')}" onclick="search_details()"></span>
+                <span id="search-reset" title="{$engine->translate('search.reset')}" onclick="search_reset()"></span>
+            </span>
+        </div>
+        <div class="searchdetails">{$engine->search_form()}</div>
+    </div>
+    <div id="domainlist"></div>
+</div>
+<div class="vsplitter"> </div>
+<div id="taskcontent" class="domain"></div>
+<div class="clear"></div>
diff --git a/public_html/skins/default/templates/role.html b/public_html/skins/default/templates/role.html
new file mode 100644
index 0000000..ba8d87e
--- /dev/null
+++ b/public_html/skins/default/templates/role.html
@@ -0,0 +1,17 @@
+<div id="toc" class="role">
+    <div id="search">
+        <div class="searchinput">
+            <input type="text" id="searchinput" name="search" value="{$engine->translate('search')}" />
+            <script type="text/javascript">search_init('role')</script>
+            <span class="searchactions">
+                <span id="search-details" title="{$engine->translate('search.criteria')}" onclick="search_details()"></span>
+                <span id="search-reset" title="{$engine->translate('search.reset')}" onclick="search_reset()"></span>
+            </span>
+        </div>
+        <div class="searchdetails">{$engine->search_form()}</div>
+    </div>
+    <div id="rolelist"></div>
+</div>
+<div class="vsplitter"> </div>
+<div id="taskcontent" class="role"></div>
+<div class="clear"></div>


commit f323bc43f46c8b108121e81d5227c5c09acbead8
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon May 14 12:12:34 2012 +0100

    Merge

diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index f690b4a..aced3d5 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -56,4 +56,70 @@ class kolab_api_service_domain extends kolab_api_service
         $auth = Auth::get_instance();
         $auth->domain_add($postdata['domain'], $postdata['parent']);
     }
+
+    public function domain_effective_rights($getdata, $postdata)
+    {
+        $auth = Auth::get_instance();
+        $conf = Conf::get_instance();
+
+        console($getdata);
+
+        if (!empty($getdata['domain'])) {
+            $entry_dn = $getdata['domain'];
+
+            $unique_attr = $conf->get('ldap', 'unique_attribute');
+
+            $domain = $auth->domain_find_by_attribute(
+                    array($unique_attr => $entry_dn)
+                );
+
+            console($domain);
+
+            if (!empty($domain)) {
+                $entry_dn = key($domain);
+            }
+
+        } else {
+            $conf = Conf::get_instance();
+            $entry_dn = $conf->get('ldap', 'domain_base_dn');
+        }
+
+        console("API/domain.effective_rights(); Using entry_dn: " . $entry_dn);
+
+        // TODO: Fix searching the correct base_dn... Perhaps find the entry
+        // first.
+        $effective_rights = $auth->list_rights($entry_dn);
+
+        console($effective_rights);
+        return $effective_rights;
+    }
+
+    /**
+     * Domain information.
+     *
+     * @param array $get   GET parameters
+     * @param array $post  POST parameters
+     *
+     * @return array|bool Domain attributes, False on error
+     */
+    public function domain_info($getdata, $postdata)
+    {
+        if (!isset($getdata['domain'])) {
+            return false;
+        }
+
+        $auth   = Auth::get_instance();
+        $result = $auth->domain_info($getdata['domain']);
+
+        // normalize result
+        $result = $this->parse_result_attributes('domain', $result);
+
+        console("API/domain.info() \$result:", $result);
+
+        if ($result) {
+            return $result;
+        }
+
+        return false;
+    }
 }
diff --git a/lib/api/kolab_api_service_domains.php b/lib/api/kolab_api_service_domains.php
index e964936..479d292 100644
--- a/lib/api/kolab_api_service_domains.php
+++ b/lib/api/kolab_api_service_domains.php
@@ -56,6 +56,7 @@ class kolab_api_service_domains extends kolab_api_service
         $auth = Auth::get_instance();
 
         $domains = $auth->list_domains();
+        console($domains);
         $count   = count($domains);
 
         // pagination
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index 67e7e53..8352ae0 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -82,11 +82,11 @@ class kolab_api_service_user extends kolab_api_service
      */
     public function user_add($getdata, $postdata)
     {
-        //console("user_add()", $postdata);
+        console("user_add()", $postdata);
 
         $user_attributes = $this->parse_input_attributes('user', $postdata); 
 
-        //console("user_add()", $user_attributes);
+        console("user_add()", $user_attributes);
 
         $auth = Auth::get_instance();
         $result = $auth->user_add($user_attributes, $postdata['type_id']);
diff --git a/lib/client/kolab_client_task_group.php b/lib/client/kolab_client_task_group.php
index 402fabe..097e150 100644
--- a/lib/client/kolab_client_task_group.php
+++ b/lib/client/kolab_client_task_group.php
@@ -298,6 +298,8 @@ class kolab_client_task_group extends kolab_client_task
             }
         }
 
+        console($_SESSION['group_types']);
+
         return $_SESSION['group_types'];
     }
 
diff --git a/lib/client/kolab_client_task_main.php b/lib/client/kolab_client_task_main.php
index b7b4621..09b0991 100644
--- a/lib/client/kolab_client_task_main.php
+++ b/lib/client/kolab_client_task_main.php
@@ -25,9 +25,11 @@
 class kolab_client_task_main extends kolab_client_task
 {
     protected $menu = array(
-        'user.default'   => 'menu.users',
-        'group.default'  => 'menu.groups',
-        'about.default'  => 'menu.about',
+        'user.default'      => 'menu.users',
+        'group.default'     => 'menu.groups',
+        'domain.default'    => 'menu.domains',
+        'role.default'      => 'menu.roles',
+        'about.default'     => 'menu.about',
     );
 
 
diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index 23556c8..3530083 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -48,11 +48,11 @@ class kolab_api_controller
                 );
             }
             else {
-                throw new Exception("Unknown method", 400);
+                throw new Exception("Unknown method " . $_GET['method'], 400);
             }
         }
         else {
-            throw new Exception("Unknown service", 400);
+            throw new Exception("Unknown service " . $_GET['service'], 400);
         }
 
         // TODO: register services based on config or whatsoever
diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index d43aa67..54687a9 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -59,7 +59,7 @@ abstract class kolab_api_service
      */
     protected function object_type_attributes($object_name, $type_id, $required = true)
     {
-        $supported = array('group', 'user');
+        $supported = array('domain', 'group', 'role', 'user');
         if (!$object_name || !in_array($object_name, $supported)) {
             return array();
         }
@@ -75,7 +75,28 @@ abstract class kolab_api_service
         $object_types = $this->object_types($object_name);
 
         if (empty($object_types[$type_id])) {
-            throw new Exception($this->controller->translate($object_name . '.invalidtypeid'), 35);
+            if ($object_name == 'domain') {
+                return array(
+                        'auto_form_fields' => array(),
+                        'form_fields' => array(
+                                'associateddomain' => array(
+                                        'type' => 'list'
+                                    ),
+                                'o' => array(
+                                        'optional' => 'true',
+                                    ),
+                            ),
+                        'fields' => array(
+                                'objectclass' => array(
+                                        'top',
+                                        'domainrelatedobject',
+                                    ),
+                            ),
+                    );
+
+            } else {
+                throw new Exception($this->controller->translate($object_name . '.invalidtypeid'), 35);
+            }
         }
 
         return $object_types[$type_id]['attributes'];
@@ -91,6 +112,8 @@ abstract class kolab_api_service
      */
     protected function object_type_id($object_name, $object_class)
     {
+        if ($object_name == 'domain') return 1;
+
         if (empty($object_class)) {
             return null;
         }
@@ -200,6 +223,12 @@ abstract class kolab_api_service
         // add group type id to the result
         $attrs['type_id'] = $this->object_type_id($object_name, $attrs['objectclass']);
 
+        if (empty($attrs['type_id'])) {
+            if ($object_name == 'domain') {
+                $attrs['type_id'] = 1;
+            }
+        }
+
         // Search for attributes associated with the type_id that are not part
         // of the results returned earlier. Example: nsrole / nsroledn / aci, etc.
         // @TODO: this should go to LDAP class
diff --git a/lib/kolab_client_api.php b/lib/kolab_client_api.php
index 622842a..96188a2 100644
--- a/lib/kolab_client_api.php
+++ b/lib/kolab_client_api.php
@@ -150,6 +150,8 @@ class kolab_client_api
 
         $this->request->setMethod(HTTP_Request2::METHOD_GET);
 
+        console("GET", $url);
+
         return $this->get_response($url);
     }
 
@@ -169,6 +171,8 @@ class kolab_client_api
         $this->request->setMethod(HTTP_Request2::METHOD_POST);
         $this->request->setBody(@json_encode($post));
 
+        console("POST", $url, $post);
+
         return $this->get_response($url);
     }
 
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index 2e01478..3721ad1 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -1,24 +1,61 @@
 <?php
 
-$LANG['loading'] = 'Loading...';
-$LANG['saving'] = 'Saving data...';
+$LANG['about.community'] = 'This is the Community Edition of the <b>Kolab Server</b>.';
+$LANG['about.warranty'] = 'It comes with absolutely <b>no warranties</b> and is typically run entirely self supported. You can find help & information on the community <a href="http://kolab.org">web site</a> & <a href="http://wiki.kolab.org">wiki</a>.';
+$LANG['about.support'] = 'Professional support is available from <a href="http://kolabsys.com">Kolab Systems</a>.';
+$LANG['creatorsname'] = 'Created by';
+$LANG['days'] = 'days';
+$LANG['debug'] = 'Debug info';
+$LANG['delete.button'] = 'Delete';
 $LANG['deleting'] = 'Deleting data...';
+
+$LANG['domain.add'] = 'Add Domain';
+$LANG['domain.list'] = 'Domains List';
+$LANG['domain.list.records'] = '$1 to $2 of $3';
+$LANG['domain.system'] = 'System';
+$LANG['domain.type_id'] = 'Standard Domain';
+
 $LANG['error'] = 'Error';
-$LANG['servererror'] = 'Server Error!';
-$LANG['loginerror'] = 'Incorrect username or password!';
-$LANG['internalerror'] = 'Internal system error!';
-$LANG['welcome'] = 'Welcome to the Kolab Groupware Server Maintenance';
-$LANG['reqtime'] = 'Request time: $1 sec.';
-$LANG['debug'] = 'Debug info';
-$LANG['info'] = 'Information';
-$LANG['creatorsname'] = 'Created by';
-$LANG['modifiersname'] = 'Modified by';
 
+$LANG['form.required.empty'] = 'Some of the required fields are empty!';
+
+$LANG['group.add'] = 'Add Group';
+$LANG['group.add.success'] = 'Group created successfully.';
+$LANG['group.cn'] = 'Common name';
+$LANG['group.delete.success'] = 'Group deleted successfully.';
+$LANG['group.edit.success'] = 'Group edited successfully.';
+$LANG['group.gidnumber'] = 'Primary group number';
+$LANG['group.list'] = 'Groups List';
+$LANG['group.list.records'] = '$1 to $2 of $3';
+$LANG['group.mail'] = 'Primary Email Address';
+$LANG['group.member'] = 'Member(s)';
+$LANG['group.norecords'] = 'No group records found!';
+$LANG['group.other'] = 'Other';
+$LANG['group.system'] = 'System';
+$LANG['group.type_id'] = 'Group type';
+$LANG['group.uniquemember'] = 'Members';
+
+$LANG['info'] = 'Information';
+$LANG['internalerror'] = 'Internal system error!';
+$LANG['loading'] = 'Loading...';
 $LANG['login.username'] = 'Username:';
 $LANG['login.password'] = 'Password:';
 $LANG['login.login'] = 'Login';
+$LANG['loginerror'] = 'Incorrect username or password!';
+$LANG['MB'] = 'MB';
 
-$LANG['form.required.empty'] = 'Some of the required fields are empty!';
+$LANG['menu.about'] = 'About';
+$LANG['menu.domains'] = 'Domains';
+$LANG['menu.groups'] = 'Groups';
+$LANG['menu.kolab'] = 'Kolab';
+$LANG['menu.kolabsys'] = 'Kolab Systems';
+$LANG['menu.technology'] = 'Technology';
+$LANG['menu.users'] = 'Users';
+
+$LANG['modifiersname'] = 'Modified by';
+$LANG['password.generate'] = 'Generate password';
+$LANG['reqtime'] = 'Request time: $1 sec.';
+$LANG['saving'] = 'Saving data...';
 
 $LANG['search'] = 'Search';
 $LANG['search.criteria'] = 'Search criteria';
@@ -34,106 +71,74 @@ $LANG['search.uid'] = 'UID';
 $LANG['search.loading'] = 'Searching...';
 $LANG['search.acchars'] = 'At least $min characters required for autocompletion';
 
-$LANG['menu.users'] = 'Users';
-$LANG['menu.groups'] = 'Groups';
-$LANG['menu.about'] = 'About';
-$LANG['menu.kolab'] = 'Kolab';
-$LANG['menu.kolabsys'] = 'Kolab Systems';
-$LANG['menu.technology'] = 'Technology';
+$LANG['servererror'] = 'Server Error!';
+$LANG['submit.button'] = 'Submit';
 
 $LANG['user.add'] = 'Add User';
+$LANG['user.add.success'] = 'User created successfully.';
+$LANG['user.alias'] = 'Secondary Email Address(es)';
 $LANG['user.c'] = 'Country';
+$LANG['user.city'] = 'City';
 $LANG['user.cn'] = 'Common name';
 $LANG['user.config'] = 'Configuration';
 $LANG['user.contact'] = 'Contact';
 $LANG['user.contact_info'] = 'Contact Information';
+$LANG['user.country'] = 'Country';
+$LANG['user.country.desc'] = '2 letter code from ISO 3166-1';
+$LANG['user.delete.success'] = 'User deleted successfully.';
+$LANG['user.displayname'] = 'Display name';
+$LANG['user.edit.success'] = 'User edited successfully.';
+$LANG['user.fax'] = 'Fax number';
+$LANG['user.fbinterval'] = 'Free-Busy interval';
+$LANG['user.fbinterval.desc'] = 'Leave blank for default (60 days)';
+$LANG['user.gidnumber'] = 'Primary group number';
+$LANG['user.givenname'] = 'Given name';
+$LANG['user.homedirectory'] = 'Home directory';
 $LANG['user.homephone'] = 'Home Phone Number';
+$LANG['user.initials'] = 'Initials';
+$LANG['user.invitation-policy'] = 'Invitation policy';
 $LANG['user.kolaballowsmtprecipient'] = 'Recipient(s) Access List';
 $LANG['user.kolaballowsmtpsender'] = 'Sender Access List';
 $LANG['user.kolabdelegate'] = 'Delegates';
+$LANG['user.kolabhomeserver'] = 'Email Server';
 $LANG['user.kolabinvitationpolicy'] = 'Invitation Handling Policy';
 $LANG['user.l'] = 'City, Region';
 $LANG['user.list'] = 'Users List';
 $LANG['user.list.records'] = '$1 to $2 of $3';
+$LANG['user.loginshell'] = 'Shell';
+$LANG['user.mail'] = 'Primary Email Address';
+$LANG['user.mailalternateaddress'] = 'Secondary Email Address(es)';
+$LANG['user.mailhost'] = 'Email Server';
 $LANG['user.mailquota'] = 'Quota';
 $LANG['user.mailquota.desc'] = 'Leave blank for unlimited';
 $LANG['user.mobile'] = 'Mobile Phone Number';
 $LANG['user.name'] = 'Name';
 $LANG['user.norecords'] = 'No user records found!';
+$LANG['user.nsrole'] = 'Role(s)';
+$LANG['user.nsroledn'] = $LANG['user.nsrole'];
 $LANG['user.other'] = 'Other';
 $LANG['user.o'] = 'Organization';
+$LANG['user.org'] = 'Organization';
+$LANG['user.orgunit'] = 'Organizational Unit';
 $LANG['user.ou'] = 'Organizational Unit';
 $LANG['user.pager'] = 'Pager Number';
+$LANG['user.password.mismatch'] = 'Passwords do not match!';
 $LANG['user.personal'] = 'Personal';
+$LANG['user.phone'] = 'Phone number';
 $LANG['user.postalcode'] = 'Postal Code';
+$LANG['user.postbox'] = 'Postal box';
+$LANG['user.postcode'] = 'Postal code';
+$LANG['user.preferredlanguage'] = 'Native tongue';
+$LANG['user.room'] = 'Room number';
 $LANG['user.sn'] = 'Surname';
+$LANG['user.street'] = 'Street';
 $LANG['user.system'] = 'System';
 $LANG['user.telephonenumber'] = 'Phone Number';
 $LANG['user.title'] = 'Job Title';
-$LANG['user.givenname'] = 'Given name';
-$LANG['user.displayname'] = 'Display name';
-$LANG['user.mail'] = 'Primary Email Address';
-$LANG['user.mailhost'] = 'Email Server';
-$LANG['user.kolabhomeserver'] = 'Email Server';
-$LANG['user.initials'] = 'Initials';
-$LANG['user.country'] = 'Country';
-$LANG['user.country.desc'] = '2 letter code from ISO 3166-1';
-$LANG['user.phone'] = 'Phone number';
-$LANG['user.fax'] = 'Fax number';
-$LANG['user.room'] = 'Room number';
-$LANG['user.street'] = 'Street';
-$LANG['user.city'] = 'City';
-$LANG['user.postbox'] = 'Postal box';
-$LANG['user.postcode'] = 'Postal code';
-$LANG['user.org'] = 'Organization';
-$LANG['user.orgunit'] = 'Organizational Unit';
-$LANG['user.fbinterval'] = 'Free-Busy interval';
-$LANG['user.fbinterval.desc'] = 'Leave blank for default (60 days)';
 $LANG['user.type_id'] = 'Account type';
-$LANG['user.alias'] = 'Secondary Email Address(es)';
-$LANG['user.mailalternateaddress'] = 'Secondary Email Address(es)';
-$LANG['user.invitation-policy'] = 'Invitation policy';
-$LANG['user.delegate'] = 'Email delegates';
-$LANG['user.delegate.desc'] = 'Others allowed to send emails with a "From" address of this account';
-$LANG['user.smtp-recipients'] = 'Allowed recipients';
-$LANG['user.smtp-recipients.desc'] = 'Restricts allowed recipients of SMTP messages';
 $LANG['user.uid'] = 'Unique identity (UID)';
-$LANG['user.nsrole'] = 'Role(s)';
-$LANG['user.nsroledn'] = $LANG['user.nsrole'];
 $LANG['user.userpassword'] = 'Password';
 $LANG['user.userpassword2'] = 'Confirm password';
-$LANG['user.password.mismatch'] = 'Passwords do not match!';
-$LANG['user.homeserver'] = 'Mailbox home server';
-$LANG['user.add.success'] = 'User created successfully.';
-$LANG['user.delete.success'] = 'User deleted successfully.';
-$LANG['user.edit.success'] = 'User edited successfully.';
-$LANG['user.preferredlanguage'] = 'Native tongue';
-$LANG['user.gidnumber'] = 'Primary group number';
-$LANG['user.homedirectory'] = 'Home directory';
-$LANG['user.loginshell'] = 'Shell';
 $LANG['user.uidnumber'] = 'User ID number';
 
-$LANG['group.add'] = 'Add Group';
-$LANG['group.member'] = 'Member(s)';
-$LANG['group.norecords'] = 'No group records found!';
-$LANG['group.list'] = 'Groups List';
-$LANG['group.list.records'] = '$1 to $2 of $3';
-$LANG['group.cn'] = 'Common name';
-$LANG['group.mail'] = 'Primary Email Address';
-$LANG['group.type_id'] = 'Group type';
-$LANG['group.add.success'] = 'Group created successfully.';
-$LANG['group.delete.success'] = 'Group deleted successfully.';
-$LANG['group.edit.success'] = 'Group edited successfully.';
-$LANG['group.gidnumber'] = 'Primary group number';
-$LANG['group.uniquemember'] = 'Members';
-$LANG['group.system'] = 'System';
-$LANG['group.other'] = 'Other';
-
-$LANG['MB'] = 'MB';
-$LANG['days'] = 'days';
-$LANG['submit.button'] = 'Submit';
-$LANG['delete.button'] = 'Delete';
-$LANG['about.community'] = 'This is the Community Edition of the <b>Kolab Server</b>.';
-$LANG['about.warranty'] = 'It comes with absolutely <b>no warranties</b> and is typically run entirely self supported. You can find help & information on the community <a href="http://kolab.org">web site</a> & <a href="http://wiki.kolab.org">wiki</a>.';
-$LANG['about.support'] = 'Professional support is available from <a href="http://kolabsys.com">Kolab Systems</a>.';
-$LANG['password.generate'] = 'Generate password';
+$LANG['welcome'] = 'Welcome to the Kolab Groupware Server Maintenance';
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index f798a87..bdc0780 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1038,6 +1038,11 @@ function kolab_admin()
     return false;
   };
 
+  this.domain_info = function(id)
+  {
+    this.http_post('domain.info', {id: id});
+  };
+
   this.user_info = function(id)
   {
     this.http_post('user.info', {id: id});
diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css
index a3cd8c0..e39ece2 100644
--- a/public_html/skins/default/style.css
+++ b/public_html/skins/default/style.css
@@ -33,6 +33,7 @@ table.list {
   border: 1px solid #d0d0d0;
   border-spacing: 0;
   border-radius: 3px;
+  width: 100%;
   -moz-border-radius: 3px;
   -webkit-border-radius: 3px;
 }
@@ -553,7 +554,7 @@ span.listelement input {
 
 span.listarea.disabled span.listelement input,
 span.listarea.readonly span.listelement input {
-  width: 370px;  
+  width: 370px;
 }
 
 span.listelement input:focus {


commit 2a86cdf9bf9a55bc4c2b92e2f19ba6ca62d74a58
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon May 14 12:11:42 2012 +0100

    Whitespace

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 02045af..c9f6ecf 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -303,6 +303,38 @@ class LDAP
         }
     }
 
+    public function domain_find_by_attribute($attribute)
+    {
+        $conf = Conf::get_instance();
+        $base_dn = $conf->get('ldap', 'domain_base_dn');
+        return $this->entry_find_by_attribute($attribute, $base_dn);
+    }
+
+    public function domain_info($domain, $attributes = array('*'))
+    {
+        $conf = Conf::get_instance();
+
+        $domain_dn = $this->entry_dn($domain);
+
+        if (!$domain_dn) {
+            $domain_base_dn = $conf->get('ldap', 'domain_base_dn');
+            $domain_filter = $conf->get('ldap', 'domain_filter');
+            $domain_name_attribute = $conf->get('ldap', 'domain_name_attribute');
+            $domain_filter = "(&$domain_filter($domain_name_attribute=$domain))";
+            $result = self::normalize_result($this->_search($domain_base_dn, $domain_filter, $attributes));
+        } else {
+            $result = self::normalize_result($this->_search($domain_dn, '(objectclass=*)', $attributes));
+        }
+
+        if (!$result) {
+            return false;
+        }
+
+        console("domain_info() result:", $result);
+
+        return $result;
+    }
+
     public function effective_rights($subject)
     {
         $effective_rights_control_oid = "1.3.6.1.4.1.42.2.27.9.5.2";
@@ -331,7 +363,7 @@ class LDAP
             $entry_dn = $conf->get("base_dn");
         }
 
-        //console("effective_rights for $subject resolves to $entry_dn");
+        console("effective_rights for $subject resolves to $entry_dn");
 
         $moz_ldapsearch = "/usr/lib64/mozldap/ldapsearch";
         if (!is_file($moz_ldapsearch)) {
@@ -346,7 +378,7 @@ class LDAP
                 '-p',
                 $this->_ldap_port,
                 '-b',
-                $conf->get('base_dn'),
+                '"' . $entry_dn . '"',
                 '-D',
                 '"' . $_SESSION['user']->user_bind_dn . '"',
                 '-w',
@@ -360,15 +392,17 @@ class LDAP
                                 'dn:' . $_SESSION['user']->user_bind_dn // User DN
                             )
                     ) . '"',
-                '"(entrydn=' . $entry_dn . ')"',
+                '-s',
+                'base',
+                '"(objectclass=*)"',
                 '"*"',
             );
 
-        //console("Executing command " . implode(' ', $command));
+        console("Executing command " . implode(' ', $command));
 
         exec(implode(' ', $command), $output, $return_code);
 
-        //console("Output", $output, "Return code: " . $return_code);
+        console("Output", $output, "Return code: " . $return_code);
 
         $lines = array();
         foreach ($output as $line_num => $line) {
@@ -525,18 +559,26 @@ class LDAP
         // Check if the user_type has a specific base DN specified.
         $base_dn = $this->conf->get($this->domain, $type_str . "_user_base_dn");
         // If not, take the regular user_base_dn
-        if (!$base_dn)
+        if (empty($base_dn))
             $base_dn = $this->conf->get($this->domain, "user_base_dn");
 
         // If no user_base_dn either, take the user type specific from the parent
         // configuration
-        if (!$base_dn)
+        if (empty($base_dn))
             $base_dn = $this->conf->get('ldap', $type_str . "_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");
+        if (empty($base_dn))
+            $base_dn = $this->conf->get('ldap', "base_dn");
+
         if (!empty($attrs['ou'])) {
             $base_dn = $attrs['ou'];
         }
 
+        console("Base DN now: $base_dn");
+
         // TODO: The rdn is configurable as well.
         // Use [$type_str . "_"]user_rdn_attr
         $dn = "uid=" . $attrs['uid'] . "," . $base_dn;
@@ -813,7 +855,7 @@ class LDAP
     {
         $section = $this->conf->get('kolab', 'auth_mechanism');
         $base_dn = $this->conf->get($section, 'domain_base_dn');
-        $filter  = $this->conf->get($section, 'kolab_domain_filter');
+        $filter  = $this->conf->get($section, 'domain_filter');
 
         return $this->_search($base_dn, $filter);
     }
@@ -836,7 +878,7 @@ class LDAP
         }
     }
 
-    private function entry_find_by_attribute($attribute)
+    private function entry_find_by_attribute($attribute, $base_dn = null)
     {
         if (empty($attribute) || !is_array($attribute) || count($attribute) > 1) {
             return false;
@@ -854,7 +896,9 @@ class LDAP
 
         $filter .= ")";
 
-        $base_dn = $this->domain_root_dn($this->domain);
+        if (empty($base_dn)) {
+            $base_dn = $this->domain_root_dn($this->domain);
+        }
 
         $result = self::normalize_result($this->_search($base_dn, $filter, array_keys($attribute)));
 
@@ -1459,8 +1503,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)) {
@@ -1500,7 +1544,7 @@ class LDAP
         return $this->modify_entry($domain_dn, $_old_attr, $_new_attr);
 
 
-        
+
     }
 
     /**
@@ -1542,6 +1586,8 @@ class LDAP
             return true;
         }
 
+        ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 9);
+
         // TODO: Debug logging
         error_log("Connecting to " . $this->_ldap_server . " on port " . $this->_ldap_port);
         $connection = ldap_connect($this->_ldap_server, $this->_ldap_port);


commit 1ec6bb08c644412ee7cc2f62af31b0c814765059
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Mon May 14 12:10:55 2012 +0100

    Add Auth::domain_find_by_attribute() and Auth::domain_info()

diff --git a/lib/Auth.php b/lib/Auth.php
index d77b6a8..b4cda69 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -210,6 +210,16 @@ class Auth {
         return $this->_auth[$_SESSION['user']->get_domain()]->domain_add($domain, $parent_domain);
     }
 
+    public function domain_find_by_attribute($attribute)
+    {
+        return $this->_auth[$_SESSION['user']->get_domain()]->domain_find_by_attribute($attribute);
+    }
+
+    public function domain_info($domaindata)
+    {
+        return $this->_auth[$_SESSION['user']->get_domain()]->domain_info($domaindata);
+    }
+
     public function find_user_groups($member_dn)
     {
         return $this->_auth[$_SESSION['user']->get_domain()]->find_user_groups($member_dn);





More information about the commits mailing list