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

Added more workflow tools

parent a22d3ddc
No related branches found
No related tags found
No related merge requests found
...@@ -137,7 +137,7 @@ class subplugin_settings { ...@@ -137,7 +137,7 @@ class subplugin_settings {
echo $OUTPUT->heading(get_string('subpluginssettings_step_heading', 'tool_cleanupcourses')); echo $OUTPUT->heading(get_string('subpluginssettings_step_heading', 'tool_cleanupcourses'));
echo $OUTPUT->single_button(new \moodle_url($PAGE->url, echo $OUTPUT->single_button(new \moodle_url($PAGE->url,
array('action' => ACTION_ADD_WORKFLOW, 'sesskey' => sesskey())), array('action' => ACTION_WORKFLOW_INSTANCE_FROM, 'sesskey' => sesskey())),
get_string('add_workflow', 'tool_cleanupcourses')); get_string('add_workflow', 'tool_cleanupcourses'));
$table = new workflow_table('tool_cleanupcourses_workflows'); $table = new workflow_table('tool_cleanupcourses_workflows');
...@@ -203,9 +203,9 @@ class subplugin_settings { ...@@ -203,9 +203,9 @@ class subplugin_settings {
trigger_manager::handle_action($action, $subpluginid); trigger_manager::handle_action($action, $subpluginid);
workflow_manager::handle_action($action, $workflowid); workflow_manager::handle_action($action, $workflowid);
$form = new form_workflow_instance($PAGE->url, $workflowid); $form = new form_workflow_instance($PAGE->url, workflow_manager::get_workflow($workflowid));
if ($action === ACTION_ADD_WORKFLOW) { if ($action === ACTION_WORKFLOW_INSTANCE_FROM) {
$this->view_workflow_instance_form($form); $this->view_workflow_instance_form($form);
} else { } else {
if ($form->is_submitted() && !$form->is_cancelled() && $data = $form->get_submitted_data()) { if ($form->is_submitted() && !$form->is_cancelled() && $data = $form->get_submitted_data()) {
......
...@@ -61,8 +61,10 @@ class form_workflow_instance extends \moodleform { ...@@ -61,8 +61,10 @@ class form_workflow_instance extends \moodleform {
public function definition() { public function definition() {
$mform = $this->_form; $mform = $this->_form;
$mform->addElement('hidden', 'id'); // Save the record's id. $elementname = 'id';
$mform->setType('id', PARAM_TEXT); $mform->addElement('hidden', $elementname); // Save the record's id.
$mform->setType($elementname, PARAM_TEXT);
$mform->setDefault($elementname, $this->workflow->id);
$mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_cleanupcourses')); $mform->addElement('header', 'general_settings_header', get_string('general_settings_header', 'tool_cleanupcourses'));
......
...@@ -63,13 +63,23 @@ class workflow_table extends \table_sql { ...@@ -63,13 +63,23 @@ class workflow_table extends \table_sql {
global $OUTPUT; global $OUTPUT;
$output = ''; $output = '';
$alt = 'edit'; $alt = get_string('viewsteps', 'tool_cleanupcourses');
$icon = 't/edit'; $icon = 't/viewdetails';
$url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php', $url = new \moodle_url('/admin/tool/cleanupcourses/workflowsettings.php',
array('workflowid' => $row->id, 'sesskey' => sesskey())); array('workflowid' => $row->id, 'sesskey' => sesskey()));
$output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)); null , array('title' => $alt));
$action = ACTION_WORKFLOW_INSTANCE_FROM;
$alt = get_string('editworkflow', 'tool_cleanupcourses');
$icon = 't/edit';
$output .= $this->format_icon_link($action, $row->id, $icon, $alt);
$action = ACTION_WORKFLOW_DELETE;
$alt = get_string('deleteworkflow', 'tool_cleanupcourses');
$icon = 't/delete';
$output .= $this->format_icon_link($action, $row->id, $icon, $alt);
return $output; return $output;
} }
...@@ -77,19 +87,18 @@ class workflow_table extends \table_sql { ...@@ -77,19 +87,18 @@ class workflow_table extends \table_sql {
* Util function for writing an action icon link * Util function for writing an action icon link
* *
* @param string $action URL parameter to include in the link * @param string $action URL parameter to include in the link
* @param string $subpluginid 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 $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 * @param string $alt The string description of the link used as the title and alt text
* @return string The icon/link * @return string The icon/link
*/ */
private function format_icon_link($action, $subpluginid, $icon, $alt) { private function format_icon_link($action, $workflowid, $icon, $alt) {
global $PAGE, $OUTPUT; global $PAGE, $OUTPUT;
return $OUTPUT->action_icon(new \moodle_url($PAGE->url, return $OUTPUT->action_icon(new \moodle_url($PAGE->url,
array('action' => $action, array('action' => $action,
'subplugin' => $subpluginid,
'sesskey' => sesskey(), 'sesskey' => sesskey(),
'workflowid' => $this->workflowid)), 'workflowid' => $workflowid)),
new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)),
null , array('title' => $alt)) . ' '; null , array('title' => $alt)) . ' ';
} }
......
...@@ -52,6 +52,9 @@ $string['workflow_title'] = 'Title'; ...@@ -52,6 +52,9 @@ $string['workflow_title'] = 'Title';
$string['workflow_active'] = 'Active'; $string['workflow_active'] = 'Active';
$string['workflow_timeactive'] = 'Active since'; $string['workflow_timeactive'] = 'Active since';
$string['workflow_tools'] = 'Tools'; $string['workflow_tools'] = 'Tools';
$string['viewsteps'] = 'View Workflow Steps';
$string['editworkflow'] = 'Edit Title';
$string['deleteworkflow'] = 'Delete Workflow';
$string['step_subpluginname'] = 'Step Type'; $string['step_subpluginname'] = 'Step Type';
$string['step_instancename'] = 'Instance Name'; $string['step_instancename'] = 'Instance Name';
......
...@@ -31,4 +31,6 @@ define('ACTION_UP_STEP', 'up_step'); ...@@ -31,4 +31,6 @@ define('ACTION_UP_STEP', 'up_step');
define('ACTION_DOWN_STEP', 'down_step'); define('ACTION_DOWN_STEP', 'down_step');
define('ACTION_STEP_INSTANCE_FORM', 'step_instance_form'); define('ACTION_STEP_INSTANCE_FORM', 'step_instance_form');
define('ACTION_STEP_INSTANCE_DELETE', 'step_instance_delete'); define('ACTION_STEP_INSTANCE_DELETE', 'step_instance_delete');
define('ACTION_ADD_WORKFLOW', 'add_workflow'); define('ACTION_WORKFLOW_INSTANCE_FROM', 'workflow_instance_form');
\ No newline at end of file define('ACTION_WORKFLOW_DELETE', 'workflow_instance_delete');
define('ACTION_WORKFLOW_ACTIVATE', 'workflow_instance_activate');
\ No newline at end of file
...@@ -35,4 +35,4 @@ $PAGE->set_context(context_system::instance()); ...@@ -35,4 +35,4 @@ $PAGE->set_context(context_system::instance());
// Execute the controller. // Execute the controller.
$subpluginsettings->execute(optional_param('action', null, PARAM_TEXT), $subpluginsettings->execute(optional_param('action', null, PARAM_TEXT),
optional_param('subplugin', null, PARAM_INT), optional_param('subplugin', null, PARAM_INT),
optional_param('workflow', null, PARAM_INT)); optional_param('workflowid', null, PARAM_INT));
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment