UserOperations View code

Class for doing user related functions. Maybe of the User object functions are just wrappers around these.

package

CMS

license

GPL

since 0.6.1

Methods

get_instance() : \UserOperations

Get the reference to the only instance of this object

static

Response

\UserOperations

LoadUsers(integer $limit = 10000, integer $offset) 

Gets a list of all users

Arguments

integer $limit

The maximum number of users to return

integer $offset

The offset

LoadUsersInGroup(mixed $groupid) : array

Gets a list of all users in a given group

Arguments

mixed $groupid

Group for the loaded users

Response

array

An array of User objects

LoadUserByUsername(mixed $username, mixed $password = '', mixed $activeonly = true, mixed $adminaccessonly = false) : mixed

Loads a user by username.

Does not use a cache, so use sparingly.

Arguments

mixed $username

Username to load

mixed $password

Password to check against

mixed $activeonly

Only load the user if they are active

mixed $adminaccessonly

Only load the user if they have admin access

Response

mixed

If successful, the filled User object. If it fails, it returns false.

LoadUserByID(mixed $id) : mixed

Loads a user by user id.

Arguments

mixed $id

User id to load

Response

mixed

If successful, the filled User object. If it fails, it returns false.

InsertUser(mixed $user) : mixed

Saves a new user to the database.

Arguments

mixed $user

User object to save

Response

mixed

The new user id. If it fails, it returns -1.

UpdateUser(mixed $user) : mixed

Updates an existing user in the database.

Arguments

mixed $user

User object to save

Response

mixed

If successful, true. If it fails, false.

DeleteUserByID(mixed $id) 

Deletes an existing user from the database.

Arguments

mixed $id

Id of the user to delete

CountPageOwnershipByID(mixed $id) : mixed

Show the number of pages the given user's id owns.

Arguments

mixed $id

Id of the user to count

Response

mixed

Number of pages they own. 0 if any problems.

GetList() : array

Generate an array of admin userids to usernames, suitable for use in a dropdown.

Response

array

GenerateDropdown(integer $currentuserid = null, string $name = 'ownerid') 

Generate an HTML select element containing a user list

deprecated

Arguments

integer $currentuserid

string $name

The HTML element name.

UserInGroup(integer $uid, integer $gid) : true

Tests $uid is a member of the group identified by $gid

Arguments

integer $uid

User ID to test

integer $gid

Group ID to test

Response

true

if test passes, false otherwise

IsSuperuser(integer $uid) : boolean

Test if the specified user is a member of the admin group, or is the first user account

Arguments

integer $uid

Response

boolean

GetMemberGroups(integer $uid) : array

Get the ids of all groups to which the user belongs.

Arguments

integer $uid

Response

array

AddMemberGroup(integer $uid, integer $gid) 

Add the user to the specified group

Arguments

integer $uid

integer $gid

CheckPermission(integer $userid, string $permname) : boolean

Test if the user has the specified permission

Given the users member groups, test if any of those groups have the specified permission.

Arguments

integer $userid

string $permname

Response

boolean