From 91a87425410a2139afa55312136acd28b5cc67b1 Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Mon, 23 Sep 2024 12:14:16 +0200 Subject: [PATCH 1/5] show kanbans in block activity_modules --- index.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 470ff8bb..5cb584d4 100644 --- a/index.php +++ b/index.php @@ -28,6 +28,52 @@ $id = required_param('id', PARAM_INT); -require_login(); +$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST); +require_course_login($course); -redirect($CFG->wwwroot . '/mod/kanban/view.php?id=' . $id); +$coursecontext = context_course::instance($course->id); + +$PAGE->set_url('/mod/kanban/index.php', ['id' => $id]); +$PAGE->set_title(format_string($course->fullname)); +$PAGE->set_heading(format_string($course->fullname)); +$PAGE->set_context($coursecontext); + +echo $OUTPUT->header(); + +$modulenameplural = get_string('modulenameplural', 'mod_kanban'); +echo $OUTPUT->heading($modulenameplural); + +$kanbans = get_all_instances_in_course('kanban', $course); + +if (empty($kanbans)) { + notice(get_string('no$kanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id])); +} + +$usesections = course_format_uses_sections($course->format); +$table = new html_table(); +$table->attributes['class'] = 'generaltable mod_index'; + +if ($usesections) { + $table->head = [get_string('sectionname', 'format_' . $course->format), get_string('name')]; + $table->align = ['left', 'left']; +} else { + $table->head = [get_string('name')]; + $table->align = ['left']; +} + +foreach ($kanbans as $kanban) { + $linkcss = null; + if (!$kanban->visible) { + $linkcss = ['class' => 'dimmed']; + } + $link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss); + + if ($usesections) { + $table->data[] = [get_section_name($course, $kanban->section), $link]; + } else { + $table->data[] = [$link]; + } +} + +echo html_writer::table($table); +echo $OUTPUT->footer(); From 5174d61450906558a0fb5ad177a085e4796da1c3 Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Sun, 6 Oct 2024 12:54:22 +0200 Subject: [PATCH 2/5] MBS-8337: Added capabilities and language string --- index.php | 25 ++++++++++++++++--------- lang/en/kanban.php | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/index.php b/index.php index 5cb584d4..8b848d58 100644 --- a/index.php +++ b/index.php @@ -43,10 +43,12 @@ $modulenameplural = get_string('modulenameplural', 'mod_kanban'); echo $OUTPUT->heading($modulenameplural); +require_capability('mod/kanban:view', $coursecontext); + $kanbans = get_all_instances_in_course('kanban', $course); if (empty($kanbans)) { - notice(get_string('no$kanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id])); + notice(get_string('nokanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id])); } $usesections = course_format_uses_sections($course->format); @@ -62,16 +64,21 @@ } foreach ($kanbans as $kanban) { + $context = context_module::instance($kanban->coursemodule); $linkcss = null; - if (!$kanban->visible) { - $linkcss = ['class' => 'dimmed']; - } - $link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss); - if ($usesections) { - $table->data[] = [get_section_name($course, $kanban->section), $link]; - } else { - $table->data[] = [$link]; + if ($kanban->visible && has_capability('mod/kanban:view', $context)) { + if (!$kanban->visible) { + $linkcss = ['class' => 'dimmed']; + } + + $link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss); + + if ($usesections) { + $table->data[] = [get_section_name($course, $kanban->section), $link]; + } else { + $table->data[] = [$link]; + } } } diff --git a/lang/en/kanban.php b/lang/en/kanban.php index 24662a89..99e393c9 100644 --- a/lang/en/kanban.php +++ b/lang/en/kanban.php @@ -133,6 +133,7 @@ $string['newcard'] = 'New card'; $string['newcolumn'] = 'New column'; $string['nogroupavailable'] = 'No group available'; +$string['nokanbaninstances'] = 'There are no kanban boards in this course'; $string['nouser'] = 'No user'; $string['nouserboards'] = 'No personal boards'; $string['pluginadministration'] = 'Kanban administration'; From 51643611931047e77af8577239c3396c4e382449 Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Mon, 28 Oct 2024 11:34:00 +0100 Subject: [PATCH 3/5] MBS-8337: Combine kanban visibility check with empty table message --- index.php | 42 +++++++++++++++++++++++------------------- lang/en/kanban.php | 8 ++++++++ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/index.php b/index.php index 8b848d58..93cd008c 100644 --- a/index.php +++ b/index.php @@ -43,15 +43,9 @@ $modulenameplural = get_string('modulenameplural', 'mod_kanban'); echo $OUTPUT->heading($modulenameplural); -require_capability('mod/kanban:view', $coursecontext); - $kanbans = get_all_instances_in_course('kanban', $course); - -if (empty($kanbans)) { - notice(get_string('nokanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id])); -} - $usesections = course_format_uses_sections($course->format); + $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; @@ -63,24 +57,34 @@ $table->align = ['left']; } +$kanbanfound = false; + foreach ($kanbans as $kanban) { - $context = context_module::instance($kanban->coursemodule); + $context = context_module::instance($kanban->coursemodule, IGNORE_MISSING); + if (!$context || !$kanban->visible || !has_capability('mod/kanban:view', $context)) { + continue; + } + + $kanbanfound = true; $linkcss = null; - if ($kanban->visible && has_capability('mod/kanban:view', $context)) { - if (!$kanban->visible) { - $linkcss = ['class' => 'dimmed']; - } + if (!$kanban->visible) { + $linkcss = ['class' => 'dimmed']; + } - $link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss); + $link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss); - if ($usesections) { - $table->data[] = [get_section_name($course, $kanban->section), $link]; - } else { - $table->data[] = [$link]; - } + if ($usesections) { + $table->data[] = [get_section_name($course, $kanban->section), $link]; + } else { + $table->data[] = [$link]; } } -echo html_writer::table($table); +if (!$kanbanfound) { + notice(get_string('nokanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id])); +} else { + echo html_writer::table($table); +} + echo $OUTPUT->footer(); diff --git a/lang/en/kanban.php b/lang/en/kanban.php index 99e393c9..0d9136d7 100644 --- a/lang/en/kanban.php +++ b/lang/en/kanban.php @@ -123,6 +123,14 @@ $string['messageprovider:due'] = 'Card due'; $string['messageprovider:moved'] = 'Card moved'; $string['modulename'] = 'Kanban board'; +$string['modulename_help'] = 'This activity supports using kanban method for managing projects or learning processes. +Kanban is an agile project management method that organizes tasks through a visual board to optimize workflow. Tasks are categorized into columns such as "To Do," "In Progress," and "Done" to make progress transparent. The goal is to identify bottlenecks in the workflow and continuously improve efficiency. + Depending on the settings, there can be several types of boards within a Kanban activity: +* The course board, which is accessible to everyone who has access to the activity +* Personal boards for each user +* Group boards +* Template boards: Anyone who has the ability to manage boards can copy an existing board as a template. +'; $string['modulenameplural'] = 'Kanban boards'; $string['moveaftercard'] = 'Move after'; $string['movecard'] = 'Move card'; From b1fff93ff524d270aae097b1c0861d157c5a516d Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Wed, 30 Oct 2024 16:20:02 +0100 Subject: [PATCH 4/5] Fix: Remove unintended modulename_help entry --- index.php | 2 +- lang/en/kanban.php | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/index.php b/index.php index 93cd008c..b857cecc 100644 --- a/index.php +++ b/index.php @@ -61,7 +61,7 @@ foreach ($kanbans as $kanban) { $context = context_module::instance($kanban->coursemodule, IGNORE_MISSING); - if (!$context || !$kanban->visible || !has_capability('mod/kanban:view', $context)) { + if (!$context || !has_capability('mod/kanban:view', $context)) { continue; } diff --git a/lang/en/kanban.php b/lang/en/kanban.php index 0d9136d7..99e393c9 100644 --- a/lang/en/kanban.php +++ b/lang/en/kanban.php @@ -123,14 +123,6 @@ $string['messageprovider:due'] = 'Card due'; $string['messageprovider:moved'] = 'Card moved'; $string['modulename'] = 'Kanban board'; -$string['modulename_help'] = 'This activity supports using kanban method for managing projects or learning processes. -Kanban is an agile project management method that organizes tasks through a visual board to optimize workflow. Tasks are categorized into columns such as "To Do," "In Progress," and "Done" to make progress transparent. The goal is to identify bottlenecks in the workflow and continuously improve efficiency. - Depending on the settings, there can be several types of boards within a Kanban activity: -* The course board, which is accessible to everyone who has access to the activity -* Personal boards for each user -* Group boards -* Template boards: Anyone who has the ability to manage boards can copy an existing board as a template. -'; $string['modulenameplural'] = 'Kanban boards'; $string['moveaftercard'] = 'Move after'; $string['movecard'] = 'Move card'; From 9821f9d495cf3c04e0459f5291fa680789e948a5 Mon Sep 17 00:00:00 2001 From: PhMemmel <65113153+PhMemmel@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:52:29 +0100 Subject: [PATCH 5/5] Update lang/en/kanban.php --- lang/en/kanban.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en/kanban.php b/lang/en/kanban.php index 99e393c9..eb007747 100644 --- a/lang/en/kanban.php +++ b/lang/en/kanban.php @@ -133,7 +133,7 @@ $string['newcard'] = 'New card'; $string['newcolumn'] = 'New column'; $string['nogroupavailable'] = 'No group available'; -$string['nokanbaninstances'] = 'There are no kanban boards in this course'; +$string['nokanbaninstances'] = 'There are no kanban boards in this course or you are not allowed to access them'; $string['nouser'] = 'No user'; $string['nouserboards'] = 'No personal boards'; $string['pluginadministration'] = 'Kanban administration';