Skip to content

Commit 5c7d16b

Browse files
authored
Merge pull request #239 from sh-csg/hide-move-if-only-one-instance
Hide move button if only one instance is present in the course
2 parents 9165012 + f4cafb4 commit 5c7d16b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

locallib.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,12 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
226226
// Check wether the user can move a topic.
227227
$canmovetopic = false;
228228
if ((!is_guest($context, $USER) && isloggedin()) && has_capability('mod/moodleoverflow:movetopic', $context)) {
229-
$canmovetopic = true;
229+
$modinfo = get_fast_modinfo($moodleoverflow->course);
230+
$coursemoodleoverflows = $modinfo->get_instances_of('moodleoverflow');
231+
$coursemoodleoverflows = array_filter($coursemoodleoverflows, function($cm) {
232+
return $cm->deletioninprogress == 0;
233+
});
234+
$canmovetopic = count($coursemoodleoverflows) > 1;
230235
}
231236

232237
// Iterate through every visible discussion.

0 commit comments

Comments
 (0)