Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
MvvPerm Class Reference

Public Member Functions

 __construct (ModuleManagementModel $mvv_object)
 
 __call ($name, $arguments)
 
 setVariant ($variant)
 
 havePerm ($perm, $status=null, $user_id=null, $institut_id=null)
 
 haveObjectPerm ($perm, $user_id=null)
 
 haveDfEntryPerm ($datafield_id, $perm)
 
 getFieldPerm ($field, $user_id=null, $institut_id=null)
 
 haveFieldPerm ($field, $perm=null, $user_id=null, $institut_id=null)
 
 disable ($field, $perm=null, $user_id=null, $institut_id=null)
 

Static Public Member Functions

static get ($mvv_object)
 
static __callStatic ($name, $arguments)
 
static getPerm ($object, $status=null, $user_id=null, $institut_id=null, $variant=null)
 
static getRoles ($user_id)
 
static refreshPrivileges ($mvv_table)
 
static getOwnInstitutes ($user_id=null, $mvv_roles=null)
 

Data Fields

const PERM_READ = 1
 
const PERM_WRITE = 3
 
const PERM_CREATE = 7
 
const PERM_ADMIN = 15
 

Constructor & Destructor Documentation

__construct ( ModuleManagementModel  $mvv_object)

Creates a new perm object for given mvv object.

Parameters
ModuleManagementModel$mvv_object

Member Function Documentation

__call (   $name,
  $arguments 
)

Intercepts instance methods to retrieve permission from configuration.

Allowed calls are:

havePermPERM($status, $user_id, $institut_id)

See Also
MvvPerm::havePerm() PERM is the constant defining the permission (MvvPerm::PERM_ADMIN, MvvPerm::PERM_CREATE, MvvPerm::PERM_READ, MvvPerm::PERM_WRITE) $status: The status of mvv object defined in config. Status 'default' as default. $user_id: The id of an user. Id of current user as default. $institut_id: The id of an institute or an array of institute ids the user has a mvv related role. All three arguments are optional

getFieldPermFIELD($user_id, $institut_id)

See Also
MvvPerm::getFieldPerm() FIELD is the name of the table field. $user_id: The id of an user. Id of current user as default. $institut_id: The id of an institute or an array of institute ids the user has a mvv related role. All two arguments are optional.

haveFieldPermFIELD($perm, $user_id, $institut_id)

See Also
MvvPerm::haveFieldPerm() FIELD is the name of the table field. $perm: The constant defining the permission (MvvPerm::PERM_ADMIN, MvvPerm::PERM_CREATE, MvvPerm::PERM_READ, MvvPerm::PERM_WRITE). Default is MvvPerm::PERM_WRITE. $user_id: The id of an user. Id of current user as default. $institut_id: The id of an institute or an array of institute ids the user has a mvv related role. All three arguments are optional.
Parameters
string$name
array$arguments
Returns
mixed
Exceptions
InvalidArgumentExceptionIf called with unknown permission.
BadMethodCallExceptionIf called with unknown method to reitrieve permission.
static __callStatic (   $name,
  $arguments 
)
static

Intercepts static calls to retrieve permission from configuration.

Allowed calls are:

MvvPerm::getFieldPermFIELD($mvv_object, $user_id, $institut_id)

See Also
MvvPerm:getFieldPerm() FIELD is the name of the table field. $mvv_object: Class name or instance of mvv object. $user_id: The id of an user. Id of current user as default. $institut_id: The id of an institute or an array of institute ids the user has a mvv related role. Last two arguments are optional.

MvvPerm::havePermPERM($mvv_object, $status, $user_id, $institut_id)

See Also
MvvPerm::havePerm() PERM is the constant defining the permission (MvvPerm::PERM_ADMIN, MvvPerm::PERM_CREATE, MvvPerm::PERM_READ, MvvPerm::PERM_WRITE) $mvv_object: Class name or instance of mvv object. $status: The status of mvv object defined in config. Status 'default' as default. $user_id: The id of an user. Id of current user as default. $institut_id: The id of an institute or an array of institute ids the user has a mvv related role. Last three arguments are optional

MvvPerm::haveFieldPermFIELD($mvv_object, $perm, $user_id, $institut_id)

See Also
MvvPerm::haveFieldPerm() FIELD is the name of the table field. $mvv_object: Class name or instance of mvv object. $perm: The constant defining the permission (MvvPerm::PERM_ADMIN, MvvPerm::PERM_CREATE, MvvPerm::PERM_READ, MvvPerm::PERM_WRITE). Default is MvvPerm::PERM_WRITE. $user_id: The id of an user. Id of current user as default. $institut_id: The id of an institute or an array of institute ids the user has a mvv related role. Last three arguments are optional.
Parameters
type$name
type$arguments
Returns
type
Exceptions
InvalidArgumentExceptionIf called with unknown permission.
BadMethodCallExceptionIf called with unknown method to retrieve permission.
disable (   $field,
  $perm = null,
  $user_id = null,
  $institut_id = null 
)

Returns 'readonly' if the given user has no access to the given field.

Parameters
string$fieldThe name of the table field.
int$permOptional. The permission. Defaults to MvvPerm:PERM_WRITE.
string$user_idOptional. The ID of the user. If not set the ID of the current user.
string | array$institut_idThe id of an institute or an array of institute ids the user has a mvv related role.
Returns
string 'readonly' if the permission is not granted.
static get (   $mvv_object)
static

Returns a new perm object for given mvv object.

Parameters
ModuleManagementModel | string$mvv_objectClass name or instance of mvv object.
Returns
MvvPerm A new perm object.
Exceptions
InvalidArgumentException
getFieldPerm (   $field,
  $user_id = null,
  $institut_id = null 
)
final

Retrieves the permission for the table or object. Returns the (max) perm the given or current user have globally. If the institute is set, checks for the perm in the context of this institute.

Parameters
string|arrayName of field or an array with name of field and related entry (usefull in the case of relations to datafields).
string$user_idOptional. The ID of the user. If not set the ID of the current user.
string | array$institut_idOptional. The id of an institute or an array of institute ids the user has a mvv related role.
Returns
int The perm defined in class MVVPlugin.
static getOwnInstitutes (   $user_id = null,
  $mvv_roles = null 
)
static

Returns all ids of institutes the user is assigned with at least one role. Have the user at least one role globally an empty array is returned.

Parameters
string$user_idOptional. The ID of the user. If not set the ID of the current user.
array$mvv_rolesOptional. An array of roles. All Mvv-Roles if not set.
Returns
array An array of institute ids or an empty array.
static getPerm (   $object,
  $status = null,
  $user_id = null,
  $institut_id = null,
  $variant = null 
)
staticfinal

Retrieves the permission for the table or object. Returns the (max) perm the given or current user has globally. If the institute is set, checks for the perm in the context of this institute.

Parameters
object | string$objectAn mvv object or its class name.
string$statusConstrain the permission to this status of the object.
string$user_idThe ID of the user. If not set the ID of the current user.
string | array$institut_idThe ID(s) of institute(s) if the user role is defined for institutes.
string$variantThe optional variant of the object table (e.g. to support different languages)
Returns
int The perm defined in class MVVPlugin.
Exceptions
InvalidArgumentExceptionIf the object is not of type ApplicationSimpleOrMap.
static getRoles (   $user_id)
static
Parameters
string$user_id
Returns
haveDfEntryPerm (   $datafield_id,
  $perm 
)

Returns whether the actual user has at least the given permission to the datafield entry.

Parameters
$datafield_idThe id of a datafield.
int$perm
Returns
bool True if permission is granted.
haveFieldPerm (   $field,
  $perm = null,
  $user_id = null,
  $institut_id = null 
)
final

Returns true if the user have at least the given permission status.

Parameters
string$fieldThe name of the table field.
int$permThe optional (default PERM_WRITE) permission status.
string$user_idOptional. The ID of the user. If not set the ID of the current user.
string | array$institut_idOptional. The id of an institute or an array of institute ids the user has a mvv related role.
Returns
bool True if the permission is at least the given permission.
haveObjectPerm (   $perm,
  $user_id = null 
)

Returns whether the given user has at least the given permission to this object with the actual status. The user_id is optional. Default is the id of the current user.

Parameters
int$permThe permission to check against.
type$user_idThe id of an user.
Returns
bool True if the permission is granted.
havePerm (   $perm,
  $status = null,
  $user_id = null,
  $institut_id = null 
)
final

Accepts the id of the user, an institute id and the status of this object as optional arguments. Returns whether the user has the given permission to this object.

The status of this object is defined in the configuration file

Parameters
int$permThe permission to check against.
string$statusThe status of the object defined in config.
string$user_idThe id of the user.
string | array$institut_idThe id of an institute or an array of institute ids the user has a mvv related role.
Returns
bool
static refreshPrivileges (   $mvv_table)
static
setVariant (   $variant)

Sets the variant of an mvv object. The variant means that a different configuration file is used to retrieve the permissions. It is used to determines permissions for different languages of a descriptor.

Parameters
string$variantThe suffix (part after las underscore) of the file name of a config file.
Returns
$this Returns this instance for method chaining.

Field Documentation

const PERM_ADMIN = 15

Permission to read, write/create and delete the value of the designated field. Possibly the admin have permission to particular functions.

const PERM_CREATE = 7

Permission to read, write/create and delete the value of the designated field.

const PERM_READ = 1

Permission to read the value of the designated field.

else PERM_WRITE = 3

Permission to read and write the value of the designated field.


The documentation for this class was generated from the following files: