Reorder the application to get a structure that makes sense within a PEAR package.
authorGunnar Wrobel <p@rdus.de>
Wed, 29 Apr 2009 03:35:08 +0000 (05:35 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 29 Apr 2009 05:43:54 +0000 (07:43 +0200)
56 files changed:
koward/app/controllers/ApplicationController.php [deleted file]
koward/app/controllers/CheckController.php [deleted file]
koward/app/controllers/IndexController.php [deleted file]
koward/app/controllers/ObjectController.php [deleted file]
koward/app/views/Check/run.html.php [deleted file]
koward/app/views/Check/show.html.php [deleted file]
koward/app/views/Index/index.html.php [deleted file]
koward/app/views/Modify/add.html.php [deleted file]
koward/app/views/Object/delete.html.php [deleted file]
koward/app/views/Object/edit.html.php [deleted file]
koward/app/views/Object/listall.html.php [deleted file]
koward/app/views/Object/search.html.php [deleted file]
koward/app/views/Object/view.html.php [deleted file]
koward/app/views/shared/_header.html.php [deleted file]
koward/app/views/shared/_menu.html.php [deleted file]
koward/lib/Cli.php [deleted file]
koward/lib/Exception.php [deleted file]
koward/lib/Form/Actions.php [deleted file]
koward/lib/Form/Object.php [deleted file]
koward/lib/Form/Search.php [deleted file]
koward/lib/Koward/Cli.php [new file with mode: 0644]
koward/lib/Koward/Controller/Application.php [new file with mode: 0644]
koward/lib/Koward/Controller/CheckController.php [new file with mode: 0644]
koward/lib/Koward/Controller/IndexController.php [new file with mode: 0644]
koward/lib/Koward/Controller/ObjectController.php [new file with mode: 0644]
koward/lib/Koward/Exception.php [new file with mode: 0644]
koward/lib/Koward/Form/Actions.php [new file with mode: 0644]
koward/lib/Koward/Form/Object.php [new file with mode: 0644]
koward/lib/Koward/Form/Search.php [new file with mode: 0644]
koward/lib/Koward/Test.php [new file with mode: 0644]
koward/lib/Koward/Test/AllTests.php [new file with mode: 0644]
koward/lib/Koward/Test/Renderer.php [new file with mode: 0644]
koward/lib/Koward/Test/Server/UserTest.php [new file with mode: 0644]
koward/lib/Koward/Test/Template/scenario.html.dist [new file with mode: 0644]
koward/lib/Koward/Test/Template/scenario_header.html.dist [new file with mode: 0644]
koward/lib/Koward/Test/Template/scenarios.html.dist [new file with mode: 0644]
koward/lib/Koward/Test/Template/step.html.dist [new file with mode: 0644]
koward/lib/Koward/View/Check/run.html.php [new file with mode: 0644]
koward/lib/Koward/View/Check/show.html.php [new file with mode: 0644]
koward/lib/Koward/View/Index/index.html.php [new file with mode: 0644]
koward/lib/Koward/View/Modify/add.html.php [new file with mode: 0644]
koward/lib/Koward/View/Object/delete.html.php [new file with mode: 0644]
koward/lib/Koward/View/Object/edit.html.php [new file with mode: 0644]
koward/lib/Koward/View/Object/listall.html.php [new file with mode: 0644]
koward/lib/Koward/View/Object/search.html.php [new file with mode: 0644]
koward/lib/Koward/View/Object/view.html.php [new file with mode: 0644]
koward/lib/Koward/View/shared/_header.html.php [new file with mode: 0644]
koward/lib/Koward/View/shared/_menu.html.php [new file with mode: 0644]
koward/lib/Test.php [deleted file]
koward/lib/Test/AllTests.php [deleted file]
koward/lib/Test/Renderer.php [deleted file]
koward/lib/Test/Server/UserTest.php [deleted file]
koward/lib/Test/Template/scenario.html.dist [deleted file]
koward/lib/Test/Template/scenario_header.html.dist [deleted file]
koward/lib/Test/Template/scenarios.html.dist [deleted file]
koward/lib/Test/Template/step.html.dist [deleted file]

diff --git a/koward/app/controllers/ApplicationController.php b/koward/app/controllers/ApplicationController.php
deleted file mode 100644 (file)
index 212890b..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-class Koward_ApplicationController extends Horde_Controller_Base
-{
-    protected function _initializeApplication()
-    {
-        $this->koward = Koward_Koward::singleton();
-
-        $this->types = array_keys($this->koward->objects);
-        if (empty($this->types)) {
-            throw new KowardException('No object types have been configured!');
-        }
-
-        $this->menu = $this->getMenu();
-
-        $this->theme = isset($this->koward->conf['koward']['theme']) ? $this->koward->conf['koward']['theme'] : 'koward';
-    }
-
-    /**
-     * Builds Koward's list of menu items.
-     */
-    public function getMenu()
-    {
-        global $registry;
-
-        require_once 'Horde/Menu.php';
-        $menu = new Menu();
-
-        $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'listall')),
-                   _("_Objects"), 'user.png', $registry->getImageDir('horde'));
-        $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'edit')),
-                   _("_Add"), 'plus.png', $registry->getImageDir('horde'));
-        $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'search')),
-                   _("_Search"), 'search.png', $registry->getImageDir('horde'));
-        $menu->add(Horde::applicationUrl('Queries'), _("_Queries"), 'query.png', $registry->getImageDir('koward'));
-        $menu->add($this->urlFor(array('controller' => 'check', 'action' => 'show')),
-                   _("_Test"), 'problem.png', $registry->getImageDir('horde'));
-        return $menu;
-    }
-}
diff --git a/koward/app/controllers/CheckController.php b/koward/app/controllers/CheckController.php
deleted file mode 100644 (file)
index 39bf83e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * @package Koward
- */
-
-// @TODO Clean up
-require_once dirname(__FILE__) . '/ApplicationController.php';
-
-/**
- * @package Koward
- */
-class CheckController extends Koward_ApplicationController
-{
-
-    protected function _initializeApplication()
-    {
-        parent::_initializeApplication();
-
-        $this->suite = Koward_Test_AllTests::suite();
-    }
-
-    public function show()
-    {
-        $this->list = array();
-
-        $this->list[0] = Horde::link(
-            $this->urlFor(array('controller' => 'check',
-                                'action' => 'run',
-                                'id' => 'all')),
-            _("All tests")) . _("All tests") . '</a>';
-
-        $this->list[1] = '';
-
-        for ($i = 0; $i < $this->suite->count(); $i++) {
-            $class_name = $this->suite->testAt($i)->getName();
-            $this->list[$i + 2] = Horde::link(
-                $this->urlFor(array('controller' => 'check',
-                                    'action' => 'run',
-                                    'id' => $i + 1)),
-                $class_name) . $class_name . '</a>';
-        }
-    }
-
-    public function run()
-    {
-        
-        if ($this->params['id'] == 'all') {
-            $this->test = $this->suite;
-        } else {
-            $id = (int) $this->params['id'];
-            if (!empty($id)) {
-                $this->test = $this->suite->testAt($id - 1);
-            } else {
-                $this->test = null;
-                $this->koward->notification->push(_("You selected no test!"));
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/koward/app/controllers/IndexController.php b/koward/app/controllers/IndexController.php
deleted file mode 100644 (file)
index 40e2c77..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-/**
- * @package Koward
- */
-
-// @TODO Clean up
-require_once dirname(__FILE__) . '/ApplicationController.php';
-
-/**
- * @package Koward
- */
-class IndexController extends Koward_ApplicationController
-{
-    protected $welcome;
-
-    public function index()
-    {
-        $this->title = _("Index");
-        $this->welcome = _("Welcome to the Koward administration interface");
-    }
-}
\ No newline at end of file
diff --git a/koward/app/controllers/ObjectController.php b/koward/app/controllers/ObjectController.php
deleted file mode 100644 (file)
index e93f5e6..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-<?php
-/**
- * @package Koward
- */
-
-// @TODO Clean up
-require_once dirname(__FILE__) . '/ApplicationController.php';
-
-/**
- * @package Koward
- */
-class ObjectController extends Koward_ApplicationController
-{
-
-    var $object_type;
-    var $objectlist;
-    var $attributes;
-    var $tabs;
-    var $object;
-    var $post;
-
-    public function listall()
-    {
-        require_once 'Horde/UI/Tabs.php';
-        require_once 'Horde/Variables.php';
-
-        $this->object_type = $this->params->get('id', $this->types[0]);
-
-        if (isset($this->koward->objects[$this->object_type]['list_attributes'])) {
-            $this->attributes = $this->koward->objects[$this->object_type]['list_attributes'];
-        } else if (isset($this->koward->objects[$this->object_type]['attributes']['fields'])) {
-            $this->attributes = $this->koward->objects[$this->object_type]['attributes']['fields'];
-        } else {
-            $this->koward->notification->push(sprintf('No attributes have been defined for the list view of objects with type %s.',
-                                                      $this->object_type),
-                                              'horde.error');
-        }
-
-        if (isset($this->attributes)
-            && isset($this->koward->objects[$this->object_type])) {
-            $params = array('attributes' => array_keys($this->attributes));
-            $class = $this->koward->objects[$this->object_type]['class'];
-            $this->objectlist = $this->koward->server->listHash($class,
-                                                                $params);
-            foreach ($this->objectlist as $uid => $info) {
-                $this->objectlist[$uid]['edit_url'] = Horde::link(
-                    $this->urlFor(array('controller' => 'object', 
-                                        'action' => 'edit',
-                                        'id' => $uid)),
-                    _("Edit")) . Horde::img('edit.png', _("Edit"), '',
-                                            $GLOBALS['registry']->getImageDir('horde'))
-                    . '</a>';
-                $this->objectlist[$uid]['delete_url'] = Horde::link(
-                    $this->urlFor(array('controller' => 'object', 
-                                        'action' => 'delete',
-                                        'id' => $uid)),
-                    _("Delete")) . Horde::img('delete.png', _("Delete"), '',
-                                              $GLOBALS['registry']->getImageDir('horde'))
-                    . '</a>';
-                $this->objectlist[$uid]['view_url'] = Horde::link(
-                    $this->urlFor(array('controller' => 'object', 
-                                        'action' => 'view',
-                                        'id' => $uid)), _("View"));
-            }
-        }
-
-        $this->tabs = new Horde_UI_Tabs(null, Variables::getDefaultVariables());
-        foreach ($this->koward->objects as $key => $configuration) {
-            $this->tabs->addTab($configuration['list_label'],
-                                $this->urlFor(array('controller' => 'object', 
-                                                    'action' => 'listall',
-                                                    'id' => $key)),
-                                $key);
-        }
-
-        $this->render();
-    }
-
-    public function delete()
-    {
-        try {
-            if (empty($this->params->id)) {
-                $this->koward->notification->push(_("The object that should be deleted has not been specified."),
-                                                 'horde.error');
-            } else {
-                $this->object = $this->koward->getObject($this->params->id);
-                $this->submit_url = $this->urlFor(array('controller' => 'object',
-                                                        'action' => 'delete',
-                                                        'id' => $this->params->id,
-                                                        'token' => $this->koward->getRequestToken('object.delete')));
-                $this->return_url = $this->urlFor(array('controller' => 'object', 
-                                                        'action' => 'listall'));
-
-                if (!empty($this->params->token)) {
-                    if (is_array($this->params->token) && count($this->params->token) == 1) {
-                        $token = $this->params->token[0];
-                    } else {
-                        $token = $this->params->token;
-                    }
-                    $this->koward->checkRequestToken('object.delete', $token);
-                    $result = $this->object->delete();
-                    if ($result === true) {
-                        $this->koward->notification->push(sprintf(_("Successfully deleted the object \"%s\""),
-                                                                  $this->params->id),
-                                                          'horde.message');
-                    } else {
-                        $this->koward->notification->push(_("Failed to delete the object."),
-                                                          'horde.error');
-                    }
-                    header('Location: ' . $this->urlFor(array('controller' => 'object', 
-                                                              'action' => 'listall')));
-                    exit;
-                }
-            }
-        } catch (Exception $e) {
-            $this->koward->notification->push($e->getMessage(), 'horde.error');
-        }
-
-        $this->render();
-    }
-
-    public function view()
-    {
-        try {
-            if (empty($this->params->id)) {
-                $this->koward->notification->push(_("The object that should be viewed has not been specified."),
-                                                 'horde.error');
-            } else {
-                require_once 'Horde/Variables.php';
-
-                $this->object = $this->koward->getObject($this->params->id);
-
-                $actions = $this->object->getActions();
-                if (!empty($actions)) {
-                    $this->actions = new Koward_Form_Actions($this->object);
-
-                    $this->post = $this->urlFor(array('controller' => 'object', 
-                                                      'action' => 'view',
-                                                      'id' => $this->params->id));
-
-                    if ($this->actions->validate()) {
-                        $this->actions->execute();
-                    }
-                }
-
-                $this->vars = Variables::getDefaultVariables();
-                $this->form = new Koward_Form_Object($this->vars, $this->object,
-                                                    array('title' => _("View object")));
-                $this->edit = Horde::link(
-                    $this->urlFor(array('controller' => 'object', 
-                                        'action' => 'edit',
-                                        'id' => $this->params->id)),
-                    _("Edit")) . Horde::img('edit.png', _("Edit"), '',
-                                            $GLOBALS['registry']->getImageDir('horde'))
-                    . '</a>';
-
-
-            }
-        } catch (Exception $e) {
-            $this->koward->notification->push($e->getMessage(), 'horde.error');
-        }
-
-        $this->render();
-    }
-
-    public function edit()
-    {
-        try {
-            if (empty($this->params->id)) {
-                $this->object = null;
-            } else {
-                $this->object = $this->koward->getObject($this->params->id);
-            }
-
-            require_once 'Horde/Variables.php';
-            $this->vars = Variables::getDefaultVariables();
-            foreach ($this->params as $key => $value) {
-                if (!$this->vars->exists($key)) {
-                    if (is_array($value) && count($value) == 1) {
-                        $this->vars->set($key, $value[0]);
-                    } else {
-                        $this->vars->set($key, $value);
-                    }
-                }
-            }
-            $this->form = new Koward_Form_Object($this->vars, $this->object);
-
-            if ($this->form->validate()) {
-                $object = $this->form->execute();
-
-                if (!empty($object)) {
-                    header('Location: ' . $this->urlFor(array('controller' => 'object', 
-                                                              'action' => 'view',
-                                                              'id' => $object->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID))));
-                    exit;
-                }
-            }
-        } catch (Exception $e) {
-            $this->koward->notification->push($e->getMessage(), 'horde.error');
-        }
-
-        $this->post = $this->urlFor(array('controller' => 'object', 
-                                          'action' => 'edit',
-                                          'id' => $this->params->id));
-
-        $this->render();
-    }
-
-    public function search()
-    {
-        try {
-            require_once 'Horde/Variables.php';
-            $this->vars = Variables::getDefaultVariables();
-            $this->form = new Koward_Form_Search($this->vars, $this->object);
-
-            if ($this->form->validate()) {
-                $result = $this->form->execute();
-
-                $uids = array_keys($result);
-
-                if (count($uids) == 1) {
-                    header('Location: ' . $this->urlFor(array('controller' => 'object', 
-                                                              'action' => 'view',
-                                                              'id' => $uids[0])));
-                    exit;
-                } else if (count($uids) == 0) {
-                    $this->koward->notification->push(_("No results found!"), 'horde.message');
-                } else {
-                    if (isset($this->koward->search['list_attributes'])) {
-                        $this->attributes = $this->koward->search['list_attributes'];
-                    } else {
-                        $this->attributes = array(
-                            '__id' => array(
-                                'title' => _("Kennung"),
-                                'width' => 100,
-                                'link_view'=> true,
-                            )
-                        );
-                    }
-                    foreach ($result as $uid => $info) {
-                        $this->objectlist[$uid]['edit_url'] = Horde::link(
-                            $this->urlFor(array('controller' => 'object', 
-                                                'action' => 'edit',
-                                                'id' => $uid)),
-                            _("Edit")) . Horde::img('edit.png', _("Edit"), '',
-                                                    $GLOBALS['registry']->getImageDir('horde'))
-                            . '</a>';
-                        $this->objectlist[$uid]['delete_url'] = Horde::link(
-                            $this->urlFor(array('controller' => 'object', 
-                                                'action' => 'delete',
-                                                'id' => $uid)),
-                            _("Delete")) . Horde::img('delete.png', _("Delete"), '',
-                                                      $GLOBALS['registry']->getImageDir('horde'))
-                            . '</a>';
-                        $this->objectlist[$uid]['view_url'] = Horde::link(
-                            $this->urlFor(array('controller' => 'object', 
-                                                'action' => 'view',
-                                                'id' => $uid)), _("View"));
-                        $this->objectlist[$uid]['__id'] = $uid;
-                    }
-                }
-            }
-        } catch (Exception $e) {
-            $this->koward->notification->push($e->getMessage(), 'horde.error');
-        }
-
-        $this->post = $this->urlFor(array('controller' => 'object', 
-                                          'action' => 'search'));
-
-        $this->render();
-    }
-
-}
\ No newline at end of file
diff --git a/koward/app/views/Check/run.html.php b/koward/app/views/Check/run.html.php
deleted file mode 100644 (file)
index ea945e8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-
-<?php
-if (!empty($this->test)) {
-    ob_start();
-    $listener = new Koward_Test_Renderer();
-    PHPUnit_TextUI_TestRunner::run($this->test, array('listeners' => array($listener)));
-    echo ob_get_clean();
-}
\ No newline at end of file
diff --git a/koward/app/views/Check/show.html.php b/koward/app/views/Check/show.html.php
deleted file mode 100644 (file)
index f58908f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-
-<?php
-
-foreach ($this->list as $test) {
-    echo $test;
-    echo '<br/>';
-}
\ No newline at end of file
diff --git a/koward/app/views/Index/index.html.php b/koward/app/views/Index/index.html.php
deleted file mode 100644 (file)
index 0696b72..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-
-<div class="contenttext">
-   <h1><?= $this->welcome ?></h1>
-</div>
diff --git a/koward/app/views/Modify/add.html.php b/koward/app/views/Modify/add.html.php
deleted file mode 100644 (file)
index fb15bbe..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-
-<?php
-$this->form->renderActive(new Horde_Form_Renderer(), $vars, 'modify', 'post');
-
diff --git a/koward/app/views/Object/delete.html.php b/koward/app/views/Object/delete.html.php
deleted file mode 100644 (file)
index 8e74c09..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-
-<form action="<?= $this->submit_url ?>" method="post" name="delete">
-<?php echo Util::formInput() ?>
-
-<div class="headerbox">
-
- <p><?php echo _("Permanently delete this object?") ?></p>
-
- <input type="submit" class="button" name="delete" value="<?php echo _("Delete") ?>" />
- <a class="button" href="<?= $this->return_url ?>"><?php echo _("Cancel") ?></a>
-</div>
-
-</form>
diff --git a/koward/app/views/Object/edit.html.php b/koward/app/views/Object/edit.html.php
deleted file mode 100644 (file)
index 5185924..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-<?= $this->form->renderActive(new Horde_Form_Renderer(), $this->vars,
-                              $this->post, 'post'); ?>
\ No newline at end of file
diff --git a/koward/app/views/Object/listall.html.php b/koward/app/views/Object/listall.html.php
deleted file mode 100644 (file)
index a790967..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-
-<?= $this->tabs->render($this->object_type); ?>
-
-<?php if (isset($this->objectlist)): ?>
-
-<table cellspacing="0" width="100%" class="linedRow">
- <thead>
-  <tr>
-   <th class="item" width="1%"><?php echo Horde::img('edit.png', _("Edit"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
-   <th class="item" width="1%"><?php echo Horde::img('delete.png', _("Delete"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
-   <?php foreach ($this->attributes as $attribute => $info): ?>
-     <th class="item leftAlign" width="<?php echo $info['width'] ?>%" nowrap="nowrap"><?= $info['title'] ?></th>
-   <?php endforeach; ?>
-  </tr>
- </thead>
- <tbody>
-  <?php foreach ($this->objectlist as $dn => $info): ?>
-  <tr>
-   <td>
-    <?= $info['edit_url'] ?>
-   </td> 
-   <td>
-    <?= $info['delete_url'] ?>
-   </td> 
-   <?php foreach ($this->attributes as $attribute => $ainfo): ?>
-   <td>
-   <?php if (!empty($ainfo['link_view'])): ?>
-   <?= $info['view_url'] . $this->escape($info[$attribute]) . '</a>'; ?>
-   <?php else: ?>
-    <?= $this->escape($info[$attribute]) ?>
-   <?php endif; ?>
-   </td> 
-   <?php endforeach; ?>
-  </tr> 
-  <?php endforeach; ?>
- </tbody>
-</table>
-<?php endif; ?>
diff --git a/koward/app/views/Object/search.html.php b/koward/app/views/Object/search.html.php
deleted file mode 100644 (file)
index 3059c8e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-<?php if (empty($this->objectlist)): ?>
-  <?= $this->form->renderActive(new Horde_Form_Renderer(), $this->vars,
-                                $this->post, 'post'); ?>
-<?php else: ?>
-<table cellspacing="0" width="100%" class="linedRow">
- <thead>
-  <tr>
-   <th class="item" width="1%"><?php echo Horde::img('edit.png', _("Edit"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
-   <th class="item" width="1%"><?php echo Horde::img('delete.png', _("Delete"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
-   <?php foreach ($this->attributes as $attribute => $info): ?>
-     <th class="item leftAlign" width="<?php echo $info['width'] ?>%" nowrap="nowrap"><?= $info['title'] ?></th>
-   <?php endforeach; ?>
-  </tr>
- </thead>
- <tbody>
-  <?php foreach ($this->objectlist as $dn => $info): ?>
-  <tr>
-   <td>
-    <?= $info['edit_url'] ?>
-   </td> 
-   <td>
-    <?= $info['delete_url'] ?>
-   </td> 
-   <?php foreach ($this->attributes as $attribute => $ainfo): ?>
-   <td>
-   <?php if (!empty($ainfo['link_view'])): ?>
-   <?= $info['view_url'] . $this->escape($info[$attribute]) . '</a>'; ?>
-   <?php else: ?>
-    <?= $this->escape($info[$attribute]) ?>
-   <?php endif; ?>
-   </td> 
-   <?php endforeach; ?>
-  </tr> 
-  <?php endforeach; ?>
- </tbody>
-</table>
-
-<?php endif; ?>
diff --git a/koward/app/views/Object/view.html.php b/koward/app/views/Object/view.html.php
deleted file mode 100644 (file)
index b9da7d2..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?= $this->renderPartial('header'); ?>
-<?= $this->renderPartial('menu'); ?>
-<?php
-if (isset($this->actions)) {
-    echo $this->actions->renderActive(new Horde_Form_Renderer(), $this->vars,
-                                      $this->post, 'post');
-}
-
-if (isset($this->form)) {
-    echo $this->form->renderInactive(new Horde_Form_Renderer(), $this->vars);
-
-    echo $this->edit;
-}
diff --git a/koward/app/views/shared/_header.html.php b/koward/app/views/shared/_header.html.php
deleted file mode 100644 (file)
index dc72ba8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-if (isset($language)) {
-    header('Content-type: text/html; charset=' . NLS::getCharset());
-    header('Vary: Accept-Language');
-}
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<!--
-Koward - The Kolab warden
-
-Copyright
-
-2004 - 2009 Klarälvdalens Datakonsult AB
-2009        The Horde Project
-
-Koward is under the GPL. GNU Public License: http://www.fsf.org/copyleft/gpl.html -->
-
-<?php echo !empty($language) ? '<html lang="' . strtr($language, '_', '-') . '">' : '<html>' ?>
-<head>
-<?php
-
-global $registry;
-
-$page_title = $registry->get('name');
-$page_title .= !empty($this->title) ? ' :: ' . $this->title : '';
-
-Horde::includeScriptFiles();
-?>
-<title><?php echo htmlspecialchars($page_title) ?></title>
-<link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-
-<?php echo Horde::stylesheetLink('koward', empty($this->print_view) ? $this->theme : 'print') ?>
-
-</head>
-
-<body>
diff --git a/koward/app/views/shared/_menu.html.php b/koward/app/views/shared/_menu.html.php
deleted file mode 100644 (file)
index 3be3269..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<div id="menu">
- <?= $this->menu->render(); ?>
-</div>
-<?php $this->koward->notification->notify(array('listeners' => 'status')) ?>
-
diff --git a/koward/lib/Cli.php b/koward/lib/Cli.php
deleted file mode 100644 (file)
index 43b31bc..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-<?php
-/**
- * Request helper for command line calls.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward
- */
-
-/**
- * A base for the Koward command line requests.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward
- */
-class Koward_Cli extends Horde_Controller_Request_Base
-{
-    /**
-     * Command line arguments
-     */
-    protected $_argv;
-
-    /**
-     * Command arguments
-     */
-    protected $_cmd_argv;
-
-   /**
-     */
-    public function __construct($options = array())
-    {
-        global $registry, $conf;
-
-        parent::__construct($options);
-
-        $options = array(
-            new Horde_Argv_Option('-b', '--base', array('type' => 'string')),
-            new Horde_Argv_Option('-u', '--user', array('type' => 'string')),
-            new Horde_Argv_Option('-p', '--pass', array('type' => 'string')),
-        );
-        $parser = new Horde_Argv_Parser(
-            array(
-                'allowUnknownArgs' => true,
-                'optionList' => $options,
-                'addHelpOption' => false,
-            )
-        );
-        list($this->_argv, $args) = $parser->parseArgs();
-        if (!count($args)) {
-            throw new Horde_Controller_Exception('unknown command: ' . implode(' ', $args));
-        }
-
-        /**
-         * FIXME: Workaround to fix the path so that the command line call
-         * really only needs the route.
-         */
-        $this->_path = $registry->get('webroot', 'koward') . '/' . $args[0];
-
-        $this->_cmd_argv = array();
-
-        /* Authenticate the user if possible. */
-        if ($this->_argv->user) {
-            require_once 'Horde/Auth.php';
-            $auth = &Auth::singleton($conf['auth']['driver']);
-            if (!$auth->authenticate($this->_argv->user,
-                                     array('password' => $this->_argv->pass))) {
-                throw new InvalidArgumentException('Failed to log in!');
-            }
-        }
-
-        /**
-         * A rough command line handler that allows us to map CLI requests into
-         * the web view of the system.
-         */
-        switch ($args[0]) {
-        case 'object/edit':
-            $this->_cmd_argv['formname'] = 'koward_form_object';
-
-            /** Has the object type been set? */
-            if ($this->_argv->type && is_array($this->_argv->type)
-                && count($this->_argv->type) == 1) {
-                $type = $this->_argv->type[0];
-
-                /**
-                 * FIXME: Editing on the command line does not work if we don't
-                 * specify the full set of form attributes. Yet another reason
-                 * for not using the Form.
-                 */
-                if ($this->_argv->id && is_array($this->_argv->id)
-                    && count($this->_argv->id) == 1) {
-                    $this->_cmd_argv['id'] = $this->_argv->id[0];
-                } else {
-                    $this->_cmd_argv['id'] = $this->_argv->id;
-                }
-
-                /**
-                 * Fake the selected type for the form handler and short circuit the
-                 * type selection machinery.
-                 */
-                $this->_cmd_argv['__old_type'] = $type;
-
-                /**
-                 * Fake the form token. Hm, it does not really make much sense
-                 * to use the standard form mechanisms via CLI. Think of some
-                 * alternatives here.
-                 */
-                $koward = &Koward_Koward::singleton();
-                $token = $koward->getRequestToken('cli');
-                $this->_cmd_argv['koward_form_object_formToken'] = $token;
-
-                /**
-                 * FIXME: Allow retrieving the form fields without specifying $vars.
-                 */
-                require_once 'Horde/Variables.php';
-                $object = null;
-                $form = new Koward_Form_Object(Variables::getDefaultVariables(), $object);
-
-                $fields = array_keys($form->getTypeFields($type));
-
-                /**
-                 * Now that we know the type of object that should be edited we
-                 * can restrict the amount of options we allow.
-                 */
-                $options = array(
-                    new Horde_Argv_Option('-b', '--base', array('type' => 'string')),
-                    new Horde_Argv_Option('-u', '--user', array('type' => 'string')),
-                    new Horde_Argv_Option('-p', '--pass', array('type' => 'string')),
-                    new Horde_Argv_Option('-t', '--type', array('type' => 'string')),
-                    new Horde_Argv_Option('-i', '--id', array('type' => 'string')),
-                );
-                foreach ($fields as $field) {
-                    $options[] = new Horde_Argv_Option(null, '--' . $field,
-                                                       array('type' => 'string'));
-                }
-                $parser = new Horde_Argv_Parser(
-                    array(
-                        'allowUnknownArgs' => false,
-                        'optionList' => $options,
-                        'addHelpOption' => true,
-                    )
-                );
-                list($cmd_argv, $cmd) = $parser->parseArgs();
-                foreach ($cmd_argv as $field => $value) {
-                    if ($field == 'userPassword') {
-                        /**
-                         * FIXME: Obvious hack and probably another reason why
-                         * mixing forms and CLI does not make that much
-                         * sense.
-                         */
-                        $this->_cmd_argv['object']['userPassword']['original'] = $value;
-                        $this->_cmd_argv['object']['userPassword']['confirm'] = $value;
-                    } else if (in_array($field, $fields) && $value !== null) {
-                        $this->_cmd_argv['object'][$field] = $value;
-                    }
-                }
-            }
-            break;
-        case 'object/delete':
-            if ($this->_argv->id && is_array($this->_argv->id)
-                && count($this->_argv->id) == 1) {
-                $this->_cmd_argv['id'] = $this->_argv->id[0];
-            } else {
-                $this->_cmd_argv['id'] = $this->_argv->id;
-            }
-
-            /**
-             * Provide a token for immediate deletion.
-             */
-            $koward = &Koward_Koward::singleton();
-            $this->_cmd_argv['token'] = $koward->getRequestToken('object.delete');
-
-            break;
-        }
-    }
-
-    public function getUri()
-    {
-        return $this->getPath();
-    }
-
-    public function getPath()
-    {
-        return $this->_path;
-    }
-
-    public function getArguments()
-    {
-        return $this->_argv;
-    }
-
-    /**
-     * Get all command line parameters.
-     * some wacky loops to make sure that nested values in one
-     * param list don't overwrite other nested values
-     *
-     * @return  array
-     */
-    public function getParameters()
-    {
-        $allParams = array();
-        $paramArrays = array($this->_pathParams, $this->_argv, $this->_cmd_argv);
-
-        foreach ($paramArrays as $params) {
-            foreach ((array)$params as $key => $value) {
-                if (!is_array($value) || !isset($allParams[$key])) {
-                    $allParams[$key] = $value;
-                } else {
-                    $allParams[$key] = array_merge($allParams[$key], $value);
-                }
-            }
-        }
-        return $allParams;
-    }
-
-}
\ No newline at end of file
diff --git a/koward/lib/Exception.php b/koward/lib/Exception.php
deleted file mode 100644 (file)
index 3498db4..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * An application for managing a Kolab server.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Koward_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward_Server
- */
-
-/**
- * This class provides the standard error class for the Koward application.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Koward_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward_Server
- */
-class Koward_Exception extends Exception
-{
-}
diff --git a/koward/lib/Form/Actions.php b/koward/lib/Form/Actions.php
deleted file mode 100644 (file)
index 73cd952..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * @package Koward
- */
-
-/**
- * @package Koward
- */
-class Koward_Form_Actions extends Horde_Form {
-
-    /**
-     * The link to the application driver.
-     *
-     * @var Koward_Koward
-     */
-    protected $koward;
-
-    public function __construct(&$object)
-    {
-        $this->koward = &Koward_Koward::singleton();
-
-        $this->object = &$object;
-
-        parent::Horde_Form(Variables::getDefaultVariables());
-
-        $this->setTitle(_("Object actions"));
-
-        $class_name = get_class($this->object);
-        foreach ($this->koward->objects as $name => $config) {
-            if ($config['class'] == $class_name) {
-                $this->type = $name;
-                if (!empty($config['preferred'])) {
-                    break;
-                }
-            }
-        }
-
-        $buttons = array();
-        foreach ($this->object->getActions() as $action) {
-            if (isset($this->koward->objects[$this->type]['actions'][$action])) {
-                $buttons[] = $this->koward->objects[$this->type]['actions'][$action];
-            }
-        }
-
-        if (!empty($buttons)) {
-            $this->setButtons($buttons);
-        }
-    }
-
-    function &execute()
-    {
-        require_once 'Horde/Util.php';
-
-        $submit = Util::getFormData('submitbutton');
-        if (!empty($submit)) {
-            foreach ($this->koward->objects[$this->type]['actions'] as $action => $label) {
-                if ($submit == $label) {
-                    $this->object->$action();
-                }
-            }
-        }
-    }
-}
diff --git a/koward/lib/Form/Object.php b/koward/lib/Form/Object.php
deleted file mode 100644 (file)
index dd65442..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-<?php
-/**
- * @package Koward
- */
-
-/**
- * @package Koward
- */
-class Koward_Form_Object extends Horde_Form {
-
-    /**
-     * The link to the application driver.
-     *
-     * @var Koward_Koward
-     */
-    protected $koward;
-
-    public function __construct(&$vars, &$object, $params = array())
-    {
-        $this->koward = &Koward_Koward::singleton();
-
-        $this->object = &$object;
-
-        parent::Horde_Form($vars);
-
-        $type = false;
-
-        if (empty($this->object)) {
-            $title = _("Add Object");
-            $this->setButtons(_("Add"));
-
-            foreach ($this->koward->objects as $key => $config) {
-                $options[$key] = $config['label'];
-            }
-            
-            $v = &$this->addVariable(_("Choose an object type"), 'type', 'enum', true, false, null, array($options, true));
-            $action = Horde_Form_Action::factory('submit');
-            $v->setAction($action);
-            $v->setOption('trackchange', true);
-            if (is_null($vars->get('formname')) &&
-                $vars->get($v->getVarName()) != $vars->get('__old_' . $v->getVarName())) {
-                $this->koward->notification->push(sprintf(_("Selected object type \"%s\"."), $object_conf[$vars->get('type')]['label']), 'horde.message');
-            }
-
-            $type = $vars->get('type');
-        } else {
-            $title = _("Edit Object");
-            $class_name = get_class($this->object);
-            foreach ($this->koward->objects as $name => $config) {
-                if ($config['class'] == $class_name) {
-                    $type = $name;
-                    if (!empty($config['preferred'])) {
-                        break;
-                    }
-                }
-            }
-            if (empty($type)) {
-                throw new Koward_Exception('Undefined object class!');
-            }
-            if (!$this->isSubmitted()) {
-                $vars->set('type', $type);
-                $keys = array_keys($this->_getFields($this->koward->objects[$type]));
-                $vars->set('object', $this->object->toHash($keys));
-                $this->setButtons(true);
-            }
-        }
-
-        if (isset($params['title'])) {
-            $title = $params['title'];
-        }
-
-        $this->setTitle($title);
-
-        if (!empty($type)) {
-            $this->_addFields($this->koward->objects[$type]);
-        }
-    }
-
-    /**
-     * Get the fields for an object type
-     */
-    public function getTypeFields($type)
-    {
-        return $this->_getFields($this->koward->objects[$type]);
-    }
-    /**
-     * Get the fields for a configuration array.
-     */
-    private function _getFields($config)
-    {
-        if (isset($config['attributes']['fields']) && !empty($config['attributes']['override'])) {
-            return $config['attributes']['fields'];
-        } else {
-            list($attributes, $attribute_map) = $this->koward->getServer()->getAttributes($config['class']);
-
-            if (isset($this->koward->visible['show'])) {
-                $akeys = $this->koward->visible['show'];
-            } else if (isset($config['attributes']['show'])) {
-                $akeys = $config['attributes']['show'];
-            } else {
-                $akeys = array_keys($attributes);
-                if (isset($config['attributes']['hide'])) {
-                    $akeys = array_diff($akeys, $config['attributes']['hide']);
-                }
-            }
-
-            $form_attributes = array();
-
-            foreach ($akeys as $key) {
-                if ((isset($this->koward->visible['hide'])
-                     && in_array($key, $this->koward->visible['hide']))
-                    || (isset($config['attributes']['hide'])
-                        && in_array($key, $config['attributes']['hide']))) {
-                    continue;
-                }
-
-                if (isset($config['attributes']['type'][$key])) {
-                    $type = $config['attributes']['type'][$key];
-                } else if (isset($attributes[$key]['syntax'])) {
-                    list($syntax, $length) = explode('{', $attributes[$key]['syntax'], 2);
-                    switch ($syntax) {
-                    case '1.3.6.1.4.1.1466.115.121.1.22':
-                    case '1.3.6.1.4.1.1466.115.121.1.50':
-                        $type = 'phone';
-                        break;
-                    case '1.3.6.1.4.1.1466.115.121.1.28':
-                        $type = 'image';
-                        break;
-                    default:
-                        $type = 'text';
-                        break;
-                    }
-                } else {
-                    $type = 'text';
-                }
-
-                $locked = in_array($key, $attribute_map['locked']) && !empty($this->object);
-                if (!$locked) {
-                    $required = in_array($key, $attribute_map['required'])  && empty($this->object);
-                }
-
-                $form_attributes[$key] = array(
-                    'type' => $type,
-                    'required' => $required,
-                    'readonly' => $locked,
-                    'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255)
-                );
-                if (isset($config['attributes']['order'][$key])) {
-                    $form_attributes[$key]['order'] = $config['attributes']['order'][$key];
-                } else if (isset($this->koward->order[$key])) {
-                    $form_attributes[$key]['order'] = $this->koward->order[$key];
-                } else {
-                    $form_attributes[$key]['order'] = -1;
-                }
-                if (isset($config['attributes']['labels'][$key])) {
-                    $form_attributes[$key]['label'] = $config['attributes']['labels'][$key];
-                } else if (isset($this->koward->labels[$key])) {
-                    $form_attributes[$key]['label'] = $this->koward->labels[$key];
-                } else {
-                    $form_attributes[$key]['label'] = $key;
-                }
-                if (isset($config['attributes']['fields'][$key])) {
-                    $form_attributes[$key] = array_merge($form_attributes[$key],
-                                                         $config['attributes']['fields'][$key]);
-                }
-            }
-            uasort($form_attributes, array($this, '_sortFields'));
-            return $form_attributes;
-        }
-        return array();
-    }
-
-    /**
-     * Sort fields for an object type
-     */
-    function _sortFields($a, $b)
-    {
-        if ($a['order'] == -1) {
-            return 1;
-        }
-        if ($b['order'] == -1) {
-            return -1;
-        }
-        if ($a['order'] == $b['order']) {
-            return 0;
-        }
-        return ($a['order'] < $b['order']) ? -1 : 1;
-    }
-
-    /**
-     * Set up the Horde_Form fields for the attributes of this object type.
-     */
-    function _addFields($config)
-    {
-        // Now run through and add the form variables.
-        $fields = $this->_getFields($config);
-        $tabs   = isset($config['tabs']) ? $config['tabs'] : array('' => $fields);
-
-        foreach ($tabs as $tab => $tab_fields) {
-            if (!empty($tab)) {
-                $this->setSection($tab, $tab);
-            }
-            foreach ($tab_fields as $key => $field) {
-                if (!in_array($key, array_keys($fields))
-                    //                    || !isset($this->koward->attributes[$key])
-                ) {
-                    continue;
-                }
-                $attribute = $field;
-                //                $attribute = $this->koward->attributes[$key];
-                $params = isset($attribute['params']) ? $attribute['params'] : array();
-                $desc = isset($attribute['desc']) ? $attribute['desc'] : null;
-
-                $readonly = isset($attribute['readonly']) ? $attribute['readonly'] : null;
-                $v = &$this->addVariable($attribute['label'], 'object[' . $key . ']', $attribute['type'], $attribute['required'], $readonly, $desc, $params);
-            }
-
-            if (isset($attribute['default'])) {
-                $v->setDefault($attribute['default']);
-            }
-        }
-    }
-
-    function &execute()
-    {
-        $this->getInfo($this->_vars, $info);
-        if (isset($info['object'])) {
-            if (empty($this->object)) {
-                if (isset($info['type'])) {
-                    if (isset($this->koward->objects[$info['type']]['class'])) {
-                        $class = $this->koward->objects[$info['type']]['class'];
-                    } else {
-                        throw new Koward_Exception(sprintf('Invalid type \"%s\" specified!',
-                                                           $info['type']));
-                    }
-                    $object = $this->koward->getServer()->add(array_merge(array('type' => $class),
-                                                                 $info['object']));
-                    $this->koward->notification->push(_("Successfully added the object."),
-                                                      'horde.message');
-                    return $object;
-                }
-            } else {
-                $this->object->save($info['object']);
-                $this->koward->notification->push(_("Successfully updated the object."),
-                                                 'horde.message');
-                return $this->object;
-            }
-        }
-    }
-}
diff --git a/koward/lib/Form/Search.php b/koward/lib/Form/Search.php
deleted file mode 100644 (file)
index 7e8a8a7..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * @package Koward
- */
-
-/**
- * @package Koward
- */
-class Koward_Form_Search extends Horde_Form {
-
-    /**
-     * The link to the application driver.
-     *
-     * @var Koward_Koward
-     */
-    protected $koward;
-
-    public function __construct(&$vars, &$object, $params = array())
-    {
-        $this->koward = &Koward_Koward::singleton();
-
-        $this->object = &$object;
-
-        parent::Horde_Form($vars);
-
-        $type = false;
-
-        $this->setButtons(_("Search"));
-        $this->_addFields($this->koward->search);
-    }
-
-
-    /**
-     * Sort fields for an object type
-     */
-    function _sortFields($a, $b)
-    {
-        if ($a['order'] == -1) {
-            return 1;
-        }
-        if ($b['order'] == -1) {
-            return -1;
-        }
-        if ($a['order'] == $b['order']) {
-            return 0;
-        }
-        return ($a['order'] < $b['order']) ? -1 : 1;
-    }
-
-    /**
-     * Set up the Horde_Form fields for the attributes of this object type.
-     */
-    function _addFields($config)
-    {
-        // Now run through and add the form variables.
-        $tabs   = isset($config['tabs']) ? $config['tabs'] : array('' => $config['fields']);
-
-        foreach ($tabs as $tab => $tab_fields) {
-            if (!empty($tab)) {
-                $this->setSection($tab, $tab);
-            }
-            foreach ($tab_fields as $key => $field) {
-                if (!in_array($key, array_keys($config['fields']))) {
-                    continue;
-                }
-                $attribute = $field;
-                $params = isset($attribute['params']) ? $attribute['params'] : array();
-                $desc = isset($attribute['desc']) ? $attribute['desc'] : null;
-
-                $v = &$this->addVariable($attribute['label'], 'object[' . $key . ']', $attribute['type'], $attribute['required'], null, $desc, $params);
-            }
-
-            if (isset($attribute['default'])) {
-                $v->setDefault($attribute['default']);
-            }
-        }
-    }
-
-    function &execute()
-    {
-        $this->getInfo($this->_vars, $info);
-        if (isset($info['object'])) {
-            $search_criteria = array();
-            foreach ($info['object'] as $key => $value) {
-                if (!empty($value)) {
-                    $search_criteria[] = array('field' => $key,
-                                               'op'    => 'contains',
-                                               'test' => $value);
-                }
-            }
-            $search_criteria = array('AND' => $search_criteria);
-            $criteria = array('AND' => array($search_criteria,
-                                             $this->koward->search['criteria']));
-            $filter = $this->koward->getServer()->searchQuery($criteria);
-            $params = array('scope' => 'sub',
-                            'attributes' => array('dn'));
-            return $this->koward->getServer()->search($filter, $params);
-        }
-    }
-}
diff --git a/koward/lib/Koward/Cli.php b/koward/lib/Koward/Cli.php
new file mode 100644 (file)
index 0000000..43b31bc
--- /dev/null
@@ -0,0 +1,227 @@
+<?php
+/**
+ * Request helper for command line calls.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward
+ */
+
+/**
+ * A base for the Koward command line requests.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward
+ */
+class Koward_Cli extends Horde_Controller_Request_Base
+{
+    /**
+     * Command line arguments
+     */
+    protected $_argv;
+
+    /**
+     * Command arguments
+     */
+    protected $_cmd_argv;
+
+   /**
+     */
+    public function __construct($options = array())
+    {
+        global $registry, $conf;
+
+        parent::__construct($options);
+
+        $options = array(
+            new Horde_Argv_Option('-b', '--base', array('type' => 'string')),
+            new Horde_Argv_Option('-u', '--user', array('type' => 'string')),
+            new Horde_Argv_Option('-p', '--pass', array('type' => 'string')),
+        );
+        $parser = new Horde_Argv_Parser(
+            array(
+                'allowUnknownArgs' => true,
+                'optionList' => $options,
+                'addHelpOption' => false,
+            )
+        );
+        list($this->_argv, $args) = $parser->parseArgs();
+        if (!count($args)) {
+            throw new Horde_Controller_Exception('unknown command: ' . implode(' ', $args));
+        }
+
+        /**
+         * FIXME: Workaround to fix the path so that the command line call
+         * really only needs the route.
+         */
+        $this->_path = $registry->get('webroot', 'koward') . '/' . $args[0];
+
+        $this->_cmd_argv = array();
+
+        /* Authenticate the user if possible. */
+        if ($this->_argv->user) {
+            require_once 'Horde/Auth.php';
+            $auth = &Auth::singleton($conf['auth']['driver']);
+            if (!$auth->authenticate($this->_argv->user,
+                                     array('password' => $this->_argv->pass))) {
+                throw new InvalidArgumentException('Failed to log in!');
+            }
+        }
+
+        /**
+         * A rough command line handler that allows us to map CLI requests into
+         * the web view of the system.
+         */
+        switch ($args[0]) {
+        case 'object/edit':
+            $this->_cmd_argv['formname'] = 'koward_form_object';
+
+            /** Has the object type been set? */
+            if ($this->_argv->type && is_array($this->_argv->type)
+                && count($this->_argv->type) == 1) {
+                $type = $this->_argv->type[0];
+
+                /**
+                 * FIXME: Editing on the command line does not work if we don't
+                 * specify the full set of form attributes. Yet another reason
+                 * for not using the Form.
+                 */
+                if ($this->_argv->id && is_array($this->_argv->id)
+                    && count($this->_argv->id) == 1) {
+                    $this->_cmd_argv['id'] = $this->_argv->id[0];
+                } else {
+                    $this->_cmd_argv['id'] = $this->_argv->id;
+                }
+
+                /**
+                 * Fake the selected type for the form handler and short circuit the
+                 * type selection machinery.
+                 */
+                $this->_cmd_argv['__old_type'] = $type;
+
+                /**
+                 * Fake the form token. Hm, it does not really make much sense
+                 * to use the standard form mechanisms via CLI. Think of some
+                 * alternatives here.
+                 */
+                $koward = &Koward_Koward::singleton();
+                $token = $koward->getRequestToken('cli');
+                $this->_cmd_argv['koward_form_object_formToken'] = $token;
+
+                /**
+                 * FIXME: Allow retrieving the form fields without specifying $vars.
+                 */
+                require_once 'Horde/Variables.php';
+                $object = null;
+                $form = new Koward_Form_Object(Variables::getDefaultVariables(), $object);
+
+                $fields = array_keys($form->getTypeFields($type));
+
+                /**
+                 * Now that we know the type of object that should be edited we
+                 * can restrict the amount of options we allow.
+                 */
+                $options = array(
+                    new Horde_Argv_Option('-b', '--base', array('type' => 'string')),
+                    new Horde_Argv_Option('-u', '--user', array('type' => 'string')),
+                    new Horde_Argv_Option('-p', '--pass', array('type' => 'string')),
+                    new Horde_Argv_Option('-t', '--type', array('type' => 'string')),
+                    new Horde_Argv_Option('-i', '--id', array('type' => 'string')),
+                );
+                foreach ($fields as $field) {
+                    $options[] = new Horde_Argv_Option(null, '--' . $field,
+                                                       array('type' => 'string'));
+                }
+                $parser = new Horde_Argv_Parser(
+                    array(
+                        'allowUnknownArgs' => false,
+                        'optionList' => $options,
+                        'addHelpOption' => true,
+                    )
+                );
+                list($cmd_argv, $cmd) = $parser->parseArgs();
+                foreach ($cmd_argv as $field => $value) {
+                    if ($field == 'userPassword') {
+                        /**
+                         * FIXME: Obvious hack and probably another reason why
+                         * mixing forms and CLI does not make that much
+                         * sense.
+                         */
+                        $this->_cmd_argv['object']['userPassword']['original'] = $value;
+                        $this->_cmd_argv['object']['userPassword']['confirm'] = $value;
+                    } else if (in_array($field, $fields) && $value !== null) {
+                        $this->_cmd_argv['object'][$field] = $value;
+                    }
+                }
+            }
+            break;
+        case 'object/delete':
+            if ($this->_argv->id && is_array($this->_argv->id)
+                && count($this->_argv->id) == 1) {
+                $this->_cmd_argv['id'] = $this->_argv->id[0];
+            } else {
+                $this->_cmd_argv['id'] = $this->_argv->id;
+            }
+
+            /**
+             * Provide a token for immediate deletion.
+             */
+            $koward = &Koward_Koward::singleton();
+            $this->_cmd_argv['token'] = $koward->getRequestToken('object.delete');
+
+            break;
+        }
+    }
+
+    public function getUri()
+    {
+        return $this->getPath();
+    }
+
+    public function getPath()
+    {
+        return $this->_path;
+    }
+
+    public function getArguments()
+    {
+        return $this->_argv;
+    }
+
+    /**
+     * Get all command line parameters.
+     * some wacky loops to make sure that nested values in one
+     * param list don't overwrite other nested values
+     *
+     * @return  array
+     */
+    public function getParameters()
+    {
+        $allParams = array();
+        $paramArrays = array($this->_pathParams, $this->_argv, $this->_cmd_argv);
+
+        foreach ($paramArrays as $params) {
+            foreach ((array)$params as $key => $value) {
+                if (!is_array($value) || !isset($allParams[$key])) {
+                    $allParams[$key] = $value;
+                } else {
+                    $allParams[$key] = array_merge($allParams[$key], $value);
+                }
+            }
+        }
+        return $allParams;
+    }
+
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/Controller/Application.php b/koward/lib/Koward/Controller/Application.php
new file mode 100644 (file)
index 0000000..e28fb3d
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+class Koward_Controller_Application extends Horde_Controller_Base
+{
+    protected function _initializeApplication()
+    {
+        $this->koward = Koward::singleton();
+
+        $this->types = array_keys($this->koward->objects);
+        if (empty($this->types)) {
+            throw new Koward_Exception('No object types have been configured!');
+        }
+
+        $this->menu = $this->getMenu();
+
+        $this->theme = isset($this->koward->conf['koward']['theme']) ? $this->koward->conf['koward']['theme'] : 'koward';
+    }
+
+    /**
+     * Builds Koward's list of menu items.
+     */
+    public function getMenu()
+    {
+        global $registry;
+
+        require_once 'Horde/Menu.php';
+        $menu = new Menu();
+
+        $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'listall')),
+                   _("_Objects"), 'user.png', $registry->getImageDir('horde'));
+        $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'edit')),
+                   _("_Add"), 'plus.png', $registry->getImageDir('horde'));
+        $menu->add($this->urlFor(array('controller' => 'object', 'action' => 'search')),
+                   _("_Search"), 'search.png', $registry->getImageDir('horde'));
+        $menu->add(Horde::applicationUrl('Queries'), _("_Queries"), 'query.png', $registry->getImageDir('koward'));
+        $menu->add($this->urlFor(array('controller' => 'check', 'action' => 'show')),
+                   _("_Test"), 'problem.png', $registry->getImageDir('horde'));
+        return $menu;
+    }
+}
diff --git a/koward/lib/Koward/Controller/CheckController.php b/koward/lib/Koward/Controller/CheckController.php
new file mode 100644 (file)
index 0000000..c3642f7
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/**
+ * @package Koward
+ */
+
+/**
+ * @package Koward
+ */
+class CheckController extends Koward_Controller_Application
+{
+
+    protected function _initializeApplication()
+    {
+        parent::_initializeApplication();
+
+        $this->suite = Koward_Test_AllTests::suite();
+    }
+
+    public function show()
+    {
+        $this->list = array();
+
+        $this->list[0] = Horde::link(
+            $this->urlFor(array('controller' => 'check',
+                                'action' => 'run',
+                                'id' => 'all')),
+            _("All tests")) . _("All tests") . '</a>';
+
+        $this->list[1] = '';
+
+        for ($i = 0; $i < $this->suite->count(); $i++) {
+            $class_name = $this->suite->testAt($i)->getName();
+            $this->list[$i + 2] = Horde::link(
+                $this->urlFor(array('controller' => 'check',
+                                    'action' => 'run',
+                                    'id' => $i + 1)),
+                $class_name) . $class_name . '</a>';
+        }
+    }
+
+    public function run()
+    {
+        
+        if ($this->params['id'] == 'all') {
+            $this->test = $this->suite;
+        } else {
+            $id = (int) $this->params['id'];
+            if (!empty($id)) {
+                $this->test = $this->suite->testAt($id - 1);
+            } else {
+                $this->test = null;
+                $this->koward->notification->push(_("You selected no test!"));
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/Controller/IndexController.php b/koward/lib/Koward/Controller/IndexController.php
new file mode 100644 (file)
index 0000000..52dba4c
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+/**
+ * @package Koward
+ */
+
+/**
+ * @package Koward
+ */
+class IndexController extends Koward_Controller_Application
+{
+    protected $welcome;
+
+    public function index()
+    {
+        $this->title = _("Index");
+        $this->welcome = _("Welcome to the Koward administration interface");
+    }
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/Controller/ObjectController.php b/koward/lib/Koward/Controller/ObjectController.php
new file mode 100644 (file)
index 0000000..e93f5e6
--- /dev/null
@@ -0,0 +1,273 @@
+<?php
+/**
+ * @package Koward
+ */
+
+// @TODO Clean up
+require_once dirname(__FILE__) . '/ApplicationController.php';
+
+/**
+ * @package Koward
+ */
+class ObjectController extends Koward_ApplicationController
+{
+
+    var $object_type;
+    var $objectlist;
+    var $attributes;
+    var $tabs;
+    var $object;
+    var $post;
+
+    public function listall()
+    {
+        require_once 'Horde/UI/Tabs.php';
+        require_once 'Horde/Variables.php';
+
+        $this->object_type = $this->params->get('id', $this->types[0]);
+
+        if (isset($this->koward->objects[$this->object_type]['list_attributes'])) {
+            $this->attributes = $this->koward->objects[$this->object_type]['list_attributes'];
+        } else if (isset($this->koward->objects[$this->object_type]['attributes']['fields'])) {
+            $this->attributes = $this->koward->objects[$this->object_type]['attributes']['fields'];
+        } else {
+            $this->koward->notification->push(sprintf('No attributes have been defined for the list view of objects with type %s.',
+                                                      $this->object_type),
+                                              'horde.error');
+        }
+
+        if (isset($this->attributes)
+            && isset($this->koward->objects[$this->object_type])) {
+            $params = array('attributes' => array_keys($this->attributes));
+            $class = $this->koward->objects[$this->object_type]['class'];
+            $this->objectlist = $this->koward->server->listHash($class,
+                                                                $params);
+            foreach ($this->objectlist as $uid => $info) {
+                $this->objectlist[$uid]['edit_url'] = Horde::link(
+                    $this->urlFor(array('controller' => 'object', 
+                                        'action' => 'edit',
+                                        'id' => $uid)),
+                    _("Edit")) . Horde::img('edit.png', _("Edit"), '',
+                                            $GLOBALS['registry']->getImageDir('horde'))
+                    . '</a>';
+                $this->objectlist[$uid]['delete_url'] = Horde::link(
+                    $this->urlFor(array('controller' => 'object', 
+                                        'action' => 'delete',
+                                        'id' => $uid)),
+                    _("Delete")) . Horde::img('delete.png', _("Delete"), '',
+                                              $GLOBALS['registry']->getImageDir('horde'))
+                    . '</a>';
+                $this->objectlist[$uid]['view_url'] = Horde::link(
+                    $this->urlFor(array('controller' => 'object', 
+                                        'action' => 'view',
+                                        'id' => $uid)), _("View"));
+            }
+        }
+
+        $this->tabs = new Horde_UI_Tabs(null, Variables::getDefaultVariables());
+        foreach ($this->koward->objects as $key => $configuration) {
+            $this->tabs->addTab($configuration['list_label'],
+                                $this->urlFor(array('controller' => 'object', 
+                                                    'action' => 'listall',
+                                                    'id' => $key)),
+                                $key);
+        }
+
+        $this->render();
+    }
+
+    public function delete()
+    {
+        try {
+            if (empty($this->params->id)) {
+                $this->koward->notification->push(_("The object that should be deleted has not been specified."),
+                                                 'horde.error');
+            } else {
+                $this->object = $this->koward->getObject($this->params->id);
+                $this->submit_url = $this->urlFor(array('controller' => 'object',
+                                                        'action' => 'delete',
+                                                        'id' => $this->params->id,
+                                                        'token' => $this->koward->getRequestToken('object.delete')));
+                $this->return_url = $this->urlFor(array('controller' => 'object', 
+                                                        'action' => 'listall'));
+
+                if (!empty($this->params->token)) {
+                    if (is_array($this->params->token) && count($this->params->token) == 1) {
+                        $token = $this->params->token[0];
+                    } else {
+                        $token = $this->params->token;
+                    }
+                    $this->koward->checkRequestToken('object.delete', $token);
+                    $result = $this->object->delete();
+                    if ($result === true) {
+                        $this->koward->notification->push(sprintf(_("Successfully deleted the object \"%s\""),
+                                                                  $this->params->id),
+                                                          'horde.message');
+                    } else {
+                        $this->koward->notification->push(_("Failed to delete the object."),
+                                                          'horde.error');
+                    }
+                    header('Location: ' . $this->urlFor(array('controller' => 'object', 
+                                                              'action' => 'listall')));
+                    exit;
+                }
+            }
+        } catch (Exception $e) {
+            $this->koward->notification->push($e->getMessage(), 'horde.error');
+        }
+
+        $this->render();
+    }
+
+    public function view()
+    {
+        try {
+            if (empty($this->params->id)) {
+                $this->koward->notification->push(_("The object that should be viewed has not been specified."),
+                                                 'horde.error');
+            } else {
+                require_once 'Horde/Variables.php';
+
+                $this->object = $this->koward->getObject($this->params->id);
+
+                $actions = $this->object->getActions();
+                if (!empty($actions)) {
+                    $this->actions = new Koward_Form_Actions($this->object);
+
+                    $this->post = $this->urlFor(array('controller' => 'object', 
+                                                      'action' => 'view',
+                                                      'id' => $this->params->id));
+
+                    if ($this->actions->validate()) {
+                        $this->actions->execute();
+                    }
+                }
+
+                $this->vars = Variables::getDefaultVariables();
+                $this->form = new Koward_Form_Object($this->vars, $this->object,
+                                                    array('title' => _("View object")));
+                $this->edit = Horde::link(
+                    $this->urlFor(array('controller' => 'object', 
+                                        'action' => 'edit',
+                                        'id' => $this->params->id)),
+                    _("Edit")) . Horde::img('edit.png', _("Edit"), '',
+                                            $GLOBALS['registry']->getImageDir('horde'))
+                    . '</a>';
+
+
+            }
+        } catch (Exception $e) {
+            $this->koward->notification->push($e->getMessage(), 'horde.error');
+        }
+
+        $this->render();
+    }
+
+    public function edit()
+    {
+        try {
+            if (empty($this->params->id)) {
+                $this->object = null;
+            } else {
+                $this->object = $this->koward->getObject($this->params->id);
+            }
+
+            require_once 'Horde/Variables.php';
+            $this->vars = Variables::getDefaultVariables();
+            foreach ($this->params as $key => $value) {
+                if (!$this->vars->exists($key)) {
+                    if (is_array($value) && count($value) == 1) {
+                        $this->vars->set($key, $value[0]);
+                    } else {
+                        $this->vars->set($key, $value);
+                    }
+                }
+            }
+            $this->form = new Koward_Form_Object($this->vars, $this->object);
+
+            if ($this->form->validate()) {
+                $object = $this->form->execute();
+
+                if (!empty($object)) {
+                    header('Location: ' . $this->urlFor(array('controller' => 'object', 
+                                                              'action' => 'view',
+                                                              'id' => $object->get(Horde_Kolab_Server_Object::ATTRIBUTE_UID))));
+                    exit;
+                }
+            }
+        } catch (Exception $e) {
+            $this->koward->notification->push($e->getMessage(), 'horde.error');
+        }
+
+        $this->post = $this->urlFor(array('controller' => 'object', 
+                                          'action' => 'edit',
+                                          'id' => $this->params->id));
+
+        $this->render();
+    }
+
+    public function search()
+    {
+        try {
+            require_once 'Horde/Variables.php';
+            $this->vars = Variables::getDefaultVariables();
+            $this->form = new Koward_Form_Search($this->vars, $this->object);
+
+            if ($this->form->validate()) {
+                $result = $this->form->execute();
+
+                $uids = array_keys($result);
+
+                if (count($uids) == 1) {
+                    header('Location: ' . $this->urlFor(array('controller' => 'object', 
+                                                              'action' => 'view',
+                                                              'id' => $uids[0])));
+                    exit;
+                } else if (count($uids) == 0) {
+                    $this->koward->notification->push(_("No results found!"), 'horde.message');
+                } else {
+                    if (isset($this->koward->search['list_attributes'])) {
+                        $this->attributes = $this->koward->search['list_attributes'];
+                    } else {
+                        $this->attributes = array(
+                            '__id' => array(
+                                'title' => _("Kennung"),
+                                'width' => 100,
+                                'link_view'=> true,
+                            )
+                        );
+                    }
+                    foreach ($result as $uid => $info) {
+                        $this->objectlist[$uid]['edit_url'] = Horde::link(
+                            $this->urlFor(array('controller' => 'object', 
+                                                'action' => 'edit',
+                                                'id' => $uid)),
+                            _("Edit")) . Horde::img('edit.png', _("Edit"), '',
+                                                    $GLOBALS['registry']->getImageDir('horde'))
+                            . '</a>';
+                        $this->objectlist[$uid]['delete_url'] = Horde::link(
+                            $this->urlFor(array('controller' => 'object', 
+                                                'action' => 'delete',
+                                                'id' => $uid)),
+                            _("Delete")) . Horde::img('delete.png', _("Delete"), '',
+                                                      $GLOBALS['registry']->getImageDir('horde'))
+                            . '</a>';
+                        $this->objectlist[$uid]['view_url'] = Horde::link(
+                            $this->urlFor(array('controller' => 'object', 
+                                                'action' => 'view',
+                                                'id' => $uid)), _("View"));
+                        $this->objectlist[$uid]['__id'] = $uid;
+                    }
+                }
+            }
+        } catch (Exception $e) {
+            $this->koward->notification->push($e->getMessage(), 'horde.error');
+        }
+
+        $this->post = $this->urlFor(array('controller' => 'object', 
+                                          'action' => 'search'));
+
+        $this->render();
+    }
+
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/Exception.php b/koward/lib/Koward/Exception.php
new file mode 100644 (file)
index 0000000..3498db4
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * An application for managing a Kolab server.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Koward_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward_Server
+ */
+
+/**
+ * This class provides the standard error class for the Koward application.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Koward_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward_Server
+ */
+class Koward_Exception extends Exception
+{
+}
diff --git a/koward/lib/Koward/Form/Actions.php b/koward/lib/Koward/Form/Actions.php
new file mode 100644 (file)
index 0000000..73cd952
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * @package Koward
+ */
+
+/**
+ * @package Koward
+ */
+class Koward_Form_Actions extends Horde_Form {
+
+    /**
+     * The link to the application driver.
+     *
+     * @var Koward_Koward
+     */
+    protected $koward;
+
+    public function __construct(&$object)
+    {
+        $this->koward = &Koward_Koward::singleton();
+
+        $this->object = &$object;
+
+        parent::Horde_Form(Variables::getDefaultVariables());
+
+        $this->setTitle(_("Object actions"));
+
+        $class_name = get_class($this->object);
+        foreach ($this->koward->objects as $name => $config) {
+            if ($config['class'] == $class_name) {
+                $this->type = $name;
+                if (!empty($config['preferred'])) {
+                    break;
+                }
+            }
+        }
+
+        $buttons = array();
+        foreach ($this->object->getActions() as $action) {
+            if (isset($this->koward->objects[$this->type]['actions'][$action])) {
+                $buttons[] = $this->koward->objects[$this->type]['actions'][$action];
+            }
+        }
+
+        if (!empty($buttons)) {
+            $this->setButtons($buttons);
+        }
+    }
+
+    function &execute()
+    {
+        require_once 'Horde/Util.php';
+
+        $submit = Util::getFormData('submitbutton');
+        if (!empty($submit)) {
+            foreach ($this->koward->objects[$this->type]['actions'] as $action => $label) {
+                if ($submit == $label) {
+                    $this->object->$action();
+                }
+            }
+        }
+    }
+}
diff --git a/koward/lib/Koward/Form/Object.php b/koward/lib/Koward/Form/Object.php
new file mode 100644 (file)
index 0000000..dd65442
--- /dev/null
@@ -0,0 +1,250 @@
+<?php
+/**
+ * @package Koward
+ */
+
+/**
+ * @package Koward
+ */
+class Koward_Form_Object extends Horde_Form {
+
+    /**
+     * The link to the application driver.
+     *
+     * @var Koward_Koward
+     */
+    protected $koward;
+
+    public function __construct(&$vars, &$object, $params = array())
+    {
+        $this->koward = &Koward_Koward::singleton();
+
+        $this->object = &$object;
+
+        parent::Horde_Form($vars);
+
+        $type = false;
+
+        if (empty($this->object)) {
+            $title = _("Add Object");
+            $this->setButtons(_("Add"));
+
+            foreach ($this->koward->objects as $key => $config) {
+                $options[$key] = $config['label'];
+            }
+            
+            $v = &$this->addVariable(_("Choose an object type"), 'type', 'enum', true, false, null, array($options, true));
+            $action = Horde_Form_Action::factory('submit');
+            $v->setAction($action);
+            $v->setOption('trackchange', true);
+            if (is_null($vars->get('formname')) &&
+                $vars->get($v->getVarName()) != $vars->get('__old_' . $v->getVarName())) {
+                $this->koward->notification->push(sprintf(_("Selected object type \"%s\"."), $object_conf[$vars->get('type')]['label']), 'horde.message');
+            }
+
+            $type = $vars->get('type');
+        } else {
+            $title = _("Edit Object");
+            $class_name = get_class($this->object);
+            foreach ($this->koward->objects as $name => $config) {
+                if ($config['class'] == $class_name) {
+                    $type = $name;
+                    if (!empty($config['preferred'])) {
+                        break;
+                    }
+                }
+            }
+            if (empty($type)) {
+                throw new Koward_Exception('Undefined object class!');
+            }
+            if (!$this->isSubmitted()) {
+                $vars->set('type', $type);
+                $keys = array_keys($this->_getFields($this->koward->objects[$type]));
+                $vars->set('object', $this->object->toHash($keys));
+                $this->setButtons(true);
+            }
+        }
+
+        if (isset($params['title'])) {
+            $title = $params['title'];
+        }
+
+        $this->setTitle($title);
+
+        if (!empty($type)) {
+            $this->_addFields($this->koward->objects[$type]);
+        }
+    }
+
+    /**
+     * Get the fields for an object type
+     */
+    public function getTypeFields($type)
+    {
+        return $this->_getFields($this->koward->objects[$type]);
+    }
+    /**
+     * Get the fields for a configuration array.
+     */
+    private function _getFields($config)
+    {
+        if (isset($config['attributes']['fields']) && !empty($config['attributes']['override'])) {
+            return $config['attributes']['fields'];
+        } else {
+            list($attributes, $attribute_map) = $this->koward->getServer()->getAttributes($config['class']);
+
+            if (isset($this->koward->visible['show'])) {
+                $akeys = $this->koward->visible['show'];
+            } else if (isset($config['attributes']['show'])) {
+                $akeys = $config['attributes']['show'];
+            } else {
+                $akeys = array_keys($attributes);
+                if (isset($config['attributes']['hide'])) {
+                    $akeys = array_diff($akeys, $config['attributes']['hide']);
+                }
+            }
+
+            $form_attributes = array();
+
+            foreach ($akeys as $key) {
+                if ((isset($this->koward->visible['hide'])
+                     && in_array($key, $this->koward->visible['hide']))
+                    || (isset($config['attributes']['hide'])
+                        && in_array($key, $config['attributes']['hide']))) {
+                    continue;
+                }
+
+                if (isset($config['attributes']['type'][$key])) {
+                    $type = $config['attributes']['type'][$key];
+                } else if (isset($attributes[$key]['syntax'])) {
+                    list($syntax, $length) = explode('{', $attributes[$key]['syntax'], 2);
+                    switch ($syntax) {
+                    case '1.3.6.1.4.1.1466.115.121.1.22':
+                    case '1.3.6.1.4.1.1466.115.121.1.50':
+                        $type = 'phone';
+                        break;
+                    case '1.3.6.1.4.1.1466.115.121.1.28':
+                        $type = 'image';
+                        break;
+                    default:
+                        $type = 'text';
+                        break;
+                    }
+                } else {
+                    $type = 'text';
+                }
+
+                $locked = in_array($key, $attribute_map['locked']) && !empty($this->object);
+                if (!$locked) {
+                    $required = in_array($key, $attribute_map['required'])  && empty($this->object);
+                }
+
+                $form_attributes[$key] = array(
+                    'type' => $type,
+                    'required' => $required,
+                    'readonly' => $locked,
+                    'params' => array('regex' => '', 'size' => 40, 'maxlength' => 255)
+                );
+                if (isset($config['attributes']['order'][$key])) {
+                    $form_attributes[$key]['order'] = $config['attributes']['order'][$key];
+                } else if (isset($this->koward->order[$key])) {
+                    $form_attributes[$key]['order'] = $this->koward->order[$key];
+                } else {
+                    $form_attributes[$key]['order'] = -1;
+                }
+                if (isset($config['attributes']['labels'][$key])) {
+                    $form_attributes[$key]['label'] = $config['attributes']['labels'][$key];
+                } else if (isset($this->koward->labels[$key])) {
+                    $form_attributes[$key]['label'] = $this->koward->labels[$key];
+                } else {
+                    $form_attributes[$key]['label'] = $key;
+                }
+                if (isset($config['attributes']['fields'][$key])) {
+                    $form_attributes[$key] = array_merge($form_attributes[$key],
+                                                         $config['attributes']['fields'][$key]);
+                }
+            }
+            uasort($form_attributes, array($this, '_sortFields'));
+            return $form_attributes;
+        }
+        return array();
+    }
+
+    /**
+     * Sort fields for an object type
+     */
+    function _sortFields($a, $b)
+    {
+        if ($a['order'] == -1) {
+            return 1;
+        }
+        if ($b['order'] == -1) {
+            return -1;
+        }
+        if ($a['order'] == $b['order']) {
+            return 0;
+        }
+        return ($a['order'] < $b['order']) ? -1 : 1;
+    }
+
+    /**
+     * Set up the Horde_Form fields for the attributes of this object type.
+     */
+    function _addFields($config)
+    {
+        // Now run through and add the form variables.
+        $fields = $this->_getFields($config);
+        $tabs   = isset($config['tabs']) ? $config['tabs'] : array('' => $fields);
+
+        foreach ($tabs as $tab => $tab_fields) {
+            if (!empty($tab)) {
+                $this->setSection($tab, $tab);
+            }
+            foreach ($tab_fields as $key => $field) {
+                if (!in_array($key, array_keys($fields))
+                    //                    || !isset($this->koward->attributes[$key])
+                ) {
+                    continue;
+                }
+                $attribute = $field;
+                //                $attribute = $this->koward->attributes[$key];
+                $params = isset($attribute['params']) ? $attribute['params'] : array();
+                $desc = isset($attribute['desc']) ? $attribute['desc'] : null;
+
+                $readonly = isset($attribute['readonly']) ? $attribute['readonly'] : null;
+                $v = &$this->addVariable($attribute['label'], 'object[' . $key . ']', $attribute['type'], $attribute['required'], $readonly, $desc, $params);
+            }
+
+            if (isset($attribute['default'])) {
+                $v->setDefault($attribute['default']);
+            }
+        }
+    }
+
+    function &execute()
+    {
+        $this->getInfo($this->_vars, $info);
+        if (isset($info['object'])) {
+            if (empty($this->object)) {
+                if (isset($info['type'])) {
+                    if (isset($this->koward->objects[$info['type']]['class'])) {
+                        $class = $this->koward->objects[$info['type']]['class'];
+                    } else {
+                        throw new Koward_Exception(sprintf('Invalid type \"%s\" specified!',
+                                                           $info['type']));
+                    }
+                    $object = $this->koward->getServer()->add(array_merge(array('type' => $class),
+                                                                 $info['object']));
+                    $this->koward->notification->push(_("Successfully added the object."),
+                                                      'horde.message');
+                    return $object;
+                }
+            } else {
+                $this->object->save($info['object']);
+                $this->koward->notification->push(_("Successfully updated the object."),
+                                                 'horde.message');
+                return $this->object;
+            }
+        }
+    }
+}
diff --git a/koward/lib/Koward/Form/Search.php b/koward/lib/Koward/Form/Search.php
new file mode 100644 (file)
index 0000000..7e8a8a7
--- /dev/null
@@ -0,0 +1,100 @@
+<?php
+/**
+ * @package Koward
+ */
+
+/**
+ * @package Koward
+ */
+class Koward_Form_Search extends Horde_Form {
+
+    /**
+     * The link to the application driver.
+     *
+     * @var Koward_Koward
+     */
+    protected $koward;
+
+    public function __construct(&$vars, &$object, $params = array())
+    {
+        $this->koward = &Koward_Koward::singleton();
+
+        $this->object = &$object;
+
+        parent::Horde_Form($vars);
+
+        $type = false;
+
+        $this->setButtons(_("Search"));
+        $this->_addFields($this->koward->search);
+    }
+
+
+    /**
+     * Sort fields for an object type
+     */
+    function _sortFields($a, $b)
+    {
+        if ($a['order'] == -1) {
+            return 1;
+        }
+        if ($b['order'] == -1) {
+            return -1;
+        }
+        if ($a['order'] == $b['order']) {
+            return 0;
+        }
+        return ($a['order'] < $b['order']) ? -1 : 1;
+    }
+
+    /**
+     * Set up the Horde_Form fields for the attributes of this object type.
+     */
+    function _addFields($config)
+    {
+        // Now run through and add the form variables.
+        $tabs   = isset($config['tabs']) ? $config['tabs'] : array('' => $config['fields']);
+
+        foreach ($tabs as $tab => $tab_fields) {
+            if (!empty($tab)) {
+                $this->setSection($tab, $tab);
+            }
+            foreach ($tab_fields as $key => $field) {
+                if (!in_array($key, array_keys($config['fields']))) {
+                    continue;
+                }
+                $attribute = $field;
+                $params = isset($attribute['params']) ? $attribute['params'] : array();
+                $desc = isset($attribute['desc']) ? $attribute['desc'] : null;
+
+                $v = &$this->addVariable($attribute['label'], 'object[' . $key . ']', $attribute['type'], $attribute['required'], null, $desc, $params);
+            }
+
+            if (isset($attribute['default'])) {
+                $v->setDefault($attribute['default']);
+            }
+        }
+    }
+
+    function &execute()
+    {
+        $this->getInfo($this->_vars, $info);
+        if (isset($info['object'])) {
+            $search_criteria = array();
+            foreach ($info['object'] as $key => $value) {
+                if (!empty($value)) {
+                    $search_criteria[] = array('field' => $key,
+                                               'op'    => 'contains',
+                                               'test' => $value);
+                }
+            }
+            $search_criteria = array('AND' => $search_criteria);
+            $criteria = array('AND' => array($search_criteria,
+                                             $this->koward->search['criteria']));
+            $filter = $this->koward->getServer()->searchQuery($criteria);
+            $params = array('scope' => 'sub',
+                            'attributes' => array('dn'));
+            return $this->koward->getServer()->search($filter, $params);
+        }
+    }
+}
diff --git a/koward/lib/Koward/Test.php b/koward/lib/Koward/Test.php
new file mode 100644 (file)
index 0000000..62b9379
--- /dev/null
@@ -0,0 +1,173 @@
+<?php
+/**
+ * Base for PHPUnit scenarios.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward
+ */
+
+/**
+ * Base for PHPUnit scenarios.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward
+ */
+class Koward_Test extends Horde_Kolab_Test_Storage
+{
+    /**
+     * Prepare the configuration.
+     *
+     * @return NULL
+     */
+    public function prepareConfiguration()
+    {
+        $fh = fopen(HORDE_BASE . '/config/conf.php', 'w');
+        $data = <<<EOD
+\$conf['use_ssl'] = 2;
+\$conf['server']['name'] = \$_SERVER['SERVER_NAME'];
+\$conf['server']['port'] = \$_SERVER['SERVER_PORT'];
+\$conf['debug_level'] = E_ALL;
+\$conf['umask'] = 077;
+\$conf['compress_pages'] = true;
+\$conf['menu']['always'] = false;
+\$conf['portal']['fixed_blocks'] = array();
+\$conf['imsp']['enabled'] = false;
+
+/** Additional config variables required for a clean Horde setup */
+\$conf['session']['use_only_cookies'] = false;
+\$conf['session']['timeout'] = 0;
+\$conf['cookie']['path'] = '/';
+\$conf['cookie']['domain'] = \$_SERVER['SERVER_NAME'];
+\$conf['use_ssl'] = false;
+\$conf['session']['cache_limiter'] = 'nocache';
+\$conf['session']['name'] = 'Horde';
+\$conf['log']['enabled'] = false;
+\$conf['prefs']['driver'] = 'session';
+\$conf['auth']['driver'] = 'kolab';
+\$conf['share']['driver'] = 'kolab';
+\$conf['server']['token_lifetime'] = 3600;
+\$conf['debug_level'] = E_ALL;
+
+/** Make the share driver happy */
+\$conf['kolab']['enabled'] = true;
+
+/** Ensure we still use the LDAP test driver */
+\$conf['kolab']['server']['driver'] = 'test';
+
+/** Ensure that we do not trigger on folder update */
+\$conf['kolab']['no_triggering'] = true;
+
+/** Storage location for the free/busy system */
+\$conf['fb']['cache_dir']             = '/tmp';
+\$conf['kolab']['freebusy']['server'] = 'https://fb.example.org/freebusy';
+
+/** Setup the virtual file system for Kolab */
+\$conf['vfs']['params']['all_folders'] = true;
+\$conf['vfs']['type'] = 'kolab';
+
+\$conf['kolab']['ldap']['phpdn'] = null;
+\$conf['fb']['use_acls'] = true;
+EOD;
+        fwrite($fh, "<?php\n" . $data);
+        fclose($fh);
+    }
+
+    /**
+     * Prepare the registry.
+     *
+     * @return NULL
+     */
+    public function prepareRegistry()
+    {
+        $fh = fopen(HORDE_BASE . '/config/registry.php', 'w');
+        $data = <<<EOD
+\$this->applications['horde'] = array(
+    'fileroot' => dirname(__FILE__) . '/..',
+    'webroot' => '/',
+    'initial_page' => 'login.php',
+    'name' => _("Horde"),
+    'status' => 'active',
+    'templates' => dirname(__FILE__) . '/../templates',
+    'provides' => 'horde',
+);
+
+\$this->applications['koward'] = array(
+    'fileroot' => KOWARD_BASE,
+    'webroot' => \$this->applications['horde']['webroot'] . '/koward',
+    'name' => _("Koward"),
+    'status' => 'active',
+    'initial_page' => 'index.php',
+);
+EOD;
+        fwrite($fh, "<?php\n" . $data);
+        fclose($fh);
+        if (!file_exists(HORDE_BASE . '/config/registry.d')) {
+            mkdir(HORDE_BASE . '/config/registry.d');
+        }
+    }
+
+    /**
+     * Handle a "given" step.
+     *
+     * @param array  &$world    Joined "world" of variables.
+     * @param string $action    The description of the step.
+     * @param array  $arguments Additional arguments to the step.
+     *
+     * @return mixed The outcome of the step.
+     */
+    public function runGiven(&$world, $action, $arguments)
+    {
+        switch($action) {
+        default:
+            return parent::runGiven($world, $action, $arguments);
+        }
+    }
+
+    /**
+     * Handle a "when" step.
+     *
+     * @param array  &$world    Joined "world" of variables.
+     * @param string $action    The description of the step.
+     * @param array  $arguments Additional arguments to the step.
+     *
+     * @return mixed The outcome of the step.
+     */
+    public function runWhen(&$world, $action, $arguments)
+    {
+        switch($action) {
+        default:
+            return parent::runWhen($world, $action, $arguments);
+        }
+    }
+
+    /**
+     * Handle a "then" step.
+     *
+     * @param array  &$world    Joined "world" of variables.
+     * @param string $action    The description of the step.
+     * @param array  $arguments Additional arguments to the step.
+     *
+     * @return mixed The outcome of the step.
+     */
+    public function runThen(&$world, $action, $arguments)
+    {
+        switch($action) {
+        default:
+            return parent::runThen($world, $action, $arguments);
+        }
+    }
+
+}
diff --git a/koward/lib/Koward/Test/AllTests.php b/koward/lib/Koward/Test/AllTests.php
new file mode 100644 (file)
index 0000000..0346a55
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/**
+ * All server tests for the Kolab server.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+
+/**
+ * The Autoloader allows us to omit "require/include" statements.
+ */
+require_once 'Horde/Autoloader.php';
+
+/**
+ * Combine the tests for this package.
+ *
+ * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Server
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Server
+ */
+class Koward_Test_AllTests
+{
+
+    /**
+     * Main entry point for running the suite.
+     *
+     * @return NULL
+     */
+    public static function main()
+    {
+        PHPUnit_TextUI_TestRunner::run(self::suite());
+    }
+
+    /**
+     * Collect the unit tests of this directory into a new suite.
+     *
+     * @return PHPUnit_Framework_TestSuite The test suite.
+     */
+    public static function suite()
+    {
+        // Catch strict standards
+        // FIXME: This does not work yet, as we still have a number of
+        //        static methods in basic Horde libraries that are not
+        //        declared as such.
+        //error_reporting(E_ALL | E_STRICT);
+
+        $suite = new PHPUnit_Framework_TestSuite('Kolab server test suite');
+
+        $basedir    = dirname(__FILE__);
+        $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/');
+
+        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir)) as $file) {
+            if ($file->isFile() && preg_match('/Test.php$/', $file->getFilename())) {
+                $pathname = $file->getPathname();
+                require $pathname;
+
+                $class = str_replace(DIRECTORY_SEPARATOR, '_',
+                                     preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname));
+                $suite->addTestSuite('Koward_Test_' . $class);
+            }
+        }
+
+        return $suite;
+    }
+
+}
diff --git a/koward/lib/Koward/Test/Renderer.php b/koward/lib/Koward/Test/Renderer.php
new file mode 100644 (file)
index 0000000..e8308aa
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+class Koward_Test_Renderer extends PHPUnit_Extensions_Story_ResultPrinter_HTML
+{
+    /**
+     * Constructor.
+     *
+     * @param  mixed   $out
+     * @throws InvalidArgumentException
+     */
+    public function __construct($out = NULL)
+    {
+        parent::__construct($out);
+
+        $this->templatePath = sprintf(
+          '%s%sTemplate%s',
+
+          dirname(__FILE__),
+          DIRECTORY_SEPARATOR,
+          DIRECTORY_SEPARATOR
+        );
+    }
+
+    /**
+     * @param  string $buffer
+     */
+    public function write($buffer)
+    {
+        if ($this->out !== NULL) {
+            fwrite($this->out, $buffer);
+
+            if ($this->autoFlush) {
+                $this->incrementalFlush();
+            }
+        } else {
+
+            print $buffer;
+
+            if ($this->autoFlush) {
+                $this->incrementalFlush();
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/Test/Server/UserTest.php b/koward/lib/Koward/Test/Server/UserTest.php
new file mode 100644 (file)
index 0000000..d2f0559
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Test the user object.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward
+ */
+
+/**
+ * Test the user object.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Koward
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Koward
+ */
+class Koward_Test_Server_UserTest extends Horde_Kolab_Test_Server {
+
+    /**
+     * Test listing users if there are no users.
+     *
+     * @scenario
+     *
+     * @return NULL
+     */
+    public function listingUsersOnEmptyServer()
+    {
+        $this->given('the current Kolab server')
+            ->when('listing all users')
+            ->then('the list is an empty array');
+    }
+}
diff --git a/koward/lib/Koward/Test/Template/scenario.html.dist b/koward/lib/Koward/Test/Template/scenario.html.dist
new file mode 100644 (file)
index 0000000..caa149a
--- /dev/null
@@ -0,0 +1,13 @@
+   <tr>
+    <td>
+     <p class="{scenarioStatus}" onclick="showHide('{id}', this)">[+] {name}</p>
+    </td>
+   </tr>
+   <tr>
+    <td>
+     <table border="0" width="100%" class="{scenarioStatus} scenarioStepsTable" id="stepContainer{id}">
+{steps}
+     </table>
+    </td>
+   </tr>
+
diff --git a/koward/lib/Koward/Test/Template/scenario_header.html.dist b/koward/lib/Koward/Test/Template/scenario_header.html.dist
new file mode 100644 (file)
index 0000000..7b205d1
--- /dev/null
@@ -0,0 +1,6 @@
+   <tr>
+    <td>
+     <p class="header">{name}</p>
+    </td>
+   </tr>
+
diff --git a/koward/lib/Koward/Test/Template/scenarios.html.dist b/koward/lib/Koward/Test/Template/scenarios.html.dist
new file mode 100644 (file)
index 0000000..1037cfb
--- /dev/null
@@ -0,0 +1,54 @@
+  <style type ="text/css">
+  .scenarioSuccess { color: green; }
+  .scenario { color: black; }
+  .scenarioFailed { color: red; }
+  .scenarioSkipped { color: teal; }
+  .scenarioIncomplete { color: gray; }
+  .scenarioStepsTable { margin-left: 10px; display: none; }
+  .stepName { }
+  </style>
+
+  <script type="text/javascript">
+  function showHide(nodeId, linkObj)
+  {
+    var subObj = document.getElementById('stepContainer' + nodeId);
+
+    if (linkObj.innerHTML.indexOf('+')>0) {
+      linkObj.innerHTML = linkObj.innerHTML.replace('+','-');
+      subObj.style.display='block';
+      subObj.style.width = '100%';
+    } else {
+      linkObj.innerHTML = linkObj.innerHTML.replace('-','+');
+      subObj.style.display='none';
+    }
+  }
+  </script>
+
+  <table border="0" width="100%" style="margin: 20 px">
+{scenarios}
+   <tr>
+    <td>
+     <p style="margin-top: 20px;" id="Summary" onclick="showHide('Summary', this)">[+] Summary:</p>
+     <div style="margin-left: 10px; display:none" id="stepContainerSummary">
+      <table border="0">
+       <tr>
+        <td width="250" class="scenarioSuccess">Successful scenarios:</td>
+        <td class="scenarioSuccessValue">{successfulScenarios}</td>
+       </tr>
+       <tr>
+        <td class="scenarioFailed">Failed scenarios:</td>
+        <td class="scenarioFailedValue">{failedScenarios}</td>
+       </tr>
+       <tr>
+        <td class="scenarioSkipped">Skipped scenarios:</td>
+        <td class="scenarioSkippedValue">{skippedScenarios}</td>
+       </tr>
+       <tr>
+        <td class="scenarioIncomplete">Incomplete scenarios:</td>
+        <td class="scenarioIncompleteValue">{incompleteScenarios}</td>
+       </tr>
+      </table>
+     </div>
+    </td>
+   </tr>
+  </table>
diff --git a/koward/lib/Koward/Test/Template/step.html.dist b/koward/lib/Koward/Test/Template/step.html.dist
new file mode 100644 (file)
index 0000000..bcdce3f
--- /dev/null
@@ -0,0 +1,6 @@
+      <tr>
+       <td width="60">{text}</td>
+       <td class="stepName">{action}</td>
+       <td>&nbsp;</td>
+      </tr>
+
diff --git a/koward/lib/Koward/View/Check/run.html.php b/koward/lib/Koward/View/Check/run.html.php
new file mode 100644 (file)
index 0000000..ea945e8
--- /dev/null
@@ -0,0 +1,10 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+
+<?php
+if (!empty($this->test)) {
+    ob_start();
+    $listener = new Koward_Test_Renderer();
+    PHPUnit_TextUI_TestRunner::run($this->test, array('listeners' => array($listener)));
+    echo ob_get_clean();
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/View/Check/show.html.php b/koward/lib/Koward/View/Check/show.html.php
new file mode 100644 (file)
index 0000000..f58908f
--- /dev/null
@@ -0,0 +1,9 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+
+<?php
+
+foreach ($this->list as $test) {
+    echo $test;
+    echo '<br/>';
+}
\ No newline at end of file
diff --git a/koward/lib/Koward/View/Index/index.html.php b/koward/lib/Koward/View/Index/index.html.php
new file mode 100644 (file)
index 0000000..0696b72
--- /dev/null
@@ -0,0 +1,6 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+
+<div class="contenttext">
+   <h1><?= $this->welcome ?></h1>
+</div>
diff --git a/koward/lib/Koward/View/Modify/add.html.php b/koward/lib/Koward/View/Modify/add.html.php
new file mode 100644 (file)
index 0000000..fb15bbe
--- /dev/null
@@ -0,0 +1,6 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+
+<?php
+$this->form->renderActive(new Horde_Form_Renderer(), $vars, 'modify', 'post');
+
diff --git a/koward/lib/Koward/View/Object/delete.html.php b/koward/lib/Koward/View/Object/delete.html.php
new file mode 100644 (file)
index 0000000..8e74c09
--- /dev/null
@@ -0,0 +1,15 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+
+<form action="<?= $this->submit_url ?>" method="post" name="delete">
+<?php echo Util::formInput() ?>
+
+<div class="headerbox">
+
+ <p><?php echo _("Permanently delete this object?") ?></p>
+
+ <input type="submit" class="button" name="delete" value="<?php echo _("Delete") ?>" />
+ <a class="button" href="<?= $this->return_url ?>"><?php echo _("Cancel") ?></a>
+</div>
+
+</form>
diff --git a/koward/lib/Koward/View/Object/edit.html.php b/koward/lib/Koward/View/Object/edit.html.php
new file mode 100644 (file)
index 0000000..5185924
--- /dev/null
@@ -0,0 +1,4 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+<?= $this->form->renderActive(new Horde_Form_Renderer(), $this->vars,
+                              $this->post, 'post'); ?>
\ No newline at end of file
diff --git a/koward/lib/Koward/View/Object/listall.html.php b/koward/lib/Koward/View/Object/listall.html.php
new file mode 100644 (file)
index 0000000..a790967
--- /dev/null
@@ -0,0 +1,40 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+
+<?= $this->tabs->render($this->object_type); ?>
+
+<?php if (isset($this->objectlist)): ?>
+
+<table cellspacing="0" width="100%" class="linedRow">
+ <thead>
+  <tr>
+   <th class="item" width="1%"><?php echo Horde::img('edit.png', _("Edit"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <th class="item" width="1%"><?php echo Horde::img('delete.png', _("Delete"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <?php foreach ($this->attributes as $attribute => $info): ?>
+     <th class="item leftAlign" width="<?php echo $info['width'] ?>%" nowrap="nowrap"><?= $info['title'] ?></th>
+   <?php endforeach; ?>
+  </tr>
+ </thead>
+ <tbody>
+  <?php foreach ($this->objectlist as $dn => $info): ?>
+  <tr>
+   <td>
+    <?= $info['edit_url'] ?>
+   </td> 
+   <td>
+    <?= $info['delete_url'] ?>
+   </td> 
+   <?php foreach ($this->attributes as $attribute => $ainfo): ?>
+   <td>
+   <?php if (!empty($ainfo['link_view'])): ?>
+   <?= $info['view_url'] . $this->escape($info[$attribute]) . '</a>'; ?>
+   <?php else: ?>
+    <?= $this->escape($info[$attribute]) ?>
+   <?php endif; ?>
+   </td> 
+   <?php endforeach; ?>
+  </tr> 
+  <?php endforeach; ?>
+ </tbody>
+</table>
+<?php endif; ?>
diff --git a/koward/lib/Koward/View/Object/search.html.php b/koward/lib/Koward/View/Object/search.html.php
new file mode 100644 (file)
index 0000000..3059c8e
--- /dev/null
@@ -0,0 +1,40 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+<?php if (empty($this->objectlist)): ?>
+  <?= $this->form->renderActive(new Horde_Form_Renderer(), $this->vars,
+                                $this->post, 'post'); ?>
+<?php else: ?>
+<table cellspacing="0" width="100%" class="linedRow">
+ <thead>
+  <tr>
+   <th class="item" width="1%"><?php echo Horde::img('edit.png', _("Edit"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <th class="item" width="1%"><?php echo Horde::img('delete.png', _("Delete"), '', $GLOBALS['registry']->getImageDir('horde')) ?></th>
+   <?php foreach ($this->attributes as $attribute => $info): ?>
+     <th class="item leftAlign" width="<?php echo $info['width'] ?>%" nowrap="nowrap"><?= $info['title'] ?></th>
+   <?php endforeach; ?>
+  </tr>
+ </thead>
+ <tbody>
+  <?php foreach ($this->objectlist as $dn => $info): ?>
+  <tr>
+   <td>
+    <?= $info['edit_url'] ?>
+   </td> 
+   <td>
+    <?= $info['delete_url'] ?>
+   </td> 
+   <?php foreach ($this->attributes as $attribute => $ainfo): ?>
+   <td>
+   <?php if (!empty($ainfo['link_view'])): ?>
+   <?= $info['view_url'] . $this->escape($info[$attribute]) . '</a>'; ?>
+   <?php else: ?>
+    <?= $this->escape($info[$attribute]) ?>
+   <?php endif; ?>
+   </td> 
+   <?php endforeach; ?>
+  </tr> 
+  <?php endforeach; ?>
+ </tbody>
+</table>
+
+<?php endif; ?>
diff --git a/koward/lib/Koward/View/Object/view.html.php b/koward/lib/Koward/View/Object/view.html.php
new file mode 100644 (file)
index 0000000..b9da7d2
--- /dev/null
@@ -0,0 +1,13 @@
+<?= $this->renderPartial('header'); ?>
+<?= $this->renderPartial('menu'); ?>
+<?php
+if (isset($this->actions)) {
+    echo $this->actions->renderActive(new Horde_Form_Renderer(), $this->vars,
+                                      $this->post, 'post');
+}
+
+if (isset($this->form)) {
+    echo $this->form->renderInactive(new Horde_Form_Renderer(), $this->vars);
+
+    echo $this->edit;
+}
diff --git a/koward/lib/Koward/View/shared/_header.html.php b/koward/lib/Koward/View/shared/_header.html.php
new file mode 100644 (file)
index 0000000..dc72ba8
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+if (isset($language)) {
+    header('Content-type: text/html; charset=' . NLS::getCharset());
+    header('Vary: Accept-Language');
+}
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<!--
+Koward - The Kolab warden
+
+Copyright
+
+2004 - 2009 Klarälvdalens Datakonsult AB
+2009        The Horde Project
+
+Koward is under the GPL. GNU Public License: http://www.fsf.org/copyleft/gpl.html -->
+
+<?php echo !empty($language) ? '<html lang="' . strtr($language, '_', '-') . '">' : '<html>' ?>
+<head>
+<?php
+
+global $registry;
+
+$page_title = $registry->get('name');
+$page_title .= !empty($this->title) ? ' :: ' . $this->title : '';
+
+Horde::includeScriptFiles();
+?>
+<title><?php echo htmlspecialchars($page_title) ?></title>
+<link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
+
+<?php echo Horde::stylesheetLink('koward', empty($this->print_view) ? $this->theme : 'print') ?>
+
+</head>
+
+<body>
diff --git a/koward/lib/Koward/View/shared/_menu.html.php b/koward/lib/Koward/View/shared/_menu.html.php
new file mode 100644 (file)
index 0000000..3be3269
--- /dev/null
@@ -0,0 +1,5 @@
+<div id="menu">
+ <?= $this->menu->render(); ?>
+</div>
+<?php $this->koward->notification->notify(array('listeners' => 'status')) ?>
+
diff --git a/koward/lib/Test.php b/koward/lib/Test.php
deleted file mode 100644 (file)
index 62b9379..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-<?php
-/**
- * Base for PHPUnit scenarios.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward
- */
-
-/**
- * Base for PHPUnit scenarios.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward
- */
-class Koward_Test extends Horde_Kolab_Test_Storage
-{
-    /**
-     * Prepare the configuration.
-     *
-     * @return NULL
-     */
-    public function prepareConfiguration()
-    {
-        $fh = fopen(HORDE_BASE . '/config/conf.php', 'w');
-        $data = <<<EOD
-\$conf['use_ssl'] = 2;
-\$conf['server']['name'] = \$_SERVER['SERVER_NAME'];
-\$conf['server']['port'] = \$_SERVER['SERVER_PORT'];
-\$conf['debug_level'] = E_ALL;
-\$conf['umask'] = 077;
-\$conf['compress_pages'] = true;
-\$conf['menu']['always'] = false;
-\$conf['portal']['fixed_blocks'] = array();
-\$conf['imsp']['enabled'] = false;
-
-/** Additional config variables required for a clean Horde setup */
-\$conf['session']['use_only_cookies'] = false;
-\$conf['session']['timeout'] = 0;
-\$conf['cookie']['path'] = '/';
-\$conf['cookie']['domain'] = \$_SERVER['SERVER_NAME'];
-\$conf['use_ssl'] = false;
-\$conf['session']['cache_limiter'] = 'nocache';
-\$conf['session']['name'] = 'Horde';
-\$conf['log']['enabled'] = false;
-\$conf['prefs']['driver'] = 'session';
-\$conf['auth']['driver'] = 'kolab';
-\$conf['share']['driver'] = 'kolab';
-\$conf['server']['token_lifetime'] = 3600;
-\$conf['debug_level'] = E_ALL;
-
-/** Make the share driver happy */
-\$conf['kolab']['enabled'] = true;
-
-/** Ensure we still use the LDAP test driver */
-\$conf['kolab']['server']['driver'] = 'test';
-
-/** Ensure that we do not trigger on folder update */
-\$conf['kolab']['no_triggering'] = true;
-
-/** Storage location for the free/busy system */
-\$conf['fb']['cache_dir']             = '/tmp';
-\$conf['kolab']['freebusy']['server'] = 'https://fb.example.org/freebusy';
-
-/** Setup the virtual file system for Kolab */
-\$conf['vfs']['params']['all_folders'] = true;
-\$conf['vfs']['type'] = 'kolab';
-
-\$conf['kolab']['ldap']['phpdn'] = null;
-\$conf['fb']['use_acls'] = true;
-EOD;
-        fwrite($fh, "<?php\n" . $data);
-        fclose($fh);
-    }
-
-    /**
-     * Prepare the registry.
-     *
-     * @return NULL
-     */
-    public function prepareRegistry()
-    {
-        $fh = fopen(HORDE_BASE . '/config/registry.php', 'w');
-        $data = <<<EOD
-\$this->applications['horde'] = array(
-    'fileroot' => dirname(__FILE__) . '/..',
-    'webroot' => '/',
-    'initial_page' => 'login.php',
-    'name' => _("Horde"),
-    'status' => 'active',
-    'templates' => dirname(__FILE__) . '/../templates',
-    'provides' => 'horde',
-);
-
-\$this->applications['koward'] = array(
-    'fileroot' => KOWARD_BASE,
-    'webroot' => \$this->applications['horde']['webroot'] . '/koward',
-    'name' => _("Koward"),
-    'status' => 'active',
-    'initial_page' => 'index.php',
-);
-EOD;
-        fwrite($fh, "<?php\n" . $data);
-        fclose($fh);
-        if (!file_exists(HORDE_BASE . '/config/registry.d')) {
-            mkdir(HORDE_BASE . '/config/registry.d');
-        }
-    }
-
-    /**
-     * Handle a "given" step.
-     *
-     * @param array  &$world    Joined "world" of variables.
-     * @param string $action    The description of the step.
-     * @param array  $arguments Additional arguments to the step.
-     *
-     * @return mixed The outcome of the step.
-     */
-    public function runGiven(&$world, $action, $arguments)
-    {
-        switch($action) {
-        default:
-            return parent::runGiven($world, $action, $arguments);
-        }
-    }
-
-    /**
-     * Handle a "when" step.
-     *
-     * @param array  &$world    Joined "world" of variables.
-     * @param string $action    The description of the step.
-     * @param array  $arguments Additional arguments to the step.
-     *
-     * @return mixed The outcome of the step.
-     */
-    public function runWhen(&$world, $action, $arguments)
-    {
-        switch($action) {
-        default:
-            return parent::runWhen($world, $action, $arguments);
-        }
-    }
-
-    /**
-     * Handle a "then" step.
-     *
-     * @param array  &$world    Joined "world" of variables.
-     * @param string $action    The description of the step.
-     * @param array  $arguments Additional arguments to the step.
-     *
-     * @return mixed The outcome of the step.
-     */
-    public function runThen(&$world, $action, $arguments)
-    {
-        switch($action) {
-        default:
-            return parent::runThen($world, $action, $arguments);
-        }
-    }
-
-}
diff --git a/koward/lib/Test/AllTests.php b/koward/lib/Test/AllTests.php
deleted file mode 100644 (file)
index 0346a55..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-/**
- * All server tests for the Kolab server.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-
-/**
- * The Autoloader allows us to omit "require/include" statements.
- */
-require_once 'Horde/Autoloader.php';
-
-/**
- * Combine the tests for this package.
- *
- * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Kolab_Server
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Server
- */
-class Koward_Test_AllTests
-{
-
-    /**
-     * Main entry point for running the suite.
-     *
-     * @return NULL
-     */
-    public static function main()
-    {
-        PHPUnit_TextUI_TestRunner::run(self::suite());
-    }
-
-    /**
-     * Collect the unit tests of this directory into a new suite.
-     *
-     * @return PHPUnit_Framework_TestSuite The test suite.
-     */
-    public static function suite()
-    {
-        // Catch strict standards
-        // FIXME: This does not work yet, as we still have a number of
-        //        static methods in basic Horde libraries that are not
-        //        declared as such.
-        //error_reporting(E_ALL | E_STRICT);
-
-        $suite = new PHPUnit_Framework_TestSuite('Kolab server test suite');
-
-        $basedir    = dirname(__FILE__);
-        $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/');
-
-        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir)) as $file) {
-            if ($file->isFile() && preg_match('/Test.php$/', $file->getFilename())) {
-                $pathname = $file->getPathname();
-                require $pathname;
-
-                $class = str_replace(DIRECTORY_SEPARATOR, '_',
-                                     preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname));
-                $suite->addTestSuite('Koward_Test_' . $class);
-            }
-        }
-
-        return $suite;
-    }
-
-}
diff --git a/koward/lib/Test/Renderer.php b/koward/lib/Test/Renderer.php
deleted file mode 100644 (file)
index e8308aa..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-class Koward_Test_Renderer extends PHPUnit_Extensions_Story_ResultPrinter_HTML
-{
-    /**
-     * Constructor.
-     *
-     * @param  mixed   $out
-     * @throws InvalidArgumentException
-     */
-    public function __construct($out = NULL)
-    {
-        parent::__construct($out);
-
-        $this->templatePath = sprintf(
-          '%s%sTemplate%s',
-
-          dirname(__FILE__),
-          DIRECTORY_SEPARATOR,
-          DIRECTORY_SEPARATOR
-        );
-    }
-
-    /**
-     * @param  string $buffer
-     */
-    public function write($buffer)
-    {
-        if ($this->out !== NULL) {
-            fwrite($this->out, $buffer);
-
-            if ($this->autoFlush) {
-                $this->incrementalFlush();
-            }
-        } else {
-
-            print $buffer;
-
-            if ($this->autoFlush) {
-                $this->incrementalFlush();
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/koward/lib/Test/Server/UserTest.php b/koward/lib/Test/Server/UserTest.php
deleted file mode 100644 (file)
index d2f0559..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/**
- * Test the user object.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward
- */
-
-/**
- * Test the user object.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package  Koward
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Koward
- */
-class Koward_Test_Server_UserTest extends Horde_Kolab_Test_Server {
-
-    /**
-     * Test listing users if there are no users.
-     *
-     * @scenario
-     *
-     * @return NULL
-     */
-    public function listingUsersOnEmptyServer()
-    {
-        $this->given('the current Kolab server')
-            ->when('listing all users')
-            ->then('the list is an empty array');
-    }
-}
diff --git a/koward/lib/Test/Template/scenario.html.dist b/koward/lib/Test/Template/scenario.html.dist
deleted file mode 100644 (file)
index caa149a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-   <tr>
-    <td>
-     <p class="{scenarioStatus}" onclick="showHide('{id}', this)">[+] {name}</p>
-    </td>
-   </tr>
-   <tr>
-    <td>
-     <table border="0" width="100%" class="{scenarioStatus} scenarioStepsTable" id="stepContainer{id}">
-{steps}
-     </table>
-    </td>
-   </tr>
-
diff --git a/koward/lib/Test/Template/scenario_header.html.dist b/koward/lib/Test/Template/scenario_header.html.dist
deleted file mode 100644 (file)
index 7b205d1..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-   <tr>
-    <td>
-     <p class="header">{name}</p>
-    </td>
-   </tr>
-
diff --git a/koward/lib/Test/Template/scenarios.html.dist b/koward/lib/Test/Template/scenarios.html.dist
deleted file mode 100644 (file)
index 1037cfb..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-  <style type ="text/css">
-  .scenarioSuccess { color: green; }
-  .scenario { color: black; }
-  .scenarioFailed { color: red; }
-  .scenarioSkipped { color: teal; }
-  .scenarioIncomplete { color: gray; }
-  .scenarioStepsTable { margin-left: 10px; display: none; }
-  .stepName { }
-  </style>
-
-  <script type="text/javascript">
-  function showHide(nodeId, linkObj)
-  {
-    var subObj = document.getElementById('stepContainer' + nodeId);
-
-    if (linkObj.innerHTML.indexOf('+')>0) {
-      linkObj.innerHTML = linkObj.innerHTML.replace('+','-');
-      subObj.style.display='block';
-      subObj.style.width = '100%';
-    } else {
-      linkObj.innerHTML = linkObj.innerHTML.replace('-','+');
-      subObj.style.display='none';
-    }
-  }
-  </script>
-
-  <table border="0" width="100%" style="margin: 20 px">
-{scenarios}
-   <tr>
-    <td>
-     <p style="margin-top: 20px;" id="Summary" onclick="showHide('Summary', this)">[+] Summary:</p>
-     <div style="margin-left: 10px; display:none" id="stepContainerSummary">
-      <table border="0">
-       <tr>
-        <td width="250" class="scenarioSuccess">Successful scenarios:</td>
-        <td class="scenarioSuccessValue">{successfulScenarios}</td>
-       </tr>
-       <tr>
-        <td class="scenarioFailed">Failed scenarios:</td>
-        <td class="scenarioFailedValue">{failedScenarios}</td>
-       </tr>
-       <tr>
-        <td class="scenarioSkipped">Skipped scenarios:</td>
-        <td class="scenarioSkippedValue">{skippedScenarios}</td>
-       </tr>
-       <tr>
-        <td class="scenarioIncomplete">Incomplete scenarios:</td>
-        <td class="scenarioIncompleteValue">{incompleteScenarios}</td>
-       </tr>
-      </table>
-     </div>
-    </td>
-   </tr>
-  </table>
diff --git a/koward/lib/Test/Template/step.html.dist b/koward/lib/Test/Template/step.html.dist
deleted file mode 100644 (file)
index bcdce3f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-      <tr>
-       <td width="60">{text}</td>
-       <td class="stepName">{action}</td>
-       <td>&nbsp;</td>
-      </tr>
-