From 1b644c907b9a0ddf41020294644a08b80ab87d5a Mon Sep 17 00:00:00 2001 From: Kevin Pham Date: Thu, 23 May 2024 11:51:49 +1000 Subject: [PATCH] fix: update list to only show session id if user has capabilities to upload Resolves #161 --- renderer.php | 19 ++++++++++++++++--- view.php | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/renderer.php b/renderer.php index e0e46e2..f824d50 100644 --- a/renderer.php +++ b/renderer.php @@ -33,7 +33,14 @@ class mod_facetoface_renderer extends plugin_renderer_base { /** * Builds session list table given an array of sessions */ - public function print_session_list_table($customfields, $sessions, $viewattendees, $editsessions, $signuplinks = true) { + public function print_session_list_table( + $customfields, + $sessions, + $viewattendees, + $editsessions, + $signuplinks = true, + $uploadbookings = false + ) { $output = ''; $tableheader = []; @@ -42,7 +49,11 @@ public function print_session_list_table($customfields, $sessions, $viewattendee $tableheader[] = format_string($field->name); } } - $tableheader[] = get_string('sessionnumber', 'facetoface'); + + if ($uploadbookings) { + $tableheader[] = get_string('sessionnumber', 'facetoface'); + } + $tableheader[] = get_string('date', 'facetoface'); $tableheader[] = get_string('time', 'facetoface'); if ($viewattendees) { @@ -90,7 +101,9 @@ public function print_session_list_table($customfields, $sessions, $viewattendee } } - $sessionrow[] = html_writer::tag('span', $session->id, ['class' => 'mr-3']); + if ($uploadbookings) { + $sessionrow[] = html_writer::tag('span', $session->id, ['class' => 'mr-3']); + } // Dates/times. $allsessiondates = ''; diff --git a/view.php b/view.php index b75d351..23559ad 100644 --- a/view.php +++ b/view.php @@ -223,7 +223,14 @@ function print_session_list($courseid, $facetoface, $location) { print_string('noupcoming', 'facetoface'); } else { $upcomingarray = array_merge($upcomingarray, $upcomingtbdarray); - echo $f2frenderer->print_session_list_table($customfields, $upcomingarray, $viewattendees, $editsessions, !$bulksignup); + echo $f2frenderer->print_session_list_table( + $customfields, + $upcomingarray, + $viewattendees, + $editsessions, + !$bulksignup, + $uploadbookings + ); } if ($editsessions) { @@ -245,7 +252,14 @@ function print_session_list($courseid, $facetoface, $location) { // Previous sessions. if (!empty($previousarray)) { echo $OUTPUT->heading(get_string('previoussessions', 'facetoface')); - echo $f2frenderer->print_session_list_table($customfields, $previousarray, $viewattendees, $editsessions); + echo $f2frenderer->print_session_list_table( + $customfields, + $previousarray, + $viewattendees, + $editsessions, + true, + $uploadbookings + ); } }