diff --git a/classes/local/controllers/infopage.php b/classes/local/controllers/infopage.php index eb7b0dc..0fdb6b6 100644 --- a/classes/local/controllers/infopage.php +++ b/classes/local/controllers/infopage.php @@ -97,7 +97,7 @@ class infopage { public function output() { global $PAGE, $CFG, $OUTPUT; - if (is_null($this->outage)) { + if (is_null($this->outage) || !has_capability('auth/outage:viewinfo', context_system::instance())) { redirect(new moodle_url('/')); } diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..cf0c3f5 --- /dev/null +++ b/db/access.php @@ -0,0 +1,37 @@ +. + +/** + * Define capabilities for plugin. + * + * @package auth_outage + * @author Andrew Madden + * @copyright 2021 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$capabilities = [ + 'auth/outage:viewinfo' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'guest' => CAP_ALLOW, + 'user' => CAP_ALLOW, + ) + ), +]; diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 9f27c96..8842f8a 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -112,6 +112,7 @@ $string['messageoutageongoing'] = 'Back online at {$a->stop}.'; $string['messageoutagewarning'] = 'Shutting down in {{countdown}}'; $string['na'] = 'n/a'; $string['notfound'] = 'No outages found.'; +$string['outage:viewinfo'] = 'View outage info'; $string['outageedit'] = 'Edit outage'; $string['outageeditcrumb'] = 'Edit'; $string['outageclone'] = 'Clone outage'; diff --git a/version.php b/version.php index 7e3e7e2..8c1d486 100644 --- a/version.php +++ b/version.php @@ -28,7 +28,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = "auth_outage"; -$plugin->version = 2021050600; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2021032500; // Human-readable release information. +$plugin->version = 2021062300; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2021062300; // Human-readable release information. $plugin->requires = 2017111309; // 2017111309 = T13, but this really requires 3.9 and higher. $plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!