Documentation

GRIS_WORKFLOWS
in package

Class for workflows

With this class workflows 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 3.0

version
3.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

dbtable  = "gris_workflow"
The constant for the database table where the settings are stored
settings_group  = "workflow"
The constant for the settings group
$classname  : object
The name of the class
$auth  : object
The object for auth
$dbconnection  : object
The database object for managing the connection
$groups  : array<string|int, mixed>
All groups with permissions to change parts of this workflow
$i18n  : object
The object for translations
$object_id  : int
The current object ID
$person_id  : int
The current object ID
$settings  : object
The object for settings
$start  : array<string|int, mixed>
The the first step to start the workflow
$state  : object
The object for logs
$workflow  : array<string|int, mixed>
The current workflow
$workflow_id  : int
The current workflow ID
$workflow_relations  : array<string|int, mixed>
The complete workflow relations for an object ID
$workflow_steps  : array<string|int, mixed>
The complete workflow steps
__construct()  : mixed
The class constructor
check_entries()  : array<string|int, mixed>
Check all entries for an object (mark invalid ones)
check_groups()  : bool
Checks if if the current person is in one of the groups of the current workflow, that have the permission to check (also Admins have permission)
check_permission()  : bool
Checks if the current person has the permission to change the ckeckbox
check_show()  : bool
Checks if the workflow of the object is the show step
copy_resources_state()  : bool
Copy the workflow state of all resources to the new workflow
current_workflow()  : array<string|int, mixed>
Return the current workflow or Null if non available
debug()  : bool
Debug method (tbd later)
delete_invalid_workflow()  : bool
Delete invalid workflow relations by given attributes (workflow ID is not taken from the object)
delete_workflow_relation()  : bool
Delete workflow relations for the current object (and optional for a step or a check)
get_all()  : array<string|int, mixed>
Get all workflows with all steps and checks
get_available_workflows()  : array<string|int, mixed>
Get all available workflow names for an object
get_checks()  : array<string|int, mixed>
Get all necessary checks of the current workflow and step order
get_current_checks()  : array<string|int, mixed>
Get all current checks for the object
get_current_step()  : int
Get the current step order
get_finished()  : array<string|int, mixed>
Get all resources or projects with a finished workflow
get_object_id()  : int
Get the current object ID
get_object_table()  : int
Get the current object table
get_orphans()  : array<string|int, mixed>
Get all resources or projects without a workflow relation for a given workflow
get_request_person()  : int
Returns the person_id that requested the reset of the workflow
get_requests()  : array<string|int, mixed>
Returns all reset requests for an object table
get_show_step()  : bool
Check if this step is final and the object ist shown (or return the step where show is set)
get_step_color()  : string
Get the current step color
get_step_name()  : int
Get the current step order
get_unfinished_workflow_list()  : array<string|int, mixed>
A list of all unfinished workflows and checks
get_workflows_for_object()  : array<string|int, mixed>
Get all workflows (only ID and Name) for the current object
id()  : int
Get the current workflow ID
initialize()  : bool
Initialize the current workflow and load its steps
lookup_group()  : bool
Check the permission of a given group for this step and check
request_reset()  : bool
Switches (or sets) a request to reset the workflow for an object
reset_workflow()  : bool
Resets a workflow for an object
set_workflow_relation()  : int
Set a new workflow relation or update an existing
switch_step()  : int
Tests if all checks for this step are completed and switches to the next step
workflow_active()  : bool
Have checks been made in workflow?
checks_complete()  : bool
Test if all checks are completed for the current step (e. g. to get to the next step order)
get_start()  : int
Get the first stept in this workflow
get_workflow()  : bool|array<string|int, mixed>
Get the workflow for the current object or all available workflows
get_workflow_relations()  : array<string|int, mixed>
Get the complete workflow relations
get_workflow_steps()  : bool
Get the complete workflow with steps for this object and store it to $this->workflow_steps
next_step()  : int
The next step
workflow_relation_exists()  : int
Check if a workflow relation exists (person ID is not included in the query)

Constants

dbtable

The constant for the database table where the settings are stored

public mixed dbtable = "gris_workflow"

settings_group

The constant for the settings group

public mixed settings_group = "workflow"

Properties

$classname

The name of the class

protected object $classname = NULL
Tags
access

private

$auth

The object for auth

private object $auth
Tags
access

private

$dbconnection

The database object for managing the connection

private object $dbconnection = null
Tags
access

private

$groups

All groups with permissions to change parts of this workflow

private array<string|int, mixed> $groups
Tags
access

private

$i18n

The object for translations

private object $i18n
Tags
access

private

$object_id

The current object ID

private int $object_id
Tags
access

private

$person_id

The current object ID

private int $person_id
Tags
access

private

$settings

The object for settings

private object $settings = null
Tags
access

private

$start

The the first step to start the workflow

private array<string|int, mixed> $start
Tags
access

private

$state

The object for logs

private object $state
Tags
access

private

$workflow

The current workflow

private array<string|int, mixed> $workflow
Tags
access

private

$workflow_id

The current workflow ID

private int $workflow_id
Tags
access

private

$workflow_relations

The complete workflow relations for an object ID

private array<string|int, mixed> $workflow_relations
Tags
access

private

$workflow_steps

The complete workflow steps

private array<string|int, mixed> $workflow_steps
Tags
access

private

Methods

__construct()

The class constructor

public __construct([int $workflow_id = NULL ][, int $object_id = NULL ][, int $person_id = NULL ]) : mixed
Parameters
$workflow_id : int = NULL

The current workflow ID (default: NULL)

$object_id : int = NULL

The current object ID (default: NULL)

$person_id : int = NULL

The current person ID (default: NULL)

Initializes the workflow object

Return values
mixed

check_entries()

Check all entries for an object (mark invalid ones)

public check_entries(int $object_id, string $object_table) : array<string|int, mixed>
Parameters
$object_id : int

The object ID

$object_table : string

The object table

Return values
array<string|int, mixed>

Returns an array with all workflow entries for an object

check_groups()

Checks if if the current person is in one of the groups of the current workflow, that have the permission to check (also Admins have permission)

public check_groups() : bool
Return values
bool

Returns true if the person is in the group

check_permission()

Checks if the current person has the permission to change the ckeckbox

public check_permission(mixed $check_id) : bool

int $check_id The current check ID

Parameters
$check_id : mixed
Return values
bool

Returns true if all checks are completed and false if not

check_show()

Checks if the workflow of the object is the show step

public check_show() : bool
Return values
bool

Returns true if show and false if not

copy_resources_state()

Copy the workflow state of all resources to the new workflow

public copy_resources_state(int $step, int $person_id) : bool
Parameters
$step : int

The step ID

$person_id : int

The current person ID

Return values
bool

true

current_workflow()

Return the current workflow or Null if non available

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

Return the current workflow

debug()

Debug method (tbd later)

public debug() : bool
Return values
bool

true

delete_invalid_workflow()

Delete invalid workflow relations by given attributes (workflow ID is not taken from the object)

public delete_invalid_workflow(int $workflow_id, int $workflow_relations_object_id, int $workflow_step_order, int $workflow_step_check_order) : bool
Parameters
$workflow_id : int

The workflow ID (usually an invalid workflow)

$workflow_relations_object_id : int

The object ID

$workflow_step_order : int

The workflow step order

$workflow_step_check_order : int

The workflow step checkorder

Return values
bool

Returns true on success and false on error

delete_workflow_relation()

Delete workflow relations for the current object (and optional for a step or a check)

public delete_workflow_relation([int $workflow_step_order = NULL ][, int $workflow_step_check_order = NULL ][, bool $all = false ]) : bool
Parameters
$workflow_step_order : int = NULL

The workflow step order (optional)

$workflow_step_check_order : int = NULL

The workflow step checkorder (optional)

$all : bool = false

Delete all entries for this object

Return values
bool

Returns true on success and false on error

get_all()

Get all workflows with all steps and checks

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

Returns all workflows and steps

get_available_workflows()

Get all available workflow names for an object

public get_available_workflows(mixed $object_table) : array<string|int, mixed>
Parameters
$object_table : mixed
Return values
array<string|int, mixed>

Return an array of all workflows for the object (workflow_id => name)

get_checks()

Get all necessary checks of the current workflow and step order

public get_checks(int $workflow_step_order[, bool $id_only = false ]) : array<string|int, mixed>
Parameters
$workflow_step_order : int

The current workflow step order

$id_only : bool = false

If true, only the IDs are returned without timestamp and person

Return values
array<string|int, mixed>

The check IDs as an array (optional without timestamp and person ID)

get_current_checks()

Get all current checks for the object

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

The check IDs as an array

get_current_step()

Get the current step order

public get_current_step() : int
Return values
int

Return the current step order

get_finished()

Get all resources or projects with a finished workflow

public get_finished(mixed $workflow_id[, mixed $limit = 20 ], mixed $offset) : array<string|int, mixed>
Parameters
$workflow_id : mixed
$limit : mixed = 20
$offset : mixed
Return values
array<string|int, mixed>

Returns an array with resource or project IDs and years

get_object_id()

Get the current object ID

public get_object_id() : int
Return values
int

Returns the object ID

get_object_table()

Get the current object table

public get_object_table() : int
Return values
int

Returns the object table

get_orphans()

Get all resources or projects without a workflow relation for a given workflow

public get_orphans(int $workflow_id[, int $limit = 20 ], int $offset[, array<string|int, mixed> $resourcetype_ids = NULL ]) : array<string|int, mixed>
Parameters
$workflow_id : int

The workflow ID

$limit : int = 20

The limit of hits

$offset : int

The offset of hits

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

The list of resourcetypes

Return values
array<string|int, mixed>

Returns an array with resource or project IDs and years

get_request_person()

Returns the person_id that requested the reset of the workflow

public get_request_person() : int
Return values
int

Returns the person_id

get_requests()

Returns all reset requests for an object table

public get_requests([mixed $object_table = NULL ]) : array<string|int, mixed>
Parameters
$object_table : mixed = NULL
Return values
array<string|int, mixed>

Returns an array of object IDs

get_show_step()

Check if this step is final and the object ist shown (or return the step where show is set)

public get_show_step([int $step_order = NULL ]) : bool
Parameters
$step_order : int = NULL

The step order to be checked (if empty, the step with show = 1 will be returned)

Return values
bool

Return true if gris_workflow_step_show is 1 or false if not (or the step ID if step was given)

get_step_color()

Get the current step color

public get_step_color(mixed $step_order) : string
Parameters
$step_order : mixed
Return values
string

Return the color for the current step (as a HEX value including #)

get_step_name()

Get the current step order

public get_step_name(mixed $step_order) : int
Parameters
$step_order : mixed
Return values
int

Return the current step order

get_unfinished_workflow_list()

A list of all unfinished workflows and checks

public get_unfinished_workflow_list(int $workflow_id[, int $limit = 20 ], int $offset[, array<string|int, mixed> $resourcetype_ids = NULL ]) : array<string|int, mixed>
Parameters
$workflow_id : int
$limit : int = 20
$offset : int
$resourcetype_ids : array<string|int, mixed> = NULL

The list of resourcetypes

Return values
array<string|int, mixed>

The list of entries (["gris_workflow_step_order"] => "gris_resource_id/gris_project_id"] => ["year"]|["checks"])

get_workflows_for_object()

Get all workflows (only ID and Name) for the current object

public get_workflows_for_object(string $object_table) : array<string|int, mixed>
Parameters
$object_table : string

The object table for the workflows

Return values
array<string|int, mixed>

Returns an array (id => name) with all available workflows for the object

id()

Get the current workflow ID

public id() : int
Return values
int

Returns the ID

initialize()

Initialize the current workflow and load its steps

public initialize(int $workflow_id[, int $object_id = NULL ][, int $person_id = NULL ]) : bool
Parameters
$workflow_id : int

The current workflow ID (default: NULL)

$object_id : int = NULL

The object ID (default: NULL)

$person_id : int = NULL

The person ID (default: NULL)

Return values
bool

Returns true on success and false on error

lookup_group()

Check the permission of a given group for this step and check

public lookup_group(int $step, int $check, int $group) : bool
Parameters
$step : int

Step order

$check : int

Step check order

$group : int

The group ID

Return values
bool

Returns true if permission is granted

request_reset()

Switches (or sets) a request to reset the workflow for an object

public request_reset(bool $state) : bool
Parameters
$state : bool

The request state (true for request)

Return values
bool

Returns true on success and false on error

reset_workflow()

Resets a workflow for an object

public reset_workflow() : bool
Return values
bool

Returns true on success and false on error

set_workflow_relation()

Set a new workflow relation or update an existing

public set_workflow_relation(int $workflow_step_order, int $workflow_step_check_order) : int
Parameters
$workflow_step_order : int

The workflow step order

$workflow_step_check_order : int

The workflow step checkorder

Return values
int

Returns 1 for insert and 0 for update (false for no workflow ID)

switch_step()

Tests if all checks for this step are completed and switches to the next step

public switch_step() : int
Return values
int

Return the current step order

workflow_active()

Have checks been made in workflow?

public workflow_active() : bool
Return values
bool

true if checks have been made

checks_complete()

Test if all checks are completed for the current step (e. g. to get to the next step order)

private checks_complete() : bool
Return values
bool

Returns true if all checks are completed and false if not

get_start()

Get the first stept in this workflow

private get_start() : int
Return values
int

Return the first step (gris_workflow_step_order)

get_workflow()

Get the workflow for the current object or all available workflows

private get_workflow([bool $get_all = false ]) : bool|array<string|int, mixed>
Parameters
$get_all : bool = false

Return all workflows as an array

Return values
bool|array<string|int, mixed>

Return true on success and false on error (or an array of all workflows)

get_workflow_relations()

Get the complete workflow relations

private get_workflow_relations() : array<string|int, mixed>
Return values
array<string|int, mixed>

The workflow relations as an array

get_workflow_steps()

Get the complete workflow with steps for this object and store it to $this->workflow_steps

private get_workflow_steps([int $workflow_id = NULL ]) : bool
Parameters
$workflow_id : int = NULL

The workflow ID (overrides $this->workflow["gris_workflow_id"])

Return values
bool

Return true on success and false on error

next_step()

The next step

private next_step() : int
Return values
int

Returns the next step order if all checks are done

workflow_relation_exists()

Check if a workflow relation exists (person ID is not included in the query)

private workflow_relation_exists(int $workflow_step_order, int $workflow_step_check_order) : int
Parameters
$workflow_step_order : int

The workflow step ID

$workflow_step_check_order : int

The workflow step check ID

Return values
int

Returns true if relation exists and false if not

Search results