WIKINDX API trunk

USER
in package

USER

Common methods for handling users.

Table of Contents

Methods

__construct()  : mixed
USER
checkPassword()  : bool
Compare encrypted passwords.
checkPasswordLdap()  : bool
Compare encrypted passwords on LDAP
deleteUser()  : mixed
Delete user from user table and handle users' metadata etc.
displayUserAddEdit()  : array<string|int, mixed>
create 'added by..., edited by... details for displaying resources
displayUserAddEditPlain()  : string
create username
displayUserDetails()  : string
display user details from users table
environment()  : mixed
set up user environment on first logon
formatUser()  : string
Format a username for displaying 'added by' or 'edited by' details
grabAll()  : mixed
Get users from users.
listUserGroups()  : mixed
List user's user groups
loadFormData()  : mixed
Load user details into an array
writePreferences()  : mixed
insert/update user preferences
writeSessionPreferences()  : mixed
Store user preferences in the session setup_ array
writeUser()  : mixed
Write user details to users

Methods

__construct()

USER

public __construct() : mixed

checkPassword()

Compare encrypted passwords.

public checkPassword(string $usersUsername, string $pwdInput) : bool

Decide if this is standard WIKINDX logon or LDAP logon

Parameters
$usersUsername : string
$pwdInput : string
Return values
bool

checkPasswordLdap()

Compare encrypted passwords on LDAP

public checkPasswordLdap(string $usersUsername, string $pwdInput[, array<string|int, mixed> &$ldapUserEntry = [] ][, string &$trace = "" ][, bool &$executionStatus = false ]) : bool

Return FALSE for password not found or password doesn't match. If LDAP user does not exist in WIKINDX, write user details to WIKINDX Superadmin is always id = 1

LDAP functions adapted from work by Fabrice Boyrie

Limitations:

  • LDAP_OPT_PROTOCOL_VERSION: v3 is stable since 1997 so we don't provide an option to choice the version (v3 is the default in php_ldap).
  • LDAP_OPT_DEREF: dereferencing seems an arcane option and could be avoided by setting the main domain name so we keep the default (never deref)
  • LDAP_OPT_REFERRALS: referrals (forests shared between servers) are very rare and AD don't provide them so we do not support them
Parameters
$usersUsername : string
$pwdInput : string
$ldapUserEntry : array<string|int, mixed> = []

User ldap info

$trace : string = ""
$executionStatus : bool = false
Return values
bool

deleteUser()

Delete user from user table and handle users' metadata etc.

public deleteUser(int $userId, int $transferId) : mixed

Can be either a delete or transfer to another user.

Parameters
$userId : int
$transferId : int

userId to transfer data to. '0' means delete rather than transfer

displayUserAddEdit()

create 'added by..., edited by... details for displaying resources

public displayUserAddEdit(array<string|int, mixed> $row[, bool $both = false ][, string $type = 'resource' ]) : array<string|int, mixed>
Parameters
$row : array<string|int, mixed>
$both : bool = false

Default is FALSE

$type : string = 'resource'

Default is 'resource'

Return values
array<string|int, mixed>

($userAdd, $userEdit)

displayUserAddEditPlain()

create username

public displayUserAddEditPlain(int $addId) : string

Plain version of displayUserAddEdit() used in core/modules/email/EMAIL.php for notify emails

Parameters
$addId : int
Return values
string

displayUserDetails()

display user details from users table

public displayUserDetails(string $form, string $hidden[, int $admin = false ][, array<string|int, mixed> $formData = [] ]) : string

If $admin != FALSE, it is the user id that an admin is editing

Parameters
$form : string
$hidden : string
$admin : int = false

Default is FALSE

$formData : array<string|int, mixed> = []

populated if validation failed

Return values
string

environment()

set up user environment on first logon

public environment(array<string|int, mixed> $row[, string $usersUsername = false ]) : mixed
Parameters
$row : array<string|int, mixed>

A user record

$usersUsername : string = false

Default is FALSE

formatUser()

Format a username for displaying 'added by' or 'edited by' details

public formatUser(array<string|int, mixed> $row, string $type) : string
Parameters
$row : array<string|int, mixed>
$type : string

('add'|'edit')

Return values
string

grabAll()

Get users from users.

public grabAll([bool $full = false ][, bool $useBib = false ][, string $addEdit = 'add' ]) : mixed

Return associative array of id => group of FALSE if no users.

Parameters
$full : bool = false

Default is FALSE

$useBib : bool = false

Default is FALSE

$addEdit : string = 'add'

Default is 'add'

Return values
mixed

FALSE|array

listUserGroups()

List user's user groups

public listUserGroups() : mixed
Return values
mixed

FALSE|array

loadFormData()

Load user details into an array

public loadFormData([int $id = false ]) : mixed
Parameters
$id : int = false

Default is FALSE

writePreferences()

insert/update user preferences

public writePreferences(int $userId[, bool $newUser = false ]) : mixed
Parameters
$userId : int
$newUser : bool = false

writeSessionPreferences()

Store user preferences in the session setup_ array

public writeSessionPreferences(int $userId) : mixed

Can come from users or config (default values for readOnly user in which case $userId = FALSE)

Parameters
$userId : int

writeUser()

Write user details to users

public writeUser([bool $add = true ][, int $admin = 0 ]) : mixed

If $admin = 0, this is a standard user. If $admin = 1, this is the initial configuration/reconfiguration and we need to insert superadmin details into the database. If $admin = 2, this is an admin editing or adding a user. a) the user may not change the username from this screen. When adding a user, we need to check there is not already $usersUsername (caseless) in the database. NB - returns FALSE in case of success, an error message in case of failure.

Parameters
$add : bool = true

Default is TRUE

$admin : int = 0

Default is 0


        
On this page

Search results