[horde] hook to select default identity

LALOT Dominique dom.lalot at gmail.com
Tue Oct 18 06:33:15 UTC 2011


2011/10/17 LALOT Dominique <dom.lalot at gmail.com>

> Hello,
>
> I would like to push tow identities for a user thanks to a hook. The user
> then would be able to select one of the identities.
> How can I dot that?
> I'm already using the hook from_addr
>
> The initial purpose is to switch from a domain to another one and let the
> user choose what identity to use.
> I played with identities and hook. I was able to add identities, but then
> the user is able to change the values and delete the identities. How can I
> protect? I put these values in prefs.local.php
>
> $_prefs['default_identity']['locked']=false;
> $_prefs['default_identity']['value']=0;
> $_prefs['identities']['locked']=true;
> $_prefs['identities']['hook']=true;
> $_prefs['from_addr']['locked']=false;
> $_prefs['from_addr']['hook']=false;
>
> and in the hook (sorry, I'm rather a PERL programmer)
>
>         case 'identities':
>                  $ds = $this->_ldap_connect();
>
>  $justecela=array('displayname','mail','amumail','maillocaladdress');
>                  $searchResult = @ldap_read($ds,
> 'uid='.$username.','.$searchBase,'uid=*',$justecela);
>                  $information = @ldap_get_entries($ds, $searchResult);
>                  $user = $information[0]['displayname'][0];
>                  $amumail = $information[0]['amumail'][0];
>                  $mail = $information[0]['mail'][0];
>                  ldap_close($ds);
>                 $default=array('from_addr'=>$amumail,'fullname'=>$user,'id'
> =>'univ-amu');
>                 $old=array('from_addr'=>$mail,'fullname'=>$user,'id'
> =>'univmed');
>                 $Talias=array();
>                 foreach ($information[0]['maillocaladdress'] as  $alias){
>                    if ($alias==$mail or $alias==$amumail) continue;
>
>  $Talias=array_merge($Talias,array('from_addr'=>$alias,'fullname'=>$user,'id'
> =>$alias));
>                 }
>                 $ident=array($default,$old,$Talias);
>                 return(serialize($ident));
>
>
Finaly, in order to avoid identity deletion, I locked that pref:

$_prefs['default_identity']['locked']=true;
And if you generate several identities, you will be able to select
identities without having possibilities to change them or delete .. except
changing default identity

For that possibility, I found no way to protect from_addr. If I lock that
pref, every identity will have the same from_addr.

I succeed finally by getting rid of it in the input form:
$prefGroups['identities']['members']=array('id', 'fullname');

Dom

-- 
Dominique LALOT
Ingénieur Systèmes et Réseaux
http://annuaire.univmed.fr/showuser.php?uid=lalot


More information about the horde mailing list