[imp] How to re-compose a login string user@domain ?

Edwin Culp eculp@encontacto.net
Wed, 26 Jun 2002 12:38:54 -0700


Quoting Nicolas Foucou <foucou@cdc.u-cergy.fr>:

 | Hi Edwin,
 | 
 | Thank for the answer.... but in fact it's a little bit more complex in my
 | case.
 | My IMP/HORDE server is not the mailserver.
 | So, I try to describe my conf now :
 | 
 | My IMP/HORDE server (only web server) permits to connecting on all the
 | mailservers we manage.
 | In those, there's only one mailserver (serving for the moment 4 maildomain
 | but normally more in few weeks) needing user@domain imapuser string login !
 | Other ones no need that.
 | 
 | So I'd like to, specially for this one, make something looking like
 | $imp['hook']['vinfo'] script .
 | 
 | I doesn't know how to get the values put in imp/config/server.php (where I
 | already said that for this mailhost the maildomain is... in the maildomain
 | field)  and use it to recompose the imapuser login only for the maildomain
 | the server work.
 | 
 | exemple : 
 | 
 | the server is called
 |  "Mailhost eco" for the eco.u-cergy.fr maildomain
 |  "Mailhost lsh" for the lsh.u-cergy.fr maildomain
 | ..etc...
 | 
 | the user toto (who received is mail on eco.u-cergy.fr) have to type
 | toto@eco.u-cergy.fr in the login field AND have to select "Mailhost eco" in
 | the servers ComboBox. But, in the file imp/config/servers.php there is :
 | 
 | 
 | $servers['eco'] = array(
 |         'name' => 'Mailhost eco',
 |         'server' => 'mailhost.eco.u-cergy.fr',
 |         'protocol' => 'imap',
 |         'port' => '143',
 |         'folders' => '',
 |         'namespace' => 'INBOX.',
 |         'maildomain' => 'eco.u-cergy.fr',
 |         'smtphost' => 'mailhost.eco.u-cergy.fr',
 |         'realm' => 'u-cergy.fr',
 |         'preferred' => ''
 | );
 | 
 | So... It's terribly redondant no ?????
 | How to get the value maildomain from this file and create the imapusers
 | string by composition of "$user" (put in the user field in login page) + "@"
 | + "$servers.[eco].[maildomain]" ???
 
I would think that something like this ?? MIGHT ?? work:

if (!function_exists('imp_get_vinfo')) {
     function imp_get_vinfo ($type = 'username') {
         global $conf, $imp;

         if ($type == 'username') {
             return $imp['user'] . '@' . $realm_value;
        } elseif ($type == "vdomain") {
            return $realm_value;
        } else {
            return new PEAR_Error('invalid type: ' . $type);
        }
    }
}

Good luck and let me know. 

ed