Skip to content
Snippets Groups Projects
Commit a56b8746 authored by Justus Dieckmann's avatar Justus Dieckmann Committed by Tobias Reischmann
Browse files

Delays: Add delete button, only show active workflows

parent 065312a2
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,7 @@ class delayed_courses_table extends \table_sql { ...@@ -49,6 +49,7 @@ class delayed_courses_table extends \table_sql {
'FROM {tool_lifecycle_delayed_workf} dw ' . 'FROM {tool_lifecycle_delayed_workf} dw ' .
'JOIN {tool_lifecycle_workflow} w ON dw.workflowid = w.id ' . // To make sure no outdated delays are counted. 'JOIN {tool_lifecycle_workflow} w ON dw.workflowid = w.id ' . // To make sure no outdated delays are counted.
'WHERE dw.delayeduntil >= :time ' . 'WHERE dw.delayeduntil >= :time ' .
'AND w.timeactive IS NOT NULL ' .
// TODO AND dw.workflowid IN $workflows // TODO AND dw.workflowid IN $workflows
'GROUP BY courseid ' . 'GROUP BY courseid ' .
') maxtable ' . ') maxtable ' .
...@@ -137,7 +138,8 @@ class delayed_courses_table extends \table_sql { ...@@ -137,7 +138,8 @@ class delayed_courses_table extends \table_sql {
public function col_tools($row) { public function col_tools($row) {
global $PAGE, $OUTPUT; global $PAGE, $OUTPUT;
$button = new \single_button( $button = new \single_button(
new \moodle_url($PAGE->url, array('cid' => $row->courseid)), new \moodle_url($PAGE->url,
array('action' => 'delete', 'cid' => $row->courseid, 'sesskey' => sesskey())),
get_string('delete_delay', 'tool_lifecycle')); get_string('delete_delay', 'tool_lifecycle'));
return $OUTPUT->render($button); return $OUTPUT->render($button);
} }
......
...@@ -33,6 +33,27 @@ require_capability('moodle/site:config', context_system::instance()); ...@@ -33,6 +33,27 @@ require_capability('moodle/site:config', context_system::instance());
admin_externalpage_setup('tool_lifecycle_delayed_courses'); admin_externalpage_setup('tool_lifecycle_delayed_courses');
$action = optional_param('action', null, PARAM_ALPHANUMEXT);
if ($action) {
if ($action == 'delete') {
global $DB;
require_sesskey();
$cid = required_param('cid', PARAM_INT);
$workflow = optional_param('workflow', null, PARAM_ALPHANUM);
if ($workflow) {
if (is_int($workflow)) {
$DB->delete_records('tool_lifecycle_delayed_workf', array('courseid' => $cid, 'workflowid' => $workflow));
} else if ($workflow == 'global') {
$DB->delete_records('tool_lifecycle_delayed', array('courseid' => $cid));
}
} else {
$DB->delete_records('tool_lifecycle_delayed', array('courseid' => $cid));
$DB->delete_records('tool_lifecycle_delayed_workf', array('courseid' => $cid));
}
}
redirect($PAGE->url);
}
$PAGE->set_url(new \moodle_url('/admin/tool/lifecycle/delayedcourses.php')); $PAGE->set_url(new \moodle_url('/admin/tool/lifecycle/delayedcourses.php'));
$PAGE->set_title(get_string('delayed_courses_header', 'tool_lifecycle')); $PAGE->set_title(get_string('delayed_courses_header', 'tool_lifecycle'));
...@@ -41,7 +62,6 @@ $PAGE->set_heading(get_string('delayed_courses_header', 'tool_lifecycle')); ...@@ -41,7 +62,6 @@ $PAGE->set_heading(get_string('delayed_courses_header', 'tool_lifecycle'));
$table = new delayed_courses_table(); $table = new delayed_courses_table();
$table->define_baseurl($PAGE->url); $table->define_baseurl($PAGE->url);
echo $OUTPUT->header(); echo $OUTPUT->header();
$table->out(100, false); $table->out(100, false);
echo $OUTPUT->footer(); echo $OUTPUT->footer();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment