[cvs] [Wiki] changed: ImapSelect
Wiki Guest
wiki at wiki.horde.org
Wed May 18 15:35:58 PDT 2005
guest [199.104.120.59] Wed, 18 May 2005 15:35:58 -0700
Modified page: http://wiki.horde.org/display.php?page=ImapSelect
New Revision: 2.1
@@ -6,11 +6,13 @@
* The SQL table
There are many ways to do this of course. In this example, we'll just be using a table with two rows:
+<code>
---------------------------------------------------------
-| username | server.domain.com |
+| username | server.domain.com |
---------------------------------------------------------
+</code>
Your table can be constructed however you like. It can even be a part of your existing DB. The important point is that you need the
table to be constructed in such a way as to be able to query a username and have the lookup return a servername. Our example
uses a table called 'host'.
@@ -18,8 +20,9 @@
* Writing a hook
Here's some sample code for a hook that could be placed into horde/config/hooks.php:
+<code>
if (!function_exists('_imp_hook_imap')) {
function _imp_hook_imap($userName)
{
global $conf;
@@ -33,22 +36,28 @@
return false;
}
}
}
+
+</code>
* Placing the hook into the session
The above hook returns a single line containing a server name. It's injected into /horde/imp/lib/Session.php as follows:
+
+<code>
if (!empty($GLOBALS['conf']['hooks']['imap'])) {
require_once HORDE_BASE . '/config/hooks.php';
if (function_exists('_imp_hook_imap')) {
$_SESSION['imp']['server'] = call_user_func('_imp_hook_imap', $_SESSION['imp']['user']);
}
}
+
+</code>
On our setup, this is done right before authentication is attempted (right around line 223). As best I can tell, you're fine so long
as you don't have $_SESSION['imp']['server'] overwritten by anything else before you get to the call to &Auth::singleton(array('imp', 'imp'));
* Disclaimer
This code works on our setup so far. It could be wrong, uneccesary, foolish, or otherwise idiotic. In short, YMMV.
More information about the cvs
mailing list