[dev] How to retrieve a user's full name

Michael J Rubinsky mrubinsk at horde.org
Sun Jan 8 17:17:36 UTC 2017


Quoting Sebastian Birnbach <birnbacs at gmail.com>:

> I am trying to retrieve a user's name from Horde. The particular user I am
> testing has two identities and two full names in the preference pane (in my
> case ' Dr. Jekyll' and 'Mr. Hyde').
>
> To my understanding, the full name in the currently active identity should
> be retrievable through $prefs->getValue('fullname'), but this returns an
> empty string. The same is true for $prefs->getValue('id').

This is not correct. You need to use the Horde_Prefs_Identity object,  
not the Horde_Prefs object.

I.e.,

$identity =  
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
$name = $identity->getName(); // User's default identity.

or

$name = $identity->getName($identity);

where $identity is one of the user's identities.



> $prefs->getValues('identities') returns a longer string that contains the
> desired information, but embedded in an unknown structure:
> a:3:{i:0;a:7{s:16:"default_identity";i:0;s:9:"from_addr";s:0:"";s:8:"fullname";s:0:"";s:2:"id";s:18:"Standardidentität";s:10:"identities";s:6:"a:0:{}";s:10:"properties";N;s:8:"location";s:0:"";}i:1;a:4:{s:2:"id";s:6:"Jekyll";s:8:"fullname";s:10:"Dr.
> Jekyll";s:9:"from_addr";s:0:"";s:8:"location";s:0:"";}i:2;a:4:{s:2:"id";s:4:"Hide";s:8:"fullname";s:8:"Mr.
> Hide";s:9:"from_addr";s:0:"";s:8:"location";s:0:"";}}
>
> What is the preferred way of obtaining the full name of the current user?
>
>
>   Sebastian
> --
> dev mailing list
> Frequently Asked Questions: http://wiki.horde.org/FAQ
> To unsubscribe, mail: dev-unsubscribe at lists.horde.org



-- 
mike
The Horde Project
http://www.horde.org
https://www.facebook.com/hordeproject
https://www.twitter.com/hordeproject
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3282 bytes
Desc: S/MIME Signature
URL: <https://lists.horde.org/archives/dev/attachments/20170108/78afa6c9/attachment.bin>


More information about the dev mailing list