mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Compare commits
46 Commits
admin-mess
...
MOODLE_38_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0609e7c952 | ||
|
|
5670df2b4d | ||
|
|
555644e486 | ||
|
|
24758a256e | ||
|
|
65b12dcf69 | ||
|
|
15d67370de | ||
|
|
b892943aad | ||
|
|
5f9788a6fe | ||
|
|
c4fc4b4396 | ||
|
|
e632b1c2f9 | ||
|
|
b4d996125d | ||
|
|
f8d0d658fa | ||
|
|
a38deb7abf | ||
|
|
1f03af1968 | ||
|
|
b29e7e914b | ||
|
|
6255ebb311 | ||
|
|
18d5864cac | ||
|
|
0a34a368d6 | ||
|
|
bfc3c2317b | ||
|
|
5fef56cb2f | ||
|
|
c55b9271c4 | ||
|
|
77ce63e4f9 | ||
|
|
47154e545f | ||
|
|
2d59580d36 | ||
|
|
49ea2a142e | ||
|
|
a6bb7f4bc2 | ||
|
|
f40f52bdc3 | ||
|
|
07a8a41ad4 | ||
|
|
19bc18512d | ||
|
|
116467429e | ||
|
|
def6e997a9 | ||
|
|
c53a629bc8 | ||
|
|
8f7d38f355 | ||
|
|
e58f7b73b3 | ||
|
|
f77c85355c | ||
|
|
56ac8aa19b | ||
|
|
c590eadb4f | ||
|
|
7cd10ab05c | ||
|
|
ca6c48d0f3 | ||
|
|
1cd0b7c365 | ||
|
|
ce93854b92 | ||
|
|
aab2af04e8 | ||
|
|
42babf617b | ||
|
|
90bc928754 | ||
|
|
e22c393681 | ||
|
|
e4dc17aae4 |
11
.github/workflows/ci.yml
vendored
Normal file
11
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: ci
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main
|
||||
secrets:
|
||||
moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }}
|
||||
with:
|
||||
disable_behat: true
|
||||
75
.travis.yml
75
.travis.yml
@@ -1,75 +0,0 @@
|
||||
language: php
|
||||
|
||||
sudo: true
|
||||
|
||||
services:
|
||||
- mysql
|
||||
|
||||
addons:
|
||||
firefox: "47.0.1"
|
||||
postgresql: "9.6"
|
||||
apt:
|
||||
packages:
|
||||
- openjdk-8-jre
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.npm
|
||||
|
||||
php:
|
||||
- 7.2
|
||||
|
||||
env:
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_36_STABLE NODEJS=8
|
||||
- DB=mysqli MOODLE_BRANCH=MOODLE_36_STABLE NODEJS=8
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_37_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_38_STABLE
|
||||
- DB=pgsql MOODLE_BRANCH=MOODLE_39_STABLE
|
||||
- DB=mysqli MOODLE_BRANCH=MOODLE_39_STABLE
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE NODEJS=8
|
||||
- php: 7.0
|
||||
env: DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
|
||||
- php: 7.1
|
||||
env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE NODEJS=8
|
||||
- php: 7.4
|
||||
env: DB=mysqli MOODLE_BRANCH=master
|
||||
- php: 7.4
|
||||
env: DB=pgsql MOODLE_BRANCH=master
|
||||
|
||||
before_install:
|
||||
- export MOODLE_VERSION=$(echo "$MOODLE_BRANCH" | cut -d'_' -f 2)
|
||||
- phpenv config-rm xdebug.ini
|
||||
- if [ "$NODEJS" = 8 ]; then
|
||||
nvm install 8.9;
|
||||
nvm use 8.9;
|
||||
else
|
||||
nvm install 14.0.0;
|
||||
nvm use 14.0.0;
|
||||
fi
|
||||
- cd ../..
|
||||
- composer selfupdate
|
||||
- composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2
|
||||
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
|
||||
|
||||
install:
|
||||
- moodle-plugin-ci install
|
||||
|
||||
script:
|
||||
- moodle-plugin-ci phplint
|
||||
- moodle-plugin-ci phpcpd
|
||||
- moodle-plugin-ci phpmd
|
||||
- moodle-plugin-ci codechecker
|
||||
- moodle-plugin-ci validate
|
||||
- moodle-plugin-ci savepoints
|
||||
- moodle-plugin-ci mustache
|
||||
- moodle-plugin-ci grunt
|
||||
- moodle-plugin-ci phpunit
|
||||
# Behat tests are failing due to issue:
|
||||
# https://github.com/blackboard-open-source/moodle-plugin-ci/issues/70
|
||||
# Commenting it out until the issue is fixed.
|
||||
# - moodle-plugin-ci behat
|
||||
10
README.md
10
README.md
@@ -1,6 +1,4 @@
|
||||
<a href="https://travis-ci.org/catalyst/moodle-auth_outage">
|
||||
<img src="https://travis-ci.org/catalyst/moodle-auth_outage.svg?branch=master">
|
||||
</a>
|
||||
[](https://github.com/catalyst/moodle-auth_outage/actions/workflows/ci.yml?branch=MOODLE_38_STABLE)
|
||||
|
||||
# Moodle Outage manager plugin
|
||||
* [Version Support](#version-support)
|
||||
@@ -46,8 +44,10 @@ Branches
|
||||
| ----------------- | ----------- | ---- |
|
||||
| Moodle 2.7 to 3.2 | MOODLE_32_STABLE | 5.5+ |
|
||||
| Totara up to 10 | TOTARA_10 | 5.5+ |
|
||||
| Moodle 3.3+ | master | 7.0+ |
|
||||
| Totara 11+ | master | 7.0+ |
|
||||
| Moodle 3.3 to 3.8 | MOODLE_38_STABLE | 7.1+ |
|
||||
| Totara 11 to 12 | MOODLE_38_STABLE | 7.1+ |
|
||||
| Moodle 3.9+ | MOODLE_39_STABLE | 7.2+ |
|
||||
| Totara 13+ | MOODLE_39_STABLE | 7.2+ |
|
||||
|
||||
Screenshots
|
||||
-----------
|
||||
|
||||
8
auth.php
8
auth.php
@@ -58,7 +58,6 @@ class auth_plugin_outage extends auth_plugin_base {
|
||||
/**
|
||||
* Always returns false (password wrong or user does not exist).
|
||||
*
|
||||
* @inheritdoc PHPMD will not warn about unused parameters if overriding.
|
||||
* @param string $username Not used in this plugin.
|
||||
* @param string $password Not used in this plugin.
|
||||
* @return bool False
|
||||
@@ -66,11 +65,4 @@ class auth_plugin_outage extends auth_plugin_base {
|
||||
public function user_login($username, $password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login page hook.
|
||||
*/
|
||||
public function loginpage_hook() {
|
||||
outagelib::inject();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
*/
|
||||
|
||||
// This call is required by Moodle, but this script should have been called by config.php anyway.
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once(__DIR__.'/../../config.php');
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
// We need the CFG->dataroot, if not set yet this script is called too early in config.php file.
|
||||
if (!isset($CFG->dataroot)) {
|
||||
@@ -71,7 +73,7 @@ if (!empty($_SERVER['REQUEST_URI'])) {
|
||||
$rooturl = parse_url($CFG->wwwroot);
|
||||
$path = '';
|
||||
if (array_key_exists('path', $rooturl) && !empty($rooturl['path'])) {
|
||||
$path = $rooturl['url'];
|
||||
$path = $rooturl['path'];
|
||||
}
|
||||
$url = $path.'/auth/outage/info.php';
|
||||
$outageinfo = strpos($_SERVER['REQUEST_URI'], $url) === 0 ? true : false;
|
||||
@@ -79,7 +81,8 @@ if (!empty($_SERVER['REQUEST_URI'])) {
|
||||
$allowed = !file_exists($CFG->dataroot.'/climaintenance.php') // Not in maintenance mode.
|
||||
|| (defined('ABORT_AFTER_CONFIG') && ABORT_AFTER_CONFIG) // Only config requested.
|
||||
|| (defined('CLI_SCRIPT') && CLI_SCRIPT) // Allow CLI scripts.
|
||||
|| $outageinfo; // Allow outage info requests.
|
||||
|| $outageinfo // Allow outage info requests.
|
||||
|| (defined('NO_AUTH_OUTAGE') && NO_AUTH_OUTAGE); // Allow any page should not be blocked by maintenance mode.
|
||||
if (!$allowed) {
|
||||
// Call the climaintenance.php which will check for allowed IPs.
|
||||
$CFG->dirroot = dirname(dirname(dirname(__FILE__))); // It is not defined yet but the script below needs it.
|
||||
|
||||
@@ -25,6 +25,12 @@
|
||||
|
||||
use auth_outage\dml\outagedb;
|
||||
|
||||
define('NO_MOODLE_COOKIES', true);
|
||||
// @codingStandardsIgnoreStart
|
||||
header('Cache-Control: public, max-age=10,s-maxage=10');
|
||||
// @codingStandardsIgnoreEnd
|
||||
define('NO_AUTH_OUTAGE', true);
|
||||
|
||||
require_once(__DIR__.'/../../config.php');
|
||||
|
||||
$active = outagedb::get_active();
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace auth_outage\event;
|
||||
use core\event\base;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* outage_created class.
|
||||
*
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace auth_outage\event;
|
||||
use core\event\base;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* outage_deleted class.
|
||||
*
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace auth_outage\event;
|
||||
use core\event\base;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* outage_updated class.
|
||||
*
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace auth_outage\local\cli;
|
||||
|
||||
use Exception;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* cli_exception class.
|
||||
*
|
||||
|
||||
@@ -29,8 +29,6 @@ use auth_outage\local\outagelib;
|
||||
use coding_exception;
|
||||
use core\session\manager;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* clibase class.
|
||||
*
|
||||
@@ -106,18 +104,18 @@ abstract class clibase {
|
||||
* Generates all options (parameters) available for the CLI command.
|
||||
* @return mixed[] Options.
|
||||
*/
|
||||
public abstract function generate_options();
|
||||
abstract public function generate_options();
|
||||
|
||||
/**
|
||||
* Generate all short forms for the available options.
|
||||
* @return string[] Short form options.
|
||||
*/
|
||||
public abstract function generate_shortcuts();
|
||||
abstract public function generate_shortcuts();
|
||||
|
||||
/**
|
||||
* Executes the CLI script.
|
||||
*/
|
||||
public abstract function execute();
|
||||
abstract public function execute();
|
||||
|
||||
/**
|
||||
* Change session to admin user.
|
||||
|
||||
@@ -29,8 +29,6 @@ use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
use coding_exception;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* create class.
|
||||
*
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace auth_outage\local\cli;
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* finish class.
|
||||
*
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace auth_outage\local\cli;
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* waitforit class.
|
||||
*
|
||||
|
||||
@@ -32,8 +32,6 @@ use coding_exception;
|
||||
use context_system;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* infopage class.
|
||||
*
|
||||
@@ -93,7 +91,6 @@ class infopage {
|
||||
/**
|
||||
* Generates and outputs the HTML for the info page.
|
||||
* @uses redirect
|
||||
* @SuppressWarnings(PHPMD.UnusedLocalVariable) $viewbag is used inside 'require'.
|
||||
*/
|
||||
public function output() {
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
@@ -108,7 +105,7 @@ class infopage {
|
||||
$PAGE->set_url(new moodle_url('/auth/outage/info.php'));
|
||||
|
||||
// No hooks injecting into this page, do it manually.
|
||||
outagelib::inject();
|
||||
echo outagelib::get_inject_code();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$viewbag = [
|
||||
|
||||
@@ -29,8 +29,6 @@ use auth_outage\local\outage;
|
||||
use coding_exception;
|
||||
use DOMDocument;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* maintenance_static_page class.
|
||||
*
|
||||
@@ -122,6 +120,7 @@ class maintenance_static_page {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets generator io.
|
||||
* @return maintenance_static_page_io
|
||||
*/
|
||||
public function get_io() {
|
||||
|
||||
@@ -32,8 +32,6 @@ use DOMElement;
|
||||
use invalid_state_exception;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* maintenance_static_page_generator class.
|
||||
*
|
||||
@@ -95,6 +93,7 @@ class maintenance_static_page_generator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets maintenance_static_page_io.
|
||||
* @return maintenance_static_page_io
|
||||
*/
|
||||
public function get_io() {
|
||||
@@ -252,7 +251,7 @@ class maintenance_static_page_generator {
|
||||
/**
|
||||
* Fetches all elements based on the given selector.
|
||||
*
|
||||
* @param $selector
|
||||
* @param string $selector element selector
|
||||
*
|
||||
* @return DOMElement[]
|
||||
*/
|
||||
@@ -270,7 +269,7 @@ class maintenance_static_page_generator {
|
||||
/**
|
||||
* Fetch all elements which contains the given class.
|
||||
*
|
||||
* @param $class
|
||||
* @param string $class element class
|
||||
*
|
||||
* @return DOMElement[]
|
||||
*/
|
||||
@@ -286,6 +285,9 @@ class maintenance_static_page_generator {
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds meta refresh to head element.
|
||||
*/
|
||||
private function add_meta_refresh() {
|
||||
$meta = $this->dom->createElement('meta');
|
||||
$meta->setAttribute('http-equiv', 'refresh');
|
||||
@@ -298,6 +300,7 @@ class maintenance_static_page_generator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets refresh time.
|
||||
* @return int
|
||||
*/
|
||||
public function get_refresh_time() {
|
||||
@@ -305,6 +308,7 @@ class maintenance_static_page_generator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets refresh time.
|
||||
* @param int $refreshtime
|
||||
*/
|
||||
public function set_refresh_time($refreshtime) {
|
||||
|
||||
@@ -31,8 +31,6 @@ use finfo;
|
||||
use invalid_parameter_exception;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* maintenance_static_page_io class.
|
||||
*
|
||||
@@ -44,11 +42,13 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class maintenance_static_page_io {
|
||||
/**
|
||||
* Checks if the given string starts with "http://" or "https://".
|
||||
* @param $url
|
||||
* Also checks for "//" at the start of image, which setting_file_url still uses.
|
||||
*
|
||||
* @param string $url url string for check
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_url($url) {
|
||||
return (bool)preg_match('#^http(s)?://#', $url);
|
||||
return ((bool) preg_match('#^http(s)?://#', $url) || (bool) preg_match('#^//#', $url));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,6 +80,7 @@ class maintenance_static_page_io {
|
||||
protected $preview = false;
|
||||
|
||||
/**
|
||||
* Sets preview
|
||||
* @param boolean $preview
|
||||
*/
|
||||
public function set_preview($preview) {
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace auth_outage\local;
|
||||
use coding_exception;
|
||||
use stdClass;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* outage class.
|
||||
*
|
||||
|
||||
@@ -49,8 +49,10 @@ require_once(__DIR__.'/../../lib.php');
|
||||
*/
|
||||
class outagelib {
|
||||
|
||||
/** Outage start. */
|
||||
const OUTAGE_START = '<!-- OUTAGESTART -->';
|
||||
|
||||
/** Outage end. */
|
||||
const OUTAGE_END = '<!-- OUTAGEEND -->';
|
||||
|
||||
/**
|
||||
@@ -58,7 +60,14 @@ class outagelib {
|
||||
*/
|
||||
private static $injectcalled = false;
|
||||
|
||||
/**
|
||||
* Fetches page.
|
||||
* @param string $file file to be fetched
|
||||
*/
|
||||
public static function fetch_page($file) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
$curl = new curl();
|
||||
$contents = $curl->get($file);
|
||||
$info = $curl->get_info();
|
||||
@@ -71,15 +80,15 @@ class outagelib {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls inject even if it was already called before.
|
||||
* Resets inject called to allow the code to be regenerated.
|
||||
*/
|
||||
public static function reinject() {
|
||||
public static function reset_injectcalled() {
|
||||
self::$injectcalled = false;
|
||||
self::inject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a time, usually now, when is the next outage window?
|
||||
* @param int $time time for next window
|
||||
*/
|
||||
public static function get_next_window($time = null) {
|
||||
|
||||
@@ -99,11 +108,12 @@ class outagelib {
|
||||
|
||||
|
||||
/**
|
||||
* Will check for ongoing or warning outages and will attach the message bar as required.
|
||||
* Will check for ongoing or warning outages and will return the message bar as required.
|
||||
*
|
||||
* @return string|void CSS and HTML for the warning bar if it should be displayed
|
||||
*/
|
||||
public static function inject() {
|
||||
global $CFG;
|
||||
|
||||
public static function get_inject_code() {
|
||||
global $PAGE;
|
||||
// Ensure we do not kill the whole website in case of an error.
|
||||
try {
|
||||
// Check if we should inject the code.
|
||||
@@ -111,8 +121,6 @@ class outagelib {
|
||||
return;
|
||||
}
|
||||
|
||||
self::clean_outages();
|
||||
|
||||
// Check for a previewing outage, then for an active outage.
|
||||
$previewid = optional_param('auth_outage_preview', null, PARAM_INT);
|
||||
$time = time();
|
||||
@@ -135,8 +143,8 @@ class outagelib {
|
||||
}
|
||||
|
||||
// There is a previewing or active outage.
|
||||
$CFG->additionalhtmltopofbody = renderer::get()->render_warningbar($active, $time, false, $preview).
|
||||
$CFG->additionalhtmltopofbody;
|
||||
$renderer = $PAGE->get_renderer('auth_outage');
|
||||
return $renderer->render_warningbar($active, $time, false, $preview);
|
||||
} catch (Exception $e) {
|
||||
debugging('Exception occured while injecting our code: '.$e->getMessage());
|
||||
debugging($e->getTraceAsString(), DEBUG_DEVELOPER);
|
||||
@@ -204,6 +212,9 @@ class outagelib {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if wwwroot accessible.
|
||||
*/
|
||||
private static function check_wwwroot_accessible() {
|
||||
global $CFG;
|
||||
$result = self::fetch_page($CFG->wwwroot);
|
||||
@@ -361,16 +372,14 @@ EOT;
|
||||
* Generates a warning message in case the plugin is not active and configured.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @internal stdClass $CFG
|
||||
* @internal bootstrap_renderer $OUTPUT
|
||||
*/
|
||||
public static function generate_plugin_configuration_warning() {
|
||||
global $CFG, $OUTPUT, $PAGE;
|
||||
|
||||
$message = [];
|
||||
|
||||
if (trim(self::get_config()->allowedips) != '' && (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded)) {
|
||||
if (trim(self::get_config()->allowedips) != ''
|
||||
&& (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded)) {
|
||||
$message[] = get_string('configurationwarning', 'auth_outage');
|
||||
}
|
||||
|
||||
@@ -396,26 +405,4 @@ EOT;
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks $CFG->additionalhtmltopofbody for saved outages and removes them.
|
||||
* We should only be temporarily injecting into that variable and not saving them to the database.
|
||||
*
|
||||
* @return string the cleaned content
|
||||
*/
|
||||
public static function clean_outages() {
|
||||
global $CFG;
|
||||
|
||||
// Replace the content to clean up pages that do not have the injection.
|
||||
$re = '/' . self::OUTAGE_START . '[\s\S]*' . self::OUTAGE_END . '/m';
|
||||
$replaced = preg_replace($re, '', $CFG->additionalhtmltopofbody);
|
||||
|
||||
// We have removed the outages and any duplicates as it should be injected and not saved to $CFG.
|
||||
if ($CFG->additionalhtmltopofbody != $replaced) {
|
||||
set_config('additionalhtmltopofbody', $replaced);
|
||||
return $replaced;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,10 @@ class base_table extends flexible_table {
|
||||
*/
|
||||
private static $autoid = 0;
|
||||
|
||||
/**
|
||||
* Creates start time string.
|
||||
* @param string $starttime start time
|
||||
*/
|
||||
protected static function create_starttime_string($starttime) {
|
||||
$absolute = userdate($starttime, get_string('datetimeformat', 'auth_outage'));
|
||||
$relative = $starttime - time();
|
||||
|
||||
@@ -33,8 +33,6 @@ use html_writer;
|
||||
use moodle_url;
|
||||
use plugin_renderer_base;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* auth_outage_renderer class.
|
||||
*
|
||||
@@ -44,15 +42,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Returns the outage renderer.
|
||||
* @return renderer The outage renderer.
|
||||
*/
|
||||
public static function get() {
|
||||
global $PAGE;
|
||||
return $PAGE->get_renderer('auth_outage');
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the view in a separate scope to avoid conflicts with variable names.
|
||||
* @param string $view View PHP file.
|
||||
@@ -75,6 +64,13 @@ class renderer extends plugin_renderer_base {
|
||||
* @return string The rendered view code.
|
||||
*/
|
||||
public function render_view($view, $viewbag = []) {
|
||||
|
||||
// Do not render if the request are from some layouts.
|
||||
$excludelayout = ['embedded', 'popup', 'secure', 'maintenance'];
|
||||
if (in_array($this->page->pagelayout, $excludelayout)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$this->output_view($view, $viewbag);
|
||||
$html = ob_get_contents();
|
||||
@@ -154,8 +150,6 @@ class renderer extends plugin_renderer_base {
|
||||
* @return string The formatted HTML.
|
||||
*/
|
||||
private function renderoutage(outage $outage, $buttons) {
|
||||
global $OUTPUT;
|
||||
|
||||
if ($outage->createdby == 0) {
|
||||
$created = get_string('na', 'auth_outage');
|
||||
} else {
|
||||
@@ -179,14 +173,14 @@ class renderer extends plugin_renderer_base {
|
||||
$url = new moodle_url('/auth/outage/edit.php', ['edit' => $outage->id]);
|
||||
$img = html_writer::empty_tag(
|
||||
'img',
|
||||
['src' => $OUTPUT->image_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall']
|
||||
['src' => $this->output->image_url('t/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall']
|
||||
);
|
||||
$linkedit = html_writer::link($url, $img, ['title' => get_string('edit')]);
|
||||
|
||||
$url = new moodle_url('/auth/outage/delete.php', ['id' => $outage->id]);
|
||||
$img = html_writer::empty_tag(
|
||||
'img',
|
||||
['src' => $OUTPUT->image_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']
|
||||
['src' => $this->output->image_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall']
|
||||
);
|
||||
$linkdelete = html_writer::link($url, $img, ['title' => get_string('delete')]);
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace auth_outage\privacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core_privacy\local\legacy_polyfill;
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,8 +29,6 @@ use auth_outage\local\controllers\infopage;
|
||||
use auth_outage\local\outagelib;
|
||||
use core\task\scheduled_task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* update_static_page class.
|
||||
*
|
||||
|
||||
@@ -24,14 +24,11 @@
|
||||
*/
|
||||
use auth_outage\local\controllers\maintenance_static_page;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Auth Outage plugin uninstall code.
|
||||
* @return bool result
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
|
||||
function xmldb_auth_outage_uninstall() {
|
||||
global $DB;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Outage plugin upgrade code
|
||||
|
||||
@@ -33,6 +33,7 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
admin_externalpage_setup('auth_outage_manage');
|
||||
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
$output = $PAGE->get_renderer('auth_outage');
|
||||
|
||||
$mform = new delete();
|
||||
if ($mform->is_cancelled()) {
|
||||
@@ -52,10 +53,10 @@ $dataid = new stdClass();
|
||||
$dataid->id = $outage->id;
|
||||
$mform->set_data($dataid);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $output->header();
|
||||
|
||||
echo renderer::get()->renderdeleteconfirmation($outage);
|
||||
echo $output->renderdeleteconfirmation($outage);
|
||||
|
||||
$mform->display();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $output->footer();
|
||||
|
||||
7
edit.php
7
edit.php
@@ -34,6 +34,7 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
admin_externalpage_setup('auth_outage_manage');
|
||||
$output = $PAGE->get_renderer('auth_outage');
|
||||
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
|
||||
$mform = new edit();
|
||||
@@ -83,7 +84,7 @@ if ($outage == null) {
|
||||
$mform->set_data($outage);
|
||||
|
||||
$PAGE->navbar->add(get_string($action.'crumb', 'auth_outage'));
|
||||
echo $OUTPUT->header();
|
||||
echo renderer::get()->rendersubtitle($action);
|
||||
echo $output->header();
|
||||
echo $output->rendersubtitle($action);
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
echo $output->footer();
|
||||
|
||||
3
file.php
3
file.php
@@ -57,7 +57,6 @@ header('Accept-Ranges: none');
|
||||
|
||||
/**
|
||||
* Callback used in bootstrap.
|
||||
* @SupressWarnings(PHPMD)
|
||||
*/
|
||||
function auth_outage_bootstrap_callback() {
|
||||
// Not using classes as classloader has not been initialized yet. Keep it minimalist.
|
||||
@@ -74,7 +73,9 @@ function auth_outage_bootstrap_callback() {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once(__DIR__.'/../../config.php');
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
// We should never reach here if config.php and auth/outage/bootstrap.php intercepted it correctly.
|
||||
// If config.php did not execute the callback function we can use the debugging function here.
|
||||
|
||||
@@ -33,6 +33,7 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
admin_externalpage_setup('auth_outage_manage');
|
||||
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
$output = $PAGE->get_renderer('auth_outage');
|
||||
|
||||
$mform = new finish();
|
||||
if ($mform->is_cancelled()) {
|
||||
@@ -52,10 +53,10 @@ $dataid = new stdClass();
|
||||
$dataid->id = $outage->id;
|
||||
$mform->set_data($dataid);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $output->header();
|
||||
|
||||
echo renderer::get()->renderfinishconfirmation($outage);
|
||||
echo $output->renderfinishconfirmation($outage);
|
||||
|
||||
$mform->display();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $output->footer();
|
||||
|
||||
2
info.php
2
info.php
@@ -25,7 +25,9 @@
|
||||
|
||||
use auth_outage\local\controllers\infopage;
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once(__DIR__.'/../../config.php');
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
$info = new infopage();
|
||||
$info->output();
|
||||
|
||||
35
lib.php
35
lib.php
@@ -25,29 +25,6 @@
|
||||
|
||||
use auth_outage\local\outagelib;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* Used in Moodle 30+ when a user is logged on.
|
||||
*/
|
||||
function auth_outage_extend_navigation_user_settings() {
|
||||
outagelib::inject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in Moodle 30+ on the frontpage.
|
||||
*/
|
||||
function auth_outage_extend_navigation_frontpage() {
|
||||
outagelib::inject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in Moodle 31+ when a user is logged on.
|
||||
*/
|
||||
function auth_outage_extend_navigation_user() {
|
||||
outagelib::inject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for adminlib::set_updatedcallback which requires a string that resolves to a function.
|
||||
*
|
||||
@@ -62,7 +39,7 @@ function auth_outage_outagelib_prepare_next_outage() {
|
||||
*
|
||||
* To keep it minimalist it was not added to the outagelib.php class.
|
||||
*
|
||||
* @param $file string Filename to fetch from sitedata
|
||||
* @param string $file Filename to fetch from sitedata
|
||||
* @return string|null Full path to the sitedata file or null if file is not valid.
|
||||
*/
|
||||
function auth_outage_get_climaintenance_resource_file($file) {
|
||||
@@ -98,3 +75,13 @@ function auth_outage_get_fontawesome_icon_map() {
|
||||
'core:i/auth_outageevent' => 'fa-power-off',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the warning bar into the page if there is currently an outage.
|
||||
*
|
||||
* @return string|void
|
||||
*/
|
||||
function auth_outage_before_standard_top_of_body_html() {
|
||||
// Get code to inject.
|
||||
return outagelib::get_inject_code();
|
||||
}
|
||||
|
||||
@@ -32,16 +32,17 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
admin_externalpage_setup('auth_outage_manage');
|
||||
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
|
||||
$output = $PAGE->get_renderer('auth_outage');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $output->header();
|
||||
|
||||
// Give it a consistent time so all outages are listed. Useful when debugging.
|
||||
$now = time();
|
||||
|
||||
renderer::get()->output_view('manage.php', [
|
||||
$output->output_view('manage.php', [
|
||||
'unended' => outagedb::get_all_unended($now),
|
||||
'ended' => outagedb::get_all_ended($now),
|
||||
'warning' => outagelib::generate_plugin_configuration_warning(),
|
||||
]);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $output->footer();
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\controllers\maintenance_static_page;
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once(__DIR__.'/../../config.php');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$id = optional_param('id', null, PARAM_INT);
|
||||
$outage = is_null($id) ? outagedb::get_next_starting() : outagedb::get_by_id($id);
|
||||
if (is_null($outage)) {
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* auth_outage_renderer class.
|
||||
*
|
||||
|
||||
@@ -39,7 +39,6 @@ require_once(__DIR__.'/../../../../lib/behat/behat_base.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class behat_auth_outage extends behat_base {
|
||||
/**
|
||||
@@ -155,6 +154,7 @@ class behat_auth_outage extends behat_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an specific action is not visible.
|
||||
* @Then /^I should see an empty settings text area "([^"]*)"$/
|
||||
* @param string $name
|
||||
*/
|
||||
@@ -163,6 +163,7 @@ class behat_auth_outage extends behat_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an specific action is not visible.
|
||||
* @When /^I go to the "Outage Settings" page$/
|
||||
*/
|
||||
public function i_go_to_the_outage_settings_page() {
|
||||
@@ -321,7 +322,7 @@ class behat_auth_outage extends behat_base {
|
||||
}
|
||||
if ($seconds >= 0) {
|
||||
$seconds++; // Give one extra second for things to happen.
|
||||
$this->getSession()->wait($seconds * 1000, false);
|
||||
$this->getSession()->wait($seconds * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
48
tests/behat/disable_in_layout.feature
Normal file
48
tests/behat/disable_in_layout.feature
Normal file
@@ -0,0 +1,48 @@
|
||||
@auth @auth_outage @javascript @_file_upload @_switch_iframe
|
||||
Feature: Disable warning bar in embedded layout
|
||||
In order alert users about an outage
|
||||
As any user
|
||||
I need to view the warning bar, but not in embedded layout
|
||||
|
||||
Background:
|
||||
Given the authentication plugin "outage" is enabled
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "activities" exist:
|
||||
| activity | name | intro | introformat | course | content | contentformat | idnumber |
|
||||
| page | PageName1 | PageDesc1 | 1 | C1 | H5Ptest | 1 | 1 |
|
||||
And the "displayh5p" filter is "on"
|
||||
|
||||
Scenario: Disable warning bar in embedded h5p in book activity
|
||||
Given I log in as "admin"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "File" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | ipsumFile |
|
||||
And I upload "h5p/tests/fixtures/ipsums.h5p" file to "Select files" filemanager
|
||||
And I press "Save and return to course"
|
||||
And I follow "PageName1"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
|
||||
And I click on "Browse repositories..." "button" in the "Insert H5P" "dialogue"
|
||||
And I click on "Server files" "link" in the ".fp-repo-area" "css_element"
|
||||
And I click on "ipsumFile (File)" "link"
|
||||
And I click on "ipsums.h5p" "link"
|
||||
And I click on "Select this file" "button"
|
||||
And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
|
||||
And I wait until the page is ready
|
||||
And I click on "Save and display" "button"
|
||||
When there is the following outage:
|
||||
| warnbefore | startsin |
|
||||
| 0 | 0 |
|
||||
And I reload the page
|
||||
Then I should see "Back online at" in the warning bar
|
||||
And I should not see "Lorum ipsum"
|
||||
# Switch to iframe created by filter
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
And I should not see the warning bar
|
||||
# Switch to iframe created by embed.php page
|
||||
And I switch to "h5p-iframe" class iframe
|
||||
And I should see "Lorum ipsum"
|
||||
And I should not see the warning bar
|
||||
@@ -33,8 +33,6 @@
|
||||
|
||||
use auth_outage\dml\outagedb;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* auth_outage_base_testcase class.
|
||||
*
|
||||
@@ -42,7 +40,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
abstract class auth_outage_base_testcase extends advanced_testcase {
|
||||
/**
|
||||
@@ -66,14 +63,20 @@ abstract class auth_outage_base_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
/**
|
||||
* Setup testcase.
|
||||
*/
|
||||
public function setUp(): void {
|
||||
global $CFG;
|
||||
|
||||
parent::setUp();
|
||||
$this->resetAfterTest(true);
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
/**
|
||||
* Tear down to restore the original DB reference.
|
||||
*/
|
||||
public function tearDown(): void {
|
||||
global $DB;
|
||||
|
||||
foreach (outagedb::get_all() as $i => $outage) {
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
use auth_outage\calendar\calendar;
|
||||
use auth_outage\local\outage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* calendar_test test class.
|
||||
*
|
||||
|
||||
@@ -36,7 +36,6 @@ require_once(__DIR__.'/../base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class outagedb_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
@@ -79,7 +78,7 @@ class outagedb_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
* Ensure DB tests run as admin.
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->setAdminUser();
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
use auth_outage\dml\outagedb;
|
||||
use auth_outage\local\outage;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* events_test tests class.
|
||||
*
|
||||
|
||||
@@ -198,6 +198,10 @@ class forms_test extends auth_outage_base_testcase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip tests for moodle below 30.
|
||||
* @param string $reason reason to be filled
|
||||
*/
|
||||
private function skip_because_moodle_is_below_30($reason = '') {
|
||||
global $CFG;
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ require_once(__DIR__.'/base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class installation_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -34,9 +34,11 @@ require_once(__DIR__.'/../../lib.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2017 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class lib_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
* Test this plugin gets climaintenance resource file.
|
||||
*/
|
||||
public function test_auth_outage_get_climaintenance_resource_file_resolves_a_file() {
|
||||
global $CFG;
|
||||
$dir = $CFG->dataroot.'/auth_outage/climaintenance';
|
||||
@@ -88,6 +90,9 @@ class lib_test extends auth_outage_base_testcase {
|
||||
self::assertSame($realfile, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test this plugin gets climaintenance resource file and prevents path traversal attack.
|
||||
*/
|
||||
public function test_auth_outage_get_climaintenance_resource_file_prevent_path_traversal() {
|
||||
global $CFG;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class cli_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -35,13 +35,12 @@ require_once(__DIR__.'/../../base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
abstract class auth_outage_cli_testcase extends auth_outage_base_testcase {
|
||||
/**
|
||||
* Always enable the auth outage plugin, resets after test and set no parameters.
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
global $CFG;
|
||||
|
||||
// PHPUnit does not load config.php file.
|
||||
|
||||
@@ -38,7 +38,6 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class create_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,6 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class finish_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,6 @@ require_once(__DIR__.'/cli_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class waitforit_test extends auth_outage_cli_testcase {
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,6 @@ require_once(__DIR__.'/../../base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class infopagecontroller_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -38,10 +38,11 @@ require_once(__DIR__.'/../../base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
* @SuppressWarnings(methods) Allow as many methods as needed.
|
||||
*/
|
||||
class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
* Test template file.
|
||||
*/
|
||||
public function test_templatefile() {
|
||||
global $CFG;
|
||||
$page = maintenance_static_page::create_from_html('<html></html>');
|
||||
@@ -51,6 +52,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
$page->get_io()->get_template_file());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test resources folder.
|
||||
*/
|
||||
public function test_resourcesfolder() {
|
||||
global $CFG;
|
||||
$page = maintenance_static_page::create_from_html('<html></html>');
|
||||
@@ -59,10 +63,16 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertSame($CFG->dataroot.'/auth_outage/climaintenance/preview', $page->get_io()->get_resources_folder());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create from outage.
|
||||
*/
|
||||
public function test_createfromoutage() {
|
||||
// How to fetch a page from PHPUnit environment?
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create from HTML.
|
||||
*/
|
||||
public function test_createfromhtml() {
|
||||
$html = "<!DOCTYPE html>\n<html><head><title>Title</title></head><body>Content</body></html>";
|
||||
$expected = "<!DOCTYPE html>\n<html><head><title>Title</title><meta http-equiv=\"refresh\" content=\"300\">".
|
||||
@@ -70,6 +80,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertSame($expected, $this->generated_page_html($html));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove script tags.
|
||||
*/
|
||||
public function test_removescripttags() {
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
'<html><head><script type="text/javascript" src="http://xyz"></script><title>Title</title></head>'.
|
||||
@@ -80,6 +93,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertNotContains('<script', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove script tags.
|
||||
*/
|
||||
public function test_updatelinkstylesheet() {
|
||||
$localcsslink = $this->get_fixture_path('simple.css');
|
||||
$externalcsslink = 'http://google.com/coolstuff.css';
|
||||
@@ -93,6 +109,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertContains($externalcsslink, $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update link style sheet urls.
|
||||
*/
|
||||
public function test_updatelinkstylesheet_urls() {
|
||||
$localcsslink = $this->get_fixture_path('withurls.css');
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -108,6 +127,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertFileExists($page->get_io()->get_resources_folder().'/ff7f7f87a26a908fc72930eaefb6b57306361d16.aW1hZ2UvcG5n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update link style sheet urls quoted.
|
||||
*/
|
||||
public function test_updatelinkstylesheet_urls_quoted() {
|
||||
$localcsslink = $this->get_fixture_path('withurls-quoted.css');
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -123,6 +145,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertFileExists($page->get_io()->get_resources_folder().'/ff7f7f87a26a908fc72930eaefb6b57306361d16.aW1hZ2UvcG5n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update link style sheet urls with sub dir.
|
||||
*/
|
||||
public function test_updatelinkstylesheet_urls_subdir() {
|
||||
$localcsslink = $this->get_fixture_path('subdir/withurls-subdir.css');
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -138,6 +163,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertFileExists($page->get_io()->get_resources_folder().'/a02a8a442fa82d5205ffb24722d9df7f35161f56.dGV4dC9wbGFpbg');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update images to file.php style link.
|
||||
*/
|
||||
public function test_updateimages() {
|
||||
$localimglink = $this->get_fixture_path('catalyst.png');
|
||||
$externalimglink = 'http://google.com/coolstyle.css';
|
||||
@@ -151,6 +179,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertContains($externalimglink, $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update favicon to file.php style link.
|
||||
*/
|
||||
public function test_updatelinkfavicon() {
|
||||
$link = $this->get_fixture_path('catalyst.png');
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -162,6 +193,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update preview path to file.php style link.
|
||||
*/
|
||||
public function test_previewpath() {
|
||||
$link = $this->get_fixture_path('catalyst.png');
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -212,6 +246,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertFileNotExists($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests created file.
|
||||
*/
|
||||
public function test_createdfile() {
|
||||
global $CFG;
|
||||
|
||||
@@ -235,7 +272,7 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
* Gets a fixture file for this test case.
|
||||
*
|
||||
* @param $file
|
||||
* @param string $file file name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -243,30 +280,59 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
return (string)new moodle_url('/auth/outage/tests/phpunit/local/controllers/fixtures/'.$file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test saving empty string for template file.
|
||||
*/
|
||||
public function test_invalid_string_saving_template_empty() {
|
||||
$io = new maintenance_static_page_io();
|
||||
$this->set_expected_exception('coding_exception');
|
||||
$io->save_template_file('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test saving non string for template file.
|
||||
*/
|
||||
public function test_invalid_string_saving_template_nostring() {
|
||||
$io = new maintenance_static_page_io();
|
||||
$this->set_expected_exception('coding_exception');
|
||||
$io->save_template_file(50);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get url for file.
|
||||
*/
|
||||
public function test_get_url_for_file() {
|
||||
$io = new maintenance_static_page_io();
|
||||
self::assertContains('www.example.com/moodle/auth/outage/file.php?file=img.png', $io->get_url_for_file('img.png'));
|
||||
}
|
||||
|
||||
public function test_is_url() {
|
||||
self::assertTrue(maintenance_static_page_io::is_url('http://catalyst.net.nz'));
|
||||
self::assertTrue(maintenance_static_page_io::is_url('https://www.catalyst-au.net/'));
|
||||
self::assertFalse(maintenance_static_page_io::is_url('/homepage'));
|
||||
self::assertFalse(maintenance_static_page_io::is_url('file://homepage'));
|
||||
/**
|
||||
* Return array of url data provider and true or false.
|
||||
*/
|
||||
public function is_url_dataprovider() {
|
||||
return [
|
||||
[true, 'http://catalyst.net.nz'],
|
||||
[true, 'https://www.catalyst-au.net/'],
|
||||
[false, '/homepage'],
|
||||
[false, 'file://homepage'],
|
||||
[true, '//catalyst-au.net/img/test.jpg'],
|
||||
[false, '://www.catalyst-au.net/img/test.jpg']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if it is url
|
||||
* @dataProvider is_url_dataprovider
|
||||
* @param string $result expected result
|
||||
* @param string $url url to be checked
|
||||
*/
|
||||
public function test_is_url($result, $url) {
|
||||
self::assertEquals($result, maintenance_static_page_io::is_url($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test file get_data.
|
||||
*/
|
||||
public function test_file_get_data() {
|
||||
$file = __DIR__.'/fixtures/catalyst.png';
|
||||
$found = maintenance_static_page_io::file_get_data($file);
|
||||
@@ -274,6 +340,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertSame('image/png', $found['mime']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test invalid file get_data.
|
||||
*/
|
||||
public function test_file_get_data_invalidfile() {
|
||||
$found = maintenance_static_page_io::file_get_data(__DIR__.'/fixtures/invalidfile');
|
||||
self::assertSame('', $found['contents']);
|
||||
@@ -282,11 +351,17 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
phpunit_util::reset_debugging();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test invalid file get_data.
|
||||
*/
|
||||
public function test_file_get_data_invalidfilename() {
|
||||
$this->set_expected_exception('coding_exception');
|
||||
maintenance_static_page_io::file_get_data(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove css selector.
|
||||
*/
|
||||
public function test_remove_css_selector() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -299,6 +374,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertNotContains('Goodbye cruel world', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove css selector id.
|
||||
*/
|
||||
public function test_remove_css_selector_id() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -311,6 +389,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertNotContains('Goodbye cruel world', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove css selector with multi lines.
|
||||
*/
|
||||
public function test_remove_css_selector_with_multiline() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -327,6 +408,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertNotContains('Goodbye cruel world', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove css selector needs trim.
|
||||
*/
|
||||
public function test_remove_css_selector_needing_trim() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -343,6 +427,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertNotContains('Goodbye cruel world', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove css selector with empty line.
|
||||
*/
|
||||
public function test_remove_css_selector_with_empty_line() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -359,6 +446,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertNotContains('Goodbye cruel world', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove css selector with invalid id.
|
||||
*/
|
||||
public function test_remove_css_selector_with_invalid_id() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -371,6 +461,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertContains('Goodbye cruel world', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test meta refresh 5 minutes.
|
||||
*/
|
||||
public function test_meta_refresh_5minutes() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
@@ -382,6 +475,9 @@ class maintenance_static_page_test extends auth_outage_base_testcase {
|
||||
self::assertContains('<meta http-equiv="refresh" content="300">', $generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test meta refresh maximum 5 minutes.
|
||||
*/
|
||||
public function test_meta_refresh_maximum_5seconds() {
|
||||
$this->resetAfterTest(true);
|
||||
$html = "<!DOCTYPE html>\n".
|
||||
|
||||
@@ -35,7 +35,6 @@ require_once(__DIR__.'/../base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class outage_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,6 @@ require_once(__DIR__.'/../base_testcase.php');
|
||||
* @author Daniel Thee Roperto <daniel.roperto@catalyst-au.net>
|
||||
* @copyright 2016 Catalyst IT
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @SuppressWarnings(public) Allow as many methods as needed.
|
||||
*/
|
||||
class outagelib_test extends auth_outage_base_testcase {
|
||||
/**
|
||||
@@ -82,7 +81,7 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
* Check outagelib::inject() works as expected.
|
||||
*/
|
||||
public function test_inject() {
|
||||
global $CFG;
|
||||
global $OUTPUT;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
self::setAdminUser();
|
||||
@@ -96,16 +95,18 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
'description' => 'Description',
|
||||
]);
|
||||
$outage->id = outagedb::save($outage);
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
outagelib::reinject();
|
||||
self::assertContains('<style>', $CFG->additionalhtmltopofbody);
|
||||
self::assertContains('<script>', $CFG->additionalhtmltopofbody);
|
||||
outagelib::reset_injectcalled();
|
||||
// Get full header to avoid interactions with other single inject plugins.
|
||||
$header1 = $OUTPUT->standard_top_of_body_html();
|
||||
self::assertContains('<style>', $header1);
|
||||
self::assertContains('<script>', $header1);
|
||||
|
||||
// Should not inject more than once with the inject() function.
|
||||
$size = strlen($CFG->additionalhtmltopofbody);
|
||||
outagelib::inject();
|
||||
self::assertSame($size, strlen($CFG->additionalhtmltopofbody));
|
||||
// Should not inject more than once.
|
||||
$size = strlen($OUTPUT->standard_top_of_body_html());
|
||||
self::assertSame($size, strlen($OUTPUT->standard_top_of_body_html()));
|
||||
// Check styles aren't reinjected.
|
||||
self::assertNotContains('<style>', $OUTPUT->standard_top_of_body_html());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +114,8 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
*/
|
||||
public function test_inject_broken() {
|
||||
$_GET = ['auth_outage_break_code' => '1'];
|
||||
outagelib::reinject();
|
||||
outagelib::reset_injectcalled();
|
||||
$header = outagelib::get_inject_code();
|
||||
self::assertCount(2, phpunit_util::get_debugging_messages());
|
||||
phpunit_util::reset_debugging();
|
||||
}
|
||||
@@ -135,12 +137,13 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
'description' => 'Description',
|
||||
]);
|
||||
$outage->id = outagedb::save($outage);
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
$_GET = ['auth_outage_preview' => (string)$outage->id];
|
||||
|
||||
outagelib::reinject();
|
||||
self::assertContains('<style>', $CFG->additionalhtmltopofbody);
|
||||
self::assertContains('<script>', $CFG->additionalhtmltopofbody);
|
||||
outagelib::reset_injectcalled();
|
||||
$header = outagelib::get_inject_code();
|
||||
self::assertContains('<style>', $header);
|
||||
self::assertContains('<script>', $header);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,11 +151,12 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
*/
|
||||
public function test_inject_preview_notfound() {
|
||||
global $CFG;
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
$_GET = ['auth_outage_preview' => '1'];
|
||||
// Should not throw exception or halt anything, silently ignore it.
|
||||
outagelib::reinject();
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
outagelib::reset_injectcalled();
|
||||
$header = outagelib::get_inject_code();
|
||||
self::assertEmpty($header);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,18 +176,20 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
'description' => 'Description',
|
||||
]);
|
||||
$outage->id = outagedb::save($outage);
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
$_GET = ['auth_outage_preview' => (string)$outage->id, 'auth_outage_delta' => '500'];
|
||||
outagelib::reinject();
|
||||
outagelib::reset_injectcalled();
|
||||
$header = outagelib::get_inject_code();
|
||||
// Still empty, delta is too high (outage ended).
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
self::assertEmpty($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test injection without active outage.
|
||||
*/
|
||||
public function test_inject_noactive() {
|
||||
outagelib::reinject();
|
||||
outagelib::reset_injectcalled();
|
||||
outagelib::get_inject_code();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,17 +279,20 @@ class outagelib_test extends auth_outage_base_testcase {
|
||||
'description' => 'Description',
|
||||
]);
|
||||
$outage->id = outagedb::save($outage);
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
// Pretend we are there...
|
||||
$_SERVER['SCRIPT_FILENAME'] = '/var/www/alternativepath/admin/settings.php'; // Issue #88 regression test.
|
||||
$_SERVER['SCRIPT_NAME'] = '/admin/settings.php';
|
||||
$_GET['section'] = 'additionalhtml';
|
||||
outagelib::reinject();
|
||||
outagelib::reset_injectcalled();
|
||||
$header = outagelib::get_inject_code();
|
||||
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
self::assertEmpty($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create maintenance php code
|
||||
*/
|
||||
public function test_createmaintenancephpcode() {
|
||||
$expected = <<<'EOT'
|
||||
<?php
|
||||
@@ -325,6 +334,9 @@ EOT;
|
||||
self::assertSame($expected, $found);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create maintenance php code without age
|
||||
*/
|
||||
public function test_createmaintenancephpcode_withoutage() {
|
||||
global $CFG;
|
||||
$this->resetAfterTest(true);
|
||||
@@ -376,6 +388,9 @@ EOT;
|
||||
self::assertSame($found, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create maintenance php code without IPs
|
||||
*/
|
||||
public function test_createmaintenancephpcode_withoutips() {
|
||||
global $CFG;
|
||||
$this->resetAfterTest(true);
|
||||
@@ -392,6 +407,9 @@ EOT;
|
||||
self::assertFileNotExists($file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create maintenance php code without outage
|
||||
*/
|
||||
public function test_createmaintenancephpcode_withoutoutage() {
|
||||
global $CFG;
|
||||
$file = $CFG->dataroot.'/climaintenance.php';
|
||||
@@ -499,17 +517,20 @@ EOT;
|
||||
'description' => 'Description',
|
||||
]);
|
||||
$outage->id = outagedb::save($outage);
|
||||
self::assertEmpty($CFG->additionalhtmltopofbody);
|
||||
|
||||
// Pretend we are there...
|
||||
$_SERVER['SCRIPT_FILENAME'] = '/var/www/alternativepath/admin/settings.php'; // Issue #88 regression test.
|
||||
$_SERVER['SCRIPT_NAME'] = '/admin/settings.php';
|
||||
$_GET['section'] = 'notadditionalhtml';
|
||||
outagelib::reinject();
|
||||
outagelib::reset_injectcalled();
|
||||
|
||||
self::assertNotEmpty($CFG->additionalhtmltopofbody);
|
||||
$header = outagelib::get_inject_code();
|
||||
self::assertNotEmpty($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates outage for tests.
|
||||
*/
|
||||
private function create_outage() {
|
||||
$this->resetAfterTest(true);
|
||||
self::setAdminUser();
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = "auth_outage";
|
||||
$plugin->version = 2020032500; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = 2020032500; // Human-readable release information.
|
||||
$plugin->version = 2021032503; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->release = 2021032503; // Human-readable release information.
|
||||
$plugin->requires = 2017051500; // Requires 3.3 and higher.
|
||||
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
|
||||
$plugin->supported = [33, 38]; // A range of branch numbers of supported moodle versions.
|
||||
|
||||
@@ -31,14 +31,15 @@ use auth_outage\local\outagelib;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $OUTPUT;
|
||||
global $PAGE;
|
||||
$output = $PAGE->get_renderer('auth_outage');
|
||||
$urlnew = new moodle_url('/auth/outage/edit.php');
|
||||
|
||||
echo $viewbag['warning'];
|
||||
?>
|
||||
|
||||
<section id="section_planned_outages">
|
||||
<?php echo renderer::get()->rendersubtitle('outageslistfuture'); ?>
|
||||
<?php echo $output->rendersubtitle('outageslistfuture'); ?>
|
||||
<?php if (empty($viewbag['unended'])): ?>
|
||||
<p>
|
||||
<small><?php echo get_string('notfound', 'auth_outage'); ?></small>
|
||||
@@ -61,7 +62,7 @@ echo $viewbag['warning'];
|
||||
echo '<p>';
|
||||
$next = outagelib::get_next_window($next);
|
||||
$urlnew->param('starttime', $next);
|
||||
echo $OUTPUT->single_button($urlnew, get_string('outagecreate', 'auth_outage'));
|
||||
echo $output->single_button($urlnew, get_string('outagecreate', 'auth_outage'));
|
||||
if ($default) {
|
||||
echo ' ' . userdate( $next, get_string('datetimeformat', 'auth_outage'));
|
||||
}
|
||||
@@ -70,7 +71,7 @@ echo $viewbag['warning'];
|
||||
</section>
|
||||
|
||||
<section id="section_outage_history">
|
||||
<?php echo renderer::get()->rendersubtitle('outageslistpast'); ?>
|
||||
<?php echo $output->rendersubtitle('outageslistpast'); ?>
|
||||
<?php if (empty($viewbag['ended'])): ?>
|
||||
<p>
|
||||
<small><?php echo get_string('notfound', 'auth_outage'); ?></small>
|
||||
|
||||
@@ -99,14 +99,30 @@ a.auth_outage_warningbar_box_finish:hover {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.auth_outage_warningbar_spacer {
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
body.auth_outage #nav-drawer {
|
||||
top: 150px;
|
||||
}
|
||||
|
||||
body.auth_outage nav.fixed-top.navbar {
|
||||
top: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
body.auth_outage #page {
|
||||
margin-top: 150px;
|
||||
}
|
||||
|
||||
body.auth_outage.path-mod-assign [data-region="grading-navigation-panel"] {
|
||||
top: 100px;
|
||||
}
|
||||
|
||||
body.auth_outage.path-mod-assign [data-region="grade-panel"] {
|
||||
top: 185px;
|
||||
}
|
||||
|
||||
body.auth_outage .layout.fullscreen {
|
||||
top: 150px;
|
||||
}
|
||||
|
||||
body.auth_outage .modal-dialog {
|
||||
margin: calc(150px + 1.75rem) auto;
|
||||
}
|
||||
|
||||
@@ -74,8 +74,6 @@ if (!$viewbag['static']) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="auth_outage_warningbar_spacer"> </div>
|
||||
|
||||
<?php if (!$viewbag['static']): ?>
|
||||
<script>
|
||||
document.body.className += ' auth_outage';
|
||||
|
||||
Reference in New Issue
Block a user