Skip to content
Snippets Groups Projects
Commit f91cbc53 authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

split active workflowstable in two based on manual field

parent be423bbe
No related branches found
No related tags found
No related merge requests found
...@@ -26,8 +26,9 @@ use tool_cleanupcourses\manager\trigger_manager; ...@@ -26,8 +26,9 @@ use tool_cleanupcourses\manager\trigger_manager;
use tool_cleanupcourses\entity\workflow; use tool_cleanupcourses\entity\workflow;
use tool_cleanupcourses\entity\step_subplugin; use tool_cleanupcourses\entity\step_subplugin;
use tool_cleanupcourses\manager\workflow_manager; use tool_cleanupcourses\manager\workflow_manager;
use tool_cleanupcourses\table\active_manual_workflows_table;
use tool_cleanupcourses\table\workflow_definition_table; use tool_cleanupcourses\table\workflow_definition_table;
use tool_cleanupcourses\table\active_workflows_table; use tool_cleanupcourses\table\active_automatic_workflows_table;
use tool_cleanupcourses\table\step_table; use tool_cleanupcourses\table\step_table;
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
...@@ -131,9 +132,14 @@ class admin_settings { ...@@ -131,9 +132,14 @@ class admin_settings {
// Set up the table. // Set up the table.
$this->view_header(); $this->view_header();
echo $OUTPUT->heading(get_string('active_workflows_heading', 'tool_cleanupcourses')); echo $OUTPUT->heading(get_string('active_automatic_workflows_heading', 'tool_cleanupcourses'));
$table = new active_workflows_table('tool_cleanupcourses_active_workflows'); $table = new active_automatic_workflows_table('tool_cleanupcourses_active_automatic_workflows');
$table->out(5000, false);
echo $OUTPUT->heading(get_string('active_manual_workflows_heading', 'tool_cleanupcourses'));
$table = new active_manual_workflows_table('tool_cleanupcourses_manual_workflows');
$table->out(5000, false); $table->out(5000, false);
echo $OUTPUT->heading(get_string('workflow_definition_heading', 'tool_cleanupcourses')); echo $OUTPUT->heading(get_string('workflow_definition_heading', 'tool_cleanupcourses'));
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Table listing all active workflows. * Table listing all active automatically triggered workflows.
* *
* @package tool_cleanupcourses * @package tool_cleanupcourses
* @copyright 2017 Tobias Reischmann WWU * @copyright 2017 Tobias Reischmann WWU
...@@ -33,13 +33,17 @@ defined('MOODLE_INTERNAL') || die; ...@@ -33,13 +33,17 @@ defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php'); require_once($CFG->libdir . '/tablelib.php');
require_once(__DIR__ . '/../../lib.php'); require_once(__DIR__ . '/../../lib.php');
class active_workflows_table extends \table_sql { class active_automatic_workflows_table extends \table_sql {
public function __construct($uniqueid) { public function __construct($uniqueid) {
parent::__construct($uniqueid); parent::__construct($uniqueid);
global $PAGE, $DB; global $PAGE, $DB;
list($sqlwhere, $params) = $DB->get_in_or_equal(true); list($sqlwhereactive, $params) = $DB->get_in_or_equal(true);
$this->set_sql("id, title, timeactive, sortindex", '{tool_cleanupcourses_workflow}', 'active ' . $sqlwhere, $params); list($sqlwheremanual, $paramsmanual) = $DB->get_in_or_equal(false);
$sqlwhere = 'active ' . $sqlwhereactive . ' AND manual ' . $sqlwheremanual;
$params[1] = $paramsmanual[0];
$this->set_sql("id, title, timeactive, sortindex", '{tool_cleanupcourses_workflow}',
$sqlwhere, $params);
$this->define_baseurl($PAGE->url); $this->define_baseurl($PAGE->url);
$this->pageable(false); $this->pageable(false);
$this->init(); $this->init();
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Table listing all active manually triggered workflows.
*
* @package tool_cleanupcourses
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_cleanupcourses\table;
use tool_cleanupcourses\manager\process_manager;
use tool_cleanupcourses\manager\step_manager;
use tool_cleanupcourses\manager\trigger_manager;
use tool_cleanupcourses\manager\workflow_manager;
defined('MOODLE_INTERNAL') || die;
require_once($CFG->libdir . '/tablelib.php');
require_once(__DIR__ . '/../../lib.php');
class active_manual_workflows_table extends \table_sql {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
global $PAGE, $DB;
list($sqlwhereactive, $params) = $DB->get_in_or_equal(true);
list($sqlwheremanual, $paramsmanual) = $DB->get_in_or_equal(true);
$sqlwhere = 'active ' . $sqlwhereactive . ' AND manual ' . $sqlwheremanual;
$params[1] = $paramsmanual[0];
$this->set_sql("id, title, timeactive", '{tool_cleanupcourses_workflow}',
$sqlwhere, $params);
$this->define_baseurl($PAGE->url);
$this->pageable(false);
$this->init();
}
public function init() {
$this->define_columns(['title', 'timeactive', 'trigger', 'processes', 'tools']);
$this->define_headers([
get_string('workflow_title', 'tool_cleanupcourses'),
get_string('workflow_timeactive', 'tool_cleanupcourses'),
get_string('trigger', 'tool_cleanupcourses'),
get_string('workflow_processes', 'tool_cleanupcourses'),
get_string('workflow_tools', 'tool_cleanupcourses'),
]);
$this->sortable(true, 'title');
$this->setup();
}
/**
* Render activate column.
* @param $row
* @return string activate time for workflows
*/
public function col_timeactive($row) {
global $OUTPUT, $PAGE;
if ($row->timeactive) {
return userdate($row->timeactive, get_string('strftimedatetime'), 0);
}
return $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('action' => ACTION_WORKFLOW_ACTIVATE,
'sesskey' => sesskey(),
'workflowid' => $row->id)),
get_string('activateworkflow', 'tool_cleanupcourses'));
}
/**
* Render the trigger column.
* @param $row
* @return string instancename of the trigger
*/
public function col_trigger($row) {
$trigger = trigger_manager::get_trigger_for_workflow($row->id);
if ($trigger) {
return $trigger->instancename;
}
}
/**
* Render the processes column. It shows the number of active processes for the workflow instance.
* @param $row
* @return string instancename of the trigger
*/
public function col_processes($row) {
return process_manager::count_processes_by_workflow($row->id);
}
/**
* Render tools column.
* @param $row
* @return string action buttons for workflows
*/
public function col_tools($row) {
global $OUTPUT;
$output = '';
$alt = get_string('viewsteps', 'tool_cleanupcourses');
$icon = 't/viewdetails';
$url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php',
array('workflowid' => $row->id, 'sesskey' => sesskey()));
$output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt));
return $output;
}
/**
* Util function for writing an action icon link
*
* @param string $action URL parameter to include in the link
* @param string $workflowid URL parameter to include in the link
* @param string $icon The key to the icon to use (e.g. 't/up')
* @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link
*/
private function format_icon_link($action, $workflowid, $icon, $alt) {
global $PAGE, $OUTPUT;
return $OUTPUT->action_icon(new \moodle_url($PAGE->url,
array('action' => $action,
'sesskey' => sesskey(),
'workflowid' => $workflowid)),
new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)) . ' ';
}
}
\ No newline at end of file
...@@ -34,7 +34,8 @@ $string['config_delay_duration'] = 'Duration of a course delay'; ...@@ -34,7 +34,8 @@ $string['config_delay_duration'] = 'Duration of a course delay';
$string['config_delay_duration_desc'] = 'Defines the time frame, which a course is excluded from the cleanup course, when rolled back via user interaction.'; $string['config_delay_duration_desc'] = 'Defines the time frame, which a course is excluded from the cleanup course, when rolled back via user interaction.';
$string['active_processes_list_header'] = 'Active Processes'; $string['active_processes_list_header'] = 'Active Processes';
$string['adminsettings_heading'] = 'Workflow Settings'; $string['adminsettings_heading'] = 'Workflow Settings';
$string['active_workflows_heading'] = 'Active Workflows'; $string['active_manual_workflows_heading'] = 'Active Manual Workflows';
$string['active_automatic_workflows_heading'] = 'Active Automatic Workflows';
$string['workflow_definition_heading'] = 'Workflow Definitions'; $string['workflow_definition_heading'] = 'Workflow Definitions';
$string['adminsettings_edit_workflow_definition_heading'] = 'Workflow Definition'; $string['adminsettings_edit_workflow_definition_heading'] = 'Workflow Definition';
$string['adminsettings_workflow_definition_steps_heading'] = 'Workflow Steps'; $string['adminsettings_workflow_definition_steps_heading'] = 'Workflow Steps';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment