UserOperations
in package
Class for doing user related functions. Maybe of the User object functions are just wrappers around these.
Tags
Table of Contents
Methods
- AddMemberGroup() : mixed
- Add the user to the specified group
- CheckPermission() : bool
- Test if the user has the specified permission
- CountPageOwnershipByID() : mixed
- Show the number of pages the given user's id owns.
- DeleteUserByID() : mixed
- Deletes an existing user from the database.
- GenerateDropdown() : mixed
- Generate an HTML select element containing a user list
- get_instance() : UserOperations
- Get the reference to the only instance of this object
- GetList() : array<string|int, mixed>
- Generate an array of admin userids to usernames, suitable for use in a dropdown.
- GetMemberGroups() : array<string|int, mixed>
- Get the ids of all groups to which the user belongs.
- InsertUser() : mixed
- Saves a new user to the database.
- IsSuperuser() : bool
- Test if the specified user is a member of the admin group, or is the first user account
- LoadUserByID() : mixed
- Loads a user by user id.
- LoadUserByUsername() : mixed
- Loads a user by username.
- LoadUsers() : mixed
- Gets a list of all users
- LoadUsersInGroup() : array<string|int, mixed>
- Gets a list of all users in a given group
- UpdateUser() : mixed
- Updates an existing user in the database.
- UserInGroup() : true
- Tests $uid is a member of the group identified by $gid
Methods
AddMemberGroup()
Add the user to the specified group
public
AddMemberGroup(int $uid, int $gid) : mixed
Parameters
- $uid : int
- $gid : int
CheckPermission()
Test if the user has the specified permission
public
CheckPermission(int $userid, string $permname) : bool
Given the users member groups, test if any of those groups have the specified permission.
Parameters
- $userid : int
- $permname : string
Return values
boolCountPageOwnershipByID()
Show the number of pages the given user's id owns.
public
CountPageOwnershipByID(mixed $id) : mixed
Parameters
- $id : mixed
-
Id of the user to count
Tags
Return values
mixed —Number of pages they own. 0 if any problems.
DeleteUserByID()
Deletes an existing user from the database.
public
DeleteUserByID(mixed $id) : mixed
Parameters
- $id : mixed
-
Id of the user to delete
Tags
GenerateDropdown()
Generate an HTML select element containing a user list
public
GenerateDropdown([int $currentuserid = null ][, string $name = 'ownerid' ]) : mixed
Parameters
- $currentuserid : int = null
- $name : string = 'ownerid'
-
The HTML element name.
get_instance()
Get the reference to the only instance of this object
public
static & get_instance() : UserOperations
Return values
UserOperationsGetList()
Generate an array of admin userids to usernames, suitable for use in a dropdown.
public
GetList() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>GetMemberGroups()
Get the ids of all groups to which the user belongs.
public
GetMemberGroups(int $uid) : array<string|int, mixed>
Parameters
- $uid : int
Return values
array<string|int, mixed>InsertUser()
Saves a new user to the database.
public
InsertUser(mixed $user) : mixed
Parameters
- $user : mixed
-
User object to save
Tags
Return values
mixed —The new user id. If it fails, it returns -1.
IsSuperuser()
Test if the specified user is a member of the admin group, or is the first user account
public
IsSuperuser(int $uid) : bool
Parameters
- $uid : int
Return values
boolLoadUserByID()
Loads a user by user id.
public
LoadUserByID(mixed $id) : mixed
Parameters
- $id : mixed
-
User id to load
Tags
Return values
mixed —If successful, the filled User object. If it fails, it returns false.
LoadUserByUsername()
Loads a user by username.
public
LoadUserByUsername(mixed $username[, mixed $password = '' ][, mixed $activeonly = true ][, mixed $adminaccessonly = false ]) : mixed
Does not use a cache, so use sparingly.
Parameters
- $username : mixed
-
Username to load
- $password : mixed = ''
-
Password to check against
- $activeonly : mixed = true
-
Only load the user if they are active
- $adminaccessonly : mixed = false
-
Only load the user if they have admin access
Tags
Return values
mixed —If successful, the filled User object. If it fails, it returns false.
LoadUsers()
Gets a list of all users
public
LoadUsers([int $limit = 10000 ][, int $offset = 0 ]) : mixed
Parameters
- $limit : int = 10000
-
The maximum number of users to return
- $offset : int = 0
-
The offset
Tags
LoadUsersInGroup()
Gets a list of all users in a given group
public
LoadUsersInGroup(mixed $groupid) : array<string|int, mixed>
Parameters
- $groupid : mixed
-
Group for the loaded users
Return values
array<string|int, mixed> —An array of User objects
UpdateUser()
Updates an existing user in the database.
public
UpdateUser(mixed $user) : mixed
Parameters
- $user : mixed
-
User object to save
Tags
Return values
mixed —If successful, true. If it fails, false.
UserInGroup()
Tests $uid is a member of the group identified by $gid
public
UserInGroup(int $uid, int $gid) : true
Parameters
- $uid : int
-
User ID to test
- $gid : int
-
Group ID to test
Return values
true —if test passes, false otherwise