[dev] getting a user's prefs without loggin the user

Atif Ghaffar aghaffar@developer.ch
Tue, 10 Jul 2001 12:10:00 +0200


Hi Jan,

thanks for pointing that out.

So this code should work then.
If I goto www.aghaffar.ispman.net, then the username is aghaffar_ispman_net


My prefs driver is LDAP and username and password are both set to "".
So in an auth session, the username and pass of the user is passed to 
the LDAP driver. What shall I pass as password in an anonymous session?

__CODE__


<?
define('HOMEPAGE_BASE', dirname(__FILE__));
require HOMEPAGE_BASE . '/../config/horde.php';
require HOMEPAGE_BASE . '/../lib/Horde.php';
require HOMEPAGE_BASE . '/../lib/Prefs.php';


$_server_name=preg_replace("/www\./", "", $SERVER_NAME);
$_user_name=str_replace('.', "_", $_server_name);

$conf['prefs']['params']['user_hook']="getUserName";

$prefs = Prefs::factory($conf['prefs']['driver'] , "" , "", "", 
$conf['prefs']['params']);



function getusername(){
    return $GLOBALS[$_user_name];
}


echo $prefs->getValue("fullname"); /* this should print "Atif Ghaffar" 
but does not */

?>

__END_CODE__



Jan Schneider wrote:

> You can use $params['user_hook'] = "function_to_get_user" to set the =
username 
> manually.
> Please take a look at lib/Prefs.php.
> 
> Jan.
> 
> 
> Zitat von Atif Ghaffar <aghaffar@developer.ch>:
> 
> 
>>Hi,
>>
>>I am writting a small user's homepage creation module for Horde.
>>I would like to use the Horde's prefs system to get information about 
>>the user.
>>
>>Example if you go to
>>www.aghaffar.ispman.net (username: aghaffar)
>>then the script may get user's name, company name, phone number etc to =

>>create a small homepage for this user.
>>
>>So is it possible to call $prefs->getValue("something") without logging=
 
>>in as that user?
>>



-- 
Atif Ghaffar
Internet Development Manager
4unet AG/SA/Ltd.
---------------------------.
           +41 21 351 53 60 ¦ voice
           +41 79 659 89 72 ¦ mobile
           +41 21 254 53 62 ¦ fax
       http://www.4unet.net ¦ www
http://www.atifghaffar.com ¦ homepage
     atif.ghaffar@4unet.net ¦ email