diff --git a/classes/studentstudyplanservice.php b/classes/studentstudyplanservice.php index dc8cce7..84725b4 100644 --- a/classes/studentstudyplanservice.php +++ b/classes/studentstudyplanservice.php @@ -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"), diff --git a/invitations.php b/invitations.php index 7269f09..3537b6b 100644 --- a/invitations.php +++ b/invitations.php @@ -51,58 +51,76 @@ 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 "
".get_string('invite_description', 'local_treestudyplan')."
"; + print $OUTPUT->header(); -$invites = $DB->get_records('local_treestudyplan_invit', array('user_id' => $USER->id)); + // Render page for skill level 0 (global). -print "".get_string('invite_name', 'local_treestudyplan')." | "; -print "".get_string('invite_email', 'local_treestudyplan')." | "; -print "".get_string('invite_date', 'local_treestudyplan')." | "; -print ""; -print ""; + print " | ||
---|---|---|---|---|---|
{$invite->name} | "; - print "{$invite->email} | "; - print "".userdate($invite->idate, "%x")." | "; - print ""; + print $OUTPUT->footer(); - print ""; - - print "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 " >"; - - print ""; - print "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 " >"; - - print " | "; - } + exit; } else { - print "||
".get_string('invite_table_empty', 'local_treestudyplan')." |
".get_string('invite_description', 'local_treestudyplan')."
"; + + $invites = $DB->get_records('local_treestudyplan_invit', array('user_id' => $USER->id)); + + print "".get_string('invite_name', 'local_treestudyplan')." | "; + print "".get_string('invite_email', 'local_treestudyplan')." | "; + print "".get_string('invite_date', 'local_treestudyplan')." | "; + print ""; + print ""; + + print ""; + if (count($invites) > 0) { + foreach ($invites as $invite) { + $testlink = $invitedurl."?key={$invite->invitekey}"; + print " | ||
---|---|---|---|---|---|
{$invite->name} | "; + print "{$invite->email} | "; + print "".userdate($invite->idate, "%x")." | "; + print ""; + + print ""; + + print "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 " >"; + + print ""; + print "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 " >"; + + print " | "; + } + } else { + print "||
".get_string('invite_table_empty', 'local_treestudyplan')." |