Add public_contact() function
- Add function to retrieve the public contact id (uid = 0) of the current logged-in user
This commit is contained in:
parent
4d591c4a07
commit
da5bbe8b50
1 changed files with 25 additions and 1 deletions
26
boot.php
26
boot.php
|
@ -1889,11 +1889,35 @@ function goaway($s) {
|
|||
* @return int|bool user id or false
|
||||
*/
|
||||
function local_user() {
|
||||
if((x($_SESSION,'authenticated')) && (x($_SESSION,'uid')))
|
||||
if (x($_SESSION, 'authenticated') && x($_SESSION, 'uid')) {
|
||||
return intval($_SESSION['uid']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the public contact id of logged in user or false.
|
||||
*
|
||||
* @return int|bool public contact id or false
|
||||
*/
|
||||
function public_contact() {
|
||||
static $public_contact_id = false;
|
||||
|
||||
if (!$public_contact_id && x($_SESSION, 'authenticated')) {
|
||||
if (x($_SESSION, 'my_address')) {
|
||||
// Local user
|
||||
$public_contact_id = intval(get_contact($_SESSION['my_address'], 0));
|
||||
} else if (x($_SESSION, 'visitor_home')) {
|
||||
// Remote user
|
||||
$public_contact_id = intval(get_contact($_SESSION['visitor_home'], 0));
|
||||
}
|
||||
} else if (!x($_SESSION, 'authenticated')) {
|
||||
$public_contact_id = false;
|
||||
}
|
||||
|
||||
return $public_contact_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns contact id of authenticated site visitor or false
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue