[dev] [patch] logout is not application fix
Vilius Sumskas
vilius at lnk.lt
Tue Sep 28 04:32:14 PDT 2004
Hi,
Quoting Vilius Šumskas <vilius at lnk.lt>:
>> This is okay, but what about following the same path we did with the problem
>> reporting link and move it out of registry.php entirely, so we can
>> remove the
>> special cases? Just handle it in Horde::getServiceLink()?
>
> Sounds reasonable to me. I will try to manage a patch tomorrow.
So here it is. Authentification if my weakest side in developing on
Horde, so I
suggest you to look through my code. Comments are welcome as usual.
--
Best Regards,
Vilius
-------------- next part --------------
Index: config/registry.php.dist
===================================================================
RCS file: /repository/horde/config/registry.php.dist,v
retrieving revision 1.240
diff -u -r1.240 registry.php.dist
--- config/registry.php.dist 27 Sep 2004 09:03:18 -0000 1.240
+++ config/registry.php.dist 28 Sep 2004 11:12:04 -0000
@@ -60,26 +60,6 @@
'provides' => 'horde'
);
-if (Auth::getAuth()) {
- $this->applications['logout'] = array(
- 'fileroot' => dirname(__FILE__) . '/..',
- 'webroot' => $this->applications['horde']['webroot'],
- 'initial_page' => 'login.php?' . AUTH_REASON_PARAM . '=' . AUTH_REASON_LOGOUT,
- 'icon' => $this->applications['horde']['webroot'] . '/graphics/logout.gif',
- 'name' => _("Log out"),
- 'status' => 'notoolbar'
- );
-} else {
- $this->applications['logout'] = array(
- 'fileroot' => dirname(__FILE__) . '/..',
- 'webroot' => $this->applications['horde']['webroot'],
- 'initial_page' => 'login.php?url=' . urlencode(Horde::selfUrl(true)),
- 'icon' => $this->applications['horde']['webroot'] . '/graphics/login.gif',
- 'name' => _("Log in"),
- 'status' => 'notoolbar'
- );
-}
-
$this->applications['imp'] = array(
'fileroot' => dirname(__FILE__) . '/../imp',
'webroot' => $this->applications['horde']['webroot'] . '/imp',
Index: framework/Horde/Horde.php
===================================================================
RCS file: /repository/framework/Horde/Horde.php,v
retrieving revision 1.443
diff -u -r1.443 Horde.php
--- framework/Horde/Horde.php 25 Sep 2004 01:17:41 -0000 1.443
+++ framework/Horde/Horde.php 28 Sep 2004 11:12:04 -0000
@@ -307,6 +307,15 @@
case 'problem':
return Horde::url($GLOBALS['registry']->getParam('webroot', 'horde') . '/services/problem.php?return_url=' . urlencode(Horde::selfUrl(true)));
+ break;
+
+ case 'logout':
+ return Auth::addLogoutParameters(Horde::url($GLOBALS['registry']->getParam('webroot', $app) . '/login.php'), AUTH_REASON_LOGOUT);
+ break;
+
+ case 'login':
+ return Auth::getLoginScreen('', Horde::selfUrl());
+ break;
case 'options':
global $conf;
@@ -330,10 +339,14 @@
{
global $conf;
+ if ($type == 'logout' || $type == 'login') {
+ return true;
+ }
+
if (empty($conf['menu']['links'][$type])) {
return false;
}
-
+
switch ($conf['menu']['links'][$type]) {
case 'all':
return true;
Index: framework/Horde/Horde/Menu.php
===================================================================
RCS file: /repository/framework/Horde/Horde/Menu.php,v
retrieving revision 1.3
diff -u -r1.3 Menu.php
--- framework/Horde/Horde/Menu.php 30 Aug 2004 20:25:12 -0000 1.3
+++ framework/Horde/Horde/Menu.php 28 Sep 2004 11:12:04 -0000
@@ -283,12 +283,11 @@
/* Login/Logout. */
if (Auth::getAuth() && $this->_with_login) {
- $url = Horde::url($registry->getParam('webroot', 'horde') . '/login.php');
- $url = Auth::addLogoutParameters($url, AUTH_REASON_LOGOUT);
- $menu[] = array('url' => $url, 'text' => _("Log out"), 'icon' => 'logout.gif', 'icon_path' => $graphics);
+ $logout_link = Horde::getServiceLink('logout', $app);
+ $menu[] = array('url' => $logout_link, 'text' => _("Log out"), 'icon' => 'logout.gif', 'icon_path' => $graphics);
} elseif ($this->_with_login) {
- $url = Auth::getLoginScreen('', Horde::selfUrl());
- $menu[] = array('url' => $url, 'text' => _("Log in"), 'icon' => 'login.gif', 'icon_path' => $graphics);
+ $login_link = Horde::getServiceLink('login', $app);
+ $menu[] = array('url' => $login_link, 'text' => _("Log in"), 'icon' => 'login.gif', 'icon_path' => $graphics);
}
/* Loop through the menu and set up necessary elements. */
Index: imp/templates/menu/menu.inc
===================================================================
RCS file: /repository/imp/templates/menu/menu.inc,v
retrieving revision 2.206
diff -u -r2.206 menu.inc
--- imp/templates/menu/menu.inc 14 Sep 2004 15:46:55 -0000 2.206
+++ imp/templates/menu/menu.inc 28 Sep 2004 11:12:05 -0000
@@ -68,11 +68,11 @@
/* Logout */
if (!IMP::canAutoLogin()) {
if ((Auth::getProvider() == 'imp') && $prefs->getValue('show_sidebar')) {
- $menu_logout_url = $registry->getParam('webroot', 'horde') . '/login.php';
- echo Menu::createItem(Auth::addLogoutParameters($menu_logout_url, AUTH_REASON_LOGOUT), _("_Log out"), 'logout.gif', $registry->getParam('graphics', 'horde'), $conf['menu']['always'] ? 'horde_main' : '_parent');
+ $logout_url = Horde::getServiceLink('logout', 'horde');
+ echo Menu::createItem($logout_url, _("_Log out"), 'logout.gif', $registry->getParam('graphics', 'horde'), $conf['menu']['always'] ? 'horde_main' : '_parent');
} else {
- $menu_logout_url = Horde::applicationUrl('login.php');
- echo Menu::createItem(Auth::addLogoutParameters($menu_logout_url, AUTH_REASON_LOGOUT), _("_Log out"), 'logout.gif', $registry->getParam('graphics', 'horde'));
+ $logout_url = Horde::getServiceLink('logout', 'imp');
+ echo Menu::createItem($logout_url, _("_Log out"), 'logout.gif', $registry->getParam('graphics', 'horde'));
}
}
Index: services/portal/menu.php
===================================================================
RCS file: /repository/horde/services/portal/menu.php,v
retrieving revision 2.99
diff -u -r2.99 menu.php
--- services/portal/menu.php 2 Sep 2004 17:32:51 -0000 2.99
+++ services/portal/menu.php 28 Sep 2004 11:12:08 -0000
@@ -157,13 +157,13 @@
$menu['logout'] = array('name' => _("Log out"),
'status' => 'active',
'icon' => $registry->getParam('graphics') . '/logout.gif',
- 'url' => Auth::addLogoutParameters(Horde::applicationUrl('login.php'), AUTH_REASON_LOGOUT),
+ 'url' => Horde::getServiceLink('logout', 'horde'),
'target' => $conf['menu']['always'] ? null : '_parent');
} else {
$menu['login'] = array('name' => _("Log in"),
'status' => 'active',
'icon' => $registry->getParam('graphics') . '/login.gif',
- 'url' => Horde::applicationUrl('login.php'));
+ 'url' => Horde::getServiceLink('login', 'horde'));
}
return $menu;
Index: templates/portal/menu.inc
===================================================================
RCS file: /repository/horde/templates/portal/menu.inc,v
retrieving revision 1.16
diff -u -r1.16 menu.inc
--- templates/portal/menu.inc 23 Sep 2004 18:23:40 -0000 1.16
+++ templates/portal/menu.inc 28 Sep 2004 11:12:08 -0000
@@ -29,7 +29,10 @@
echo Menu::createItem($help_link, _("_Help"), 'manual.gif');
}
-echo Menu::createItem(Auth::addLogoutParameters(Horde::applicationUrl('login.php'), AUTH_REASON_LOGOUT), _("_Log out"), 'logout.gif', null, '_parent', null, '__noselection');
+/* Logout */
+if ($logout_link = Horde::getServiceLink('logout', 'horde')) {
+ echo Menu::createItem($logout_link, _("_Log out"), 'logout.gif', null, '_parent', null, '__noselection');
+}
?>
</tr>
</table></td>
More information about the dev
mailing list