[imp] get pref Value in preauthenticate

Jan Schneider jan at horde.org
Tue Oct 25 08:47:24 UTC 2011


Zitat von Makeri <makeri-kutsonu at t-online.de>:

> Jan Schneider <jan <at> horde.org> writes:
>
>>
>>
>> Zitat von Makeri <makeri-kutsonu <at> t-online.de>:
>>
>> > Hello !
>> >
>> > We log in Horde per LDAP-User and want autologin to IMP (IMAP-Server).
>> > Usernameand Password from Horde and IMP are not similar.
>> >
>> > In Horde3 i can save the IMAP-Login-Information in Horde and can
>> > autologin to IMP.
>> >
>> > In Horde4 dont gives the option.
>> >
>> > So, i make 3 new prefs in horde-hooks, where the User save his
>> > Login-Information
>> > (servername, loginname and password).
>>
>> Where? How?
>
> Sorry - not in horde-hooks.
>
> 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.

> global $conf, $injector, $language, $prefs, $registry, $_prefs;

You don't use any of those, don't import them from global scope.

>         $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.

>          {
>         $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.

>         $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.

>            }
>           else
>            {
>             $credentials['password'] = $own_mail_passwort;
>            }
>           $credentials['transparent'] = "true";
>           return $result;
>          } // end if empty ...
>
>          } // end if prefs own_mail_server
>
>         } // end if not empty horde_user
>
>      }
>
>
> But it does not work !

What exactly doesn't work?

>> > Now, i want acces to this settings, in the function  
>> "preauthenticate" in IMP.
>> >
>> > But i cant !
>> >
>> > How can i acces it ?
>> >
>> >
>> > $GLOBALS[prefs]->getValue('mail_server_name')
>> > $GLOBALS[prefs]['mail_server_name']
>> >
>> > prefs->getValue('mail_server_name')
>> > prefs['mail_server_name']
>> >
>> > and with _prefs ...
>> >
>> > dont work.
>> >
>> >
>> > Please help !
>> >
>> >
>> >
>> > --
>> > IMP mailing list
>> > Frequently Asked Questions: http://horde.org/faq/
>> > To unsubscribe, mail: imp-unsubscribe <at> lists.horde.org
>>
>> Jan.
>>
>
>
>
>
> --
> IMP mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe at lists.horde.org


Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the imp mailing list