2023-05-17 21:19:14 +02:00
|
|
|
<?php
|
2023-08-24 23:02:41 +02:00
|
|
|
// This file is part of the Studyplan plugin for Moodle
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
/**
|
2023-08-27 15:12:54 +02:00
|
|
|
* Entry point for students to manage invitations to view their study plan
|
2023-08-24 23:02:41 +02:00
|
|
|
* @package local_treestudyplan
|
|
|
|
* @copyright 2023 P.M. Kuipers
|
|
|
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2023-08-25 13:04:19 +02:00
|
|
|
require_once("../../config.php");
|
2023-05-17 21:19:14 +02:00
|
|
|
|
|
|
|
require_once($CFG->libdir.'/weblib.php');
|
|
|
|
require_once($CFG->dirroot.'/grade/querylib.php');
|
|
|
|
|
|
|
|
use local_treestudyplan;
|
|
|
|
|
2023-08-25 13:04:19 +02:00
|
|
|
$invitedurl = "/local/treestudyplan/invited.php";
|
2023-05-17 21:19:14 +02:00
|
|
|
|
|
|
|
$systemcontext = context_system::instance();
|
|
|
|
|
2023-08-24 23:02:41 +02:00
|
|
|
$PAGE->set_url("/local/treestudyplan/invitations.php", array());
|
2023-05-17 21:19:14 +02:00
|
|
|
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'));
|
|
|
|
|
2023-08-24 23:02:41 +02:00
|
|
|
// Load javascripts.
|
2023-05-17 21:19:14 +02:00
|
|
|
$PAGE->requires->js_call_amd('local_treestudyplan/page-invitemanager', 'init');
|
|
|
|
|
2023-08-25 13:04:19 +02:00
|
|
|
// Retrieve list of courses that the student is enrolled in.
|
2023-08-24 23:02:41 +02:00
|
|
|
$sent = optional_param('sent', '', PARAM_INT);
|
|
|
|
if (!empty($sent)) {
|
2023-08-25 09:44:34 +02:00
|
|
|
$invite = $DB->get_record('local_treestudyplan_invit', array('id' => $sent));
|
|
|
|
\core\notification::success(get_string('invite_resent_msg', 'local_treestudyplan', $invite));
|
2023-05-17 21:19:14 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2023-12-11 23:57:56 +01:00
|
|
|
if (!get_config("local_treestudyplan","enableplansharing")) {
|
|
|
|
$PAGE->set_title(get_string('accessdenied', 'admin'));
|
|
|
|
$PAGE->set_heading(get_string('accessdenied', 'admin'));
|
|
|
|
|
|
|
|
print $OUTPUT->header();
|
|
|
|
|
|
|
|
// Render page for skill level 0 (global).
|
|
|
|
|
|
|
|
print "<div class='box errorbox alert alert-danger'>";
|
|
|
|
print get_string('accessdenied','admin');
|
|
|
|
print "</div>";
|
|
|
|
|
|
|
|
print $OUTPUT->footer();
|
|
|
|
|
|
|
|
exit;
|
2023-08-25 09:33:42 +02:00
|
|
|
} else {
|
2023-05-17 21:19:14 +02:00
|
|
|
|
2023-12-11 23:57:56 +01:00
|
|
|
print $OUTPUT->header();
|
|
|
|
|
|
|
|
print "<p>".get_string('invite_description', 'local_treestudyplan')."</p>";
|
|
|
|
|
|
|
|
$invites = $DB->get_records('local_treestudyplan_invit', array('user_id' => $USER->id));
|
|
|
|
|
|
|
|
print "<h3>".get_string('invite_tablecaption', 'local_treestudyplan')."</h3>";
|
|
|
|
print "<table class='m-manage_invites'>";
|
|
|
|
print "<thead>";
|
|
|
|
print "<th>".get_string('invite_name', 'local_treestudyplan')."</th>";
|
|
|
|
print "<th>".get_string('invite_email', 'local_treestudyplan')."</th>";
|
|
|
|
print "<th>".get_string('invite_date', 'local_treestudyplan')."</th>";
|
|
|
|
print "<th> </th>";
|
|
|
|
print "</thead>";
|
|
|
|
|
|
|
|
print "<tbody>";
|
|
|
|
if (count($invites) > 0) {
|
|
|
|
foreach ($invites as $invite) {
|
|
|
|
$testlink = $invitedurl."?key={$invite->invitekey}";
|
|
|
|
print "<tr data-id='{$invite->id}'>";
|
|
|
|
print "<td data-field='name'>{$invite->name}</td>";
|
|
|
|
print "<td data-field='email'>{$invite->email}</td>";
|
|
|
|
print "<td data-field='date'>".userdate($invite->idate, "%x")."</td>";
|
|
|
|
print "<td data-field='control'>";
|
|
|
|
|
|
|
|
print "<a class='m-action-view ' href='{$testlink}' title='"
|
|
|
|
.get_string('invite_tooltip_testlink', 'local_treestudyplan')."'><i class='fa fa-eye'></i></a>";
|
|
|
|
|
|
|
|
print "<a class='m-action-resend m-action-confirm'";
|
|
|
|
print " data-confirmtext='".get_string('invite_confirm_resend', 'local_treestudyplan', $invite->name)."'";
|
|
|
|
print " data-confirmbtn='".get_string('send', 'local_treestudyplan')."'";
|
|
|
|
print " href='#' data-actionhref='edit-invite.php?resend={$invite->id}' title='"
|
|
|
|
.get_string('invite_tooltip_resend', 'local_treestudyplan')."'";
|
|
|
|
print " ><i class='fa fa-envelope'></i></a>";
|
|
|
|
|
|
|
|
print "<a href='edit-invite.php?update={$invite->id}'><i class='fa fa-pencil' title='"
|
|
|
|
.get_string('invite_tooltip_edit', 'local_treestudyplan')."'></i></a>";
|
|
|
|
print "<a class='m-action-delete m-action-confirm'";
|
|
|
|
print " data-confirmtext='".get_string('invite_confirm_delete', 'local_treestudyplan', $invite->name)."'";
|
|
|
|
print " data-confirmbtn='".get_string('delete')."'";
|
|
|
|
print " href='#' data-actionhref='edit-invite.php?delete={$invite->id}' title='"
|
|
|
|
.get_string('invite_tooltip_delete', 'local_treestudyplan')."'";
|
|
|
|
print " ><i class='fa fa-trash'></i></a>";
|
|
|
|
|
|
|
|
print "</td>";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
print "<tr><td colspan='6'>".get_string('invite_table_empty', 'local_treestudyplan')."</td></tr>";
|
|
|
|
}
|
|
|
|
print "</tbody></table>";
|
|
|
|
|
|
|
|
print "<a class='btn btn-info' href='/local/treestudyplan/edit-invite.php?add=true' class='btn btn-primary' id='add_invite'>";
|
|
|
|
print "<i class='fa fa-plus'></i> ".get_string('invite_button_new', 'local_treestudyplan')."</a>";
|
2023-05-17 21:19:14 +02:00
|
|
|
|
2023-12-11 23:57:56 +01:00
|
|
|
print $OUTPUT->footer();
|
|
|
|
}
|