Skip to content
Snippets Groups Projects
Commit cf8bb591 authored by Yorick Reum's avatar Yorick Reum
Browse files

added disabling capability to workflow manager, added abort processes...

added disabling capability to workflow manager, added abort processes capability to workflow manager
parent bac0005d
No related branches found
No related tags found
No related merge requests found
...@@ -109,6 +109,21 @@ class process_manager { ...@@ -109,6 +109,21 @@ class process_manager {
return $DB->count_records('tool_lifecycle_process', array('workflowid' => $workflowid)); return $DB->count_records('tool_lifecycle_process', array('workflowid' => $workflowid));
} }
/**
* Returns all processes for given workflow id
* @param int $workflowid id of the workflow
* @return array of proccesses initiated by specifed workflow id
*/
public static function get_processes_by_workflow($workflowid) {
global $DB;
$records = $DB->get_records('tool_lifecycle_process', array('workflowid' => $workflowid));
$processes = array();
foreach ($records as $record) {
$processes [] = process::from_record($record);
}
return $processes;
}
/** /**
* Proceeds the process to the next step. * Proceeds the process to the next step.
* @param process $process * @param process $process
......
...@@ -57,6 +57,33 @@ class workflow_manager { ...@@ -57,6 +57,33 @@ class workflow_manager {
$DB->delete_records('tool_lifecycle_workflow', array('id' => $workflowid)); $DB->delete_records('tool_lifecycle_workflow', array('id' => $workflowid));
} }
/**
* Disables a workflow
* @param int $workflowid id of the workflow
*/
public static function disable($workflowid)
{
$workflow = self::get_workflow($workflowid);
if ($workflow) {
$workflow->active = false;
$workflow->timeactive = null;
$workflow->sortindex = null;
self::insert_or_update($workflow);
}
}
/**
* Deletes all running processes of given workflow
* @param int $workflowid id of the workflow
*/
public static function abortprocesses($workflowid)
{
$processes = process_manager::get_processes_by_workflow($workflowid);
foreach ($processes as $process) {
process_manager::remove_process($process);
}
}
/** /**
* Returns a workflow instance if one with the is is available. * Returns a workflow instance if one with the is is available.
* @param int $workflowid id of the workflow * @param int $workflowid id of the workflow
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment