From 4f4a06d98d3fd3c543db8b1dfe0996d0e275d686 Mon Sep 17 00:00:00 2001
From: Chris Sangwin <C.J.Sangwin@gmail.com>
Date: Wed, 11 Jul 2018 16:30:00 +0100
Subject: [PATCH] Code tidy.

---
 doc/doc.php          | 3 +++
 plot.php             | 2 ++
 stack/input/ajax.php | 4 +---
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/doc.php b/doc/doc.php
index dec98af26..133df3233 100644
--- a/doc/doc.php
+++ b/doc/doc.php
@@ -23,7 +23,10 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
+// The docs should be public and not require a login, so we ignore the fact we load config here without a login check.
+// @codingStandardsIgnoreStart
 require_once(__DIR__ . '/../../../../config.php');
+// @codingStandardsIgnoreEnd
 require_once(__DIR__ . '/docslib.php');
 
 /*
diff --git a/plot.php b/plot.php
index 02b5bc932..d7db411bb 100644
--- a/plot.php
+++ b/plot.php
@@ -24,6 +24,8 @@
 require_once(__DIR__ . '/../../../config.php');
 require_once($CFG->libdir . '/filelib.php');
 
+require_login();
+
 $filename = clean_filename(get_file_argument());
 $filenamesplit = explode('.', $filename);
 $filetype = end($filenamesplit);
diff --git a/stack/input/ajax.php b/stack/input/ajax.php
index ef6824fc2..0785106a4 100644
--- a/stack/input/ajax.php
+++ b/stack/input/ajax.php
@@ -29,9 +29,7 @@ $qaid  = required_param('qaid', PARAM_INT);
 $inputname = required_param('name', PARAM_ALPHANUMEXT);
 $inputvalue = required_param('input', PARAM_RAW);
 
-if (!isloggedin()) {
-    die;
-}
+require_login();
 
 // This should not be necessary, but the TeX filter requires it, because it uses $OUTPUT.
 $PAGE->set_context(context_system::instance());
-- 
GitLab