diff --git a/classes/local/table/interaction_attention_table.php b/classes/local/table/interaction_attention_table.php
index acff10bc67dd00d86592b29189cbfa49411cedcc..7e5b19b32c9b2b74638534313acf807622b81d58 100644
--- a/classes/local/table/interaction_attention_table.php
+++ b/classes/local/table/interaction_attention_table.php
@@ -45,9 +45,9 @@ class interaction_attention_table extends interaction_table {
* @param int $uniqueid Unique id of this table.
* @param int[] $courseids List of ids for courses that require attention.
*/
- public function __construct($uniqueid, $courseids) {
+ public function __construct($uniqueid, $courseids, $filterdata) {
parent::__construct($uniqueid);
- global $PAGE;
+ global $PAGE, $DB;
$fields = "p.id as processid, c.id as courseid, c.fullname as coursefullname, c.shortname as courseshortname, " .
"c.startdate, cc.name as category , s.id as stepinstanceid, s.instancename as stepinstancename, ".
@@ -59,13 +59,27 @@ class interaction_attention_table extends interaction_table {
'left join {course_categories} cc on c.category = cc.id';
$ids = implode(',', $courseids);
- $where = 'FALSE';
+ $where = ['FALSE'];
if ($ids) {
- $where = 'p.courseid IN (' . $ids . ')';
+ $where = ['p.courseid IN (' . $ids . ')'];
+ }
+
+ $params = [];
+
+ if ($filterdata) {
+ if ($filterdata && $filterdata->shortname) {
+ $where[] = $DB->sql_like('c.shortname', ':shortname', false, false);
+ $params['shortname'] = '%' . $DB->sql_like_escape($filterdata->shortname) . '%';
+ }
+
+ if ($filterdata && $filterdata->fullname) {
+ $where[] = $DB->sql_like('c.fullname', ':fullname', false, false);
+ $params['fullname'] = '%' . $DB->sql_like_escape($filterdata->fullname) . '%';
+ }
}
$this->column_nosort = array('status', 'tools');
- $this->set_sql($fields, $from, $where, []);
+ $this->set_sql($fields, $from, join(" AND ", $where), $params);
$this->define_baseurl($PAGE->url);
$this->init();
}
diff --git a/classes/view_controller.php b/classes/view_controller.php
index 32e297d3b4e1c8f8f61495a5760be0dbad6ab684..015830a605445a16ab82fac9e0a0cb81200b836c 100644
--- a/classes/view_controller.php
+++ b/classes/view_controller.php
@@ -52,7 +52,7 @@ class view_controller {
* @throws \dml_exception
* @throws \invalid_parameter_exception
*/
- public function handle_view($renderer) {
+ public function handle_view($renderer, $filterdata) {
global $DB;
$courses = get_user_capability_course('tool/lifecycle:managecourses', null, false);
@@ -91,7 +91,7 @@ class view_controller {
}
echo $renderer->heading(get_string('tablecoursesrequiringattention', 'tool_lifecycle'), 3);
- $table1 = new interaction_attention_table('tool_lifecycle_interaction', $requiresinteraction);
+ $table1 = new interaction_attention_table('tool_lifecycle_interaction', $requiresinteraction, $filterdata);
echo $renderer->box_start("managing_courses_tables");
$table1->out(50, false);
diff --git a/view.php b/view.php
index b0970e7deda73cf1bd64fa27fea98e75a8c605ca..8ad1df50a3e7b09d55ff4950cae628ec0a9f2eb1 100644
--- a/view.php
+++ b/view.php
@@ -63,6 +63,28 @@ $renderer = $PAGE->get_renderer('tool_lifecycle');
echo $renderer->header();
-$controller->handle_view($renderer);
+$mform = new \tool_lifecycle\local\form\form_backups_filter();
+
+// Cache handling.
+$cache = cache::make('tool_lifecycle', 'mformdata');
+if ($mform->is_cancelled()) {
+ $cache->delete('coursebackups_filter');
+ redirect($PAGE->url);
+} else if ($data = $mform->get_data()) {
+ $cache->set('coursebackups_filter', $data);
+} else {
+ $data = $cache->get('coursebackups_filter');
+ if ($data) {
+ $mform->set_data($data);
+ }
+}
+
+echo '<br>';
+
+$mform->display();
+
+echo '<br>';
+
+$controller->handle_view($renderer, $data);
echo $renderer->footer();