Skip to content

Commit

Permalink
refactor: rename variables and add missing phpdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
keevan committed May 23, 2024
1 parent 7b559e0 commit cac9907
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
11 changes: 9 additions & 2 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,20 @@ class mod_facetoface_renderer extends plugin_renderer_base {

/**
* Builds session list table given an array of sessions
*
* @param array $customfields
* @param array $sessions
* @param bool $canviewattendees
* @param bool $caneditsessions
* @param bool $showsignuplinks
* @param bool $canuploadbookings
*/
public function print_session_list_table(
$customfields,
$sessions,
$viewattendees,
$editsessions,
$signuplinks = true,
$showsignuplinks = true,
$uploadbookings = false
) {
$output = '';
Expand Down Expand Up @@ -192,7 +199,7 @@ public function print_session_list_table(
['title' => get_string('cancelbooking', 'facetoface')]
);
}
} else if (!$sessionstarted && !$bookedsession && $signuplinks) {
} else if (!$sessionstarted && !$bookedsession && $showsignuplinks) {
$options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface,
get_string('signup', 'facetoface'));
}
Expand Down
28 changes: 14 additions & 14 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ function print_session_list($courseid, $facetoface, $location) {
$timenow = time();

$context = context_course::instance($courseid);
$viewattendees = has_capability('mod/facetoface:viewattendees', $context);
$editsessions = has_capability('mod/facetoface:editsessions', $context);
$uploadbookings = has_capability('mod/facetoface:uploadbookings', $context);
$canviewattendees = has_capability('mod/facetoface:viewattendees', $context);
$caneditsessions = has_capability('mod/facetoface:editsessions', $context);
$canuploadbookings = has_capability('mod/facetoface:uploadbookings', $context);
$multiplesignups = $facetoface->signuptype == MOD_FACETOFACE_SIGNUP_MULTIPLE;
$bulksignup = $facetoface->multiplesignupmethod == MOD_FACETOFACE_SIGNUP_MULTIPLE_PER_ACTIVITY;
$isbulksignup = $facetoface->multiplesignupmethod == MOD_FACETOFACE_SIGNUP_MULTIPLE_PER_ACTIVITY;

$bookedsession = null;
if ($submissions = facetoface_get_user_submissions($facetoface->id, $USER->id)) {
Expand Down Expand Up @@ -217,7 +217,7 @@ function print_session_list($courseid, $facetoface, $location) {
// Upcoming sessions.
echo $OUTPUT->heading(get_string('upcomingsessions', 'facetoface'));

if (!empty($upcomingarray) && $bulksignup) {
if (!empty($upcomingarray) && $isbulksignup) {
$firstsession = $sessions[array_keys($sessions)[0]];
$signupforstreamlink = html_writer::link(
'signup.php?s=' . $firstsession->id . '&backtoallsessions=' . $session->facetoface,
Expand All @@ -233,22 +233,22 @@ function print_session_list($courseid, $facetoface, $location) {
echo $f2frenderer->print_session_list_table(
$customfields,
$upcomingarray,
$viewattendees,
$editsessions,
!$bulksignup,
$uploadbookings
$canviewattendees,
$caneditsessions,
!$isbulksignup,
$canuploadbookings
);
}

if ($editsessions) {
if ($caneditsessions) {
$addsessionlink = html_writer::link(
new moodle_url('sessions.php', ['f' => $facetoface->id]),
get_string('addsession', 'facetoface')
);
echo html_writer::tag('p', $addsessionlink);
}

if ($uploadbookings) {
if ($canuploadbookings) {
$adduploadlink = html_writer::link(
new moodle_url('upload.php', ['f' => $facetoface->id]),
get_string('uploadbookings', 'facetoface')
Expand All @@ -262,10 +262,10 @@ function print_session_list($courseid, $facetoface, $location) {
echo $f2frenderer->print_session_list_table(
$customfields,
$previousarray,
$viewattendees,
$editsessions,
$canviewattendees,
$caneditsessions,
true,
$uploadbookings
$canuploadbookings
);
}
}
Expand Down

0 comments on commit cac9907

Please sign in to comment.