$this->auth = &Auth::singleton($conf['auth']['driver']);
- $this->conf = Horde::loadConfiguration('koward.php', 'koward');
+ $this->conf = Horde::loadConfiguration('conf.php', 'conf');
$this->objects = Horde::loadConfiguration('objects.php', 'objects');
$this->attributes = Horde::loadConfiguration('attributes.php', 'attributes');
$this->labels = Horde::loadConfiguration('labels.php', 'labels');
$browser = Horde_Browser::singleton();
}
- $result = $registry->pushApp('koward', false);
- if ($result instanceOf PEAR_Error) {
- $notification->push($result);
- }
-
$webroot = Koward::_detectWebroot($koward);
// Set up our request and routing objects
}
// Check for route definitions.
- $routeFile = dirname($koward) . '/../config/routes.php';
+ $routeFile = dirname($koward) . '/../../koward/config/routes.php';
if (!file_exists($routeFile)) {
throw new Horde_Controller_Exception('Not routable');
}
{
global $registry;
- $this->koward = Koward::singleton();
-
- if (is_a(($pushed = $registry->pushApp('horde', empty($this->auth_handler))), 'PEAR_Error')) {
+ if (is_a(($pushed = $registry->pushApp('koward',
+ empty($this->auth_handler)
+ || $this->auth_handler != $this->params[':action'])), 'PEAR_Error')) {
if ($pushed->getCode() == 'permission_denied') {
- header('Location: ' . $this->urlFor(array('controller' => 'login', 'action' => 'login')));
+ header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login')));
exit;
}
}
+ $this->koward = Koward::singleton();
+
+ if ($this->koward->objects instanceOf PEAR_Error) {
+ return;
+ }
- $this->types = array_keys($this->koward->objects);
- if (empty($this->types)) {
+ if (!empty($this->koward->objects)) {
+ $this->types = array_keys($this->koward->objects);
+ } else {
throw new Koward_Exception('No object types have been configured!');
}
$this->menu = $this->getMenu();
- $this->theme = isset($this->koward->conf['theme']) ? $this->koward->conf['theme'] : 'koward';
+ $this->theme = isset($this->koward->conf['koward']['theme']) ? $this->koward->conf['koward']['theme'] : 'koward';
+
}
/**
_("_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')),
+ if (!empty($this->koward->conf['koward']['menu']['queries'])) {
+ $menu->add(Horde::applicationUrl('Queries'), _("_Queries"), 'query.png', $registry->getImageDir('koward'));
+ }
+ if (!empty($this->koward->conf['koward']['menu']['test'])) {
+ $menu->add($this->urlFor(array('controller' => 'check', 'action' => 'show')),
_("_Test"), 'problem.png', $registry->getImageDir('horde'));
+ }
+ if (Auth::getAuth()) {
+ $menu->add($this->urlFor(array('controller' => 'index', 'action' => 'logout')),
+ _("_Logout"), 'logout.png', $registry->getImageDir('horde'));
+ }
return $menu;
}
}
{
protected $welcome;
+ protected $auth_handler = 'login';
+
public function index()
{
$this->title = _("Index");
$this->welcome = _("Welcome to the Koward administration interface");
}
+
+ public function login()
+ {
+ $auth = Auth::getAuth();
+ if (!empty($auth)) {
+ header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'index')));
+ exit;
+ }
+
+ $this->title = _("Login");
+ $this->welcome = _("Welcome.");
+
+ $this->post = $this->urlFor(array('controller' => 'index',
+ 'action' => 'login'));
+
+ if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
+ /* Destroy any existing session on login and make sure to use a
+ * new session ID, to avoid session fixation issues. */
+ Horde::getCleanSession();
+ if ($this->koward->auth->authenticate(Util::getPost('horde_user'),
+ array('password' => Util::getPost('horde_pass')))) {
+ $entry = sprintf('Login success for %s [%s] to Horde',
+ Auth::getAuth(), $_SERVER['REMOTE_ADDR']);
+ Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+ header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'index')));
+ exit;
+ } else {
+ $entry = sprintf('FAILED LOGIN for %s [%s] to Horde',
+ Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
+ Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR);
+ }
+ }
+
+ if ($reason = $this->koward->auth->getLogoutReasonString()) {
+ $this->koward->notification->push(str_replace('<br />', ' ', $reason), 'horde.message');
+ }
+
+ }
+
+ public function logout()
+ {
+ $entry = sprintf('User %s [%s] logged out of Horde',
+ Auth::getAuth(), $_SERVER['REMOTE_ADDR']);
+ Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
+ Auth::clearAuth();
+ @session_destroy();
+
+ header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login')));
+ exit;
+ }
}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * @package Koward
- */
-
-/**
- * @package Koward
- */
-class LoginController extends Koward_Controller_Application
-{
- protected $welcome;
-
- protected $auth_handler = true;
-
- public function login()
- {
- $auth = Auth::getAuth();
- if (!empty($auth)) {
- header('Location: ' . $this->urlFor(array('controller' => 'index')));
- exit;
- }
-
- $this->title = _("Login");
- $this->welcome = _("Welcome.");
-
- $this->post = $this->urlFor(array('controller' => 'login',
- 'action' => 'login'));
-
- if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
- /* Destroy any existing session on login and make sure to use a
- * new session ID, to avoid session fixation issues. */
- Horde::getCleanSession();
- if ($this->koward->auth->authenticate(Util::getPost('horde_user'),
- array('password' => Util::getPost('horde_pass')))) {
- $entry = sprintf('Login success for %s [%s] to Horde',
- Auth::getAuth(), $_SERVER['REMOTE_ADDR']);
- Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_NOTICE);
-
- header('Location: ' . $this->urlFor(array('controller' => 'index')));
- exit;
- } else {
- $entry = sprintf('FAILED LOGIN for %s [%s] to Horde',
- Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
- Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_ERR);
- }
- }
-
- if ($reason = $this->koward->auth->getLogoutReasonString()) {
- $this->koward->notification->push(str_replace('<br />', ' ', $reason), 'horde.message');
- }
-
- }
-}
\ No newline at end of file
--- /dev/null
+<?= $this->renderPartial('header'); ?>
+
+<div id="menu">
+ <h1 style="text-align:center"><?= $this->welcome ?></h1>
+</div>
+
+<?php $this->koward->notification->notify(array('listeners' => 'status')) ?>
+
+<form name="koward_login" method="post" action="<?= $this->post ?>">
+<table width="100%"><tr><td align="center"><table width="300" align="center">
+
+<tr>
+ <td class="light rightAlign"><strong><?php echo Horde::label('horde_user', _("Username")) ?></strong> </td>
+ <td class="leftAlign"><input type="text" id="horde_user" name="horde_user" value="<?php echo htmlspecialchars(Util::getFormData('horde_user')) ?>" style="direction:ltr" /></td>
+</tr>
+
+<tr>
+ <td class="light rightAlign"><strong><?php echo Horde::label('horde_pass', _("Password")) ?></strong> </td>
+ <td class="leftAlign"><input type="password" id="horde_pass" name="horde_pass" value="" style="direction:ltr" /></td>
+</tr>
+
+<tr>
+ <td> </td>
+ <td class="light leftAlign"><input name="loginButton" class="button" value="<?php echo _("Log in") ?>" type="submit" onclick="return submit_login();" /></td>
+</tr>
+
+</table></td></tr></table>
+</form>
+++ /dev/null
-<?= $this->renderPartial('header'); ?>
-
-<div id="menu">
- <h1 style="text-align:center"><?= $this->welcome ?></h1>
-</div>
-
-<?php $this->koward->notification->notify(array('listeners' => 'status')) ?>
-
-<form name="koward_login" method="post" action="<?= $this->post ?>"
-<table width="100%"><tr><td align="center"><table width="300" align="center">
-
-<tr>
- <td class="light rightAlign"><strong><?php echo Horde::label('horde_user', _("Username")) ?></strong> </td>
- <td class="leftAlign"><input type="text" id="horde_user" name="horde_user" value="<?php echo htmlspecialchars(Util::getFormData('horde_user')) ?>" style="direction:ltr" /></td>
-</tr>
-
-<tr>
- <td class="light rightAlign"><strong><?php echo Horde::label('horde_pass', _("Password")) ?></strong> </td>
- <td class="leftAlign"><input type="password" id="horde_pass" name="horde_pass" value="" style="direction:ltr" /></td>
-</tr>
-
-<tr>
- <td> </td>
- <td class="light leftAlign"><input name="loginButton" class="button" value="<?php echo _("Log in") ?>" type="submit" onclick="return submit_login();" /></td>
-</tr>
-
-</table></td></tr></table>
-</form>