Datamanager 2 privilege set datatype.

This type encapsulates a simple privilege or set thereof. You need to specify privilege name, assignee and value. If the corresponding checkbox is set, all privileges will be set accordingly. If it is unset, all privileges will be set to INHERIT. This type only supports a checkbox as widget.

When determining the current value of the type, only the first specified privilege is checked. If it is set and matches the configuraiton, the whole list is assumed set. On every sync-to-storage cycle, the current boolean state will be set to accordingly (thus overwriting existing privileges).

If the current user does not have privileges permissions on the storage object, nothing is done.

As with the attachment types, this type also uses the base storage object directly. If no object is set while reading, no temporary object is requested, the privilege is assumed unset in that case.

The class extends the boolean type, overriding the storage I/O methods only. The storage location should be set to null.

While all boolean widgets are usable with this type, it is recommended to use the privilegecheckbox widget instead, which validates permissions before actually doing anything.

Available configuration options:

  • All of the boolean base type.
  • Array privileges: This array is a list of arrays containing the privilege name, assignee and value, in that order. Example: 'privileges' => Array( Array('midgard:update', 'USERS', MIDCOM_PRIVILEGE_ALLOW)).
package midcom.helper.datamanager2

 Methods

_on_initialize ()

This startup handler validates that the privileges array is populated.

convert_from_storage ($source)

Loads the privileges value from the database if we have sufficient privileges, otherwise the value stays false.

This is ok as storage operations will be ignored as well.

Parameters

$source

convert_to_raw ()

convert_to_storage ()

Stores the privileges to the database.

This call retrieves a temporary object if necessary. If the midgard:privileges privilege is missing, nothing is updated.

 Properties

 

Array $privileges

Privileges declarations.

This array is a list of arrays containing the privilege name, assignee and value, in that order. Example: 'privileges' => Array( Array('midgard:update', 'USERS', MIDCOM_PRIVILEGE_ALLOW)).

Assignees should be valid string-based identifiers like group:xxx or user:xxxx etc. The value must be one of MIDCOM_PRIVILEGE_ALLOW or ..._DENY.