add incognito mode, allows to hide my user ID. For example, this is useful to access public resources while a user is still logged in

This commit is contained in:
Bjoern Schiessle 2013-11-22 13:55:38 +01:00
parent 391f267d38
commit 7e4f50d4e3
1 changed files with 13 additions and 1 deletions

View File

@ -54,6 +54,9 @@ class OC_User {
private static $_setupedBackends = array();
// bool, stores if a user want to access a resource anonymously, e.g if he opens a public link
private static $incognitoMode = false;
/**
* @brief registers backend
* @param string $backend name of the backend
@ -319,6 +322,15 @@ class OC_User {
return false;
}
/**
* @brief set incognito mode, e.g. if a user wants to open a public link
* @param bool $status
*/
public static function setIncognitoMode($status) {
self::$incognitoMode = $status;
}
/**
* Supplies an attribute to the logout hyperlink. The default behaviour
* is to return an href with '?logout=true' appended. However, it can
@ -354,7 +366,7 @@ class OC_User {
*/
public static function getUser() {
$uid = OC::$session ? OC::$session->get('user_id') : null;
if (!is_null($uid)) {
if (!is_null($uid) && self::$incognitoMode === false) {
return $uid;
} else {
return false;