[imp] get pref Value in preauthenticate

Makeri makeri-kutsonu at t-online.de
Tue Oct 25 09:24:09 UTC 2011


Jan Schneider <jan <at> horde.org> writes:


> > I defined in horde/config/prefs.local.php 3 new fields and 1 new checkbox :
> >
> > // EIGENE - Mail-Zugangsdaten
> >
> > $prefGroups['owngroup01'] = array(
> >     'column' => 'Eigene-Erweiterungen',
> >     'label' => 'Mailserver Zugangsdaten',
> >     'desc' => 'Mailserverdaten kannst Du hier hinterlegen',
> >     'members' => array(
> >         'own_mail_server', 'own_mail_login', 'own_mail_pw_gleich',
> > 'own_mail_passwort'
> >     )
> > );
> >
> > // pw in horde and imap are similar - so user dont need save his  
> > password. I can
> > get it with getAuthCredential('password')
> >
> > $_prefs['own_mail_pw_gleich'] = array(
> >     'value' => false,
> >     'type' => 'checkbox',
> >     'desc' => 'IMAP-MailPasswort ist das gleiche wie bei Webmail'
> > );
> >
> > // Mailserver
> > $_prefs['own_mail_server'] = array(
> >     'value' => 'mail.domain.de',
> >     'type' => 'text',
> >     'desc' => 'Bitte Mailserver angeben'
> > );
> >
> > // Loginname
> > $_prefs['own_mail_login'] = array(
> >     'value' => '',
> >     'type' => 'text',
> >     'desc' => 'Mail-Loginname :'
> > );
> >
> > // Passwort
> > $_prefs['own_mail_passwort'] = array(
> >     'value' => '',
> >     'type' => 'text',
> >     'desc' => 'Mail-Passwort :'
> > );
> >
> > And now i want get this values is preauthenticate of imp :
> >
> >      public function preauthenticate ($userId, $credentials)
> >      {
> > global $GLOBALS, $prefs;
> 
> $GLOBALS is already global, no need to add this.

O.K. - i'm just testing
> 
> > global $conf, $injector, $language, $prefs, $registry, $_prefs;
> 
> You don't use any of those, don't import them from global scope.

I'm testing

> 
> >         $tmp_horde_user = $GLOBALS['registry']->getAuth();
> >
> >         if (!empty($tmp_horde_user))
> >          {
> >
> >         If ($prefs['own_mail_server'])
> 
> What is that supposed to be? $prefs is a Horde_Prefs object.

I am testing, how i get the values - i also try 

$_pref
$GLOBALS['prefs']
$GLOBALS['_prefs']
...

> 
> >          {
> >         $own_mail_pw_gleich =  
> > @$GLOBALS['prefs']->getValue('own_mail_pw_gleich');
> 
> No need to silence these calls, if anything this would hide error  
> messages that might help you spotting a problem.

O.K. 

> 
> >         $own_mail_server = @$GLOBALS['prefs']->getValue('own_mail_server');
> >         $own_mail_login = @$GLOBALS['prefs']->getValue('own_mail_login');
> >         $own_mail_passwort =  
> > @$GLOBALS['prefs']->getValue('own_mail_passwort');
> >
> >         if (!empty($own_mail_server) && !empty($own_mail_login) &&
> > !empty($own_mail_passwort))
> >          {
> >           $result['userId'] = $own_mail_login;
> >           if ($own_mail_pw_gleich)
> >            {
> >             $credentials['password'] =
> > $GLOBALS['registry']->getAuthCredential('password');
> 
> Setting $credentials doesn't have any effect. See the hook description.

No effect ?

i also set $credentials['transparent'] = "true"; !

...

> > But it does not work !
> 
> What exactly doesn't work?

What i want is : i want the values of the fields, what the user saved, so i can
set loginname ($result['userId']) and password ($credentials['password']) - and
the user can "autologin" to IMAP-Server via IMP.

P.S. : If i set 
$result['userId']
$credentials['password'] and 
$credentials['transparent'] = "true"; 

manually for my Mail-account, then its work !. therefor i make new fields, where
user save his credentials and i want get it and set the values - for
"IMAP-autologin".

This option gives in horde 3 but you say it was removed (see my post "save
IMAP-Login")

> 




More information about the imp mailing list