From: Gunnar Wrobel
Date: Wed, 29 Apr 2009 03:35:08 +0000 (+0200)
Subject: Reorder the application to get a structure that makes sense within a PEAR package.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0a58487bbd120b9803f2613ca872ce69bec0519b;p=horde.git
Reorder the application to get a structure that makes sense within a PEAR package.
---
diff --git a/koward/app/controllers/ApplicationController.php b/koward/app/controllers/ApplicationController.php
deleted file mode 100644
index 212890b23..000000000
--- a/koward/app/controllers/ApplicationController.php
+++ /dev/null
@@ -1,40 +0,0 @@
-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
index 39bf83e5b..000000000
--- a/koward/app/controllers/CheckController.php
+++ /dev/null
@@ -1,59 +0,0 @@
-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") . '';
-
- $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 . '';
- }
- }
-
- 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
index 40e2c7702..000000000
--- a/koward/app/controllers/IndexController.php
+++ /dev/null
@@ -1,21 +0,0 @@
-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
index e93f5e623..000000000
--- a/koward/app/controllers/ObjectController.php
+++ /dev/null
@@ -1,273 +0,0 @@
-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'))
- . '';
- $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'))
- . '';
- $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'))
- . '';
-
-
- }
- } 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'))
- . '';
- $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'))
- . '';
- $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
index ea945e832..000000000
--- a/koward/app/views/Check/run.html.php
+++ /dev/null
@@ -1,10 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-
-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
index f58908fef..000000000
--- a/koward/app/views/Check/show.html.php
+++ /dev/null
@@ -1,9 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-
-list as $test) {
- echo $test;
- echo '
';
-}
\ 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
index 0696b72ec..000000000
--- a/koward/app/views/Index/index.html.php
+++ /dev/null
@@ -1,6 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-
-
-
= $this->welcome ?>
-
diff --git a/koward/app/views/Modify/add.html.php b/koward/app/views/Modify/add.html.php
deleted file mode 100644
index fb15bbee4..000000000
--- a/koward/app/views/Modify/add.html.php
+++ /dev/null
@@ -1,6 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-
-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
index 8e74c09c1..000000000
--- a/koward/app/views/Object/delete.html.php
+++ /dev/null
@@ -1,15 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-
-
diff --git a/koward/app/views/Object/edit.html.php b/koward/app/views/Object/edit.html.php
deleted file mode 100644
index 5185924e7..000000000
--- a/koward/app/views/Object/edit.html.php
+++ /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
index a790967fd..000000000
--- a/koward/app/views/Object/listall.html.php
+++ /dev/null
@@ -1,40 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-
-= $this->tabs->render($this->object_type); ?>
-
-objectlist)): ?>
-
-
-
-
- | getImageDir('horde')) ?> |
- getImageDir('horde')) ?> |
- attributes as $attribute => $info): ?>
- = $info['title'] ?> |
-
-
-
-
- objectlist as $dn => $info): ?>
-
- |
- = $info['edit_url'] ?>
- |
-
- = $info['delete_url'] ?>
- |
- attributes as $attribute => $ainfo): ?>
-
-
- = $info['view_url'] . $this->escape($info[$attribute]) . ''; ?>
-
- = $this->escape($info[$attribute]) ?>
-
- |
-
-
-
-
-
-
diff --git a/koward/app/views/Object/search.html.php b/koward/app/views/Object/search.html.php
deleted file mode 100644
index 3059c8e50..000000000
--- a/koward/app/views/Object/search.html.php
+++ /dev/null
@@ -1,40 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-objectlist)): ?>
- = $this->form->renderActive(new Horde_Form_Renderer(), $this->vars,
- $this->post, 'post'); ?>
-
-
-
-
- | getImageDir('horde')) ?> |
- getImageDir('horde')) ?> |
- attributes as $attribute => $info): ?>
- = $info['title'] ?> |
-
-
-
-
- objectlist as $dn => $info): ?>
-
- |
- = $info['edit_url'] ?>
- |
-
- = $info['delete_url'] ?>
- |
- attributes as $attribute => $ainfo): ?>
-
-
- = $info['view_url'] . $this->escape($info[$attribute]) . ''; ?>
-
- = $this->escape($info[$attribute]) ?>
-
- |
-
-
-
-
-
-
-
diff --git a/koward/app/views/Object/view.html.php b/koward/app/views/Object/view.html.php
deleted file mode 100644
index b9da7d298..000000000
--- a/koward/app/views/Object/view.html.php
+++ /dev/null
@@ -1,13 +0,0 @@
-= $this->renderPartial('header'); ?>
-= $this->renderPartial('menu'); ?>
-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
index dc72ba84e..000000000
--- a/koward/app/views/shared/_header.html.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-' : '' ?>
-
-get('name');
-$page_title .= !empty($this->title) ? ' :: ' . $this->title : '';
-
-Horde::includeScriptFiles();
-?>
-
-
-
-print_view) ? $this->theme : 'print') ?>
-
-
-
-
diff --git a/koward/app/views/shared/_menu.html.php b/koward/app/views/shared/_menu.html.php
deleted file mode 100644
index 3be3269c7..000000000
--- a/koward/app/views/shared/_menu.html.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-koward->notification->notify(array('listeners' => 'status')) ?>
-
diff --git a/koward/lib/Cli.php b/koward/lib/Cli.php
deleted file mode 100644
index 43b31bccf..000000000
--- a/koward/lib/Cli.php
+++ /dev/null
@@ -1,227 +0,0 @@
-
- * @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
- * @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
index 3498db45e..000000000
--- a/koward/lib/Exception.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
- * @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
- * @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
index 73cd95203..000000000
--- a/koward/lib/Form/Actions.php
+++ /dev/null
@@ -1,63 +0,0 @@
-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
index dd6544261..000000000
--- a/koward/lib/Form/Object.php
+++ /dev/null
@@ -1,250 +0,0 @@
-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
index 7e8a8a70d..000000000
--- a/koward/lib/Form/Search.php
+++ /dev/null
@@ -1,100 +0,0 @@
-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
index 000000000..43b31bccf
--- /dev/null
+++ b/koward/lib/Koward/Cli.php
@@ -0,0 +1,227 @@
+
+ * @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
+ * @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
index 000000000..e28fb3d0d
--- /dev/null
+++ b/koward/lib/Koward/Controller/Application.php
@@ -0,0 +1,40 @@
+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
index 000000000..c3642f7b3
--- /dev/null
+++ b/koward/lib/Koward/Controller/CheckController.php
@@ -0,0 +1,56 @@
+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") . '';
+
+ $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 . '';
+ }
+ }
+
+ 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
index 000000000..52dba4c2d
--- /dev/null
+++ b/koward/lib/Koward/Controller/IndexController.php
@@ -0,0 +1,18 @@
+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
index 000000000..e93f5e623
--- /dev/null
+++ b/koward/lib/Koward/Controller/ObjectController.php
@@ -0,0 +1,273 @@
+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'))
+ . '';
+ $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'))
+ . '';
+ $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'))
+ . '';
+
+
+ }
+ } 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'))
+ . '';
+ $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'))
+ . '';
+ $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
index 000000000..3498db45e
--- /dev/null
+++ b/koward/lib/Koward/Exception.php
@@ -0,0 +1,30 @@
+
+ * @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
+ * @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
index 000000000..73cd95203
--- /dev/null
+++ b/koward/lib/Koward/Form/Actions.php
@@ -0,0 +1,63 @@
+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
index 000000000..dd6544261
--- /dev/null
+++ b/koward/lib/Koward/Form/Object.php
@@ -0,0 +1,250 @@
+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
index 000000000..7e8a8a70d
--- /dev/null
+++ b/koward/lib/Koward/Form/Search.php
@@ -0,0 +1,100 @@
+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
index 000000000..62b937973
--- /dev/null
+++ b/koward/lib/Koward/Test.php
@@ -0,0 +1,173 @@
+
+ * @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
+ * @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 = <<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, "
+ * @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
+ * @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
index 000000000..e8308aa1f
--- /dev/null
+++ b/koward/lib/Koward/Test/Renderer.php
@@ -0,0 +1,44 @@
+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
index 000000000..d2f055924
--- /dev/null
+++ b/koward/lib/Koward/Test/Server/UserTest.php
@@ -0,0 +1,43 @@
+
+ * @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
+ * @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
index 000000000..caa149aab
--- /dev/null
+++ b/koward/lib/Koward/Test/Template/scenario.html.dist
@@ -0,0 +1,13 @@
+
+ |
+ [+] {name}
+ |
+
+
+ |
+
+ |
+
+
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
index 000000000..7b205d1cd
--- /dev/null
+++ b/koward/lib/Koward/Test/Template/scenario_header.html.dist
@@ -0,0 +1,6 @@
+
+ |
+
+ |
+
+
diff --git a/koward/lib/Koward/Test/Template/scenarios.html.dist b/koward/lib/Koward/Test/Template/scenarios.html.dist
new file mode 100644
index 000000000..1037cfb70
--- /dev/null
+++ b/koward/lib/Koward/Test/Template/scenarios.html.dist
@@ -0,0 +1,54 @@
+
+
+
+
+
+{scenarios}
+
+ |
+ [+] Summary:
+
+
+
+ | Successful scenarios: |
+ {successfulScenarios} |
+
+
+ | Failed scenarios: |
+ {failedScenarios} |
+
+
+ | Skipped scenarios: |
+ {skippedScenarios} |
+
+
+ | Incomplete scenarios: |
+ {incompleteScenarios} |
+
+
+
+ |
+
+
diff --git a/koward/lib/Koward/Test/Template/step.html.dist b/koward/lib/Koward/Test/Template/step.html.dist
new file mode 100644
index 000000000..bcdce3f40
--- /dev/null
+++ b/koward/lib/Koward/Test/Template/step.html.dist
@@ -0,0 +1,6 @@
+
+ | {text} |
+ {action} |
+ |
+
+
diff --git a/koward/lib/Koward/View/Check/run.html.php b/koward/lib/Koward/View/Check/run.html.php
new file mode 100644
index 000000000..ea945e832
--- /dev/null
+++ b/koward/lib/Koward/View/Check/run.html.php
@@ -0,0 +1,10 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+
+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
index 000000000..f58908fef
--- /dev/null
+++ b/koward/lib/Koward/View/Check/show.html.php
@@ -0,0 +1,9 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+
+list as $test) {
+ echo $test;
+ echo '
';
+}
\ 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
index 000000000..0696b72ec
--- /dev/null
+++ b/koward/lib/Koward/View/Index/index.html.php
@@ -0,0 +1,6 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+
+
+
= $this->welcome ?>
+
diff --git a/koward/lib/Koward/View/Modify/add.html.php b/koward/lib/Koward/View/Modify/add.html.php
new file mode 100644
index 000000000..fb15bbee4
--- /dev/null
+++ b/koward/lib/Koward/View/Modify/add.html.php
@@ -0,0 +1,6 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+
+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
index 000000000..8e74c09c1
--- /dev/null
+++ b/koward/lib/Koward/View/Object/delete.html.php
@@ -0,0 +1,15 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+
+
diff --git a/koward/lib/Koward/View/Object/edit.html.php b/koward/lib/Koward/View/Object/edit.html.php
new file mode 100644
index 000000000..5185924e7
--- /dev/null
+++ b/koward/lib/Koward/View/Object/edit.html.php
@@ -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
index 000000000..a790967fd
--- /dev/null
+++ b/koward/lib/Koward/View/Object/listall.html.php
@@ -0,0 +1,40 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+
+= $this->tabs->render($this->object_type); ?>
+
+objectlist)): ?>
+
+
+
+
+ | getImageDir('horde')) ?> |
+ getImageDir('horde')) ?> |
+ attributes as $attribute => $info): ?>
+ = $info['title'] ?> |
+
+
+
+
+ objectlist as $dn => $info): ?>
+
+ |
+ = $info['edit_url'] ?>
+ |
+
+ = $info['delete_url'] ?>
+ |
+ attributes as $attribute => $ainfo): ?>
+
+
+ = $info['view_url'] . $this->escape($info[$attribute]) . ''; ?>
+
+ = $this->escape($info[$attribute]) ?>
+
+ |
+
+
+
+
+
+
diff --git a/koward/lib/Koward/View/Object/search.html.php b/koward/lib/Koward/View/Object/search.html.php
new file mode 100644
index 000000000..3059c8e50
--- /dev/null
+++ b/koward/lib/Koward/View/Object/search.html.php
@@ -0,0 +1,40 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+objectlist)): ?>
+ = $this->form->renderActive(new Horde_Form_Renderer(), $this->vars,
+ $this->post, 'post'); ?>
+
+
+
+
+ | getImageDir('horde')) ?> |
+ getImageDir('horde')) ?> |
+ attributes as $attribute => $info): ?>
+ = $info['title'] ?> |
+
+
+
+
+ objectlist as $dn => $info): ?>
+
+ |
+ = $info['edit_url'] ?>
+ |
+
+ = $info['delete_url'] ?>
+ |
+ attributes as $attribute => $ainfo): ?>
+
+
+ = $info['view_url'] . $this->escape($info[$attribute]) . ''; ?>
+
+ = $this->escape($info[$attribute]) ?>
+
+ |
+
+
+
+
+
+
+
diff --git a/koward/lib/Koward/View/Object/view.html.php b/koward/lib/Koward/View/Object/view.html.php
new file mode 100644
index 000000000..b9da7d298
--- /dev/null
+++ b/koward/lib/Koward/View/Object/view.html.php
@@ -0,0 +1,13 @@
+= $this->renderPartial('header'); ?>
+= $this->renderPartial('menu'); ?>
+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
index 000000000..dc72ba84e
--- /dev/null
+++ b/koward/lib/Koward/View/shared/_header.html.php
@@ -0,0 +1,36 @@
+
+
+
+
+' : '' ?>
+
+get('name');
+$page_title .= !empty($this->title) ? ' :: ' . $this->title : '';
+
+Horde::includeScriptFiles();
+?>
+
+
+
+print_view) ? $this->theme : 'print') ?>
+
+
+
+
diff --git a/koward/lib/Koward/View/shared/_menu.html.php b/koward/lib/Koward/View/shared/_menu.html.php
new file mode 100644
index 000000000..3be3269c7
--- /dev/null
+++ b/koward/lib/Koward/View/shared/_menu.html.php
@@ -0,0 +1,5 @@
+
+koward->notification->notify(array('listeners' => 'status')) ?>
+
diff --git a/koward/lib/Test.php b/koward/lib/Test.php
deleted file mode 100644
index 62b937973..000000000
--- a/koward/lib/Test.php
+++ /dev/null
@@ -1,173 +0,0 @@
-
- * @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
- * @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 = <<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, "
- * @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
- * @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
index e8308aa1f..000000000
--- a/koward/lib/Test/Renderer.php
+++ /dev/null
@@ -1,44 +0,0 @@
-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
index d2f055924..000000000
--- a/koward/lib/Test/Server/UserTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-
- * @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
- * @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
index caa149aab..000000000
--- a/koward/lib/Test/Template/scenario.html.dist
+++ /dev/null
@@ -1,13 +0,0 @@
-
- |
- [+] {name}
- |
-
-
- |
-
- |
-
-
diff --git a/koward/lib/Test/Template/scenario_header.html.dist b/koward/lib/Test/Template/scenario_header.html.dist
deleted file mode 100644
index 7b205d1cd..000000000
--- a/koward/lib/Test/Template/scenario_header.html.dist
+++ /dev/null
@@ -1,6 +0,0 @@
-
- |
-
- |
-
-
diff --git a/koward/lib/Test/Template/scenarios.html.dist b/koward/lib/Test/Template/scenarios.html.dist
deleted file mode 100644
index 1037cfb70..000000000
--- a/koward/lib/Test/Template/scenarios.html.dist
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-{scenarios}
-
- |
- [+] Summary:
-
-
-
- | Successful scenarios: |
- {successfulScenarios} |
-
-
- | Failed scenarios: |
- {failedScenarios} |
-
-
- | Skipped scenarios: |
- {skippedScenarios} |
-
-
- | Incomplete scenarios: |
- {incompleteScenarios} |
-
-
-
- |
-
-
diff --git a/koward/lib/Test/Template/step.html.dist b/koward/lib/Test/Template/step.html.dist
deleted file mode 100644
index bcdce3f40..000000000
--- a/koward/lib/Test/Template/step.html.dist
+++ /dev/null
@@ -1,6 +0,0 @@
-
- | {text} |
- {action} |
- |
-
-