Finished enable/disable setting for studyplan sharing
This commit is contained in:
parent
f6b53a1623
commit
43c0af4730
|
@ -198,6 +198,10 @@ class studentstudyplanservice extends \external_api {
|
|||
*/
|
||||
public static function list_invited_studyplans($invitekey) {
|
||||
global $DB;
|
||||
// First check if studyplan sharing is enabled.
|
||||
if (!get_config("local_treestudyplan","enableplansharing")) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$invite = $DB->get_record_select(
|
||||
"local_treestudyplan_invit",
|
||||
|
@ -252,7 +256,10 @@ class studentstudyplanservice extends \external_api {
|
|||
*/
|
||||
public static function get_invited_studyplan($invitekey,$studyplanid) {
|
||||
global $DB;
|
||||
|
||||
// First check if studyplan sharing is enabled.
|
||||
if (!get_config("local_treestudyplan","enableplansharing")) {
|
||||
return [];
|
||||
}
|
||||
$invite = $DB->get_record_select(
|
||||
"local_treestudyplan_invit",
|
||||
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
|
||||
|
@ -306,7 +313,10 @@ class studentstudyplanservice extends \external_api {
|
|||
*/
|
||||
public static function get_invited_page($invitekey,$pageid) {
|
||||
global $DB;
|
||||
|
||||
// First check if studyplan sharing is enabled.
|
||||
if (!get_config("local_treestudyplan","enableplansharing")) {
|
||||
return [];
|
||||
}
|
||||
$invite = $DB->get_record_select(
|
||||
"local_treestudyplan_invit",
|
||||
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
|
||||
|
|
|
@ -51,23 +51,40 @@ if (!empty($sent)) {
|
|||
|
||||
};
|
||||
|
||||
print $OUTPUT->header();
|
||||
if (!get_config("local_treestudyplan","enableplansharing")) {
|
||||
$PAGE->set_title(get_string('accessdenied', 'admin'));
|
||||
$PAGE->set_heading(get_string('accessdenied', 'admin'));
|
||||
|
||||
print "<p>".get_string('invite_description', 'local_treestudyplan')."</p>";
|
||||
print $OUTPUT->header();
|
||||
|
||||
$invites = $DB->get_records('local_treestudyplan_invit', array('user_id' => $USER->id));
|
||||
// Render page for skill level 0 (global).
|
||||
|
||||
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 "<div class='box errorbox alert alert-danger'>";
|
||||
print get_string('accessdenied','admin');
|
||||
print "</div>";
|
||||
|
||||
print "<tbody>";
|
||||
if (count($invites) > 0) {
|
||||
print $OUTPUT->footer();
|
||||
|
||||
exit;
|
||||
} else {
|
||||
|
||||
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}'>";
|
||||
|
@ -97,12 +114,13 @@ if (count($invites) > 0) {
|
|||
|
||||
print "</td>";
|
||||
}
|
||||
} else {
|
||||
} 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>";
|
||||
|
||||
print $OUTPUT->footer();
|
||||
}
|
||||
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>";
|
||||
|
||||
print $OUTPUT->footer();
|
||||
|
|
17
invited.php
17
invited.php
|
@ -47,7 +47,22 @@ $invite = $DB->get_record_select("local_treestudyplan_invit",
|
|||
$DB->sql_compare_text("invitekey"). " = " . $DB->sql_compare_text(":invitekey"),
|
||||
['invitekey' => $invitekey]);
|
||||
|
||||
if (empty($invite)) {
|
||||
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;
|
||||
} else if (empty($invite)) {
|
||||
$PAGE->set_title(get_string('invalid_invitekey_title', 'local_treestudyplan'));
|
||||
$PAGE->set_heading(get_string('invalid_invitekey_title', 'local_treestudyplan'));
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user