Skip to content

Commit

Permalink
#102 - Added check on activity deletion in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
AraPraxis committed Sep 20, 2023
1 parent 0f537c9 commit 7f81816
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion block_sharing_cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 "";
Expand Down

0 comments on commit 7f81816

Please sign in to comment.