User
class User
User Object This object stores almost everything you associate with the user it also provides core functions associated with the user such as login,logout
Traits
Static Cache Trait Adds a static (per request) cache to the object which can hold data for the time of the request (in the frontend) or a certain duration during long running processes. It works together with the global caching system and enforces a static cache clearing in case of global cache clearings as well.
Constants
| ACTIVITY_UPDATE_INTERVAL_SEC |
|
| WEBSERVICE_OAUTH_METHOD |
Set by the webservice as the login method for OAuth logins. |
Properties
| $GPvars | |||
| $policy | |||
| protected string[]|AuthenticationInterface[] | $authentication_methods | Loaded from Config during init() |
Methods
MAGIC Destructor is called when script execution ends
Called upon serialize
Called upon deserialize
Check password against a hashed version
No description
No description
Find matches for a policy (Answers the question: To what IDs does the user have access)
Save a user setting (Duration: Session Lifetime) return mixed
Get the count of users which are counted as active in terms of the license
Fetches the meta data off the database from the selected user, if given. Otherwise the current user will be selected.
No description
Returns the user limit specified in the XELOS licence
No description
Returns a SQL filter to filter by the usergroup of the current user (using fileds filter_allow and filter_deny)
Get Group Classes for user
Return the rights/roles/group tree todo This method should not be here, but in usermanagement_hook
No description
Gets the last user message with the given status
No description
No description
Loads the Centroid of a given Policy Cluster into cache and returns it
Returns the required minimum security level for the passed policy
Loads the Policy User Diff of a given user into cache and returns it
Get the current Auth Method for this session
Get a user setting (Duration: User Lifetime) return bool success
Return User ID by given login/password
!Accessor
returns user_id found through given email address Warning: expects user emails to be unique! only one id is returned
Return User ID by given login/password
returns an array of all user_ids matching the given meta-field conditions
No description
returns user_object found through given email address Warning: expects user emails to be unique! only one object is returned
No description
No description
No description
No description
No description
Hash the password for the user database with bcrypt
Check if User is in a specific group
No description
Checks if the user is logged in via OAuth in the view with a bearer token.
Checks if the user limit of the systems licence has been reached
No description
Determines if the "Enable online status" setting in system_userprofile is activated or not
Is additional authentication required for this user?
Can user change login, password, email? Or is this controlled via auth?
No description
Returns true when the user object has loaded the settings and the user object is usable
No description
No description
Load user settings from database (user needs to be logged in)
Load User Security Groups from Session or DB, depending on availability or dirty session
lazy load policy for user
Try to login the user/pass
Login user with specific authMethod only
Logout out the current user
New User Object optional: Supply login to check for
No description
this function will reload all user-relevant data e.g. very important, if this user has joined a certain rights-group and needs to obtain this group's rights without re-login
Returns the numeric id for the passed group short id (verbose group id)
Salt a password
Save a user setting (Duration: Session Lifetime) return void
With this method you can set a temporary user group for this user This will automatically invalidate existing policy cache
No description
Sets a user message
No description
Get the current Auth Method for this session
Save a user setting (Duration: User Lifetime) return void
No description
this function sets the XF mode to USER and sets the used user to given id
Clears the specified cache pool from the static cache
Retrieves a value from the static cache
Returns an array of all cache keys which have been set
Returns an key/value array with all cached values from the passed pool
Checks if the passed is key has a value set
Removes the passed key
Store a value in the static cache
Switches the currently logged in user to the selected user.
Update Displayname
Checks wether a specific user already exists in the user db
No description
Details
at line 91
__destruct()
MAGIC Destructor is called when script execution ends
at line 121
array
__sleep()
Called upon serialize
This object should NEVER be serialized!
at line 128
__wakeup()
Called upon deserialize
at line 322
static bool
check_password($user_id, $plain_text_password, $hashed_password, string $salt = null)
Check password against a hashed version
at line 1389
clear($var)
No description
at line 3315
mixed
executeInUserContext(Closure $closure, int $userID)
Execute function in user context
at line 2441
array|bool
find_policy(array $search_params, string $source = 'old_compat_mode')
No description
at line 2290
array
find_policy_values(Core|string $instance, string $policy, string|null $table = null, string $id_field = 'id', string $pid_field = 'pid', array|bool $group_context_ids = false, int|bool|array $group_security_id = false, bool|null $restrictedAccess = true, bool $returnUnrestrictedValues = true)
Find matches for a policy (Answers the question: To what IDs does the user have access)
at line 1380
get($var, $context = false)
Save a user setting (Duration: Session Lifetime) return mixed
at line 3481
int
getActiveUserCountForLicense()
Get the count of users which are counted as active in terms of the license
at line 3341
array
getMetaPopData()
Fetches the meta data off the database from the selected user, if given. Otherwise the current user will be selected.
at line 3412
int|null
getTempSecurityGroupId()
No description
at line 3459
int
getUserLimit()
Returns the user limit specified in the XELOS licence
at line 829
array|mixed
get_accessible_pages()
No description
at line 938
string
get_filter_where_statement(string|bool $table_name = false, bool $strict = true)
Returns a SQL filter to filter by the usergroup of the current user (using fileds filter_allow and filter_deny)
at line 1665
string
get_group_class(int $user_id = false)
Get Group Classes for user
at line 2916
string
get_group_tree(bool|int $user_id = false, mixed $filter = false, bool $limit_to_tenant = false, bool $hide_systemonly = false)
Return the rights/roles/group tree todo This method should not be here, but in usermanagement_hook
at line 1518
array
get_groups(int $group_security_id = null)
No description
at line 1479
bool
get_message(string $status = FATAL)
Gets the last user message with the given status
Example:
$XF->lib->user->set_message(_("File has been saved successfull"),OK);
echo ($XF->lib->user->get_message(OK));
at line 739
get_mobile_token()
No description
at line 799
get_page_options($instance_id, $page_id)
No description
at line 1691
mixed
get_policy_cluster_centroids(mixed $cluster_id)
Loads the Centroid of a given Policy Cluster into cache and returns it
at line 2082
bool
get_policy_security_level(string $instance, string $policy)
Returns the required minimum security level for the passed policy
at line 1737
mixed
get_policy_user_diff($user_id)
Loads the Policy User Diff of a given user into cache and returns it
at line 1311
string
get_session_auth_method()
Get the current Auth Method for this session
at line 1440
get_setting($var, $instance_id = false)
Get a user setting (Duration: User Lifetime) return bool success
at line 1223
User|bool
get_user_by_login(string $login, string $password = NULL)
Return User ID by given login/password
at line 1272
int|string
get_user_id(bool $format_for_cache = false)
!Accessor
at line 1151
int
get_user_id_by_email(string $email)
returns user_id found through given email address Warning: expects user emails to be unique! only one id is returned
at line 1207
int
get_user_id_by_login(string $login, string $password = NULL)
Return User ID by given login/password
at line 3208
array
get_user_ids_by_meta_value(string $meta_field_name, mixed $meta_values, bool $active_only = true)
returns an array of all user_ids matching the given meta-field conditions
at line 1108
User|User[]|false
get_user_obj(int|string|array|bool $user_id = false, bool $useCache = true)
No description
at line 1187
User
get_user_obj_by_email(string $email)
returns user_object found through given email address Warning: expects user emails to be unique! only one object is returned
at line 2886
int
get_userid_by_email(string $email)
No description
at line 761
bool
has_access(string $instance_id, null $page = null, int $group_security_id = 0, bool $include_public_pages = true)
No description
at line 2008
bool
has_policy(string $instance, string $policy, string $value = '*', string|bool $target_user = false, int|bool $group_security_id = false, string $default_policy = 'deny')
No description
at line 2058
bool
has_policy_by_security_level(string $instance, string $policy, string $security_level)
No description
at line 2118
array|bool
has_tree_policy(string $instance, string $policy, string $value, string $table = false, string $id_field = 'id', string $pid_field = 'pid', int $group_security_id = false, bool $default_access = false, string $is_root_field = false, int $context_id = false)
No description
at line 291
static string
hash_password(string $user_id, string $plain_text_password, string $salt = null, bool $use_old_algorithm = false)
Hash the password for the user database with bcrypt
at line 1501
bool
in_group(mixed $group_id)
Check if User is in a specific group
at line 141
init()
No description
at line 1371
bool
isApiAccess()
Checks if the user is logged in via OAuth in the view with a bearer token.
at line 3441
bool
isUserLimitReached()
Checks if the user limit of the systems licence has been reached
at line 3081
bool
isUserModeEnabled()
No description
at line 3373
bool
isUserStatusEnabled()
Determines if the "Enable online status" setting in system_userprofile is activated or not
at line 1349
bool
is_admin_auth_required()
Is additional authentication required for this user?
at line 1319
bool
is_controlled_via_auth()
Can user change login, password, email? Or is this controlled via auth?
at line 746
is_guest()
No description
at line 1409
bool
is_loaded()
Returns true when the user object has loaded the settings and the user object is usable
at line 1291
is_logged_in()
No description
at line 734
true
is_urlaccess()
No description
at line 1416
load_settings()
Load user settings from database (user needs to be logged in)
at line 1587
protected
load_user_groups()
Load User Security Groups from Session or DB, depending on availability or dirty session
at line 1900
bool|array
load_user_policy(string $instance, string $policy, string $value = false, int[]|int $group_security_ids = [], string $default_policy = 'deny')
lazy load policy for user
at line 360
bool
login(string $login, string $password, bool $this_login_only = false, array $disallowed_methods = null)
Try to login the user/pass
at line 341
bool
loginWithAuthMethod(AuthenticationInterface $authMethod, string $login = null, string $password = null)
Login user with specific authMethod only
at line 1005
bool
logout(bool $skip_auth_logout = false, bool $addLogEntry = true)
Logout out the current user
at line 1054
User
new_user_obj(string $login = null)
New User Object optional: Supply login to check for
at line 975
bool
refresh(bool $only_user_specific = false)
No description
at line 3165
reload()
this function will reload all user-relevant data e.g. very important, if this user has joined a certain rights-group and needs to obtain this group's rights without re-login
at line 1536
int|null
resolve_group_id(string|int $group_short_id, bool $force = false)
Returns the numeric id for the passed group short id (verbose group id)
at line 307
static string
salt_password($user_id, $plain_text_password, string $salt = null)
Salt a password
at line 1398
set($var, $value)
Save a user setting (Duration: Session Lifetime) return void
at line 3424
void
setTempSecurityGroupId(int|null $tempSecurityGroupId = null)
With this method you can set a temporary user group for this user This will automatically invalidate existing policy cache
Use Case: Apply usergroup "mobile access" to modify
at line 2606
set_group_policy(array $groups, string $instance, string $policy, mixed $value = false, bool $allow_parity = true, int $group_security_id = 0)
No description
at line 1459
set_message(string $msg, string $status = OK)
Sets a user message
Used for intra-module message exchange, e.g. save or error messages
at line 2742
set_policy(string $instance, string $policy, string $value = '', bool $allow = true)
No description
at line 1303
string
set_session_auth_method($auth_method)
Get the current Auth Method for this session
at line 1431
set_setting($var, $value, $instance_id = false)
Save a user setting (Duration: User Lifetime) return void
at line 2760
set_user_policy(int|int[] $users, string $instance, string $policy, mixed $value = '', bool $allow_parity = true, bool $modify_only_passed_users = false, int $group_security_id = 0)
No description
at line 3093
set_xf_user_mode(string $action, int|null $new_user_id = null, $is_guest = false)
this function sets the XF mode to USER and sets the used user to given id
it is used for daemons to be able to use user context
in
StaticCacheTrait at line 121
static void
staticCacheClearAllCachePools()
No description
in
StaticCacheTrait at line 114
static void
staticCacheClearCachePool($cache_pool = 'default')
Clears the specified cache pool from the static cache
in
StaticCacheTrait at line 61
static array|string|int|bool|null
staticCacheGet($key, string $cache_pool = 'default')
Retrieves a value from the static cache
in
StaticCacheTrait at line 98
static array
staticCacheGetKeys(string $cache_pool = 'default')
Returns an array of all cache keys which have been set
in
StaticCacheTrait at line 107
static array
staticCacheGetPool($cache_pool)
Returns an key/value array with all cached values from the passed pool
in
StaticCacheTrait at line 34
static bool
staticCacheIsEnabled()
No description
in
StaticCacheTrait at line 85
static bool
staticCacheIsSet($key, string $cache_pool = 'default')
Checks if the passed is key has a value set
in
StaticCacheTrait at line 73
static
staticCacheRemove($key, string $cache_pool = 'default')
Removes the passed key
in
StaticCacheTrait at line 46
static void
staticCacheSet(string|int $key, mixed $value, string $cache_pool = 'default')
Store a value in the static cache
at line 3383
switchUser(int $userId, string $loginMethod)
Switches the currently logged in user to the selected user.
at line 3257
bool|mixed
update_displayname(mixed $user_id = false, string $force_display_name = '')
Update Displayname
at line 1562
user_exists($login)
Checks wether a specific user already exists in the user db
at line 179
user_init($only_user_specific = false)
No description