. /** * Entry point for students to manage invitations to view their study plan * @package local_treestudyplan * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once("../../config.php"); require_once($CFG->libdir.'/weblib.php'); require_once($CFG->dirroot.'/grade/querylib.php'); $systemcontext = context_system::instance(); $PAGE->set_url("/local/treestudyplan/invitations.php", []); require_login(); $PAGE->set_pagelayout('base'); $PAGE->set_context($systemcontext); $PAGE->set_title(get_string('manage_invites', 'local_treestudyplan')); $PAGE->set_heading(get_string('manage_invites', 'local_treestudyplan')); // Load javascripts. $PAGE->requires->js_call_amd('local_treestudyplan/page-invitemanager', 'init'); // Retrieve list of courses that the student is enrolled in. $sent = optional_param('sent', '', PARAM_INT); if (!empty($sent)) { $invite = $DB->get_record('local_treestudyplan_invit', ['id' => $sent]); \core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite)); }; if (!get_config("local_treestudyplan", "enableplansharing")) { $PAGE->set_title(get_string('accessdenied', 'admin')); $PAGE->set_heading(get_string('accessdenied', 'admin')); print $OUTPUT->header(); print $OUTPUT->render_from_template('local_treestudyplan/error', [ "title" => get_string('accessdenied', 'admin'), "message" => get_string('error:invitationsdisabled', 'local_treestudyplan'), ]); print $OUTPUT->footer(); exit; // Just in case some code is added after this if statement erroneously later. } else { print $OUTPUT->header(); $invites = $DB->get_records('local_treestudyplan_invit', ['user_id' => $USER->id]); $data = [ "invites" => array_values($invites), "hasinvites" => boolval(count($invites) > 0), "invitedurl" => "{$CFG->wwwroot}/local/treestudyplan/invited.php", ]; print $OUTPUT->render_from_template('local_treestudyplan/invitations', $data); print $OUTPUT->footer(); }