[dev] Patch for AutoLogin (hordeauth) for IMP and Gollem

Joel Vandal jvandal at infoteck.qc.ca
Fri Oct 3 17:48:20 PDT 2003


Hi,

I submit these 2 patch :

IMP :

- autologin if there`s only one source
- don't show logout button if there's only one source and it's either
hordeauth

GOLLEM :

- fix a bug w/ canAutoLogin

--
Joel Vandal
-------------- next part --------------
Index: login.php
===================================================================
RCS file: /repository/imp/login.php,v
retrieving revision 2.188
diff -r2.188 login.php
38a39
> $server_key = Util::getFormData('server_key');
131a133,168
> }
>
> $used_servers = $servers;
> if ($conf['server']['server_list'] != 'shown') {
>
>     $server_key = Util::getFormData('server_key');
>     if (is_null($server_key)) {
>       /* Grab some default values from the first entry in
>        *          * config/servers.php. */
>       foreach ($servers as $key => $curServer) {
>           if (is_null($server_key) && substr($key, 0, 1) != '_') {
>               $server_key = $key;
>           }
>           if (IMP::isPreferredServer($curServer)) {
>               $server_key = $key;
>               break;
>           }
>       }
>     }
>     $used_servers = array($server_key => $servers[$server_key]);
>     $autologin = Util::getFormData('autologin');
> }
>
> if (($reason == 'login') &&
>     IMP::canAutoLogin($server_key, $autologin)) {
>     $url = Horde::applicationUrl('redirect.php', true);
>     if (count($used_servers) == 1) {
>       reset($used_servers);
>       list($server_key, $curServer) = each($used_servers);
>       $url = Util::addParameter($url, 'server_key', $server_key);
>     }
>     $url = Util::addParameter($url, 'actionID', 'login');
>     $url = Util::addParameter($url, 'autologin', true);
>     $url = Util::addParameter($url, 'frameset', true);
>     header('Location: ' . $url);
>     exit;
Index: lib/IMP.php
===================================================================
RCS file: /repository/imp/lib/IMP.php,v
retrieving revision 1.399
diff -r1.399 IMP.php
56c56,99
<
---
>
>     /**
>      * Get the AutoLogin server key.
>      *
>      * @access public
>      *
>      * @return string  The server key.
>      */
>     function getAutoLoginServer()
>     {
>       require IMP_BASE . '/config/servers.php';
>       foreach ($servers as $key => $curServer) {
>           if (empty($server_key) && substr($key, 0, 1) != '_') {
>               $server_key = $key;
>           }
>           if (IMP::isPreferredServer($curServer)) {
>               $server_key = $key;
>           }
>       }
>         return $server_key;
>     }
>
>     /**
>      * Can we log in without a login screen for $server_key?
>      *
>      * @param string  $server_key   (optional) The server to check. Defaults to
>      *                              IMP::getCurrentServer().
>      * @param boolean $force        (optional) If true, check $server_key even if there
>      *                              is more than one server available. Defaults to false.
>      *
>      * @return boolean  True or false.
>      */
>     function canAutoLogin($server_key = '', $force = false)
>     {
>       require IMP_BASE . '/config/servers.php';
>
>         if (empty($server_key)) {
>             $server_key = IMP::getAutoLoginServer();
>       }
>         return ((count(IMP::getAutoLoginServer()) == 1 || $force) &&
>               (Auth::getAuth() &&
>                !empty($servers[$server_key]['hordeauth'])));
>     }
>
Index: templates/menu/menu.inc
===================================================================
RCS file: /repository/imp/templates/menu/menu.inc,v
retrieving revision 2.179
diff -r2.179 menu.inc
61,67c61,69
< if ((Auth::getProvider() == 'imp') && $conf['menu']['display']) {
<     $menu_logout_url = $registry->getParam('webroot', 'horde') . '/login.php';
<     Menu::printItem(Util::addParameter($menu_logout_url, 'reason', 'logout'), _("Logout"), 'logout.gif', $registry->getParam('graphics', 'horde'), '_parent');
< } else {
<     $menu_logout_url = Horde::applicationUrl('login.php');
<     Menu::printItem(Util::addParameter($menu_logout_url, 'reason', 'logout'), _("Logout"), 'logout.gif', $registry->getParam('graphics', 'horde'));
< }
---
> if (!IMP::canAutoLogin()) {
>     if ((Auth::getProvider() == 'imp') && $conf['menu']['display']) {
>         $menu_logout_url = $registry->getParam('webroot', 'horde') . '/login.php';
>         Menu::printItem(Util::addParameter($menu_logout_url, 'reason', 'logout'), _("Logout"), 'logout.gif', $registry->getParam('graphics', 'horde'), '_parent');
>     } else {
>         $menu_logout_url = Horde::applicationUrl('login.php');
>         Menu::printItem(Util::addParameter($menu_logout_url, 'reason', 'logout'), _("Logout"), 'logout.gif', $registry->getParam('graphics', 'horde'));
>     }
> }
-------------- next part --------------
Index: lib/Gollem.php
===================================================================
RCS file: /repository/gollem/lib/Gollem.php,v
retrieving revision 1.106
diff -r1.106 Gollem.php
208c208
<
---
>
212,213c212,213
<                   implode(',', $vfs[$backend_key]->getRequiredCredentials()) $
<                   !empty($backends[$backend_key]['hordeauth']))));
---
>                   implode(',', $GLOBALS['vfs'][$backend_key]->getRequiredCred$
>                   !empty($GLOBALS['backends'][$backend_key]['hordeauth']))));



More information about the dev mailing list