Documentation

GRIS_PERMISSIONS
in package

Class for permissions

With this class permissions are managed

PHP version 7

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany

Tags
copyright

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences

link

GESIS Leibniz Institute for the Social Sciences

since
1

File available since Release 1.0

version
1.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

dbtable  = "gris_permissions"
The constant for the database table where the settings are stored
settings_group  = "permissions"
The constant for the settings group
$classname  : object
The name of the class
$dbconnection  : object
The database object for managing the connection
$i18n  : object
The object for translations
$is_admin  : object
The object for translations
$settings  : object
The object for settings
$state  : object
The object for logs
__construct()  : mixed
The class constructor
check_rights()  : int
Checks if all IDs are valid and the person or group has the permission to do this action
delete_permission()  : bool
Deletes a permission according to the given data
delete_permission_by_id()  : bool
Deletes a permission according to the given ID
edit_admin()  : bool
Edit the admin state for a given person ID
edit_group()  : bool
Sets a new group for a given user
get_admin()  : bool
Returns the admin state
get_groups()  : array<string|int, mixed>
Returns all groups from gris_groups
get_itemnames_by_id()  : array<string|int, mixed>
Get an array with item ID as key and page name as value
get_itemtree()  : array<string|int, mixed>
Create an itemtree
get_pagenames_by_id()  : Returns
Get an array with page ID as key and page name as value
get_pagetree()  : void
Create a pagetree
get_permissions()  : array<string|int, mixed>
Returns an array of all permissions for a given action and group
get_used_group_ids()  : array<string|int, mixed>
Returns IDs of groups that are used for a given action
permission_exists()  : bool
Checks wether a permission exists or nor
set_admin()  : bool
Sets the current user as an admin (or not on false)
set_permission()  : int
Sets a new permission
set_permission_list()  : bool
Sets a list of permissions
get_node()  : array<string|int, mixed>
Returns a node for JStree

Constants

dbtable

The constant for the database table where the settings are stored

public mixed dbtable = "gris_permissions"

settings_group

The constant for the settings group

public mixed settings_group = "permissions"

Properties

$classname

The name of the class

protected object $classname = NULL
Tags
access

private

$dbconnection

The database object for managing the connection

private object $dbconnection = null
Tags
access

private

$i18n

The object for translations

private object $i18n
Tags
access

private

$is_admin

The object for translations

private object $is_admin
Tags
access

private

$settings

The object for settings

private object $settings = null
Tags
access

private

Methods

__construct()

The class constructor

public __construct([bool $is_admin = false ]) : mixed
Parameters
$is_admin : bool = false

True for admin, false if no admin

Initializes the permission object

Return values
mixed

check_rights()

Checks if all IDs are valid and the person or group has the permission to do this action

public check_rights(string $person_id[, string $action = "save_data" ][, string $param_01 = NULL ][, string $param_02 = NULL ]) : int
Parameters
$person_id : string

The person or group ID (depends on the action)

$action : string = "save_data"

The action to be checked (dafault is "save_data")

$param_01 : string = NULL

The first param of the element (e. g. page or workflow)

$param_02 : string = NULL

The second param of the element (e. g. workflow step)

Return values
int

Returns 1 for success or an error code Error codes: -1 missing rights or missing ID (no rights anyway)

delete_permission()

Deletes a permission according to the given data

public delete_permission(string $group_id, string $action, string $param_01, string $param_02) : bool
Parameters
$group_id : string

The group

$action : string

The action

$param_01 : string

The first param

$param_02 : string

The secand param

Return values
bool

Returns true

delete_permission_by_id()

Deletes a permission according to the given ID

public delete_permission_by_id(string $id) : bool
Parameters
$id : string

The permission ID

Return values
bool

Returns true

edit_admin()

Edit the admin state for a given person ID

public edit_admin(string $person_id[, booelan $is_admin = false ]) : bool
Parameters
$person_id : string

The person ID

$is_admin : booelan = false

The admin state

Return values
bool

Returns true on succes or false on error

edit_group()

Sets a new group for a given user

public edit_group(string $person_id, string $group_id) : bool
Parameters
$person_id : string

The person ID

$group_id : string

The group ID

Return values
bool

Returns true on success or false on error

get_admin()

Returns the admin state

public get_admin() : bool
Return values
bool

true

get_groups()

Returns all groups from gris_groups

public get_groups() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns an array of permissions

get_itemnames_by_id()

Get an array with item ID as key and page name as value

public get_itemnames_by_id(array<string|int, mixed> $item_ids) : array<string|int, mixed>
Parameters
$item_ids : array<string|int, mixed>

The list of item IDs

Return values
array<string|int, mixed>

Returns an array with item ID as key and page name as value

get_itemtree()

Create an itemtree

public get_itemtree(array<string|int, mixed> $selection) : array<string|int, mixed>
Parameters
$selection : array<string|int, mixed>

The array of item permissions

Return values
array<string|int, mixed>

Returns an array with the items (prepared for jstree)

get_pagenames_by_id()

Get an array with page ID as key and page name as value

public get_pagenames_by_id(array<string|int, mixed> $page_ids) : Returns
Parameters
$page_ids : array<string|int, mixed>

The list of page IDs

Return values
Returns

an array with page ID as key and page name as value

get_pagetree()

Create a pagetree

public get_pagetree(array<string|int, mixed> $selection) : void
Parameters
$selection : array<string|int, mixed>

The array of page permissions

Return values
void

get_permissions()

Returns an array of all permissions for a given action and group

public get_permissions(string $action[, string $group_id = NULL ][, int $param = NULL ]) : array<string|int, mixed>
Parameters
$action : string

The action

$group_id : string = NULL

The group ID

$param : int = NULL

Return only one param as a list (1 or 2)

Return values
array<string|int, mixed>

Returns an array of the permissions

get_used_group_ids()

Returns IDs of groups that are used for a given action

public get_used_group_ids(string $action) : array<string|int, mixed>
Parameters
$action : string

The action

Return values
array<string|int, mixed>

Returns an array with IDs or NULL if no results

permission_exists()

Checks wether a permission exists or nor

public permission_exists(string $group, string $action, string $param_01, string $param_02) : bool
Parameters
$group : string

The group

$action : string

The action

$param_01 : string

The first param

$param_02 : string

The secand param

Return values
bool

Returns true if permission exists or false if not

set_admin()

Sets the current user as an admin (or not on false)

public set_admin([bool $is_admin = false ]) : bool
Parameters
$is_admin : bool = false

True for admin, flase if no admin

Return values
bool

true

set_permission()

Sets a new permission

public set_permission(string $group, string $action, string $param_01, string $param_02) : int
Parameters
$group : string

The group

$action : string

The action

$param_01 : string

The first param

$param_02 : string

The second param

Return values
int

Returns the ID of the new permission or NULL if permission already exists

set_permission_list()

Sets a list of permissions

public set_permission_list(string $group, string $action, array<string|int, mixed> $list_01[, array<string|int, mixed> $list_02 = NULL ]) : bool
Parameters
$group : string

The group ID

$action : string

The action

$list_01 : array<string|int, mixed>

The list of IDs for parameter 1

$list_02 : array<string|int, mixed> = NULL

The list of IDs for parameter 2 (if used param_02 has to have the same length as param_01)

Return values
bool

Returns true on succes and false if two params are used and don't have the same length

get_node()

Returns a node for JStree

private get_node(mixed $id, mixed $title, mixed $selection[, mixed $children = NULL ]) : array<string|int, mixed>
Parameters
$id : mixed
$title : mixed
$selection : mixed
$children : mixed = NULL
Return values
array<string|int, mixed>

Returns an array with node data

Search results