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 array | $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
creates a group in sys|group.
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
Fetches the meta data off the database from the selected user, if given. Otherwise the current user will be selected.
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 Security Context
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
Return a fixed length string (e.g. 00000001 for userid 1)
!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.
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
Check if 2-Factor-Auth is activated and applicable for the currently logged in user
Check if the user needs to use two factor authorization.
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
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
Sends an email to the user with the authentication token required for two factor authentication.
Save a user setting (Duration: Session Lifetime) return void
No description
Sets a user message
No description
Set Security Context
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 73
__destruct()
MAGIC Destructor is called when script execution ends
at line 103
array
__sleep()
Called upon serialize
This object should NEVER be serialized!
at line 118
__wakeup()
Called upon deserialize
at line 314
static bool
check_password($user_id, $plain_text_password, $hashed_password, string $salt = null)
Check password against a hashed version
at line 1507
clear($var)
No description
at line 3302
mixed
create_group(string $label, string $grouptype = 'group', int $pid = 0, string $name = "", int $is_active = 1, string $category = 'user_defined', string $description = "", string $css_class = "", string $groupconfig = "")
creates a group in sys|group.
at line 3472
mixed
executeInUserContext(Closure $closure, int $userID)
Execute function in user context
at line 2560
array|bool
find_policy(array $search_params, string $source = 'old_compat_mode')
No description
at line 2431
mixed
find_policy_values(string $instance, mixed $policy, string|bool $table = false, string $id_field = 'id', string $pid_field = 'pid', array|bool $group_context_ids = false, int|bool $group_security_id = false)
Find matches for a policy (Answers the question: To what IDs does the user have access)
at line 1497
get($var, $context = false)
Save a user setting (Duration: Session Lifetime) return mixed
at line 3498
array
getMetaPopData()
Fetches the meta data off the database from the selected user, if given. Otherwise the current user will be selected.
at line 943
array|mixed
get_accessible_pages()
No description
at line 1051
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 1774
string
get_group_class(int $user_id = false)
Get Group Classes for user
at line 3028
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 1636
array
get_groups(int $group_security_id = null)
No description
at line 1597
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 854
get_mobile_token()
No description
at line 913
get_page_options($instance_id, $page_id)
No description
at line 1800
mixed
get_policy_cluster_centroids(mixed $cluster_id)
Loads the Centroid of a given Policy Cluster into cache and returns it
at line 2192
bool
get_policy_security_level(string $instance, string $policy)
Returns the required minimum security level for the passed policy
at line 1846
mixed
get_policy_user_diff($user_id)
Loads the Policy User Diff of a given user into cache and returns it
at line 2374
array|bool
get_security_context(string $instance)
Get Security Context
at line 1430
string
get_session_auth_method()
Get the current Auth Method for this session
at line 1558
get_setting($var, $instance_id = false)
Get a user setting (Duration: User Lifetime) return bool success
at line 1333
User|bool
get_user_by_login(string $login, string $password = NULL)
Return User ID by given login/password
at line 1405
string
get_user_cache_id(int $user_id = 0)
Return a fixed length string (e.g. 00000001 for userid 1)
at line 1382
int|string
get_user_id(bool $format_for_cache = false)
!Accessor
at line 1261
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 1317
int
get_user_id_by_login(string $login, string $password = NULL)
Return User ID by given login/password
at line 3365
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 1221
User|User[]
get_user_obj(int|string|array|bool $user_id = false, bool $useCache = true)
No description
at line 1297
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 2998
int
get_userid_by_email(string $email)
No description
at line 875
bool
has_access(string $instance_id, string|bool $page = false, int $group_security_id = 0, bool $include_public_pages = true)
No description
at line 2112
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 2168
bool
has_policy_by_security_level(string $instance, string $policy, string $security_level)
No description
at line 2228
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 283
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 1619
bool
in_group(mixed $group_id)
Check if User is in a specific group
at line 138
init()
No description
at line 1488
bool
isApiAccess()
Checks if the user is logged in via OAuth in the view with a bearer token.
at line 3530
bool
isUserStatusEnabled()
Determines if the "Enable online status" setting in system_userprofile is activated or not
at line 1466
bool
is_admin_auth_required()
Is additional authentication required for this user?
at line 1438
bool
is_controlled_via_auth()
Can user change login, password, email? Or is this controlled via auth?
at line 861
is_guest()
No description
at line 1527
bool
is_loaded()
Returns true when the user object has loaded the settings and the user object is usable
at line 1410
is_logged_in()
No description
at line 352
bool
is_two_factor_auth_activated($global_enforcement_only = false)
Check if 2-Factor-Auth is activated and applicable for the currently logged in user
at line 393
bool
is_two_factor_needed()
Check if the user needs to use two factor authorization.
at line 849
true
is_urlaccess()
No description
at line 1534
load_settings()
Load user settings from database (user needs to be logged in)
at line 1706
protected
load_user_groups()
Load User Security Groups from Session or DB, depending on availability or dirty session
at line 2004
load_user_policy(string $instance, string $policy, string $value = false, int[] $group_security_ids = array(), string $default_policy = 'deny')
lazy load policy for user
at line 441
bool
login(string $login, string $password, bool $this_login_only = false, array $disallowed_methods = null)
Try to login the user/pass
at line 1117
bool
logout(bool $skip_auth_logout = false)
Logout out the current user
at line 1168
User
new_user_obj(string $login = null)
New User Object optional: Supply login to check for
at line 1088
bool
refresh(bool $only_user_specific = false)
No description
at line 3259
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 1654
string
resolve_group_id(mixed $group_short_id)
Returns the numeric id for the passed group short id (verbose group id)
at line 299
static string
salt_password($user_id, $plain_text_password, string $salt = null)
Salt a password
at line 419
send_two_factor_code()
Sends an email to the user with the authentication token required for two factor authentication.
at line 1516
set($var, $value)
Save a user setting (Duration: Session Lifetime) return void
at line 2725
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 1577
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 2857
set_policy(string $instance, string $policy, string $value = '', bool $allow = true)
No description
at line 2360
void
set_security_context(string $instance, $security_level, $exclude_dyn_policies = false)
Set Security Context
at line 1422
string
set_session_auth_method($auth_method)
Get the current Auth Method for this session
at line 1549
set_setting($var, $value, $instance_id = false)
Save a user setting (Duration: User Lifetime) return void
at line 2875
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 3194
set_xf_user_mode(string $action, int|bool $new_user_id = false, $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 3540
switchUser(int $userId, string $loginMethod)
Switches the currently logged in user to the selected user.
at line 3414
bool|mixed
update_displayname(mixed $user_id = false, string $force_display_name = '')
Update Displayname
at line 1681
user_exists($login)
Checks wether a specific user already exists in the user db
at line 175
user_init($only_user_specific = false)
No description