Class waRightConfig
An interface between application and contacts app to allow access rights
management.
To allow custom access configuration for an app, add a 'rights' => true to
/lib/confid/app.php Then create /lib/appnameRightsConfig.class.php with
appnameRightConfig class that extends waRightConfig. Instance of this class will
be used to get HTML for access control form for current app.
Though the HTML form can be thoroughly generated by app (by overriding
getHTML), normally it is not needed. Class has a templating system to add
controls commonly used in access control forms. To use this feature, override
init() and use addItem() to add controls to the form. The default implementation
if getHTML() will build the form for you. If you need some custom controls, you
can override getItemHTML() to generate them.
Normally system keeps access_key => value pairs in a centralized storage.
Application may choose to implement its own storage for all or some of the
access keys. getRights() and setRights() are hooks that get called when admin
manages application access for contact or group. This allows application to
control whether given key => value pair to be stored by system or by
application.
Methods summary
public
|
|
public
|
#
init( )
Override in subclass to initialize access keys. See addItem()
Override in subclass to initialize access keys. See addItem()
|
public
|
#
addItem( string $name, string $label, string $type = 'checkbox', array $params = array() )
Adds one control to the form that the default implementation of getHTML will
return.
Adds one control to the form that the default implementation of getHTML will
return.
Type: checkbox
- cssclass: CSS class for <tr>
Type: list - list of checkboxes with $label being a header above them.
- cssclass: CSS class for <tr>
- items: array(access_key => human readable name) - checkboxes to show in
the list.
- hint1: string to show above left checkbox col; 'all_checkbox' will show a
checkbox to check everything at once, and its status will be saved with
access_key $name.all
- hint2: string to show above right checkbox col, if it's present
Parameters
- $name
string $name access_key to store in DB
- $label
string $label human readable name for a field
- $type
string $type control type; currently checkbox|list
- $params
array $params parameters passed to getItemHTML
|
public
array
|
#
getRights( integer|array $contact_id )
Return custom access rights managed by app for contact id (not considering
group he's in) or a set of group ids. Application must override this if it uses
custom access rights storage.
Return custom access rights managed by app for contact id (not considering
group he's in) or a set of group ids. Application must override this if it uses
custom access rights storage.
Parameters
- $contact_id
integer|array $contact_id contact_id (positive) or a list of group_ids (positive)
Returns
array access_key => value; for group_ids aggregate status is returned, as if for a
member of all groups.
|
public
boolean
|
#
setRights( integer $contact_id, string $right, mixed $value = null )
Update custom rights storage for given contact and access_key setting given
value.
Update custom rights storage for given contact and access_key setting given
value.
Parameters
- $contact_id
integer $contact_id contact_id (if positive) or group id (if negative)
- $right
string $right access_key to set value for
- $value
mixed $value value to save
Returns
boolean false to write this key and value to system storage; true if application chooses
to keep it in its own place.
|
public
|
#
clearRights( integer $contact_id )
Remove all access control data for given contact or group id.
Remove all access control data for given contact or group id.
Parameters
- $contact_id
integer $contact_id contact id (if positive) or group id (if negative)
|
public
array
|
#
setDefaultRights( integer $contact_id )
Set default access for given contact and return access rights to set up in
system access storage.
Set default access for given contact and return access rights to set up in
system access storage.
Parameters
- $contact_id
integer $contact_id
Returns
array access key => value
|
public
string
|
#
getHTML( array $rights = array(), array $inherited = null )
Return HTML to include into page to customize user access for
application.
Return HTML to include into page to customize user access for
application.
Parameters
- $rights
array $rights access_key => value for both system-managed and app-managed rights
- $inherited
array $inherited access_key => value for rights inherited from groups member is in.
Default is null: do not show group UI at all (e.g. when managing group access)
Returns
string - generated HTML
|
protected
string
|
#
getItemHTML( string $name, string $label, string $type, array $params, array $rights, array $inherited = null )
Generate HTML for one field that was previously added by addItem(). Used by
the default implementation of getHTML() to build a form. See addItem() for
details
Generate HTML for one field that was previously added by addItem(). Used by
the default implementation of getHTML() to build a form. See addItem() for
details
Parameters
- $name
string $name access_key to store in DB
- $label
string $label human readable name for a field
- $type
string $type control type; currently checkbox|list
- $params
array $params parameters
- $rights
array $rights
- $inherited
array $inherited
Returns
string HTML
Throws
|
Properties summary
protected
mixed
|
$app
|
|
|
protected
array
|
$items
|
array() |
|