moodle_local_treestudyplan/invitations.php

118 lines
5.0 KiB
PHP
Raw Normal View History

<?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/>.
/**
*
* @package local_treestudyplan
* @copyright 2023 P.M. Kuipers
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (isset($_SERVER['SCRIPT_FILENAME'])) {
2023-08-25 09:44:34 +02:00
// If SCRIPT_FILENAME is set, use that so the symlinked directories the developmen environment uses are handled correctly.
$root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
error_log("Using {$root}/config.php");
require_once($root."/config.php");
2023-08-25 09:33:42 +02:00
} else {
2023-08-25 09:44:34 +02:00
// If not, assume the cwd is not symlinked and proceed as we are used to.
require_once("../../config.php");
}
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->dirroot.'/grade/querylib.php');
use local_treestudyplan;
2023-08-25 09:33:42 +02:00
$INVITEDURL = "/local/treestudyplan/invited.php";
2023-08-25 09:44:34 +02:00
// Admin_externalpage_setup('major');.
$systemcontext = context_system::instance();
2023-08-24 23:02:41 +02:00
$PAGE->set_url("/local/treestudyplan/invitations.php", array());
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.
$PAGE->requires->js_call_amd('local_treestudyplan/page-invitemanager', 'init');
$PAGE->requires->js_call_amd('local_treestudyplan/buttonlinks', 'init');
2023-08-24 23:02:41 +02:00
// retrieve list of courses that the student is enrolled in.
$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));
};
print $OUTPUT->header();
print "<p>".get_string('invite_description', 'local_treestudyplan')."</p>";
$invites = $DB->get_records('local_treestudyplan_invit', array('user_id' => $USER->id));
2023-08-24 23:02:41 +02:00
print "<h3>".get_string('invite_tablecaption', 'local_treestudyplan')."</h3>";
print "<table class='m-manage_invites'>";
print "<thead>";
2023-08-24 23:02:41 +02:00
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>&nbsp;</th>";
print "</thead>";
print "<tbody>";
2023-08-24 23:02:41 +02:00
if (count($invites) > 0) {
2023-08-25 10:41:56 +02:00
foreach ($invites as $invite) {
2023-08-25 09:44:34 +02:00
$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'>";
2023-08-25 11:52:05 +02:00
print "<a class='m-action-view ' href='{$testlink}' title='"
.get_string('invite_tooltip_testlink', 'local_treestudyplan')."'><i class='fa fa-eye'></i></a>";
2023-08-25 09:44:34 +02:00
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')."'";
2023-08-25 11:52:05 +02:00
print " href='#' data-actionhref='edit-invite.php?resend={$invite->id}' title='"
.get_string('invite_tooltip_resend', 'local_treestudyplan')."'";
2023-08-25 09:44:34 +02:00
print " ><i class='fa fa-envelope'></i></a>";
2023-08-25 11:52:05 +02:00
print "<a href='edit-invite.php?update={$invite->id}'><i class='fa fa-pencil' title='"
.get_string('invite_tooltip_edit', 'local_treestudyplan')."'></i></a>";
2023-08-25 09:44:34 +02:00
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')."'";
2023-08-25 11:52:05 +02:00
print " href='#' data-actionhref='edit-invite.php?delete={$invite->id}' title='"
.get_string('invite_tooltip_delete', 'local_treestudyplan')."'";
2023-08-25 09:44:34 +02:00
print " ><i class='fa fa-trash'></i></a>";
print "</td>";
}
2023-08-25 09:33:42 +02:00
} else {
2023-08-25 09:44:34 +02:00
print "<tr><td colspan='6'>".get_string('invite_table_empty', 'local_treestudyplan')."</td></tr>";
}
print "</tbody></table>";
2023-08-25 11:52:05 +02:00
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-08-25 11:52:05 +02:00
print $OUTPUT->footer();