Class to work with user and group access rights.
Each application may store its access rights in a centralized storage kept by
this model. It keeps (int) access values associated with (string) app_id, (int)
contact_id, (string) name.
To get values for groups, pass a negative group_id instead of contact_id.
Methods summary
public
array|integer
|
#
check( string $name )
Check key for current auth user and application
Check key for current auth user and application
Parameters
Returns
array|integer
|
public
integer|array
|
#
get( integer|array $id = null, string $app_id = null, string|null $name = null, boolean $check_groups = TRUE )
Get access value for user or group. Value for a group is determined from
group acces preferences. Eventual value for a user is MAX(preference for this
user, preferences for groups user is member of).
Get access value for user or group. Value for a group is determined from
group acces preferences. Eventual value for a user is MAX(preference for this
user, preferences for groups user is member of).
Parameters
- $id
integer|array $id (defaults to current auth user) user id if positive; group id if negative (0
is group id for guests); can be a list of such integers.
- $app_id
string $app_id application id; defaults to current application.
- $name
string|null $name key to fetch value for; if not specified, then an array name => value
is returned.
- $check_groups
boolean $check_groups (default is true) if set to false then only own access rights are
considered, as if contact has no groups assigned
Returns
integer|array depends on $name
|
public
array
|
#
getAccessStatus( array $ids )
Parameters
- $ids
array $ids list of contact (if positive) or group (if negative) ids.
Returns
array id => admin|custom; for users with no access at all there's no key=>value
pair.
|
public
boolean
|
#
save( integer $id, string $app_id, string $name, integer $value )
Save access preference for user or group.
Save access preference for user or group.
Parameters
- $id
integer $id treated as user id if positive; group id otherwise; 0 is group id for
guests.
- $app_id
string $app_id application id
- $name
string $name key to save value for
- $value
integer $value int value to save; negative saved as 0.
Returns
boolean
|
public
array
|
#
getAllowedUsers( mixed $app_id, mixed $name )
Parameters
- $app_id
mixed $app_id
- $name
mixed $name
Returns
array (contact_id => value) of users allowed for given app and access key
|
public
array
|
#
getAllowedGroups( mixed $app_id, mixed $name )
Parameters
- $app_id
mixed $app_id
- $name
mixed $name
Returns
array (group_id => value) of groups allowed for given app and access key
|
public
array(group_id
|
#
countApps( )
Returns
array(group_id => total number of applications that storage keeps values for, not counting
webasyst itself)
|
public
array
|
#
getUsers( string $app_id, string $name = 'backend', integer $value = 1 )
Return array ids of users who have access right to given application
Return array ids of users who have access right to given application
Parameters
- $app_id
string $app_id
- $name
string $name
- $value
integer $value minimal user rights
Returns
array
|
public
array
|
#
getApps( integer|array $id, string $name = 'backend', boolean $check_groups = true, boolean $noWA = true )
Get access rights by group and key
Get access rights by group and key
Parameters
- $id
integer|array $id group ids (if positive) or contact ids (negative)
- $name
string $name key to check value for; default is 'backend'
- $check_groups
boolean $check_groups (default is true) if set to false then only own access rights are
considered, as if contact has no groups assigned
- $noWA
boolean $noWA
Returns
array (app_id => value)
|
public
array
|
#
getByIds( array $ids, null|string $app_id = null, string $name = 'backend', boolean $check_groups = true )
Get rights for all contacts/groups from $ids.
Get rights for all contacts/groups from $ids.
Parameters
- $ids
array $ids
- $app_id
null|string $app_id
- $name
string $name
- $check_groups
boolean $check_groups
Returns
array
|