From 7f81816ea9b2b931140b560b9ef4a02267f547c3 Mon Sep 17 00:00:00 2001 From: Anders Rasmussen Date: Wed, 20 Sep 2023 12:46:12 +0200 Subject: [PATCH] #102 - Added check on activity deletion in progress --- block_sharing_cart.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/block_sharing_cart.php b/block_sharing_cart.php index 6f0b968..ea3b36d 100644 --- a/block_sharing_cart.php +++ b/block_sharing_cart.php @@ -162,7 +162,11 @@ public function get_content() { $activities_dropdown = ''; /** @var \cm_info $activity */ foreach ($activities as $activity) { - if ($section_id !== $activity->get_section_info()->section) { + if ($this->is_activity_not_in_section($section_id, $activity)) { + continue; + } + + if ($this->is_activity_deletion_in_progress($activity)) { continue; } @@ -187,6 +191,14 @@ public function get_content() { return $this->content = (object) array('text' => $html, 'footer' => $footer); } + private function is_activity_not_in_section(int $section_id, \cm_info $activity): bool { + return $section_id !== $activity->get_section_info()->section; + } + + private function is_activity_deletion_in_progress(\cm_info $activity): bool { + return $activity->deletioninprogress == 1; + } + private function insert_copy_section_in_footer(int $section_id, string $sections_dropdown): string { if (!get_config('block_sharing_cart', 'show_copy_section_in_block')) { return "";