Compare commits
225 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 77be1e3fe3 | |||
| de7b3e37b3 | |||
| ffd8dfcf27 | |||
| 8a82f51043 | |||
| 68cab31dba | |||
| 3f50c24fc3 | |||
| 9973646ca7 | |||
| f14420c739 | |||
| 70868d8648 | |||
| 8f45c9b6a5 | |||
| 1f5c6c6b7a | |||
| 26999dda23 | |||
| 022206f2fe | |||
| f9e0f61467 | |||
| c07bc83480 | |||
| 7d7d3520a7 | |||
| f34f8131ba | |||
| 85ba5d1d88 | |||
| e0b8a3b17a | |||
| 5577e472e5 | |||
| 571f508d4e | |||
| 764ec8d7fb | |||
| eb04dc8792 | |||
| 6fefb88819 | |||
| 1b2a8dad89 | |||
| ec63d3eab4 | |||
| 5f4250dc43 | |||
| b024306e5c | |||
| 0d285e9334 | |||
| bed212f61b | |||
| 14d58697a3 | |||
| e98103354d | |||
| d8dfb98417 | |||
| 3684d9e03c | |||
| 629ef7772f | |||
| 9e57c09d7b | |||
| 949d3f1c02 | |||
| 11524653b0 | |||
| f9b2f6634d | |||
| dafe4c5a78 | |||
| 550c4e1c42 | |||
| 0287928c4b | |||
| 701d27e5d9 | |||
| 13d5d3edb1 | |||
| abc8f149ce | |||
| c3a6437220 | |||
| c910982c49 | |||
| 4d5849b0e4 | |||
| cc0b18ec0e | |||
| 3c7ebda9a5 | |||
| 19401adbdd | |||
| a7fb29a8ff | |||
| c53861fd66 | |||
| 88d4a01089 | |||
| b71e7b79e8 | |||
| 6c7199a426 | |||
| 827f3cd471 | |||
| 0260074ba1 | |||
| edab811944 | |||
| 348ceb4631 | |||
| 5544dc1cc7 | |||
| c02d168cd7 | |||
| 53fde6278a | |||
| 25221f73a6 | |||
| b901252f6d | |||
| be73a0ed4e | |||
| e654258446 | |||
| 8c14984028 | |||
| dd6bbf3962 | |||
| 01e84ac720 | |||
| b423c5ad38 | |||
| f70cc95a13 | |||
| d9887f7350 | |||
| f2db42f921 | |||
| b85896f7bc | |||
| 6350a758d7 | |||
| a3ea0db227 | |||
| cd62c520e2 | |||
| 86d4aca10d | |||
| 40ba9d9cfa | |||
| 5c510b92e2 | |||
| 754ecb5768 | |||
| e7a122bba9 | |||
| 13edb4f9f9 | |||
| db394d5b08 | |||
| d18802eb2f | |||
| ead3a41240 | |||
| ae7b1be0b6 | |||
| cca393d2f6 | |||
| 69430157a3 | |||
| f077d9fbea | |||
| 8c20e76d43 | |||
| a0ac535549 | |||
| 11260d5f3f | |||
| 67fc9943b9 | |||
| 29a5f6eaa2 | |||
| a6fd7ada34 | |||
| c86c872db3 | |||
| 7b4848ca80 | |||
| d9e3c11834 | |||
| 1437e35d2d | |||
| 914d5ab82d | |||
| fbf0c8810b | |||
| 25da0b49ea | |||
| 70e47fdc2a | |||
| 3bfdc05d3a | |||
| d64a94713e | |||
| 8d7f1fd428 | |||
| a7268b4f8a | |||
| 4792cc508e | |||
| 7bc625d846 | |||
| 6dc25cc165 | |||
| 747000a2fe | |||
| bec0808b18 | |||
| 7f40272535 | |||
| f9735bbde7 | |||
| 4dc1413cc7 | |||
| 79b6a4acac | |||
| cf50c5f1cb | |||
| fc74a6e6d2 | |||
| a48bd1c4e3 | |||
| ee215ddd43 | |||
| f3e7533b9d | |||
| 921469db8f | |||
| b99f2bce77 | |||
| 7df9eb36cd | |||
| aee09a6357 | |||
| 8ae7a4ad68 | |||
| d911548cf4 | |||
| c8435454a7 | |||
| df2bda2f00 | |||
| bf52b2a3bc | |||
| f130c810f9 | |||
| d294483e9c | |||
| ca89aca702 | |||
| 7e561cc4a8 | |||
| 57d601bc23 | |||
| 7cdc332930 | |||
| 484eab15e3 | |||
| 0a0d55a3e1 | |||
| 773b1f738f | |||
| 96475f49de | |||
| 9a64cc2b0b | |||
| 56c570f68a | |||
| ab2bb07f2e | |||
| d0aa6bf098 | |||
| 132e638209 | |||
| 6713912510 | |||
| 96c48a5058 | |||
| d3de95f446 | |||
| 6d98038c8f | |||
| 83e5983a88 | |||
| 0ddd9c54bc | |||
| 39bd01c11a | |||
| 1e58e180d4 | |||
| 163bff4a18 | |||
| 910c2ab7b4 | |||
| fcf199b0ec | |||
| bb511f30d6 | |||
| 481ad40e0e | |||
| 031f3a1d4b | |||
| 5548689ead | |||
| f751a8edbe | |||
| 0de719024c | |||
| ac084982cf | |||
| d3158895a8 | |||
| 0e58303ea3 | |||
| f0d380703a | |||
| baf264ebc8 | |||
| e61f7ba324 | |||
| afda296526 | |||
| 6d6b14e8a4 | |||
| 27d6bd5de1 | |||
| 907db7f06b | |||
| 33bfd161cd | |||
| f88b4e9f81 | |||
| 114f0b612f | |||
| a5f1dd6cb1 | |||
| 283cd6db67 | |||
| 3eac4851e3 | |||
| 006ec3c96f | |||
| cabc1dafa9 | |||
| 1b4c878f48 | |||
| 91286bb138 | |||
| 71af7accff | |||
| ce97501b2b | |||
| dadb3cb372 | |||
| 5cb05d8b77 | |||
| e29b355121 | |||
| 95ca6f656e | |||
| fbd1829594 | |||
| 0c91305856 | |||
| c42b488aaf | |||
| 5bde4eb35e | |||
| 1943c03bbb | |||
| 0da427c800 | |||
| 7045a22f3a | |||
| c7f9c7ae0f | |||
| 751e4964b1 | |||
| 5a108a3064 | |||
| 417ff4f035 | |||
| d3a5df14f7 | |||
| 82853489ca | |||
| 9eaea6a7bf | |||
| f11b82df7c | |||
| 5d2f8bd98d | |||
| 023109f1b1 | |||
| 51bedcee13 | |||
| 7cec76396f | |||
| daed88e656 | |||
| 212595bbd0 | |||
| 6cff678c08 | |||
| 980193f55b | |||
| b4f9c2e906 | |||
| 93ed2a597c | |||
| a2c6a69070 | |||
| 7a68a37fda | |||
| 3c1b6ed7bd | |||
| 8ff55e3b1b | |||
| 7d05f78363 | |||
| d0a9211f51 | |||
| e2a0a42003 | |||
| 7e24491f2c | |||
| 4619c8a7e3 | |||
| 2aff0046c1 |
+16
-18
@@ -9,8 +9,6 @@ cache/stores/mongodb/MongoDB/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
filter/tex/mimetex.*
|
||||
h5p/h5plib/v124/joubel/core/
|
||||
h5p/h5plib/v124/joubel/editor/
|
||||
lib/editor/atto/plugins/html/yui/src/codemirror/
|
||||
lib/editor/atto/plugins/html/yui/src/beautify/
|
||||
lib/editor/atto/yui/src/rangy/js/*.*
|
||||
@@ -63,9 +61,9 @@ lib/amd/src/popper.js
|
||||
lib/geopattern-php/
|
||||
lib/php-jwt/
|
||||
lib/babel-polyfill/
|
||||
lib/polyfills/
|
||||
lib/mdn-polyfills/
|
||||
lib/emoji-data/
|
||||
lib/plist/
|
||||
lib/h5p/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
@@ -74,19 +72,19 @@ media/player/videojs/videojs/video-js.swf
|
||||
mod/assign/feedback/editpdf/fpdi/
|
||||
repository/s3/S3.php
|
||||
theme/boost/scss/bootstrap/
|
||||
theme/boost/amd/src/bootstrap/alert.js
|
||||
theme/boost/amd/src/bootstrap/button.js
|
||||
theme/boost/amd/src/bootstrap/carousel.js
|
||||
theme/boost/amd/src/bootstrap/collapse.js
|
||||
theme/boost/amd/src/bootstrap/dropdown.js
|
||||
theme/boost/amd/src/bootstrap/index.js
|
||||
theme/boost/amd/src/bootstrap/modal.js
|
||||
theme/boost/amd/src/bootstrap/popover.js
|
||||
theme/boost/amd/src/bootstrap/tools/sanitizer.js
|
||||
theme/boost/amd/src/bootstrap/scrollspy.js
|
||||
theme/boost/amd/src/bootstrap/tab.js
|
||||
theme/boost/amd/src/bootstrap/toast.js
|
||||
theme/boost/amd/src/bootstrap/tooltip.js
|
||||
theme/boost/amd/src/bootstrap/util.js
|
||||
theme/boost/amd/src/alert.js
|
||||
theme/boost/amd/src/button.js
|
||||
theme/boost/amd/src/carousel.js
|
||||
theme/boost/amd/src/collapse.js
|
||||
theme/boost/amd/src/dropdown.js
|
||||
theme/boost/amd/src/index.js
|
||||
theme/boost/amd/src/modal.js
|
||||
theme/boost/amd/src/popover.js
|
||||
theme/boost/amd/src/sanitizer.js
|
||||
theme/boost/amd/src/scrollspy.js
|
||||
theme/boost/amd/src/tab.js
|
||||
theme/boost/amd/src/toast.js
|
||||
theme/boost/amd/src/tooltip.js
|
||||
theme/boost/amd/src/util.js
|
||||
theme/boost/amd/src/tether.js
|
||||
theme/boost/scss/fontawesome/
|
||||
+3
-7
@@ -3,8 +3,6 @@
|
||||
"Feature": 0,
|
||||
"Background": 2,
|
||||
"Scenario": 2,
|
||||
"Examples": 4,
|
||||
"example": 6,
|
||||
"Step": 4,
|
||||
"given": 4,
|
||||
"and": 4
|
||||
@@ -16,9 +14,7 @@
|
||||
"no-multiple-empty-lines": "on",
|
||||
"no-partially-commented-tag-lines": "on",
|
||||
"no-trailing-spaces": "on",
|
||||
"no-unnamed-features": "on",
|
||||
"no-unnamed-scenarios": "on",
|
||||
"no-scenario-outlines-without-examples": "on",
|
||||
"no-examples-in-scenarios": "on",
|
||||
"new-line-at-eof": ["on", "yes"]
|
||||
"no-unamed-features": "on",
|
||||
"no-unamed-scenarios": "on",
|
||||
"no-scenario-outlines-without-examples": "on"
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Primary donations pages.
|
||||
custom: ["https://moodle.com/donations/", moodle.org]
|
||||
+16
-18
@@ -10,8 +10,6 @@ cache/stores/mongodb/MongoDB/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
filter/tex/mimetex.*
|
||||
h5p/h5plib/v124/joubel/core/
|
||||
h5p/h5plib/v124/joubel/editor/
|
||||
lib/editor/atto/plugins/html/yui/src/codemirror/
|
||||
lib/editor/atto/plugins/html/yui/src/beautify/
|
||||
lib/editor/atto/yui/src/rangy/js/*.*
|
||||
@@ -64,9 +62,9 @@ lib/amd/src/popper.js
|
||||
lib/geopattern-php/
|
||||
lib/php-jwt/
|
||||
lib/babel-polyfill/
|
||||
lib/polyfills/
|
||||
lib/mdn-polyfills/
|
||||
lib/emoji-data/
|
||||
lib/plist/
|
||||
lib/h5p/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
@@ -75,19 +73,19 @@ media/player/videojs/videojs/video-js.swf
|
||||
mod/assign/feedback/editpdf/fpdi/
|
||||
repository/s3/S3.php
|
||||
theme/boost/scss/bootstrap/
|
||||
theme/boost/amd/src/bootstrap/alert.js
|
||||
theme/boost/amd/src/bootstrap/button.js
|
||||
theme/boost/amd/src/bootstrap/carousel.js
|
||||
theme/boost/amd/src/bootstrap/collapse.js
|
||||
theme/boost/amd/src/bootstrap/dropdown.js
|
||||
theme/boost/amd/src/bootstrap/index.js
|
||||
theme/boost/amd/src/bootstrap/modal.js
|
||||
theme/boost/amd/src/bootstrap/popover.js
|
||||
theme/boost/amd/src/bootstrap/tools/sanitizer.js
|
||||
theme/boost/amd/src/bootstrap/scrollspy.js
|
||||
theme/boost/amd/src/bootstrap/tab.js
|
||||
theme/boost/amd/src/bootstrap/toast.js
|
||||
theme/boost/amd/src/bootstrap/tooltip.js
|
||||
theme/boost/amd/src/bootstrap/util.js
|
||||
theme/boost/amd/src/alert.js
|
||||
theme/boost/amd/src/button.js
|
||||
theme/boost/amd/src/carousel.js
|
||||
theme/boost/amd/src/collapse.js
|
||||
theme/boost/amd/src/dropdown.js
|
||||
theme/boost/amd/src/index.js
|
||||
theme/boost/amd/src/modal.js
|
||||
theme/boost/amd/src/popover.js
|
||||
theme/boost/amd/src/sanitizer.js
|
||||
theme/boost/amd/src/scrollspy.js
|
||||
theme/boost/amd/src/tab.js
|
||||
theme/boost/amd/src/toast.js
|
||||
theme/boost/amd/src/tooltip.js
|
||||
theme/boost/amd/src/util.js
|
||||
theme/boost/amd/src/tether.js
|
||||
theme/boost/scss/fontawesome/
|
||||
+10
-10
@@ -2,6 +2,8 @@
|
||||
# process (which uses our internal CI system) this file is here for the benefit
|
||||
# of community developers git clones - see MDL-51458.
|
||||
|
||||
sudo: required
|
||||
|
||||
# We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976
|
||||
# is fixed.
|
||||
notifications:
|
||||
@@ -9,8 +11,6 @@ notifications:
|
||||
|
||||
language: php
|
||||
|
||||
os: linux
|
||||
|
||||
dist: xenial
|
||||
|
||||
services:
|
||||
@@ -18,8 +18,8 @@ services:
|
||||
|
||||
php:
|
||||
# We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
|
||||
- 7.4
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.1.30 # Make this sticky because current default version (7.1.11) has a bug with redis-extension output (MDL-66062)
|
||||
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
@@ -41,18 +41,18 @@ env:
|
||||
# Perform an upgrade test too.
|
||||
- DB=pgsql TASK=UPGRADE
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
# Enable fast finish.
|
||||
# This will fail the build if a single job fails (except those in allow_failures).
|
||||
# It will not stop the jobs from running.
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
# Run mysql only on highest - it's just too slow
|
||||
- php: 7.4
|
||||
# Run mysql only on 7.3 - it's just too slow
|
||||
- php: 7.3
|
||||
env: DB=mysqli TASK=PHPUNIT
|
||||
# Run grunt/npm install on highest version too ('node' is an alias for the latest node.js version.)
|
||||
- php: 7.4
|
||||
# Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
|
||||
- php: 7.2
|
||||
env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'
|
||||
|
||||
cache:
|
||||
@@ -206,7 +206,7 @@ before_script:
|
||||
# We need the official upstream for comparison
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
git fetch upstream master;
|
||||
git fetch upstream MOODLE_38_STABLE;
|
||||
export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
|
||||
export GIT_COMMIT="$TRAVIS_COMMIT";
|
||||
export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
|
||||
|
||||
+123
-335
@@ -20,136 +20,22 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Grunt configuration
|
||||
*/
|
||||
|
||||
/* eslint-env node */
|
||||
|
||||
/**
|
||||
* Calculate the cwd, taking into consideration the `root` option (for Windows).
|
||||
*
|
||||
* @param {Object} grunt
|
||||
* @returns {String} The current directory as best we can determine
|
||||
*/
|
||||
const getCwd = grunt => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
let cwd = fs.realpathSync(process.env.PWD || process.cwd());
|
||||
|
||||
// Windows users can't run grunt in a subdirectory, so allow them to set
|
||||
// the root by passing --root=path/to/dir.
|
||||
if (grunt.option('root')) {
|
||||
const root = grunt.option('root');
|
||||
if (grunt.file.exists(__dirname, root)) {
|
||||
cwd = fs.realpathSync(path.join(__dirname, root));
|
||||
grunt.log.ok('Setting root to ' + cwd);
|
||||
} else {
|
||||
grunt.fail.fatal('Setting root to ' + root + ' failed - path does not exist');
|
||||
}
|
||||
}
|
||||
|
||||
return cwd;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register any stylelint tasks.
|
||||
*
|
||||
* @param {Object} grunt
|
||||
* @param {Array} files
|
||||
* @param {String} fullRunDir
|
||||
*/
|
||||
const registerStyleLintTasks = (grunt, files, fullRunDir) => {
|
||||
const getCssConfigForFiles = files => {
|
||||
return {
|
||||
stylelint: {
|
||||
css: {
|
||||
// Use a fully-qualified path.
|
||||
src: files,
|
||||
options: {
|
||||
configOverrides: {
|
||||
rules: {
|
||||
// These rules have to be disabled in .stylelintrc for scss compat.
|
||||
"at-rule-no-unknown": true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const getScssConfigForFiles = files => {
|
||||
return {
|
||||
stylelint: {
|
||||
scss: {
|
||||
options: {syntax: 'scss'},
|
||||
src: files,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
let hasCss = true;
|
||||
let hasScss = true;
|
||||
|
||||
if (files) {
|
||||
// Specific files were passed. Just set them up.
|
||||
grunt.config.merge(getCssConfigForFiles(files));
|
||||
grunt.config.merge(getScssConfigForFiles(files));
|
||||
} else {
|
||||
// The stylelint system does not handle the case where there was no file to lint.
|
||||
// Check whether there are any files to lint in the current directory.
|
||||
const glob = require('glob');
|
||||
|
||||
const scssSrc = [];
|
||||
glob.sync(`${fullRunDir}/**/*.scss`).forEach(path => scssSrc.push(path));
|
||||
|
||||
if (scssSrc.length) {
|
||||
grunt.config.merge(getScssConfigForFiles(scssSrc));
|
||||
} else {
|
||||
hasScss = false;
|
||||
}
|
||||
|
||||
const cssSrc = [];
|
||||
glob.sync(`${fullRunDir}/**/*.css`).forEach(path => cssSrc.push(path));
|
||||
|
||||
if (cssSrc.length) {
|
||||
grunt.config.merge(getCssConfigForFiles(cssSrc));
|
||||
} else {
|
||||
hasCss = false;
|
||||
}
|
||||
}
|
||||
|
||||
const scssTasks = ['sass'];
|
||||
if (hasScss) {
|
||||
scssTasks.unshift('stylelint:scss');
|
||||
}
|
||||
grunt.registerTask('scss', scssTasks);
|
||||
|
||||
const cssTasks = [];
|
||||
if (hasCss) {
|
||||
cssTasks.push('stylelint:css');
|
||||
}
|
||||
grunt.registerTask('rawcss', cssTasks);
|
||||
|
||||
grunt.registerTask('css', ['scss', 'rawcss']);
|
||||
};
|
||||
|
||||
/**
|
||||
* Grunt configuration.
|
||||
*
|
||||
* @param {Object} grunt
|
||||
*/
|
||||
module.exports = function(grunt) {
|
||||
const path = require('path');
|
||||
const tasks = {};
|
||||
const async = require('async');
|
||||
const DOMParser = require('xmldom').DOMParser;
|
||||
const xpath = require('xpath');
|
||||
const semver = require('semver');
|
||||
const watchman = require('fb-watchman');
|
||||
const watchmanClient = new watchman.Client();
|
||||
const fs = require('fs');
|
||||
const ComponentList = require(path.resolve('GruntfileComponents.js'));
|
||||
const sass = require('node-sass');
|
||||
var path = require('path'),
|
||||
tasks = {},
|
||||
cwd = process.env.PWD || process.cwd(),
|
||||
async = require('async'),
|
||||
DOMParser = require('xmldom').DOMParser,
|
||||
xpath = require('xpath'),
|
||||
semver = require('semver'),
|
||||
watchman = require('fb-watchman'),
|
||||
watchmanClient = new watchman.Client(),
|
||||
gruntFilePath = process.cwd();
|
||||
|
||||
// Verify the node version is new enough.
|
||||
var expected = semver.validRange(grunt.file.readJSON('package.json').engines.node);
|
||||
@@ -158,64 +44,34 @@ module.exports = function(grunt) {
|
||||
grunt.fail.fatal('Node version not satisfied. Require ' + expected + ', version installed: ' + actual);
|
||||
}
|
||||
|
||||
// Detect directories:
|
||||
// * gruntFilePath The real path on disk to this Gruntfile.js
|
||||
// * cwd The current working directory, which can be overridden by the `root` option
|
||||
// * relativeCwd The cwd, relative to the Gruntfile.js
|
||||
// * componentDirectory The root directory of the component if the cwd is in a valid component
|
||||
// * inComponent Whether the cwd is in a valid component
|
||||
// * runDir The componentDirectory or cwd if not in a component, relative to Gruntfile.js
|
||||
// * fullRunDir The full path to the runDir
|
||||
const gruntFilePath = fs.realpathSync(process.cwd());
|
||||
const cwd = getCwd(grunt);
|
||||
const relativeCwd = path.relative(gruntFilePath, cwd);
|
||||
const componentDirectory = ComponentList.getOwningComponentDirectory(relativeCwd);
|
||||
const inComponent = !!componentDirectory;
|
||||
const runDir = inComponent ? componentDirectory : relativeCwd;
|
||||
const fullRunDir = fs.realpathSync(gruntFilePath + path.sep + runDir);
|
||||
grunt.log.debug('============================================================================');
|
||||
grunt.log.debug(`= Node version: ${process.versions.node}`);
|
||||
grunt.log.debug(`= grunt version: ${grunt.package.version}`);
|
||||
grunt.log.debug(`= process.cwd: '` + process.cwd() + `'`);
|
||||
grunt.log.debug(`= process.env.PWD: '${process.env.PWD}'`);
|
||||
grunt.log.debug(`= path.sep '${path.sep}'`);
|
||||
grunt.log.debug('============================================================================');
|
||||
grunt.log.debug(`= gruntFilePath: '${gruntFilePath}'`);
|
||||
grunt.log.debug(`= relativeCwd: '${relativeCwd}'`);
|
||||
grunt.log.debug(`= componentDirectory: '${componentDirectory}'`);
|
||||
grunt.log.debug(`= inComponent: '${inComponent}'`);
|
||||
grunt.log.debug(`= runDir: '${runDir}'`);
|
||||
grunt.log.debug(`= fullRunDir: '${fullRunDir}'`);
|
||||
grunt.log.debug('============================================================================');
|
||||
|
||||
if (inComponent) {
|
||||
grunt.log.ok(`Running tasks for component directory ${componentDirectory}`);
|
||||
// Windows users can't run grunt in a subdirectory, so allow them to set
|
||||
// the root by passing --root=path/to/dir.
|
||||
if (grunt.option('root')) {
|
||||
var root = grunt.option('root');
|
||||
if (grunt.file.exists(__dirname, root)) {
|
||||
cwd = path.join(__dirname, root);
|
||||
grunt.log.ok('Setting root to ' + cwd);
|
||||
} else {
|
||||
grunt.fail.fatal('Setting root to ' + root + ' failed - path does not exist');
|
||||
}
|
||||
}
|
||||
|
||||
let files = null;
|
||||
var files = null;
|
||||
if (grunt.option('files')) {
|
||||
// Accept a comma separated list of files to process.
|
||||
files = grunt.option('files').split(',');
|
||||
}
|
||||
|
||||
// If the cwd is the amd directory in the current component then it will be empty.
|
||||
// If the cwd is a child of the component's AMD directory, the relative directory will not start with ..
|
||||
const inAMD = !path.relative(`${componentDirectory}/amd`, cwd).startsWith('..');
|
||||
var inAMD = path.basename(cwd) == 'amd';
|
||||
|
||||
// Globbing pattern for matching all AMD JS source files.
|
||||
let amdSrc = [];
|
||||
if (inComponent) {
|
||||
amdSrc.push(componentDirectory + "/amd/src/*.js");
|
||||
amdSrc.push(componentDirectory + "/amd/src/**/*.js");
|
||||
var amdSrc = [];
|
||||
if (inAMD) {
|
||||
amdSrc.push(cwd + "/src/*.js");
|
||||
amdSrc.push(cwd + "/src/**/*.js");
|
||||
} else {
|
||||
amdSrc = ComponentList.getAmdSrcGlobList();
|
||||
}
|
||||
|
||||
let yuiSrc = [];
|
||||
if (inComponent) {
|
||||
yuiSrc.push(componentDirectory + "/yui/src/**/*.js");
|
||||
} else {
|
||||
yuiSrc = ComponentList.getYuiSrcGlobList(gruntFilePath + '/');
|
||||
amdSrc.push("**/amd/src/*.js");
|
||||
amdSrc.push("**/amd/src/**/*.js");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,65 +97,40 @@ module.exports = function(grunt) {
|
||||
* @return {array} The list of thirdparty paths.
|
||||
*/
|
||||
var getThirdPartyPathsFromXML = function() {
|
||||
const thirdpartyfiles = ComponentList.getThirdPartyLibsList(gruntFilePath + '/');
|
||||
const libs = ['node_modules/', 'vendor/'];
|
||||
var thirdpartyfiles = grunt.file.expand('*/**/thirdpartylibs.xml');
|
||||
var libs = ['node_modules/', 'vendor/'];
|
||||
|
||||
thirdpartyfiles.forEach(function(file) {
|
||||
const dirname = path.dirname(file);
|
||||
var dirname = path.dirname(file);
|
||||
|
||||
const doc = new DOMParser().parseFromString(grunt.file.read(file));
|
||||
const nodes = xpath.select("/libraries/library/location/text()", doc);
|
||||
var doc = new DOMParser().parseFromString(grunt.file.read(file));
|
||||
var nodes = xpath.select("/libraries/library/location/text()", doc);
|
||||
|
||||
nodes.forEach(function(node) {
|
||||
let lib = path.posix.join(dirname, node.toString());
|
||||
if (grunt.file.isDir(lib)) {
|
||||
// Ensure trailing slash on dirs.
|
||||
lib = lib.replace(/\/?$/, '/');
|
||||
}
|
||||
nodes.forEach(function(node) {
|
||||
var lib = path.join(dirname, node.toString());
|
||||
if (grunt.file.isDir(lib)) {
|
||||
// Ensure trailing slash on dirs.
|
||||
lib = lib.replace(/\/?$/, '/');
|
||||
}
|
||||
|
||||
// Look for duplicate paths before adding to array.
|
||||
if (libs.indexOf(lib) === -1) {
|
||||
libs.push(lib);
|
||||
}
|
||||
});
|
||||
// Look for duplicate paths before adding to array.
|
||||
if (libs.indexOf(lib) === -1) {
|
||||
libs.push(lib);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return libs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the list of feature files to pass to the gherkin linter.
|
||||
*
|
||||
* @returns {Array}
|
||||
*/
|
||||
const getGherkinLintTargets = () => {
|
||||
if (files) {
|
||||
// Specific files were requested. Only check these.
|
||||
return files;
|
||||
}
|
||||
|
||||
if (inComponent) {
|
||||
return [`${runDir}/tests/behat/*.feature`];
|
||||
}
|
||||
|
||||
return ['**/tests/behat/*.feature'];
|
||||
};
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
eslint: {
|
||||
// Even though warnings dont stop the build we don't display warnings by default because
|
||||
// at this moment we've got too many core warnings.
|
||||
// To display warnings call: grunt eslint --show-lint-warnings
|
||||
// To fail on warnings call: grunt eslint --max-lint-warnings=0
|
||||
// Also --max-lint-warnings=-1 can be used to display warnings but not fail.
|
||||
options: {
|
||||
quiet: (!grunt.option('show-lint-warnings')) && (typeof grunt.option('max-lint-warnings') === 'undefined'),
|
||||
maxWarnings: ((typeof grunt.option('max-lint-warnings') !== 'undefined') ? grunt.option('max-lint-warnings') : -1)
|
||||
},
|
||||
options: {quiet: !grunt.option('show-lint-warnings')},
|
||||
amd: {src: files ? files : amdSrc},
|
||||
// Check YUI module source files.
|
||||
yui: {src: files ? files : yuiSrc},
|
||||
yui: {src: files ? files : ['**/yui/src/**/*.js', '!*/**/yui/src/*/meta/*.js']}
|
||||
},
|
||||
babel: {
|
||||
options: {
|
||||
@@ -359,7 +190,6 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
options: {
|
||||
implementation: sass,
|
||||
includePaths: ["theme/boost/scss/", "theme/classic/scss/"]
|
||||
}
|
||||
},
|
||||
@@ -368,72 +198,73 @@ module.exports = function(grunt) {
|
||||
nospawn: true // We need not to spawn so config can be changed dynamically.
|
||||
},
|
||||
amd: {
|
||||
files: inComponent
|
||||
? ['amd/src/*.js', 'amd/src/**/*.js']
|
||||
: ['**/amd/src/**/*.js'],
|
||||
files: ['**/amd/src/**/*.js'],
|
||||
tasks: ['amd']
|
||||
},
|
||||
boost: {
|
||||
files: [inComponent ? 'scss/**/*.scss' : 'theme/boost/scss/**/*.scss'],
|
||||
files: ['**/theme/boost/scss/**/*.scss'],
|
||||
tasks: ['scss']
|
||||
},
|
||||
rawcss: {
|
||||
files: [
|
||||
'**/*.css',
|
||||
],
|
||||
excludes: [
|
||||
'**/moodle.css',
|
||||
'**/editor.css',
|
||||
],
|
||||
files: ['**/*.css', '**/theme/**/!(moodle.css|editor.css)'],
|
||||
tasks: ['rawcss']
|
||||
},
|
||||
yui: {
|
||||
files: inComponent
|
||||
? ['yui/src/*.json', 'yui/src/**/*.js']
|
||||
: ['**/yui/src/**/*.js'],
|
||||
files: ['**/yui/src/**/*.js'],
|
||||
tasks: ['yui']
|
||||
},
|
||||
gherkinlint: {
|
||||
files: [inComponent ? 'tests/behat/*.feature' : '**/tests/behat/*.feature'],
|
||||
files: ['**/tests/behat/*.feature'],
|
||||
tasks: ['gherkinlint']
|
||||
}
|
||||
},
|
||||
shifter: {
|
||||
options: {
|
||||
recursive: true,
|
||||
// Shifter takes a relative path.
|
||||
paths: files ? files : [runDir]
|
||||
paths: files ? files : [cwd]
|
||||
}
|
||||
},
|
||||
gherkinlint: {
|
||||
options: {
|
||||
files: getGherkinLintTargets(),
|
||||
files: files ? files : ['**/tests/behat/*.feature'],
|
||||
}
|
||||
},
|
||||
stylelint: {
|
||||
scss: {
|
||||
options: {syntax: 'scss'},
|
||||
src: files ? files : ['*/**/*.scss']
|
||||
},
|
||||
css: {
|
||||
src: files ? files : ['*/**/*.css'],
|
||||
options: {
|
||||
configOverrides: {
|
||||
rules: {
|
||||
// These rules have to be disabled in .stylelintrc for scss compat.
|
||||
"at-rule-no-unknown": true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Generate ignore files (utilising thirdpartylibs.xml data)
|
||||
*/
|
||||
tasks.ignorefiles = function() {
|
||||
// An array of paths to third party directories.
|
||||
const thirdPartyPaths = getThirdPartyPathsFromXML();
|
||||
// Generate .eslintignore.
|
||||
const eslintIgnores = [
|
||||
'# Generated by "grunt ignorefiles"',
|
||||
'*/**/yui/src/*/meta/',
|
||||
'*/**/build/',
|
||||
].concat(thirdPartyPaths);
|
||||
grunt.file.write('.eslintignore', eslintIgnores.join('\n'));
|
||||
|
||||
// Generate .stylelintignore.
|
||||
const stylelintIgnores = [
|
||||
'# Generated by "grunt ignorefiles"',
|
||||
'**/yui/build/*',
|
||||
'theme/boost/style/moodle.css',
|
||||
'theme/classic/style/moodle.css',
|
||||
].concat(thirdPartyPaths);
|
||||
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n'));
|
||||
// An array of paths to third party directories.
|
||||
var thirdPartyPaths = getThirdPartyPathsFromXML();
|
||||
// Generate .eslintignore.
|
||||
var eslintIgnores = ['# Generated by "grunt ignorefiles"', '*/**/yui/src/*/meta/', '*/**/build/'].concat(thirdPartyPaths);
|
||||
grunt.file.write('.eslintignore', eslintIgnores.join('\n'));
|
||||
// Generate .stylelintignore.
|
||||
var stylelintIgnores = [
|
||||
'# Generated by "grunt ignorefiles"',
|
||||
'**/yui/build/*',
|
||||
'theme/boost/style/moodle.css',
|
||||
'theme/classic/style/moodle.css',
|
||||
].concat(thirdPartyPaths);
|
||||
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n'));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -525,32 +356,19 @@ module.exports = function(grunt) {
|
||||
};
|
||||
|
||||
tasks.gherkinlint = function() {
|
||||
const done = this.async();
|
||||
const options = grunt.config('gherkinlint.options');
|
||||
var done = this.async(),
|
||||
options = grunt.config('gherkinlint.options');
|
||||
|
||||
// Grab the gherkin-lint linter and required scaffolding.
|
||||
const linter = require('gherkin-lint/dist/linter.js');
|
||||
const featureFinder = require('gherkin-lint/dist/feature-finder.js');
|
||||
const configParser = require('gherkin-lint/dist/config-parser.js');
|
||||
const formatter = require('gherkin-lint/dist/formatters/stylish.js');
|
||||
|
||||
// Run the linter.
|
||||
return linter.lint(
|
||||
featureFinder.getFeatureFiles(grunt.file.expand(options.files)),
|
||||
configParser.getConfiguration(configParser.defaultConfigFileName)
|
||||
)
|
||||
.then(results => {
|
||||
// Print the results out uncondtionally.
|
||||
formatter.printResults(results);
|
||||
|
||||
return results;
|
||||
})
|
||||
.then(results => {
|
||||
// Report on the results.
|
||||
// The done function takes a bool whereby a falsey statement causes the task to fail.
|
||||
return results.every(result => result.errors.length === 0);
|
||||
})
|
||||
.then(done); // eslint-disable-line promise/no-callback-in-promise
|
||||
var args = grunt.file.expand(options.files);
|
||||
args.unshift(path.normalize(__dirname + '/node_modules/.bin/gherkin-lint'));
|
||||
grunt.util.spawn({
|
||||
cmd: 'node',
|
||||
args: args,
|
||||
opts: {stdio: 'inherit', env: process.env}
|
||||
}, function(error, result, code) {
|
||||
// Propagate the exit code.
|
||||
done(code === 0);
|
||||
});
|
||||
};
|
||||
|
||||
tasks.startup = function() {
|
||||
@@ -610,7 +428,7 @@ module.exports = function(grunt) {
|
||||
grunt: true,
|
||||
// Run from current working dir and inherit stdio from process.
|
||||
opts: {
|
||||
cwd: fullRunDir,
|
||||
cwd: cwd,
|
||||
stdio: 'inherit'
|
||||
},
|
||||
args: [task, filesOption]
|
||||
@@ -636,26 +454,18 @@ module.exports = function(grunt) {
|
||||
);
|
||||
};
|
||||
|
||||
const originalWatchConfig = grunt.config.get(['watch']);
|
||||
const watchConfig = Object.keys(originalWatchConfig).reduce(function(carry, key) {
|
||||
var watchConfig = grunt.config.get(['watch']);
|
||||
watchConfig = Object.keys(watchConfig).reduce(function(carry, key) {
|
||||
if (key == 'options') {
|
||||
return carry;
|
||||
}
|
||||
|
||||
const value = originalWatchConfig[key];
|
||||
|
||||
const taskNames = value.tasks;
|
||||
const files = value.files;
|
||||
let excludes = [];
|
||||
if (value.excludes) {
|
||||
excludes = value.excludes;
|
||||
}
|
||||
var value = watchConfig[key];
|
||||
var fileGlobs = value.files;
|
||||
var taskNames = value.tasks;
|
||||
|
||||
taskNames.forEach(function(taskName) {
|
||||
carry[taskName] = {
|
||||
files,
|
||||
excludes,
|
||||
};
|
||||
carry[taskName] = fileGlobs;
|
||||
});
|
||||
|
||||
return carry;
|
||||
@@ -689,14 +499,12 @@ module.exports = function(grunt) {
|
||||
resp.files.forEach(function(file) {
|
||||
grunt.log.ok('File changed: ' + file.name);
|
||||
|
||||
var fullPath = fullRunDir + '/' + file.name;
|
||||
var fullPath = cwd + '/' + file.name;
|
||||
Object.keys(watchConfig).forEach(function(task) {
|
||||
|
||||
const fileGlobs = watchConfig[task].files;
|
||||
var match = fileGlobs.some(function(fileGlob) {
|
||||
return grunt.file.isMatch(`**/${fileGlob}`, fullPath);
|
||||
var fileGlobs = watchConfig[task];
|
||||
var match = fileGlobs.every(function(fileGlob) {
|
||||
return grunt.file.isMatch(fileGlob, fullPath);
|
||||
});
|
||||
|
||||
if (match) {
|
||||
// If we are watching a subdirectory then the file.name will be relative
|
||||
// to that directory. However the grunt tasks expect the file paths to be
|
||||
@@ -728,7 +536,7 @@ module.exports = function(grunt) {
|
||||
});
|
||||
|
||||
// Initiate the watch on the current directory.
|
||||
watchmanClient.command(['watch-project', fullRunDir], function(watchError, watchResponse) {
|
||||
watchmanClient.command(['watch-project', cwd], function(watchError, watchResponse) {
|
||||
if (watchError) {
|
||||
grunt.log.error('Error initiating watch:', watchError);
|
||||
watchTaskDone(1);
|
||||
@@ -750,40 +558,18 @@ module.exports = function(grunt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate the expression query used by watchman.
|
||||
// Documentation is limited, but see https://facebook.github.io/watchman/docs/expr/allof.html for examples.
|
||||
// We generate an expression to match any value in the files list of all of our tasks, but excluding
|
||||
// all value in the excludes list of that task.
|
||||
//
|
||||
// [anyof, [
|
||||
// [allof, [
|
||||
// [anyof, [
|
||||
// ['match', validPath, 'wholename'],
|
||||
// ['match', validPath, 'wholename'],
|
||||
// ],
|
||||
// [not,
|
||||
// [anyof, [
|
||||
// ['match', invalidPath, 'wholename'],
|
||||
// ['match', invalidPath, 'wholename'],
|
||||
// ],
|
||||
// ],
|
||||
// ],
|
||||
var matchWholeName = fileGlob => ['match', fileGlob, 'wholename'];
|
||||
// Use the matching patterns specified in the watch config.
|
||||
var matches = Object.keys(watchConfig).map(function(task) {
|
||||
const matchAll = [];
|
||||
matchAll.push(['anyof'].concat(watchConfig[task].files.map(matchWholeName)));
|
||||
var fileGlobs = watchConfig[task];
|
||||
var fileGlobMatches = fileGlobs.map(function(fileGlob) {
|
||||
return ['match', fileGlob, 'wholename'];
|
||||
});
|
||||
|
||||
if (watchConfig[task].excludes.length) {
|
||||
matchAll.push(['not', ['anyof'].concat(watchConfig[task].excludes.map(matchWholeName))]);
|
||||
}
|
||||
|
||||
return ['allof'].concat(matchAll);
|
||||
return ['allof'].concat(fileGlobMatches);
|
||||
});
|
||||
|
||||
matches = ['anyof'].concat(matches);
|
||||
|
||||
var sub = {
|
||||
expression: matches,
|
||||
expression: ["anyof"].concat(matches),
|
||||
// Which fields we're interested in.
|
||||
fields: ["name", "size", "type"],
|
||||
// Add our time constraint.
|
||||
@@ -803,7 +589,7 @@ module.exports = function(grunt) {
|
||||
return;
|
||||
}
|
||||
|
||||
grunt.log.ok('Listening for changes to files in ' + fullRunDir);
|
||||
grunt.log.ok('Listening for changes to files in ' + cwd);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -848,8 +634,10 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('amd', ['eslint:amd', 'babel']);
|
||||
grunt.registerTask('js', ['amd', 'yui']);
|
||||
|
||||
// Register CSS tasks.
|
||||
registerStyleLintTasks(grunt, files, fullRunDir);
|
||||
// Register CSS taks.
|
||||
grunt.registerTask('css', ['stylelint:scss', 'sass', 'stylelint:css']);
|
||||
grunt.registerTask('scss', ['stylelint:scss', 'sass']);
|
||||
grunt.registerTask('rawcss', ['stylelint:css']);
|
||||
|
||||
// Register the startup task.
|
||||
grunt.registerTask('startup', 'Run the correct tasks for the current directory', tasks.startup);
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Helper functions for working with Moodle component names, directories, and sources.
|
||||
*
|
||||
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
/* eslint-env node */
|
||||
|
||||
/** @var {Object} A list of subsystems in Moodle */
|
||||
const componentData = {};
|
||||
|
||||
/**
|
||||
* Load details of all moodle modules.
|
||||
*
|
||||
* @returns {object}
|
||||
*/
|
||||
const fetchComponentData = () => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const glob = require('glob');
|
||||
const gruntFilePath = process.cwd();
|
||||
|
||||
if (!Object.entries(componentData).length) {
|
||||
componentData.subsystems = {};
|
||||
componentData.pathList = [];
|
||||
|
||||
// Fetch the component definiitions from the distributed JSON file.
|
||||
const components = JSON.parse(fs.readFileSync(`${gruntFilePath}/lib/components.json`));
|
||||
|
||||
// Build the list of moodle subsystems.
|
||||
componentData.subsystems.lib = 'core';
|
||||
componentData.pathList.push(process.cwd() + path.sep + 'lib');
|
||||
for (const [component, thisPath] of Object.entries(components.subsystems)) {
|
||||
if (thisPath) {
|
||||
// Prefix "core_" to the front of the subsystems.
|
||||
componentData.subsystems[thisPath] = `core_${component}`;
|
||||
componentData.pathList.push(process.cwd() + path.sep + thisPath);
|
||||
}
|
||||
}
|
||||
|
||||
// The list of components incldues the list of subsystems.
|
||||
componentData.components = componentData.subsystems;
|
||||
|
||||
// Go through each of the plugintypes.
|
||||
Object.entries(components.plugintypes).forEach(([pluginType, pluginTypePath]) => {
|
||||
// We don't allow any code in this place..?
|
||||
glob.sync(`${pluginTypePath}/*/version.php`).forEach(versionPath => {
|
||||
const componentPath = fs.realpathSync(path.dirname(versionPath));
|
||||
const componentName = path.basename(componentPath);
|
||||
const frankenstyleName = `${pluginType}_${componentName}`;
|
||||
componentData.components[`${pluginTypePath}/${componentName}`] = frankenstyleName;
|
||||
componentData.pathList.push(componentPath);
|
||||
|
||||
// Look for any subplugins.
|
||||
const subPluginConfigurationFile = `${componentPath}/db/subplugins.json`;
|
||||
if (fs.existsSync(subPluginConfigurationFile)) {
|
||||
const subpluginList = JSON.parse(fs.readFileSync(fs.realpathSync(subPluginConfigurationFile)));
|
||||
|
||||
Object.entries(subpluginList.plugintypes).forEach(([subpluginType, subpluginTypePath]) => {
|
||||
glob.sync(`${subpluginTypePath}/*/version.php`).forEach(versionPath => {
|
||||
const componentPath = fs.realpathSync(path.dirname(versionPath));
|
||||
const componentName = path.basename(componentPath);
|
||||
const frankenstyleName = `${subpluginType}_${componentName}`;
|
||||
|
||||
componentData.components[`${subpluginTypePath}/${componentName}`] = frankenstyleName;
|
||||
componentData.pathList.push(componentPath);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return componentData;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the list of paths to build AMD sources.
|
||||
*
|
||||
* @returns {Array}
|
||||
*/
|
||||
const getAmdSrcGlobList = () => {
|
||||
const globList = [];
|
||||
fetchComponentData().pathList.forEach(componentPath => {
|
||||
globList.push(`${componentPath}/amd/src/*.js`);
|
||||
globList.push(`${componentPath}/amd/src/**/*.js`);
|
||||
});
|
||||
|
||||
return globList;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the list of paths to build YUI sources.
|
||||
*
|
||||
* @param {String} relativeTo
|
||||
* @returns {Array}
|
||||
*/
|
||||
const getYuiSrcGlobList = relativeTo => {
|
||||
const globList = [];
|
||||
fetchComponentData().pathList.forEach(componentPath => {
|
||||
const relativeComponentPath = componentPath.replace(relativeTo, '');
|
||||
globList.push(`${relativeComponentPath}/yui/src/**/*.js`);
|
||||
});
|
||||
|
||||
return globList;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the list of paths to thirdpartylibs.xml.
|
||||
*
|
||||
* @param {String} relativeTo
|
||||
* @returns {Array}
|
||||
*/
|
||||
const getThirdPartyLibsList = relativeTo => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
return fetchComponentData().pathList
|
||||
.map(componentPath => path.relative(relativeTo, componentPath) + '/thirdpartylibs.xml')
|
||||
.map(componentPath => componentPath.replace(/\\/g, '/'))
|
||||
.filter(path => fs.existsSync(path))
|
||||
.sort();
|
||||
};
|
||||
|
||||
/**
|
||||
* Find the name of the component matching the specified path.
|
||||
*
|
||||
* @param {String} path
|
||||
* @returns {String|null} Name of matching component.
|
||||
*/
|
||||
const getComponentFromPath = path => {
|
||||
const componentList = fetchComponentData().components;
|
||||
|
||||
if (componentList.hasOwnProperty(path)) {
|
||||
return componentList[path];
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check whether the supplied path, relative to the Gruntfile.js, is in a known component.
|
||||
*
|
||||
* @param {String} checkPath The path to check. This can be with either Windows, or Linux directory separators.
|
||||
* @returns {String|null}
|
||||
*/
|
||||
const getOwningComponentDirectory = checkPath => {
|
||||
const path = require('path');
|
||||
|
||||
// Fetch all components into a reverse sorted array.
|
||||
// This ensures that components which are within the directory of another component match first.
|
||||
const pathList = Object.keys(fetchComponentData().components).sort().reverse();
|
||||
for (const componentPath of pathList) {
|
||||
// If the componentPath is the directory being checked, it will be empty.
|
||||
// If the componentPath is a parent of the directory being checked, the relative directory will not start with ..
|
||||
if (!path.relative(componentPath, checkPath).startsWith('..')) {
|
||||
return componentPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getAmdSrcGlobList,
|
||||
getComponentFromPath,
|
||||
getOwningComponentDirectory,
|
||||
getYuiSrcGlobList,
|
||||
getThirdPartyLibsList,
|
||||
};
|
||||
@@ -98,10 +98,8 @@ switch ($action) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$new = implode(',', $activeantiviruses);
|
||||
add_to_config_log('antiviruses', $CFG->antiviruses, $new, 'core');
|
||||
set_config('antiviruses', $new);
|
||||
|
||||
set_config('antiviruses', implode(',', $activeantiviruses));
|
||||
core_plugin_manager::reset_caches();
|
||||
|
||||
redirect ($returnurl);
|
||||
redirect ($returnurl);
|
||||
@@ -1,122 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Task executor for adhoc tasks.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once("{$CFG->libdir}/clilib.php");
|
||||
require_once("{$CFG->libdir}/cronlib.php");
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
[
|
||||
'execute' => false,
|
||||
'help' => false,
|
||||
'keep-alive' => 0,
|
||||
'showsql' => false,
|
||||
'showdebugging' => false,
|
||||
'ignorelimits' => false,
|
||||
], [
|
||||
'h' => 'help',
|
||||
'e' => 'execute',
|
||||
'k' => 'keep-alive',
|
||||
'i' => 'ignorelimits',
|
||||
]
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help'] or empty($options['execute'])) {
|
||||
$help = <<<EOT
|
||||
Ad hoc cron tasks.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
--showsql Show sql queries before they are executed
|
||||
--showdebugging Show developer level debugging information
|
||||
-e, --execute Run all queued adhoc tasks
|
||||
-k, --keep-alive=N Keep this script alive for N seconds and poll for new adhoc tasks
|
||||
-i --ignorelimits Ignore task_adhoc_concurrency_limit and task_adhoc_max_runtime limits
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/adhoc_task.php --execute
|
||||
|
||||
EOT;
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if ($options['showdebugging']) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
}
|
||||
|
||||
if ($options['showsql']) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
|
||||
if (CLI_MAINTENANCE) {
|
||||
echo "CLI maintenance mode active, cron execution suspended.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (moodle_needs_upgrading()) {
|
||||
echo "Moodle upgrade pending, cron execution suspended.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (empty($options['execute'])) {
|
||||
exit(0);
|
||||
}
|
||||
if (empty($options['keep-alive'])) {
|
||||
$options['keep-alive'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($CFG->showcronsql)) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
if (!empty($CFG->showcrondebugging)) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
}
|
||||
|
||||
$checklimits = empty($options['ignorelimits']);
|
||||
|
||||
core_php_time_limit::raise();
|
||||
|
||||
// Increase memory limit.
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
// Emulate normal session - we use admin account by default.
|
||||
cron_setup_user();
|
||||
|
||||
$humantimenow = date('r', time());
|
||||
$keepalive = (int)$options['keep-alive'];
|
||||
|
||||
\core\local\cli\shutdown::script_supports_graceful_exit();
|
||||
|
||||
mtrace("Server Time: {$humantimenow}\n");
|
||||
cron_run_adhoc_tasks(time(), $keepalive, $checklimits);
|
||||
+1
-6
@@ -124,12 +124,7 @@ if ($options['unset'] || $options['set'] !== null) {
|
||||
cli_error('The configuration variable is hard-set in the config.php, unable to change.', 4);
|
||||
}
|
||||
|
||||
$new = $options['set'];
|
||||
$old = get_config($options['component'], $options['name']);
|
||||
if ($new !== $old) {
|
||||
set_config($options['name'], $options['set'], $options['component']);
|
||||
add_to_config_log($options['name'], $old, $new, $options['component']);
|
||||
}
|
||||
set_config($options['name'], $options['set'], $options['component']);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI tool for system checks
|
||||
*
|
||||
* @package core
|
||||
* @category check
|
||||
* @copyright 2020 Brendan Heywood (brendan@catalyst-au.net)
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
||||
use core\check\result;
|
||||
|
||||
list($options, $unrecognized) = cli_get_params([
|
||||
'help' => false,
|
||||
'filter' => '',
|
||||
'type' => 'status',
|
||||
'verbose' => false,
|
||||
], [
|
||||
'h' => 'help',
|
||||
'f' => 'filter',
|
||||
'v' => 'verbose',
|
||||
't' => 'type',
|
||||
]);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
$checks = \core\check\manager::get_checks($options['type']);
|
||||
$types = join(', ', \core\check\manager::TYPES);
|
||||
|
||||
$help = "Run Moodle system checks
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-f, --filter Filter to a subset of checks
|
||||
-t, --type Which set of checks? Defaults to 'status'
|
||||
One of $types
|
||||
-v, --verbose Show details of all checks, not just failed checks
|
||||
|
||||
Example:
|
||||
|
||||
sudo -u www-data php admin/cli/checks.php
|
||||
sudo -u www-data php admin/cli/checks.php -v
|
||||
sudo -u www-data php admin/cli/checks.php -v --filter=environment
|
||||
|
||||
";
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
die();
|
||||
}
|
||||
|
||||
$filter = $options['filter'];
|
||||
if ($filter) {
|
||||
$checks = array_filter($checks, function($check, $key) use ($filter) {
|
||||
$ref = $check->get_ref();
|
||||
return (strpos($ref, $filter) !== false);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
// These shell exit codes and labels align with the NRPE standard.
|
||||
$exitcodes = [
|
||||
result::NA => 0,
|
||||
result::OK => 0,
|
||||
result::INFO => 0,
|
||||
result::UNKNOWN => 3,
|
||||
result::WARNING => 1,
|
||||
result::ERROR => 2,
|
||||
result::CRITICAL => 2,
|
||||
];
|
||||
$exitlabel = [
|
||||
result::NA => 'OK',
|
||||
result::OK => 'OK',
|
||||
result::INFO => 'OK',
|
||||
result::UNKNOWN => 'UNKNOWN',
|
||||
result::WARNING => 'WARNING',
|
||||
result::ERROR => 'CRITICAL',
|
||||
result::CRITICAL => 'CRITICAL',
|
||||
];
|
||||
|
||||
$format = "% 10s| % -60s\n";
|
||||
$spacer = "----------+--------------------------------------------------------------------\n";
|
||||
$prefix = ' |';
|
||||
|
||||
$output = '';
|
||||
$header = $exitlabel[result::OK] . ': ' . get_string('checksok', '', $options['type']) . "\n";
|
||||
$exitcode = $exitcodes[result::OK];
|
||||
|
||||
foreach ($checks as $check) {
|
||||
$ref = $check->get_ref();
|
||||
$result = $check->get_result();
|
||||
|
||||
$status = $result->get_status();
|
||||
$checkexitcode = $exitcodes[$status];
|
||||
|
||||
// Summary is treated as html.
|
||||
$summary = $result->get_summary();
|
||||
$summary = html_to_text($summary, 60, false);
|
||||
|
||||
if ($checkexitcode > $exitcode) {
|
||||
$exitcode = $checkexitcode;
|
||||
$header = $exitlabel[$status] . ': ' . $check->get_name() . " (" . $check->get_ref() . ")\n";
|
||||
}
|
||||
|
||||
if (empty($messages[$status])) {
|
||||
$messages[$status] = $result;
|
||||
}
|
||||
|
||||
$len = strlen(get_string('status' . $status));
|
||||
|
||||
if ($options['verbose'] ||
|
||||
$status == result::WARNING ||
|
||||
$status == result::CRITICAL ||
|
||||
$status == result::ERROR) {
|
||||
|
||||
$output .= sprintf(
|
||||
$format,
|
||||
$OUTPUT->check_result($result),
|
||||
sprintf('%s (%s)', $check->get_name(), $ref)
|
||||
);
|
||||
|
||||
$summary = str_replace("\n", "\n" . $prefix . ' ', $summary);
|
||||
$output .= sprintf( $format, '', ' ' . $summary);
|
||||
|
||||
if ($options['verbose']) {
|
||||
$actionlink = $check->get_action_link();
|
||||
if ($actionlink) {
|
||||
$output .= sprintf( $format, '', ' ' . $actionlink->url);
|
||||
}
|
||||
$output .= sprintf( $format, '', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print NRPE header.
|
||||
print $header;
|
||||
|
||||
// Only show the table header if there is anything to show.
|
||||
if ($output) {
|
||||
print sprintf($format,
|
||||
get_string('status'). ' ',
|
||||
get_string('check')
|
||||
) . $spacer;
|
||||
print $output;
|
||||
}
|
||||
|
||||
// NRPE shell exit code.
|
||||
exit($exitcode);
|
||||
|
||||
+2
-20
@@ -35,16 +35,8 @@ require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
require_once($CFG->libdir.'/cronlib.php');
|
||||
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
'stop' => false,
|
||||
),
|
||||
array(
|
||||
'h' => 'help',
|
||||
's' => 'stop',
|
||||
)
|
||||
);
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
@@ -57,7 +49,6 @@ if ($options['help']) {
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
-s, --stop Notify all other running cron processes to stop after the current task
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/cron.php
|
||||
@@ -67,13 +58,4 @@ Example:
|
||||
die;
|
||||
}
|
||||
|
||||
if ($options['stop']) {
|
||||
// By clearing the caches this signals to other running processes
|
||||
// to exit after finishing the current task.
|
||||
\core\task\manager::clear_static_caches();
|
||||
die;
|
||||
}
|
||||
|
||||
\core\local\cli\shutdown::script_supports_graceful_exit();
|
||||
|
||||
cron_run();
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* CLI task execution.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2014 Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/cronlib.php");
|
||||
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array('help' => false, 'list' => false, 'execute' => false, 'showsql' => false, 'showdebugging' => false),
|
||||
array('h' => 'help')
|
||||
);
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help'] or (!$options['list'] and !$options['execute'])) {
|
||||
$help =
|
||||
"Scheduled cron tasks.
|
||||
|
||||
Options:
|
||||
--execute=\\some\\task Execute scheduled task manually
|
||||
--list List all scheduled tasks
|
||||
--showsql Show sql queries before they are executed
|
||||
--showdebugging Show developer level debugging information
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/scheduled_task.php --execute=\\core\\task\\session_cleanup_task
|
||||
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
if ($options['showdebugging']) {
|
||||
set_debugging(DEBUG_DEVELOPER, true);
|
||||
}
|
||||
|
||||
if ($options['showsql']) {
|
||||
$DB->set_debug(true);
|
||||
}
|
||||
if ($options['list']) {
|
||||
cli_heading("List of scheduled tasks ($CFG->wwwroot)");
|
||||
|
||||
$shorttime = get_string('strftimedatetimeshort');
|
||||
|
||||
$tasks = \core\task\manager::get_all_scheduled_tasks();
|
||||
echo str_pad(get_string('scheduledtasks', 'tool_task'), 50, ' ') . ' ' . str_pad(get_string('runpattern', 'tool_task'), 17, ' ')
|
||||
. ' ' . str_pad(get_string('lastruntime', 'tool_task'), 40, ' ') . get_string('nextruntime', 'tool_task') . "\n";
|
||||
foreach ($tasks as $task) {
|
||||
$class = '\\' . get_class($task);
|
||||
$schedule = $task->get_minute() . ' '
|
||||
. $task->get_hour() . ' '
|
||||
. $task->get_day() . ' '
|
||||
. $task->get_day_of_week() . ' '
|
||||
. $task->get_month() . ' '
|
||||
. $task->get_day_of_week();
|
||||
$nextrun = $task->get_next_run_time();
|
||||
$lastrun = $task->get_last_run_time();
|
||||
|
||||
$plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component());
|
||||
$plugindisabled = $plugininfo && $plugininfo->is_enabled() === false && !$task->get_run_if_component_disabled();
|
||||
|
||||
if ($plugindisabled) {
|
||||
$nextrun = get_string('plugindisabled', 'tool_task');
|
||||
} else if ($task->get_disabled()) {
|
||||
$nextrun = get_string('taskdisabled', 'tool_task');
|
||||
} else if ($nextrun > time()) {
|
||||
$nextrun = userdate($nextrun);
|
||||
} else {
|
||||
$nextrun = get_string('asap', 'tool_task');
|
||||
}
|
||||
|
||||
if ($lastrun) {
|
||||
$lastrun = userdate($lastrun);
|
||||
} else {
|
||||
$lastrun = get_string('never');
|
||||
}
|
||||
|
||||
echo str_pad($class, 50, ' ') . ' ' . str_pad($schedule, 17, ' ') .
|
||||
' ' . str_pad($lastrun, 40, ' ') . ' ' . $nextrun . "\n";
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($execute = $options['execute']) {
|
||||
if (!$task = \core\task\manager::get_scheduled_task($execute)) {
|
||||
mtrace("Task '$execute' not found");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (moodle_needs_upgrading()) {
|
||||
mtrace("Moodle upgrade pending, cannot execute tasks.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Increase memory limit.
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
// Emulate normal session - we use admin account by default.
|
||||
cron_setup_user();
|
||||
|
||||
// Execute the task.
|
||||
\core\local\cli\shutdown::script_supports_graceful_exit();
|
||||
$cronlockfactory = \core\lock\lock_config::get_lock_factory('cron');
|
||||
if (!$cronlock = $cronlockfactory->get_lock('core_cron', 10)) {
|
||||
mtrace('Cannot obtain cron lock');
|
||||
exit(129);
|
||||
}
|
||||
if (!$lock = $cronlockfactory->get_lock('\\' . get_class($task), 10)) {
|
||||
$cronlock->release();
|
||||
mtrace('Cannot obtain task lock');
|
||||
exit(130);
|
||||
}
|
||||
|
||||
$task->set_lock($lock);
|
||||
if (!$task->is_blocking()) {
|
||||
$cronlock->release();
|
||||
} else {
|
||||
$task->set_cron_lock($cronlock);
|
||||
}
|
||||
|
||||
cron_run_inner_scheduled_task($task);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ if (!$envstatus) {
|
||||
|
||||
// Test plugin dependencies.
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed, $CFG->branch)) {
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
cli_problem(get_string('pluginscheckfailed', 'admin', array('pluginslist' => implode(', ', array_unique($failed)))));
|
||||
cli_error(get_string('pluginschecktodo', 'admin'));
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Content bank and its plugins settings.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage contentbank
|
||||
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$name = required_param('name', PARAM_PLUGIN);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/contentbank.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_admin();
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'managecontentbanktypes'));
|
||||
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('contenttype');
|
||||
$sortorder = array_flip(array_keys($plugins));
|
||||
|
||||
if (!isset($plugins[$name])) {
|
||||
print_error('contenttypenotfound', 'error', $return, $name);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($plugins[$name]->is_enabled()) {
|
||||
set_config('disabled', 1, 'contentbank_'. $name);
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$plugins[$name]->is_enabled()) {
|
||||
unset_config('disabled', 'contentbank_'. $name);
|
||||
}
|
||||
break;
|
||||
case 'up':
|
||||
if ($sortorder[$name]) {
|
||||
$currentindex = $sortorder[$name];
|
||||
$seq = array_keys($plugins);
|
||||
$seq[$currentindex] = $seq[$currentindex - 1];
|
||||
$seq[$currentindex - 1] = $name;
|
||||
set_config('contentbank_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
case 'down':
|
||||
if ($sortorder[$name] < count($sortorder) - 1) {
|
||||
$currentindex = $sortorder[$name];
|
||||
$seq = array_keys($plugins);
|
||||
$seq[$currentindex] = $seq[$currentindex + 1];
|
||||
$seq[$currentindex + 1] = $name;
|
||||
set_config('contentbank_plugins_sortorder', implode(',', $seq));
|
||||
}
|
||||
break;
|
||||
}
|
||||
core_plugin_manager::reset_caches();
|
||||
$cache = cache::make('core', 'contentbank_enabled_extensions');
|
||||
$cache->purge();
|
||||
$cache = cache::make('core', 'contentbank_context_extensions');
|
||||
$cache->purge();
|
||||
|
||||
redirect($return);
|
||||
+14
-36
@@ -226,7 +226,7 @@ if (!core_tables_exist()) {
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environmentresults) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
@@ -235,13 +235,13 @@ if (!core_tables_exist()) {
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environmentresults, $release);
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
|
||||
die();
|
||||
}
|
||||
|
||||
// check plugin dependencies
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed, $CFG->branch)) {
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$PAGE->navbar->add(get_string('pluginscheck', 'admin'));
|
||||
$PAGE->set_title($strinstallation);
|
||||
$PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
|
||||
@@ -358,9 +358,9 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmrelease)) {
|
||||
} else if (empty($confirmrelease)){
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environmentresults) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
@@ -368,7 +368,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environmentresults);
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmplugins)) {
|
||||
@@ -508,7 +508,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
} else {
|
||||
// Always verify plugin dependencies!
|
||||
$failed = array();
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed, $CFG->branch)) {
|
||||
if (!core_plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
||||
die();
|
||||
}
|
||||
@@ -533,10 +533,7 @@ if (!$cache and $branch <> $CFG->branch) { // Update the branch
|
||||
|
||||
if (!$cache and moodle_needs_upgrading()) {
|
||||
|
||||
$PAGE->set_url(new moodle_url($PAGE->url, array(
|
||||
'confirmrelease' => $confirmrelease,
|
||||
'confirmplugincheck' => $confirmplugins,
|
||||
)));
|
||||
$PAGE->set_url(new moodle_url($PAGE->url, array('confirmplugincheck' => $confirmplugins)));
|
||||
|
||||
check_upgrade_key($upgradekeyhash);
|
||||
|
||||
@@ -546,21 +543,7 @@ if (!$cache and moodle_needs_upgrading()) {
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
if (empty($confirmrelease)) {
|
||||
require_once($CFG->libdir . '/environmentlib.php');
|
||||
|
||||
list($envstatus, $environmentresults) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
$PAGE->set_title($strcurrentrelease);
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environmentresults);
|
||||
die();
|
||||
|
||||
} else if (!$confirmplugins) {
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
@@ -699,7 +682,7 @@ if (!$cache and moodle_needs_upgrading()) {
|
||||
|
||||
// Make sure plugin dependencies are always checked.
|
||||
$failed = array();
|
||||
if (!$pluginman->all_plugins_ok($version, $failed, $CFG->branch)) {
|
||||
if (!$pluginman->all_plugins_ok($version, $failed)) {
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
||||
die();
|
||||
@@ -819,7 +802,7 @@ $SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
|
||||
$adminroot = admin_get_root();
|
||||
|
||||
// Check if there are any new admin settings which have still yet to be set
|
||||
if (any_new_admin_settings($adminroot)) {
|
||||
if (any_new_admin_settings($adminroot)){
|
||||
redirect('upgradesettings.php');
|
||||
}
|
||||
|
||||
@@ -843,9 +826,8 @@ $errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
||||
$lastcron = get_config('tool_task', 'lastcronstart');
|
||||
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
||||
$lastcroninterval = get_config('tool_task', 'lastcroninterval');
|
||||
|
||||
$expectedfrequency = $CFG->expectedcronfrequency ?? MINSECS;
|
||||
$croninfrequent = !$cronoverdue && ($lastcroninterval > ($expectedfrequency + MINSECS) || $lastcron < time() - $expectedfrequency);
|
||||
$expectedfrequency = $CFG->expectedcronfrequency ?? 200;
|
||||
$croninfrequent = !$cronoverdue && ($lastcroninterval > $expectedfrequency || $lastcron < time() - $expectedfrequency);
|
||||
$dbproblems = $DB->diagnose();
|
||||
$maintenancemode = !empty($CFG->maintenance_enabled);
|
||||
|
||||
@@ -899,9 +881,6 @@ if (empty($CFG->disabledevlibdirscheck) && (is_dir($CFG->dirroot.'/vendor') || i
|
||||
// Check if the site is being foced onto ssl.
|
||||
$overridetossl = !empty($CFG->overridetossl);
|
||||
|
||||
// Check if moodle campaign content setting is enabled or not.
|
||||
$showcampaigncontent = !isset($CFG->showcampaigncontent) || $CFG->showcampaigncontent;
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
@@ -909,5 +888,4 @@ $output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
|
||||
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered, $cachewarnings, $eventshandlers, $themedesignermode, $devlibdir,
|
||||
$mobileconfigured, $overridetossl, $invalidforgottenpasswordurl, $croninfrequent,
|
||||
$showcampaigncontent);
|
||||
$mobileconfigured, $overridetossl, $invalidforgottenpasswordurl, $croninfrequent);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -15,32 +16,41 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* License manager page.
|
||||
*
|
||||
* @package tool_licensemanager
|
||||
* @copyright 2019 Tom Dickman <tomdickman@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* Allows admin to configure licenses.
|
||||
*/
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/licenselib.php');
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/licenselib.php');
|
||||
|
||||
require_admin();
|
||||
|
||||
$returnurl = \tool_licensemanager\helper::get_licensemanager_url();
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/settings.php?section=managelicenses";
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$license = optional_param('license', '', PARAM_SAFEDIR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// process actions
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
// Route via the manager.
|
||||
$licensemanager = new \tool_licensemanager\manager();
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_url(\tool_licensemanager\helper::get_licensemanager_url());
|
||||
$PAGE->set_title(get_string('licensemanager', 'tool_licensemanager'));
|
||||
$return = true;
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
license_manager::disable($license);
|
||||
break;
|
||||
|
||||
$licensemanager->execute($action, $license);
|
||||
case 'enable':
|
||||
license_manager::enable($license);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
redirect ($returnurl);
|
||||
}
|
||||
+1
-1
@@ -83,7 +83,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
}
|
||||
} else {
|
||||
$newsettings = array();
|
||||
if (property_exists($form, $componentprovidersetting)) {
|
||||
if (array_key_exists($componentprovidersetting, $form)) {
|
||||
// We must be processing loggedin or loggedoff checkboxes.
|
||||
// Store defained comma-separated processors as setting value.
|
||||
// Using array_filter eliminates elements set to 0 above.
|
||||
|
||||
@@ -156,7 +156,7 @@ class mnet_review_host_form extends moodleform {
|
||||
if ($mnet_peer && !empty($mnet_peer->deleted)) {
|
||||
$radioarray = array();
|
||||
$radioarray[] = $mform->createElement('static', 'deletedinfo', '',
|
||||
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'alert alert-warning'));
|
||||
$OUTPUT->container(get_string('deletedhostinfo', 'mnet'), 'deletedhostinfo'));
|
||||
$radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('yes'), 1);
|
||||
$radioarray[] = $mform->createElement('radio', 'deleted', '', get_string('no'), 0);
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
|
||||
|
||||
@@ -170,7 +170,7 @@ foreach ($sortedbehaviours as $behaviour => $behaviourname) {
|
||||
if ($version) {
|
||||
$row[] = $version;
|
||||
} else {
|
||||
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'text-muted'));
|
||||
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'disabled'));
|
||||
}
|
||||
|
||||
// Other question types required by this one.
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ foreach ($sortedqtypes as $qtypename => $localname) {
|
||||
if ($version) {
|
||||
$row[] = $version;
|
||||
} else {
|
||||
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'text-muted'));
|
||||
$row[] = html_writer::tag('span', get_string('nodatabase', 'admin'), array('class' => 'disabled'));
|
||||
}
|
||||
|
||||
// Other question types required by this one.
|
||||
|
||||
@@ -45,7 +45,7 @@ $error = optional_param('error', '', PARAM_ALPHANUM);
|
||||
|
||||
admin_externalpage_setup('registrationmoodleorg');
|
||||
|
||||
if (parse_url($url, PHP_URL_HOST) !== parse_url(HUB_MOODLEORGHUBURL, PHP_URL_HOST)) {
|
||||
if ($url !== HUB_MOODLEORGHUBURL) {
|
||||
// Allow other plugins to confirm registration on custom hubs. Plugins implementing this
|
||||
// callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
|
||||
$callbacks = get_plugins_with_function('hub_registration');
|
||||
|
||||
@@ -39,7 +39,7 @@ $token = optional_param('token', '', PARAM_TEXT);
|
||||
|
||||
admin_externalpage_setup('registrationmoodleorg');
|
||||
|
||||
if (parse_url($url, PHP_URL_HOST) !== parse_url(HUB_MOODLEORGHUBURL, PHP_URL_HOST)) {
|
||||
if ($url !== HUB_MOODLEORGHUBURL) {
|
||||
// Allow other plugins to renew registration on custom hubs. Plugins implementing this
|
||||
// callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
|
||||
$callbacks = get_plugins_with_function('hub_registration');
|
||||
|
||||
+77
-120
@@ -253,7 +253,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->container(get_string('cancelinstallinfodir', 'core_plugin', $pluginfo->rootdir));
|
||||
if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
|
||||
$out .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
|
||||
'alert alert-warning mt-2');
|
||||
'uninstalldeleteconfirmexternal');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @param bool $overridetossl Whether or not ssl is being forced.
|
||||
* @param bool $invalidforgottenpasswordurl Whether the forgotten password URL does not link to a valid URL.
|
||||
* @param bool $croninfrequent If true, warn that cron hasn't run in the past few minutes
|
||||
* @param bool $showcampaigncontent Whether the campaign content should be visible or not.
|
||||
*
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
@@ -290,9 +289,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
|
||||
$buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
|
||||
$themedesignermode = false, $devlibdir = false, $mobileconfigured = false,
|
||||
$overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false,
|
||||
$showcampaigncontent = false) {
|
||||
|
||||
$overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
@@ -315,7 +312,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->registration_warning($registered);
|
||||
$output .= $this->mobile_configuration_warning($mobileconfigured);
|
||||
$output .= $this->forgotten_password_url_warning($invalidforgottenpasswordurl);
|
||||
$output .= $this->campaign_content($showcampaigncontent);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE ///
|
||||
@@ -365,15 +361,14 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output = '';
|
||||
|
||||
if ($checker->enabled()) {
|
||||
$output .= $this->container_start('checkforupdates mb-4');
|
||||
$output .= $this->container_start('checkforupdates');
|
||||
$output .= $this->single_button(
|
||||
new moodle_url($reloadurl, array('fetchupdates' => 1)),
|
||||
get_string('checkforupdates', 'core_plugin')
|
||||
);
|
||||
if ($timefetched = $checker->get_last_timefetched()) {
|
||||
$timefetched = userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'));
|
||||
$output .= $this->container(get_string('checkforupdateslast', 'core_plugin', $timefetched),
|
||||
'lasttimefetched small text-muted mt-1');
|
||||
$output .= $this->container(get_string('checkforupdateslast', 'core_plugin', $timefetched), 'lasttimefetched');
|
||||
}
|
||||
$output .= $this->container_end();
|
||||
}
|
||||
@@ -437,7 +432,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
|
||||
$confirm .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
|
||||
'alert alert-warning mt-2');
|
||||
'uninstalldeleteconfirmexternal');
|
||||
}
|
||||
|
||||
// After any uninstall we must execute full upgrade to finish the cleanup!
|
||||
@@ -516,7 +511,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
protected function warning($message, $type = 'warning') {
|
||||
return $this->box($message, 'generalbox alert alert-' . $type);
|
||||
return $this->box($message, 'generalbox admin' . $type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -531,7 +526,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $this->warning(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot));
|
||||
|
||||
} else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
|
||||
return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'danger');
|
||||
return $this->warning(get_string('datarootsecurityerror', 'admin', $CFG->dataroot), 'error');
|
||||
|
||||
} else {
|
||||
return '';
|
||||
@@ -549,7 +544,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
if ($devlibdir) {
|
||||
$moreinfo = new moodle_url('/report/security/index.php');
|
||||
$warning = get_string('devlibdirpresent', 'core_admin', ['moreinfourl' => $moreinfo->out()]);
|
||||
return $this->warning($warning, 'danger');
|
||||
return $this->warning($warning, 'error');
|
||||
|
||||
} else {
|
||||
return '';
|
||||
@@ -606,9 +601,19 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
$check = new \tool_task\check\cronrunning();
|
||||
$result = $check->get_result();
|
||||
return $this->warning($result->get_summary() . ' ' . $this->help_icon('cron', 'admin'));
|
||||
if (empty($CFG->cronclionly)) {
|
||||
$url = new moodle_url('/admin/cron.php');
|
||||
if (!empty($CFG->cronremotepassword)) {
|
||||
$url = new moodle_url('/admin/cron.php', array('password' => $CFG->cronremotepassword));
|
||||
}
|
||||
|
||||
return $this->warning(get_string('cronwarning', 'admin', $url->out()) . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
// $CFG->cronclionly is not empty: cron can run only from CLI.
|
||||
return $this->warning(get_string('cronwarningcli', 'admin') . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,9 +629,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
$check = new \tool_task\check\cronrunning();
|
||||
$result = $check->get_result();
|
||||
return $this->warning($result->get_summary() . ' ' . $this->help_icon('cron', 'admin'));
|
||||
$expectedfrequency = $CFG->expectedcronfrequency ?? 200;
|
||||
return $this->warning(get_string('croninfrequent', 'admin', $expectedfrequency) . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -716,7 +721,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $this->warning(
|
||||
$this->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) .
|
||||
$this->container($this->doc_link('admin/versions', get_string('morehelp'))),
|
||||
'danger');
|
||||
'error');
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -732,7 +737,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$warning = (get_string('testsiteupgradewarning', 'admin', $testsite));
|
||||
return $this->warning($warning, 'danger');
|
||||
return $this->warning($warning, 'error');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -767,7 +772,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$level = 'warning';
|
||||
|
||||
if ($maturity == MATURITY_ALPHA) {
|
||||
$level = 'danger';
|
||||
$level = 'error';
|
||||
}
|
||||
|
||||
$maturitylevel = get_string('maturity' . $maturity, 'admin');
|
||||
@@ -818,7 +823,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
|
||||
$updateinfo .= $this->container_start('checkforupdates mt-1');
|
||||
$updateinfo .= $this->container_start('checkforupdates');
|
||||
$fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
|
||||
$updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
|
||||
if ($fetch) {
|
||||
@@ -882,20 +887,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display campaign content.
|
||||
*
|
||||
* @param bool $showcampaigncontent Whether the campaign content should be visible or not.
|
||||
* @return string the campaign content raw html.
|
||||
*/
|
||||
protected function campaign_content(bool $showcampaigncontent): string {
|
||||
if (!$showcampaigncontent) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->render_from_template('core/campaign_content', ['lang' => current_language()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a warning about the forgotten password URL not linking to a valid URL.
|
||||
*
|
||||
@@ -921,7 +912,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
protected function moodle_available_update_info(\core\update\info $updateinfo) {
|
||||
|
||||
$boxclasses = 'moodleupdateinfo mb-2';
|
||||
$boxclasses = 'moodleupdateinfo';
|
||||
$info = array();
|
||||
|
||||
if (isset($updateinfo->release)) {
|
||||
@@ -941,8 +932,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
if (isset($updateinfo->download)) {
|
||||
$info[] = html_writer::link($updateinfo->download, get_string('download'),
|
||||
array('class' => 'info download btn btn-secondary'));
|
||||
$info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
|
||||
}
|
||||
|
||||
if (isset($updateinfo->url)) {
|
||||
@@ -950,9 +940,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
array('class' => 'info more'));
|
||||
}
|
||||
|
||||
$box = $this->output->container_start($boxclasses);
|
||||
$box .= $this->output->container(implode(html_writer::tag('span', ' | ', array('class' => 'separator')), $info), '');
|
||||
$box .= $this->output->container_end();
|
||||
$box = $this->output->box_start($boxclasses);
|
||||
$box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
|
||||
$box .= $this->output->box_end();
|
||||
|
||||
return $box;
|
||||
}
|
||||
@@ -964,7 +954,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
protected function release_notes_link() {
|
||||
$releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/dev/Releases');
|
||||
$releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink); // extremely ugly validation hack
|
||||
return $this->box($releasenoteslink, 'generalbox alert alert-info');
|
||||
return $this->box($releasenoteslink, 'generalbox releasenoteslink');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -993,7 +983,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function plugins_check_table(core_plugin_manager $pluginman, $version, array $options = array()) {
|
||||
global $CFG;
|
||||
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
|
||||
if (empty($plugininfo)) {
|
||||
@@ -1064,7 +1054,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$displayname = new html_table_cell(
|
||||
$icon.
|
||||
html_writer::span($plugin->displayname, 'pluginname').
|
||||
html_writer::div($plugin->get_dir(), 'plugindir text-muted small')
|
||||
html_writer::div($plugin->get_dir(), 'plugindir')
|
||||
);
|
||||
|
||||
$versiondb = new html_table_cell($plugin->versiondb);
|
||||
@@ -1079,10 +1069,8 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$coredependency = $plugin->is_core_dependency_satisfied($version);
|
||||
$incompatibledependency = $plugin->is_core_compatible_satisfied($CFG->branch);
|
||||
|
||||
$otherpluginsdependencies = $pluginman->are_dependencies_satisfied($plugin->get_other_required_plugins());
|
||||
$dependenciesok = $coredependency && $otherpluginsdependencies && $incompatibledependency;
|
||||
$dependenciesok = $coredependency && $otherpluginsdependencies;
|
||||
|
||||
$statuscode = $plugin->get_status();
|
||||
$row->attributes['class'] .= ' status-' . $statuscode;
|
||||
@@ -1101,7 +1089,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
break;
|
||||
case core_plugin_manager::PLUGIN_STATUS_NODB:
|
||||
case core_plugin_manager::PLUGIN_STATUS_UPTODATE:
|
||||
$statusclass .= $dependenciesok ? 'badge-light' : 'badge-warning';
|
||||
$statusclass .= $dependenciesok ? '' : 'badge-warning';
|
||||
break;
|
||||
}
|
||||
$status = html_writer::span(get_string('status_' . $statuscode, 'core_plugin'), $statusclass);
|
||||
@@ -1111,7 +1099,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortinstall' => $plugin->component)),
|
||||
get_string('cancelinstallone', 'core_plugin'),
|
||||
'post',
|
||||
array('class' => 'actionbutton cancelinstallone d-block mt-1')
|
||||
array('class' => 'actionbutton cancelinstallone')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1120,7 +1108,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortupgrade' => $plugin->component)),
|
||||
get_string('cancelupgradeone', 'core_plugin'),
|
||||
'post',
|
||||
array('class' => 'actionbutton cancelupgradeone d-block mt-1')
|
||||
array('class' => 'actionbutton cancelupgradeone')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1132,11 +1120,8 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$status = new html_table_cell($sourcelabel.' '.$status);
|
||||
if ($plugin->pluginsupported != null) {
|
||||
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version, $CFG->branch));
|
||||
} else {
|
||||
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
|
||||
}
|
||||
|
||||
$requires = new html_table_cell($this->required_column($plugin, $pluginman, $version));
|
||||
|
||||
$statusisboring = in_array($statuscode, array(
|
||||
core_plugin_manager::PLUGIN_STATUS_NODB, core_plugin_manager::PLUGIN_STATUS_UPTODATE));
|
||||
@@ -1193,7 +1178,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
|
||||
$out .= $this->output->container_start('actions mb-2');
|
||||
$out .= $this->output->container_start('actions');
|
||||
|
||||
$installableupdates = $pluginman->filter_installable($pluginman->available_updates());
|
||||
if ($installableupdates) {
|
||||
@@ -1201,7 +1186,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('installupdatex' => 1)),
|
||||
get_string('updateavailableinstallall', 'core_admin', count($installableupdates)),
|
||||
'post',
|
||||
array('class' => 'singlebutton updateavailableinstallall mr-1')
|
||||
array('class' => 'singlebutton updateavailableinstallall')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1210,7 +1195,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortinstallx' => 1)),
|
||||
get_string('cancelinstallall', 'core_plugin', count($installabortable)),
|
||||
'post',
|
||||
array('class' => 'singlebutton cancelinstallall mr-1')
|
||||
array('class' => 'singlebutton cancelinstallall')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1219,17 +1204,15 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortupgradex' => 1)),
|
||||
get_string('cancelupgradeall', 'core_plugin', count($upgradeabortable)),
|
||||
'post',
|
||||
array('class' => 'singlebutton cancelupgradeall mr-1')
|
||||
array('class' => 'singlebutton cancelupgradeall')
|
||||
);
|
||||
}
|
||||
|
||||
$out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 0)),
|
||||
get_string('plugincheckattention', 'core_plugin')).' '.html_writer::span($sumattention, 'badge badge-light'),
|
||||
'btn btn-link mr-1');
|
||||
get_string('plugincheckattention', 'core_plugin')).' '.html_writer::span($sumattention, 'badge'));
|
||||
|
||||
$out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 1)),
|
||||
get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge badge-light'),
|
||||
'btn btn-link mr-1');
|
||||
get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge'));
|
||||
|
||||
$out .= $this->output->container_end(); // End of .actions container.
|
||||
$out .= $this->output->container_end(); // End of #plugins-check-info container.
|
||||
@@ -1297,13 +1280,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
|
||||
$out = $this->output->container_start('plugins-check-dependencies mb-4');
|
||||
$out = $this->output->container_start('plugins-check-dependencies');
|
||||
|
||||
if ($unavailable or $unknown) {
|
||||
$out .= $this->output->heading(get_string('misdepsunavail', 'core_plugin'));
|
||||
if ($unknown) {
|
||||
$out .= $this->output->render((new \core\output\notification(get_string('misdepsunknownlist', 'core_plugin',
|
||||
implode(', ', $unknown))))->set_show_closebutton(false));
|
||||
$out .= $this->output->notification(get_string('misdepsunknownlist', 'core_plugin', implode($unknown, ', ')));
|
||||
}
|
||||
if ($unavailable) {
|
||||
$unavailablelist = array();
|
||||
@@ -1317,18 +1299,18 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$unavailablelist[] = $unavailablelistitem;
|
||||
}
|
||||
$out .= $this->output->render((new \core\output\notification(get_string('misdepsunavaillist', 'core_plugin',
|
||||
implode(', ', $unavailablelist))))->set_show_closebutton(false));
|
||||
$out .= $this->output->notification(get_string('misdepsunavaillist', 'core_plugin',
|
||||
implode($unavailablelist, ', ')));
|
||||
}
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions mb-4');
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions');
|
||||
$out .= ' '.html_writer::link(new moodle_url('/admin/tool/installaddon/'),
|
||||
get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-secondary'));
|
||||
get_string('dependencyuploadmissing', 'core_plugin'));
|
||||
$out .= $this->output->container_end(); // End of .plugins-check-dependencies-actions container.
|
||||
}
|
||||
|
||||
if ($available) {
|
||||
$out .= $this->output->heading(get_string('misdepsavail', 'core_plugin'));
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions mb-2');
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions');
|
||||
|
||||
$installable = $pluginman->filter_installable($available);
|
||||
if ($installable) {
|
||||
@@ -1336,13 +1318,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('installdepx' => 1)),
|
||||
get_string('dependencyinstallmissing', 'core_plugin', count($installable)),
|
||||
'post',
|
||||
array('class' => 'singlebutton dependencyinstallmissing d-inline-block mr-1')
|
||||
array('class' => 'singlebutton dependencyinstallmissing')
|
||||
);
|
||||
}
|
||||
|
||||
$out .= html_writer::div(html_writer::link(new moodle_url('/admin/tool/installaddon/'),
|
||||
get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-link')),
|
||||
'dependencyuploadmissing d-inline-block mr-1');
|
||||
get_string('dependencyuploadmissing', 'core_plugin')), 'dependencyuploadmissing');
|
||||
|
||||
$out .= $this->output->container_end(); // End of .plugins-check-dependencies-actions container.
|
||||
|
||||
@@ -1383,7 +1364,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
if ($CFG->branch == str_replace('.', '', $moodle->release)) {
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'badge badge-success');
|
||||
} else {
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'badge badge-light');
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'label');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1397,7 +1378,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$info = html_writer::div(
|
||||
get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
|
||||
'requiredby mb-1'
|
||||
'requiredby'
|
||||
);
|
||||
} else {
|
||||
$info = '';
|
||||
@@ -1408,39 +1389,38 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$info .= html_writer::div(
|
||||
html_writer::link('https://moodle.org/plugins/view.php?plugin='.$plugin->component,
|
||||
get_string('misdepinfoplugin', 'core_plugin')),
|
||||
'misdepinfoplugin d-inline-block mr-3 mb-1'
|
||||
'misdepinfoplugin'
|
||||
);
|
||||
|
||||
$info .= html_writer::div(
|
||||
html_writer::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version->id,
|
||||
get_string('misdepinfoversion', 'core_plugin')),
|
||||
'misdepinfoversion d-inline-block mr-3 mb-1'
|
||||
'misdepinfoversion'
|
||||
);
|
||||
|
||||
$info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')),
|
||||
'misdepdownload d-inline-block mr-3 mb-1');
|
||||
$info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')), 'misdepdownload');
|
||||
|
||||
if ($pluginman->is_remote_plugin_installable($plugin->component, $plugin->version->version, $reason)) {
|
||||
$info .= $this->output->single_button(
|
||||
new moodle_url($this->page->url, array('installdep' => $plugin->component)),
|
||||
get_string('dependencyinstall', 'core_plugin'),
|
||||
'post',
|
||||
array('class' => 'singlebutton dependencyinstall mr-3 mb-1')
|
||||
array('class' => 'singlebutton dependencyinstall')
|
||||
);
|
||||
} else {
|
||||
$reasonhelp = $this->info_remote_plugin_not_installable($reason);
|
||||
if ($reasonhelp) {
|
||||
$info .= html_writer::div($reasonhelp, 'reasonhelp dependencyinstall d-inline-block mr-3 mb-1');
|
||||
$info .= html_writer::div($reasonhelp, 'reasonhelp dependencyinstall');
|
||||
}
|
||||
}
|
||||
|
||||
$info .= $this->output->container_end(); // End of .actions container.
|
||||
|
||||
$table->data[] = array(
|
||||
html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component text-muted small'),
|
||||
html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component'),
|
||||
$plugin->version->release,
|
||||
$plugin->version->version,
|
||||
implode(' ', $supportedmoodles),
|
||||
implode($supportedmoodles, ' '),
|
||||
$info
|
||||
);
|
||||
}
|
||||
@@ -1472,38 +1452,24 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @param \core\plugininfo\base $plugin the plugin we are rendering the row for.
|
||||
* @param core_plugin_manager $pluginman provides data on all the plugins.
|
||||
* @param string $version
|
||||
* @param int $branch the current Moodle branch
|
||||
* @return string HTML code
|
||||
*/
|
||||
protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version, $branch = null) {
|
||||
protected function required_column(\core\plugininfo\base $plugin, core_plugin_manager $pluginman, $version) {
|
||||
|
||||
$requires = array();
|
||||
$displayuploadlink = false;
|
||||
$displayupdateslink = false;
|
||||
|
||||
$requirements = $pluginman->resolve_requirements($plugin, $version, $branch);
|
||||
foreach ($requirements as $reqname => $reqinfo) {
|
||||
foreach ($pluginman->resolve_requirements($plugin, $version) as $reqname => $reqinfo) {
|
||||
if ($reqname === 'core') {
|
||||
if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OK) {
|
||||
$class = 'requires-ok text-muted';
|
||||
$class = 'requires-ok';
|
||||
$label = '';
|
||||
} else {
|
||||
$class = 'requires-failed';
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
|
||||
}
|
||||
|
||||
if ($branch != null && !$plugin->is_core_compatible_satisfied($branch)) {
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::span(get_string('incompatibleversion', 'core_plugin', $branch), 'dep dep-core').
|
||||
' '.$label, array('class' => $class));
|
||||
|
||||
} else if ($branch != null && $plugin->pluginsupported != null) {
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::span(get_string('moodlebranch', 'core_plugin',
|
||||
array('min' => $plugin->pluginsupported[0], 'max' => $plugin->pluginsupported[1])), 'dep dep-core').
|
||||
' '.$label, array('class' => $class));
|
||||
|
||||
} else if ($reqinfo->reqver != ANY_VERSION) {
|
||||
if ($reqinfo->reqver != ANY_VERSION) {
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::span(get_string('moodleversion', 'core_plugin', $plugin->versionrequires), 'dep dep-core').
|
||||
' '.$label, array('class' => $class));
|
||||
@@ -1514,7 +1480,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OK) {
|
||||
$label = '';
|
||||
$class = 'requires-ok text-muted';
|
||||
$class = 'requires-ok';
|
||||
|
||||
} else if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_MISSING) {
|
||||
if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) {
|
||||
@@ -1568,14 +1534,13 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
$out = html_writer::tag('ul', implode("\n", $requires), array('class' => 'm-0'));
|
||||
$out = html_writer::tag('ul', implode("\n", $requires));
|
||||
|
||||
if ($displayuploadlink) {
|
||||
$out .= html_writer::div(
|
||||
html_writer::link(
|
||||
new moodle_url('/admin/tool/installaddon/'),
|
||||
get_string('dependencyuploadmissing', 'core_plugin'),
|
||||
array('class' => 'btn btn-secondary btn-sm m-1')
|
||||
get_string('dependencyuploadmissing', 'core_plugin')
|
||||
),
|
||||
'dependencyuploadmissing'
|
||||
);
|
||||
@@ -1585,20 +1550,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= html_writer::div(
|
||||
html_writer::link(
|
||||
new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1)),
|
||||
get_string('checkforupdates', 'core_plugin'),
|
||||
array('class' => 'btn btn-secondary btn-sm m-1')
|
||||
get_string('checkforupdates', 'core_plugin')
|
||||
),
|
||||
'checkforupdates'
|
||||
);
|
||||
}
|
||||
|
||||
// Check if supports is present, and $branch is not in, only if $incompatible check was ok.
|
||||
if ($plugin->pluginsupported != null && $class == 'requires-ok' && $branch != null) {
|
||||
if ($pluginman->check_explicitly_supported($plugin, $branch) == $pluginman::VERSION_NOT_SUPPORTED) {
|
||||
$out .= html_writer::div(get_string('notsupported', 'core_plugin', $branch));
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
|
||||
}
|
||||
@@ -1945,7 +1902,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('status'),
|
||||
);
|
||||
$servertable->colclasses = array('centeralign name', 'centeralign info', 'leftalign report', 'leftalign plugin', 'centeralign status');
|
||||
$servertable->attributes['class'] = 'admintable environmenttable generaltable table-sm';
|
||||
$servertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$servertable->id = 'serverstatus';
|
||||
|
||||
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
@@ -1958,7 +1915,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('status'),
|
||||
);
|
||||
$othertable->colclasses = array('aligncenter info', 'alignleft report', 'alignleft plugin', 'aligncenter status');
|
||||
$othertable->attributes['class'] = 'admintable environmenttable generaltable table-sm';
|
||||
$othertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$othertable->id = 'otherserverstatus';
|
||||
|
||||
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
@@ -2054,7 +2011,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
if (empty($CFG->docroot) or $environment_result->plugin) {
|
||||
$report = get_string($stringtouse, 'admin', $rec);
|
||||
} else {
|
||||
$report = $this->doc_link(join('/', $linkparts), get_string($stringtouse, 'admin', $rec), true);
|
||||
$report = $this->doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec), true);
|
||||
}
|
||||
// Enclose report text in div so feedback text will be displayed underneath it.
|
||||
$report = html_writer::div($report);
|
||||
|
||||
@@ -43,7 +43,7 @@ abstract class core_role_capability_table_base {
|
||||
protected $id;
|
||||
|
||||
/** Added to the class="" attribute on output. */
|
||||
protected $classes = array('rolecap table-hover');
|
||||
protected $classes = array('rolecap');
|
||||
|
||||
/** Default number of capabilities in the table for the search UI to be shown. */
|
||||
const NUM_CAPS_FOR_SEARCH = 12;
|
||||
|
||||
@@ -50,7 +50,6 @@ class core_role_check_capability_table extends core_role_capability_table_base {
|
||||
$this->contextname = $contextname;
|
||||
$this->stryes = get_string('yes');
|
||||
$this->strno = get_string('no');
|
||||
$this->add_classes(['table-striped']);
|
||||
}
|
||||
|
||||
protected function add_header_cells() {
|
||||
|
||||
@@ -55,7 +55,6 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
foreach ($levels as $level => $classname) {
|
||||
$this->allcontextlevels[$level] = context_helper::get_level_name($level);
|
||||
}
|
||||
$this->add_classes(['table-striped']);
|
||||
}
|
||||
|
||||
protected function load_current_permissions() {
|
||||
|
||||
@@ -66,9 +66,9 @@ class core_role_override_permissions_table_advanced extends core_role_capability
|
||||
$rowattributes = parent::get_row_attributes($capability);
|
||||
if ($this->permissions[$capability->name] !== 0) {
|
||||
if (empty($rowattributes['class'])) {
|
||||
$rowattributes['class'] = "overriddenpermission table-warning";
|
||||
$rowattributes['class'] = "overriddenpermission";
|
||||
} else {
|
||||
$rowattributes['class'] .= " overriddenpermission table-warning";
|
||||
$rowattributes['class'] .= " overriddenpermission";
|
||||
}
|
||||
}
|
||||
return $rowattributes;
|
||||
|
||||
@@ -25,12 +25,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
$temp->add(new admin_setting_configcheckbox('allowcohortthemes', new lang_string('allowcohortthemes', 'admin'), new lang_string('configallowcohortthemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), new lang_string('configallowthemechangeonurl', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), new lang_string('configallowuserblockhiding', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('langmenuinsecurelayout',
|
||||
new lang_string('langmenuinsecurelayout', 'admin'),
|
||||
new lang_string('langmenuinsecurelayout_desc', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('logininfoinsecurelayout',
|
||||
new lang_string('logininfoinsecurelayout', 'admin'),
|
||||
new lang_string('logininfoinsecurelayout_desc', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtextarea('custommenuitems', new lang_string('custommenuitems', 'admin'),
|
||||
new lang_string('configcustommenuitems', 'admin'), '', PARAM_RAW, '50', '10'));
|
||||
$temp->add(new admin_setting_configtextarea(
|
||||
|
||||
@@ -100,11 +100,10 @@ if (($hassiteconfig || has_any_capability(array(
|
||||
new lang_string('allowexternalbackpack', 'badges'),
|
||||
new lang_string('allowexternalbackpack_desc', 'badges'), 1));
|
||||
|
||||
$bp = $DB->get_record('badge_external_backpack', ['backpackweburl' => BADGRIO_BACKPACKWEBURL]);
|
||||
$backpacksettings->add(new admin_setting_configselect('badges_site_backpack',
|
||||
new lang_string('sitebackpack', 'badges'),
|
||||
new lang_string('sitebackpack_help', 'badges'),
|
||||
$bp->id, $choices));
|
||||
1, $choices));
|
||||
|
||||
$warning = badges_verify_site_backpack();
|
||||
if (!empty($warning)) {
|
||||
|
||||
@@ -181,30 +181,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
|
||||
}
|
||||
|
||||
// Add a category for the Activity Chooser.
|
||||
$ADMIN->add('courses', new admin_category('activitychooser', new lang_string('activitychoosercategory', 'course')));
|
||||
$temp = new admin_settingpage('activitychoosersettings', new lang_string('activitychoosersettings', 'course'));
|
||||
$temp->add(
|
||||
new admin_setting_configselect(
|
||||
'activitychoosertabmode',
|
||||
new lang_string('activitychoosertabmode', 'course'),
|
||||
new lang_string('activitychoosertabmode_desc', 'course'),
|
||||
0,
|
||||
[
|
||||
0 => new lang_string('activitychoosertabmodeone', 'course'),
|
||||
1 => new lang_string('activitychoosertabmodetwo', 'course'),
|
||||
2 => new lang_string('activitychoosertabmodethree', 'course'),
|
||||
]
|
||||
)
|
||||
);
|
||||
$ADMIN->add('activitychooser', $temp);
|
||||
$ADMIN->add('activitychooser',
|
||||
new admin_externalpage('activitychooserrecommended', new lang_string('activitychooserrecommendations', 'course'),
|
||||
new moodle_url('/course/recommendations.php'),
|
||||
array('moodle/course:recommendactivity')
|
||||
)
|
||||
);
|
||||
|
||||
// Add a category for backups.
|
||||
$ADMIN->add('courses', new admin_category('backups', new lang_string('backups','admin')));
|
||||
|
||||
@@ -253,11 +229,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
|
||||
array('value' => 1, 'locked' => 0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_contentbankcontent',
|
||||
new lang_string('generalcontentbankcontent', 'backup'),
|
||||
new lang_string('configgeneralcontentbankcontent', 'backup'),
|
||||
['value' => 1, 'locked' => 0])
|
||||
);
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
@@ -279,12 +250,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
|
||||
array('value' => 1, 'locked' => 0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_import_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock(
|
||||
'backup/backup_import_contentbankcontent',
|
||||
new lang_string('generalcontentbankcontent', 'backup'),
|
||||
new lang_string('configgeneralcontentbankcontent', 'backup'),
|
||||
['value' => 1, 'locked' => 0])
|
||||
);
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
@@ -311,8 +276,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$maxkeptoptions = array(
|
||||
0 => new lang_string('all'), 1 => '1',
|
||||
2 => '2',
|
||||
3 => '3',
|
||||
4 => '4',
|
||||
5 => '5',
|
||||
10 => '10',
|
||||
20 => '20',
|
||||
@@ -404,12 +367,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_groups', new lang_string('generalgroups', 'backup'),
|
||||
new lang_string('configgeneralgroups', 'backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_competencies', new lang_string('generalcompetencies','backup'), new lang_string('configgeneralcompetencies','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox(
|
||||
'backup/backup_auto_contentbankcontent',
|
||||
new lang_string('generalcontentbankcontent', 'backup'),
|
||||
new lang_string('configgeneralcontentbankcontent', 'backup'),
|
||||
1)
|
||||
);
|
||||
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
|
||||
@@ -470,9 +427,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_competencies',
|
||||
new lang_string('generalcompetencies', 'backup'),
|
||||
new lang_string('configrestorecompetencies', 'backup'), array('value' => 1, 'locked' => 0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('restore/restore_general_contentbankcontent',
|
||||
new lang_string('generalcontentbankcontent', 'backup'),
|
||||
new lang_string('configrestorecontentbankcontent', 'backup'), array('value' => 1, 'locked' => 0)));
|
||||
|
||||
// Restore defaults when merging into another course.
|
||||
$temp->add(new admin_setting_heading('mergerestoredefaults', new lang_string('mergerestoredefaults', 'backup'), ''));
|
||||
|
||||
@@ -10,6 +10,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp = new admin_settingpage('experimentalsettings', new lang_string('experimentalsettings', 'admin'));
|
||||
//TODO: Re-enable cc-import once re-implemented in 2.0.x
|
||||
//$temp->add(new admin_setting_configcheckbox('enableimsccimport', new lang_string('enable_cc_import', 'imscc'), new lang_string('enable_cc_import_description', 'imscc'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', new lang_string('enablesafebrowserintegration', 'admin'), new lang_string('configenablesafebrowserintegration', 'admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('dndallowtextandlinks', new lang_string('dndallowtextandlinks', 'admin'), new lang_string('configdndallowtextandlinks', 'admin'), 0));
|
||||
|
||||
|
||||
+2
-17
@@ -24,21 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
// H5P overview.
|
||||
$ADMIN->add('h5p', new admin_externalpage('h5poverview', get_string('h5poverview', 'core_h5p'),
|
||||
new moodle_url('/h5p/overview.php'), ['moodle/site:config']));
|
||||
|
||||
// Manage H5P libraries page.
|
||||
$ADMIN->add('h5p', new admin_externalpage('h5pmanagelibraries', get_string('h5pmanage', 'core_h5p'),
|
||||
// Settings page.
|
||||
$ADMIN->add('h5p', new admin_externalpage('h5psettings', get_string('h5pmanage', 'core_h5p'),
|
||||
new moodle_url('/h5p/libraries.php'), ['moodle/site:config', 'moodle/h5p:updatelibraries']));
|
||||
|
||||
// H5P settings.
|
||||
$defaulth5plib = \core_h5p\local\library\autoloader::get_default_handler_library();
|
||||
if (!empty($defaulth5plib)) {
|
||||
// As for now this page only has this setting, it will be hidden if there isn't any H5P libraries handler defined.
|
||||
$settings = new admin_settingpage('h5psettings', new lang_string('h5psettings', 'core_h5p'));
|
||||
$ADMIN->add('h5p', $settings);
|
||||
|
||||
$settings->add(new admin_settings_h5plib_handler_select('h5plibraryhandler', new lang_string('h5plibraryhandler', 'core_h5p'),
|
||||
new lang_string('h5plibraryhandler_help', 'core_h5p'), $defaulth5plib));
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file defines the settings pages for licenses.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2020 Tom Dickman <tomdickman@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/licenselib.php');
|
||||
|
||||
if ($hassiteconfig) {
|
||||
|
||||
$temp = new admin_settingpage('licensesettings', new lang_string('licensesettings', 'admin'));
|
||||
|
||||
$licenses = license_manager::get_active_licenses_as_array();
|
||||
|
||||
$temp->add(new admin_setting_configselect('sitedefaultlicense',
|
||||
new lang_string('configsitedefaultlicense', 'admin'),
|
||||
new lang_string('configsitedefaultlicensehelp', 'admin'),
|
||||
'unknown',
|
||||
$licenses));
|
||||
$temp->add(new admin_setting_configcheckbox('rememberuserlicensepref',
|
||||
new lang_string('rememberuserlicensepref', 'admin'),
|
||||
new lang_string('rememberuserlicensepref_help', 'admin'),
|
||||
1));
|
||||
$ADMIN->add('license', $temp);
|
||||
}
|
||||
+14
-13
@@ -182,6 +182,20 @@ if ($hassiteconfig) {
|
||||
$plugin->load_settings($ADMIN, 'mlbackendsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
/// License types
|
||||
$ADMIN->add('modules', new admin_category('licensesettings', new lang_string('licenses')));
|
||||
$temp = new admin_settingpage('managelicenses', new lang_string('managelicenses', 'admin'));
|
||||
|
||||
require_once($CFG->libdir . '/licenselib.php');
|
||||
$licenses = array();
|
||||
$array = explode(',', $CFG->licenses);
|
||||
foreach ($array as $value) {
|
||||
$licenses[$value] = new lang_string($value, 'license');
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('sitedefaultlicense', new lang_string('configsitedefaultlicense','admin'), new lang_string('configsitedefaultlicensehelp','admin'), 'allrightsreserved', $licenses));
|
||||
$temp->add(new admin_setting_managelicenses());
|
||||
$ADMIN->add('licensesettings', $temp);
|
||||
|
||||
/// Filter plugins
|
||||
$ADMIN->add('modules', new admin_category('filtersettings', new lang_string('managefilters')));
|
||||
|
||||
@@ -643,19 +657,6 @@ if ($hassiteconfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// Content bank content types.
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('contenbanksettings', new lang_string('contentbank')));
|
||||
$temp = new admin_settingpage('managecontentbanktypes', new lang_string('managecontentbanktypes'));
|
||||
$temp->add(new admin_setting_managecontentbankcontenttypes());
|
||||
$ADMIN->add('contenbanksettings', $temp);
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('contenttype');
|
||||
foreach ($plugins as $plugin) {
|
||||
/** @var \core\plugininfo\contentbank $plugin */
|
||||
$plugin->load_settings($ADMIN, 'contenbanksettings', $hassiteconfig);
|
||||
}
|
||||
}
|
||||
|
||||
/// Add all local plugins - must be always last!
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('localplugins', new lang_string('localplugins')));
|
||||
|
||||
@@ -100,9 +100,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configtext('minpasswordupper', new lang_string('minpasswordupper', 'admin'), new lang_string('configminpasswordupper', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('minpasswordnonalphanum', new lang_string('minpasswordnonalphanum', 'admin'), new lang_string('configminpasswordnonalphanum', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('maxconsecutiveidentchars', new lang_string('maxconsecutiveidentchars', 'admin'), new lang_string('configmaxconsecutiveidentchars', 'admin'), 0, PARAM_INT));
|
||||
$temp->add(new admin_setting_configcheckbox('passwordpolicycheckonlogin',
|
||||
new lang_string('passwordpolicycheckonlogin', 'admin'),
|
||||
new lang_string('configpasswordpolicycheckonlogin', 'admin'), 0));
|
||||
|
||||
$temp->add(new admin_setting_configtext('passwordreuselimit',
|
||||
new lang_string('passwordreuselimit', 'admin'),
|
||||
|
||||
@@ -44,10 +44,15 @@ $temp = new admin_settingpage('sessionhandling', new lang_string('sessionhandlin
|
||||
if (empty($CFG->session_handler_class) and $DB->session_lock_supported()) {
|
||||
$temp->add(new admin_setting_configcheckbox('dbsessions', new lang_string('dbsessions', 'admin'), new lang_string('configdbsessions', 'admin'), 0));
|
||||
}
|
||||
|
||||
$temp->add(new admin_setting_configduration('sessiontimeout', new lang_string('sessiontimeout', 'admin'),
|
||||
new lang_string('configsessiontimeout', 'admin'), 8 * 60 * 60));
|
||||
|
||||
$temp->add(new admin_setting_configselect('sessiontimeout', new lang_string('sessiontimeout', 'admin'), new lang_string('configsessiontimeout', 'admin'), 7200, array(14400 => new lang_string('numhours', '', 4),
|
||||
10800 => new lang_string('numhours', '', 3),
|
||||
7200 => new lang_string('numhours', '', 2),
|
||||
5400 => new lang_string('numhours', '', '1.5'),
|
||||
3600 => new lang_string('numminutes', '', 60),
|
||||
2700 => new lang_string('numminutes', '', 45),
|
||||
1800 => new lang_string('numminutes', '', 30),
|
||||
900 => new lang_string('numminutes', '', 15),
|
||||
300 => new lang_string('numminutes', '', 5))));
|
||||
$temp->add(new admin_setting_configtext('sessioncookie', new lang_string('sessioncookie', 'admin'), new lang_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiepath', new lang_string('sessioncookiepath', 'admin'), new lang_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
|
||||
$temp->add(new admin_setting_configtext('sessioncookiedomain', new lang_string('sessioncookiedomain', 'admin'), new lang_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
|
||||
@@ -92,10 +97,7 @@ $options = array(
|
||||
GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'),
|
||||
new lang_string('configgetremoteaddrconf', 'admin'),
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP, $options));
|
||||
$temp->add(new admin_setting_configtext('reverseproxyignore', new lang_string('reverseproxyignore', 'admin'), new lang_string('configreverseproxyignore', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'), new lang_string('configgetremoteaddrconf', 'admin'), 0, $options));
|
||||
|
||||
$temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
|
||||
|
||||
@@ -20,9 +20,6 @@ $moodleservices = new admin_settingpage('moodleservices', new lang_string('moodl
|
||||
'admin'));
|
||||
$ADMIN->add('root', $moodleservices);
|
||||
|
||||
$userfeedback = new admin_settingpage('userfeedback', new lang_string('feedbacksettings', 'admin'));
|
||||
$ADMIN->add('root', $userfeedback);
|
||||
|
||||
if ($hassiteconfig) {
|
||||
$optionalsubsystems = new admin_settingpage('optionalsubsystems', new lang_string('advancedfeatures', 'admin'));
|
||||
$ADMIN->add('root', $optionalsubsystems);
|
||||
@@ -35,7 +32,6 @@ $ADMIN->add('root', new admin_category('analytics', new lang_string('analytics',
|
||||
$ADMIN->add('root', new admin_category('competencies', new lang_string('competencies', 'core_competency')));
|
||||
$ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empty($CFG->enablebadges)));
|
||||
$ADMIN->add('root', new admin_category('h5p', new lang_string('h5p', 'core_h5p')));
|
||||
$ADMIN->add('root', new admin_category('license', new lang_string('license')));
|
||||
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
|
||||
$ADMIN->add('root', new admin_category('language', new lang_string('language')));
|
||||
$ADMIN->add('root', new admin_category('messaging', new lang_string('messagingcategory', 'admin')));
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains call to feedback settings
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2020 Shamim Rezaie <shamim@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($hassiteconfig) {
|
||||
|
||||
$userfeedback->add(new admin_setting_configcheckbox('enableuserfeedback',
|
||||
new lang_string('enableuserfeedback', 'admin'),
|
||||
new lang_string('enableuserfeedback_desc', 'admin'), 1, 1, 0));
|
||||
|
||||
$options = [
|
||||
core_userfeedback::REMIND_AFTER_UPGRADE => new lang_string('userfeedbackafterupgrade', 'admin'),
|
||||
core_userfeedback::REMIND_PERIODICALLY => new lang_string('userfeedbackperiodically', 'admin'),
|
||||
core_userfeedback::REMIND_NEVER => new lang_string('never'),
|
||||
];
|
||||
$userfeedback->add(new admin_setting_configselect('userfeedback_nextreminder',
|
||||
new lang_string('userfeedbacknextreminder', 'admin'),
|
||||
new lang_string('userfeedbacknextreminder_desc', 'admin'), 1, $options));
|
||||
$userfeedback->hide_if('userfeedback_nextreminder', 'enableuserfeedback');
|
||||
|
||||
$userfeedback->add(new admin_setting_configtext('userfeedback_remindafter',
|
||||
new lang_string('userfeedbackremindafter', 'admin'),
|
||||
new lang_string('userfeedbackremindafter_desc', 'admin'), 90, PARAM_INT));
|
||||
$userfeedback->hide_if('userfeedback_remindafter', 'enableuserfeedback');
|
||||
$userfeedback->hide_if('userfeedback_remindafter', 'userfeedback_nextreminder', 'eq', 3);
|
||||
|
||||
}
|
||||
@@ -186,7 +186,6 @@ if ($hassiteconfig
|
||||
'email' => new lang_string('email'),
|
||||
'city' => new lang_string('city'),
|
||||
'country' => new lang_string('country'),
|
||||
'moodlenetprofile' => new lang_string('moodlenetprofile', 'user'),
|
||||
'timezone' => new lang_string('timezone'),
|
||||
'webpage' => new lang_string('webpage'),
|
||||
'icqnumber' => new lang_string('icqnumber'),
|
||||
|
||||
@@ -62,8 +62,6 @@ if (null !== $logid) {
|
||||
$renderer = $PAGE->get_renderer('tool_task');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Output the search form.
|
||||
echo $OUTPUT->render_from_template('core_admin/tasklogs', (object) [
|
||||
'action' => $pageurl->out(),
|
||||
'filter' => $filter,
|
||||
@@ -86,7 +84,6 @@ echo $OUTPUT->render_from_template('core_admin/tasklogs', (object) [
|
||||
],
|
||||
]);
|
||||
|
||||
// Output any matching logs.
|
||||
$table = new \core_admin\task_log_table($filter, $result);
|
||||
$table->baseurl = $pageurl;
|
||||
$table->out(100, false);
|
||||
|
||||
@@ -49,28 +49,15 @@
|
||||
}}
|
||||
<div class="form-item row" id="{{id}}">
|
||||
<div class="form-label col-sm-3 text-sm-right">
|
||||
{{#customcontrol}}
|
||||
<p {{#labelfor}}id="{{labelfor}}_label"{{/labelfor}}>
|
||||
{{{title}}}
|
||||
{{#override}}
|
||||
<div class="alert alert-info">{{override}}</div>
|
||||
{{/override}}
|
||||
{{#warning}}
|
||||
<div class="alert alert-warning">{{warning}}</div>
|
||||
{{/warning}}
|
||||
</p>
|
||||
{{/customcontrol}}
|
||||
{{^customcontrol}}
|
||||
<label {{#labelfor}}for="{{labelfor}}"{{/labelfor}}>
|
||||
{{{title}}}
|
||||
{{#override}}
|
||||
<div class="alert alert-info">{{override}}</div>
|
||||
{{/override}}
|
||||
{{#warning}}
|
||||
<div class="alert alert-warning">{{warning}}</div>
|
||||
{{/warning}}
|
||||
</label>
|
||||
{{/customcontrol}}
|
||||
<label {{#labelfor}}for="{{labelfor}}"{{/labelfor}}>
|
||||
{{{title}}}
|
||||
{{#override}}
|
||||
<div class="form-overridden">{{override}}</div>
|
||||
{{/override}}
|
||||
{{#warning}}
|
||||
<div class="form-warning">{{warning}}</div>
|
||||
{{/warning}}
|
||||
</label>
|
||||
<span class="form-shortname d-block small text-muted">{{{name}}}</span>
|
||||
</div>
|
||||
<div class="form-setting col-sm-9">
|
||||
@@ -85,16 +72,3 @@
|
||||
{{#dependenton}}<div class="form-dependenton mb-4 text-muted">{{{.}}}</div>{{/dependenton}}
|
||||
</div>
|
||||
</div>
|
||||
{{#customcontrol}}
|
||||
{{#js}}
|
||||
require(['jquery'], function($) {
|
||||
$('#{{id}}_label').css('cursor', 'default');
|
||||
$('#{{id}}_label').click(function() {
|
||||
$('#{{id}}')
|
||||
.find('button, a, input:not([type="hidden"]), select, textarea, [tabindex]')
|
||||
.filter(':not([disabled]):not([tabindex="0"]):not([tabindex="-1"])')
|
||||
.first().focus();
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
{{/customcontrol}}
|
||||
|
||||
@@ -24,30 +24,15 @@
|
||||
* size - form element size
|
||||
* value - form element value
|
||||
* id - element id
|
||||
* forced - has value been defined in config.php
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "test",
|
||||
"id": "test0",
|
||||
"size": "8",
|
||||
"value": "secret",
|
||||
"forced": false
|
||||
"value": "secret"
|
||||
}
|
||||
}}
|
||||
{{#forced}}
|
||||
<div class="form-password">
|
||||
<input type="text"
|
||||
name = "{{ name }}"
|
||||
id="{{ id }}"
|
||||
value="********"
|
||||
size="{{ size }}"
|
||||
class="form-control"
|
||||
disabled
|
||||
>
|
||||
</div>
|
||||
{{/forced}}
|
||||
{{^forced}}
|
||||
<div class="form-password">
|
||||
<span data-passwordunmask="wrapper" data-passwordunmaskid="{{ id }}">
|
||||
<span data-passwordunmask="editor">
|
||||
@@ -76,4 +61,3 @@ require(['core_form/passwordunmask'], function(PasswordUnmask) {
|
||||
new PasswordUnmask("{{ id }}");
|
||||
});
|
||||
{{/js}}
|
||||
{{/forced}}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<h3 class="adminpagetitle"><a href="{{url}}">{{{title}}}</a></h3>
|
||||
<ul class="adminpagepath" aria-label="{{#str}} pagepath, core {{/str}}">
|
||||
{{#path}}
|
||||
<li class="small text-muted">{{.}}</li>
|
||||
<li>{{.}}</li>
|
||||
{{/path}}
|
||||
</ul>
|
||||
<fieldset class="adminsettings">
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
{{!
|
||||
@template core_admin/tasklogs
|
||||
|
||||
This is the template for the search form which appears above the task logs report.
|
||||
Task Logs template.
|
||||
}}
|
||||
<form class="form-inline" method="GET" action="{{{action}}}">
|
||||
<label class="sr-only" for="tasklog-filter">{{#str}}filter{{/str}}</label>
|
||||
|
||||
@@ -46,8 +46,7 @@ if ($data) {
|
||||
$emailuser->email = $data->recipient;
|
||||
$emailuser->id = -99;
|
||||
|
||||
$subject = get_string('testoutgoingmailconf_subject', 'admin',
|
||||
format_string($SITE->fullname, true, ['context' => context_system::instance()]));
|
||||
$subject = get_string('testoutgoingmailconf_subject', 'admin', $SITE->fullname);
|
||||
$messagetext = get_string('testoutgoingmailconf_message', 'admin');
|
||||
|
||||
// Manage Moodle debugging options.
|
||||
|
||||
@@ -6,11 +6,11 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email | auth | confirmed | lastip | institution | department |
|
||||
| user1 | User | One | one@example.com | manual | 0 | 127.0.1.1 | moodle | red |
|
||||
| user2 | User | Two | two@example.com | ldap | 1 | 0.0.0.0 | moodle | blue |
|
||||
| user3 | User | Three | three@example.com | manual | 1 | 0.0.0.0 | | |
|
||||
| user4 | User | Four | four@example.com | ldap | 0 | 127.0.1.2 | | |
|
||||
| username | firstname | lastname | email | auth | confirmed | lastip |
|
||||
| user1 | User | One | one@example.com | manual | 0 | 127.0.1.1 |
|
||||
| user2 | User | Two | two@example.com | ldap | 1 | 0.0.0.0 |
|
||||
| user3 | User | Three | three@example.com | manual | 1 | 0.0.0.0 |
|
||||
| user4 | User | Four | four@example.com | ldap | 0 | 127.0.1.2 |
|
||||
And the following "cohorts" exist:
|
||||
| name | idnumber |
|
||||
| Cohort 1 | CH1 |
|
||||
@@ -104,15 +104,3 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
|
||||
And I should see "User Two"
|
||||
And I should see "User Three"
|
||||
And I should see "User Four"
|
||||
|
||||
Scenario: Filter users by institution and department
|
||||
When I set the field "id_institution" to "moodle"
|
||||
And I press "Add filter"
|
||||
Then I should see "User One"
|
||||
And I should see "User Two"
|
||||
And I should not see "User Three"
|
||||
And I should not see "User Four"
|
||||
And I set the field "id_department" to "red"
|
||||
And I press "Add filter"
|
||||
And I should see "User One"
|
||||
And I should not see "User Two"
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace tool_analytics\output;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use plugin_renderer_base;
|
||||
|
||||
use templatable;
|
||||
use renderable;
|
||||
|
||||
/**
|
||||
* Renderer class.
|
||||
@@ -73,12 +74,14 @@ class renderer extends plugin_renderer_base {
|
||||
* @return string HTML
|
||||
*/
|
||||
public function render_evaluate_results($results, $logs = array()) {
|
||||
global $OUTPUT;
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach ($results as $timesplittingid => $result) {
|
||||
|
||||
if (!CLI_SCRIPT) {
|
||||
$output .= $this->output->box_start('generalbox mb-3');
|
||||
$output .= $OUTPUT->box_start('generalbox mb-3');
|
||||
}
|
||||
|
||||
// Check that the array key is a string, not all results depend on time splitting methods (e.g. general errors).
|
||||
@@ -87,48 +90,47 @@ class renderer extends plugin_renderer_base {
|
||||
$langstrdata = (object)array('name' => $timesplitting->get_name(), 'id' => $timesplittingid);
|
||||
|
||||
if (CLI_SCRIPT) {
|
||||
$output .= $this->output->heading(get_string('scheduledanalysisresultscli', 'tool_analytics', $langstrdata), 3);
|
||||
$output .= $OUTPUT->heading(get_string('scheduledanalysisresultscli', 'tool_analytics', $langstrdata), 3);
|
||||
} else {
|
||||
$output .= $this->output->heading(get_string('scheduledanalysisresults', 'tool_analytics', $langstrdata), 3);
|
||||
$output .= $OUTPUT->heading(get_string('scheduledanalysisresults', 'tool_analytics', $langstrdata), 3);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result->status == 0) {
|
||||
$output .= $this->output->notification(get_string('goodmodel', 'tool_analytics'),
|
||||
$output .= $OUTPUT->notification(get_string('goodmodel', 'tool_analytics'),
|
||||
\core\output\notification::NOTIFY_SUCCESS);
|
||||
} else if ($result->status === \core_analytics\model::NO_DATASET) {
|
||||
$output .= $this->output->notification(get_string('nodatatoevaluate', 'tool_analytics'),
|
||||
$output .= $OUTPUT->notification(get_string('nodatatoevaluate', 'tool_analytics'),
|
||||
\core\output\notification::NOTIFY_WARNING);
|
||||
}
|
||||
|
||||
if (isset($result->score)) {
|
||||
// Score.
|
||||
$output .= $this->output->heading(get_string('accuracy', 'tool_analytics') . ': ' .
|
||||
$output .= $OUTPUT->heading(get_string('accuracy', 'tool_analytics') . ': ' .
|
||||
round(floatval($result->score), 4) * 100 . '%', 4);
|
||||
}
|
||||
|
||||
if (!empty($result->info)) {
|
||||
foreach ($result->info as $message) {
|
||||
$output .= $this->output->notification($message, \core\output\notification::NOTIFY_WARNING);
|
||||
$output .= $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CLI_SCRIPT) {
|
||||
$output .= $this->output->box_end();
|
||||
$output .= $OUTPUT->box_end();
|
||||
}
|
||||
}
|
||||
|
||||
// Info logged during evaluation.
|
||||
if (!empty($logs) && debugging()) {
|
||||
$output .= $this->output->heading(get_string('extrainfo', 'tool_analytics'), 3);
|
||||
$output .= $OUTPUT->heading(get_string('extrainfo', 'tool_analytics'), 3);
|
||||
foreach ($logs as $log) {
|
||||
$output .= $this->output->notification($log, \core\output\notification::NOTIFY_WARNING);
|
||||
$output .= $OUTPUT->notification($log, \core\output\notification::NOTIFY_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CLI_SCRIPT) {
|
||||
$output .= $this->output->single_button(new \moodle_url('/admin/tool/analytics/index.php'),
|
||||
get_string('continue'), 'get');
|
||||
$output .= $OUTPUT->single_button(new \moodle_url('/admin/tool/analytics/index.php'), get_string('continue'), 'get');
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -145,68 +147,62 @@ class renderer extends plugin_renderer_base {
|
||||
* @return string HTML
|
||||
*/
|
||||
public function render_get_predictions_results($trainresults = false, $trainlogs = array(), $predictresults = false, $predictlogs = array()) {
|
||||
global $OUTPUT;
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($trainresults || (!empty($trainlogs) && debugging())) {
|
||||
$output .= $this->output->heading(get_string('trainingresults', 'tool_analytics'), 3);
|
||||
$output .= $OUTPUT->heading(get_string('trainingresults', 'tool_analytics'), 3);
|
||||
}
|
||||
|
||||
if ($trainresults) {
|
||||
if ($trainresults->status == 0) {
|
||||
$output .= $this->output->notification(
|
||||
get_string('trainingprocessfinished', 'tool_analytics'),
|
||||
$output .= $OUTPUT->notification(get_string('trainingprocessfinished', 'tool_analytics'),
|
||||
\core\output\notification::NOTIFY_SUCCESS);
|
||||
} else if ($trainresults->status === \core_analytics\model::NO_DATASET ||
|
||||
$trainresults->status === \core_analytics\model::NOT_ENOUGH_DATA) {
|
||||
$output .= $this->output->notification(
|
||||
get_string('nodatatotrain', 'tool_analytics'),
|
||||
$output .= $OUTPUT->notification(get_string('nodatatotrain', 'tool_analytics'),
|
||||
\core\output\notification::NOTIFY_WARNING);
|
||||
} else {
|
||||
$output .= $this->output->notification(
|
||||
get_string('generalerror', 'tool_analytics', $trainresults->status),
|
||||
$output .= $OUTPUT->notification(get_string('generalerror', 'tool_analytics', $trainresults->status),
|
||||
\core\output\notification::NOTIFY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($trainlogs) && debugging()) {
|
||||
$output .= $this->output->heading(get_string('extrainfo', 'tool_analytics'), 4);
|
||||
$output .= $OUTPUT->heading(get_string('extrainfo', 'tool_analytics'), 4);
|
||||
foreach ($trainlogs as $log) {
|
||||
$output .= $this->output->notification($log, \core\output\notification::NOTIFY_WARNING);
|
||||
$output .= $OUTPUT->notification($log, \core\output\notification::NOTIFY_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if ($predictresults || (!empty($predictlogs) && debugging())) {
|
||||
$output .= $this->output->heading(
|
||||
get_string('predictionresults', 'tool_analytics'), 3, 'main mt-3');
|
||||
$output .= $OUTPUT->heading(get_string('predictionresults', 'tool_analytics'), 3, 'main mt-3');
|
||||
}
|
||||
|
||||
if ($predictresults) {
|
||||
if ($predictresults->status == 0) {
|
||||
$output .= $this->output->notification(
|
||||
get_string('predictionprocessfinished', 'tool_analytics'),
|
||||
$output .= $OUTPUT->notification(get_string('predictionprocessfinished', 'tool_analytics'),
|
||||
\core\output\notification::NOTIFY_SUCCESS);
|
||||
} else if ($predictresults->status === \core_analytics\model::NO_DATASET ||
|
||||
$predictresults->status === \core_analytics\model::NOT_ENOUGH_DATA) {
|
||||
$output .= $this->output->notification(
|
||||
get_string('nodatatopredict', 'tool_analytics'),
|
||||
$output .= $OUTPUT->notification(get_string('nodatatopredict', 'tool_analytics'),
|
||||
\core\output\notification::NOTIFY_WARNING);
|
||||
} else {
|
||||
$output .= $this->output->notification(
|
||||
get_string('generalerror', 'tool_analytics', $predictresults->status),
|
||||
$output .= $OUTPUT->notification(get_string('generalerror', 'tool_analytics', $predictresults->status),
|
||||
\core\output\notification::NOTIFY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($predictlogs) && debugging()) {
|
||||
$output .= $this->output->heading(get_string('extrainfo', 'tool_analytics'), 4);
|
||||
$output .= $OUTPUT->heading(get_string('extrainfo', 'tool_analytics'), 4);
|
||||
foreach ($predictlogs as $log) {
|
||||
$output .= $this->output->notification($log, \core\output\notification::NOTIFY_WARNING);
|
||||
$output .= $OUTPUT->notification($log, \core\output\notification::NOTIFY_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if (!CLI_SCRIPT) {
|
||||
$output .= $this->output->single_button(new \moodle_url('/admin/tool/analytics/index.php'),
|
||||
get_string('continue'), 'get');
|
||||
$output .= $OUTPUT->single_button(new \moodle_url('/admin/tool/analytics/index.php'), get_string('continue'), 'get');
|
||||
}
|
||||
|
||||
return $output;
|
||||
@@ -240,18 +236,17 @@ class renderer extends plugin_renderer_base {
|
||||
* @return string HTML
|
||||
*/
|
||||
public function render_analytics_disabled() {
|
||||
global $FULLME;
|
||||
global $OUTPUT, $PAGE, $FULLME;
|
||||
|
||||
$this->page->set_url($FULLME);
|
||||
$this->page->set_title(get_string('pluginname', 'tool_analytics'));
|
||||
$this->page->set_heading(get_string('pluginname', 'tool_analytics'));
|
||||
$PAGE->set_url($FULLME);
|
||||
$PAGE->set_title(get_string('pluginname', 'tool_analytics'));
|
||||
$PAGE->set_heading(get_string('pluginname', 'tool_analytics'));
|
||||
|
||||
$output = $this->output->header();
|
||||
$output .= $this->output->notification(get_string('analyticsdisabled', 'analytics'),
|
||||
\core\output\notification::NOTIFY_INFO);
|
||||
$output = $OUTPUT->header();
|
||||
$output .= $OUTPUT->notification(get_string('analyticsdisabled', 'analytics'), \core\output\notification::NOTIFY_INFO);
|
||||
$output .= \html_writer::tag('a', get_string('continue'), ['class' => 'btn btn-primary',
|
||||
'href' => (new \moodle_url('/'))->out()]);
|
||||
$output .= $this->output->footer();
|
||||
$output .= $OUTPUT->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
|
||||
// systems, but let's allow room for expansion.
|
||||
core_php_time_limit::raise(300);
|
||||
|
||||
$filter = optional_param('filter', '', PARAM_NOTAGS);
|
||||
$filter = optional_param('filter', '', PARAM_ALPHANUMEXT);
|
||||
$type = optional_param('type', false, PARAM_ALPHAEXT);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
$string['aim'] = 'This administration tool helps developers and test writers to create .feature files describing Moodle\'s functionalities and run them automatically. Step definitions available for use in .feature files are listed below.';
|
||||
$string['allavailablesteps'] = 'All available step definitions';
|
||||
$string['errorapproot'] = '$CFG->behat_ionic_dirroot is not pointing to a valid Moodle app developer install.';
|
||||
$string['errorapproot'] = '$CFG->behat_ionic_dirroot is not pointing to a valid Moodle Mobile developer install.';
|
||||
$string['errorbehatcommand'] = 'Error running behat CLI command. Try running "{$a} --help" manually from CLI to find out more about the problem.';
|
||||
$string['errorcomposer'] = 'Composer dependencies are not installed.';
|
||||
$string['errordataroot'] = '$CFG->behat_dataroot is not set or is invalid.';
|
||||
|
||||
@@ -55,13 +55,13 @@ class tool_behat {
|
||||
// The loaded steps depends on the component specified.
|
||||
behat_config_manager::update_config_file($component, false);
|
||||
|
||||
// The Moodle\BehatExtension\Definition\Printer\ConsoleDefinitionInformationPrinter will parse this search format.
|
||||
// The Moodle\BehatExtension\HelpPrinter\MoodleDefinitionsPrinter will parse this search format.
|
||||
if ($type) {
|
||||
$filter .= '&&' . $type;
|
||||
}
|
||||
|
||||
if ($filter) {
|
||||
$filteroption = ' -d ' . escapeshellarg($filter);
|
||||
$filteroption = ' -d "' . $filter . '"';
|
||||
} else {
|
||||
$filteroption = ' -di';
|
||||
}
|
||||
|
||||
@@ -44,9 +44,13 @@ class tool_behat_renderer extends plugin_renderer_base {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/behat/classes/behat_selectors.php');
|
||||
|
||||
$html = $this->output->header();
|
||||
$html .= $this->output->heading(get_string('pluginname', 'tool_behat'));
|
||||
$html .= $form->render();
|
||||
$html = $this->generic_info();
|
||||
|
||||
// Form.
|
||||
ob_start();
|
||||
$form->display();
|
||||
$html .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if (empty($stepsdefinitions)) {
|
||||
$stepsdefinitions = get_string('nostepsdefinitions', 'tool_behat');
|
||||
@@ -124,9 +128,7 @@ class tool_behat_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
public function render_error($msg) {
|
||||
|
||||
$html = $this->output->header();
|
||||
$html .= $this->output->heading(get_string('pluginname', 'tool_behat'));
|
||||
$html .= $this->generic_info();
|
||||
$html = $this->generic_info();
|
||||
|
||||
$a = new stdClass();
|
||||
$a->errormsg = $msg;
|
||||
@@ -151,7 +153,13 @@ class tool_behat_renderer extends plugin_renderer_base {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generic_info() {
|
||||
protected function generic_info() {
|
||||
|
||||
$title = get_string('pluginname', 'tool_behat');
|
||||
|
||||
// Header.
|
||||
$html = $this->output->header();
|
||||
$html .= $this->output->heading($title);
|
||||
|
||||
// Info.
|
||||
$installurl = behat_command::DOCS_URL;
|
||||
@@ -167,7 +175,8 @@ class tool_behat_renderer extends plugin_renderer_base {
|
||||
);
|
||||
|
||||
// List of steps.
|
||||
$html = $this->output->box_start();
|
||||
$html .= $this->output->box_start();
|
||||
$html .= html_writer::tag('h3', get_string('infoheading', 'tool_behat'));
|
||||
$html .= html_writer::tag('div', get_string('aim', 'tool_behat'));
|
||||
$html .= html_writer::start_tag('div');
|
||||
$html .= html_writer::start_tag('ul');
|
||||
|
||||
@@ -40,14 +40,8 @@ class steps_definitions_form extends moodleform {
|
||||
* @return void
|
||||
*/
|
||||
public function definition() {
|
||||
global $PAGE;
|
||||
|
||||
$mform = $this->_form;
|
||||
$output = $PAGE->get_renderer('tool_behat');
|
||||
|
||||
$mform->addElement('header', 'info', get_string('infoheading', 'tool_behat'));
|
||||
$mform->setExpanded('info', false);
|
||||
$mform->addElement('html', $output->generic_info());
|
||||
|
||||
$mform->addElement('header', 'filters', get_string('stepsdefinitionsfilters', 'tool_behat'));
|
||||
|
||||
|
||||
+14
-20
@@ -1,31 +1,25 @@
|
||||
#page-admin-tool-behat-index .steps-definitions {
|
||||
margin: 1rem auto;
|
||||
.steps-definitions {
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-color: #bbb;
|
||||
padding: 5px;
|
||||
margin: auto;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
#page-admin-tool-behat-index .steps-definitions .step {
|
||||
margin: 1rem 0 0 0;
|
||||
border: 1px solid #eee;
|
||||
padding: 1rem;
|
||||
.steps-definitions .step {
|
||||
margin: 10px 0 10px 0;
|
||||
}
|
||||
|
||||
#page-admin-tool-behat-index .steps-definitions .stepdescription {
|
||||
font-style: italic;
|
||||
.steps-definitions .stepdescription {
|
||||
color: #bf8c12;
|
||||
}
|
||||
|
||||
#page-admin-tool-behat-index .steps-definitions .stepcontent {
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
#page-admin-tool-behat-index .steps-definitions .steptype {
|
||||
.steps-definitions .steptype {
|
||||
color: #1467a6;
|
||||
margin-right: 1ex;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#page-admin-tool-behat-index .steps-definitions .stepapipath {
|
||||
font-family: monospace;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
#page-admin-tool-behat-index .steps-definitions .stepregex {
|
||||
.steps-definitions .stepregex {
|
||||
color: #060;
|
||||
}
|
||||
|
||||
@@ -143,15 +143,15 @@ Feature: Set up contextual data for tests
|
||||
And I log out
|
||||
And I log in as "user2"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Turn editing on" "button" should exist
|
||||
And "Turn editing on" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user3"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Turn editing on" "button" should exist
|
||||
And "Turn editing on" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user4"
|
||||
And I am on "Course 1" course homepage
|
||||
And "Turn editing on" "button" should exist
|
||||
And "Turn editing on" "link" should exist in current page administration
|
||||
And I log out
|
||||
And I log in as "user5"
|
||||
And I should see "You are logged in as"
|
||||
@@ -259,9 +259,9 @@ Feature: Set up contextual data for tests
|
||||
Then the "groups" select box should contain "Group 1 (1)"
|
||||
And the "groups" select box should contain "Group 2 (1)"
|
||||
And I set the field "groups" to "Group 1 (1)"
|
||||
And the "members" select box should contain "Student 1 (student1@example.com)"
|
||||
And the "members" select box should contain "Student 1"
|
||||
And I set the field "groups" to "Group 2 (1)"
|
||||
And the "members" select box should contain "Student 2 (student2@example.com)"
|
||||
And the "members" select box should contain "Student 2"
|
||||
|
||||
Scenario: Add cohorts and cohort members with data generator
|
||||
Given the following "categories" exist:
|
||||
|
||||
@@ -147,13 +147,13 @@ Feature: Verify that all form fields values can be get and set
|
||||
And I navigate to "Users > Groups" in current page administration
|
||||
# Select (multi-select & AJAX) - Checking "I set the field" and "select box should contain".
|
||||
And I set the field "groups" to "Group 2"
|
||||
And the "members" select box should contain "Student 2 (s2@example.com)"
|
||||
And the "members" select box should contain "Student 3 (s3@example.com)"
|
||||
And the "members" select box should not contain "Student 1 (s1@example.com)"
|
||||
And the "members" select box should contain "Student 2"
|
||||
And the "members" select box should contain "Student 3"
|
||||
And the "members" select box should not contain "Student 1"
|
||||
And I set the field "groups" to "Group 1"
|
||||
And the "members" select box should contain "Student 1 (s1@example.com)"
|
||||
And the "members" select box should contain "Student 2 (s2@example.com)"
|
||||
And the "members" select box should not contain "Student 3 (s3@example.com)"
|
||||
And the "members" select box should contain "Student 1"
|
||||
And the "members" select box should contain "Student 2"
|
||||
And the "members" select box should not contain "Student 3"
|
||||
# Checkbox (AJAX) - Checking "I set the field" and "I set the following fields to these values".
|
||||
And I am on "Course 1" course homepage
|
||||
And I add a "Lesson" to section "1"
|
||||
|
||||
@@ -26,11 +26,3 @@ Feature: List the system steps definitions
|
||||
Given I set the field "Contains" to "homepage"
|
||||
When I press "Filter"
|
||||
Then I should see "Opens Moodle homepage."
|
||||
|
||||
@javascript
|
||||
Scenario: Filtering by the multiple words pattern
|
||||
Given I set the field "Contains" to "should exist"
|
||||
When I press "Filter"
|
||||
Then I should not see "There aren't steps definitions matching this filter"
|
||||
And I should see "Checks the provided element and selector type exists in the current page."
|
||||
And I should see "Checks that an element and selector type exists in another element and selector type on the current page."
|
||||
|
||||
@@ -60,11 +60,6 @@ class tool_capability_settings_form extends moodleform {
|
||||
$form->addElement('select', 'roles', get_string('roleslabel', 'tool_capability'), $roles, $attributes);
|
||||
$form->setType('roles', PARAM_TEXT);
|
||||
|
||||
$form->addElement('checkbox', 'onlydiff',
|
||||
get_string('filters', 'tool_capability'),
|
||||
get_string('onlydiff', 'tool_capability'));
|
||||
$form->setType('onlydiff', PARAM_BOOL);
|
||||
|
||||
$form->addElement('submit', 'submitbutton', get_string('getreport', 'tool_capability'));
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ $capabilities = array();
|
||||
$rolestoshow = array();
|
||||
$roleids = array('0');
|
||||
$cleanedroleids = array();
|
||||
$onlydiff = false;
|
||||
if ($data = $form->get_data()) {
|
||||
|
||||
$roleids = array();
|
||||
@@ -91,10 +90,6 @@ if ($data = $form->get_data()) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data->onlydiff)) {
|
||||
$onlydiff = $data->onlydiff;
|
||||
}
|
||||
}
|
||||
|
||||
\tool_capability\event\report_viewed::create()->trigger();
|
||||
@@ -108,7 +103,7 @@ $form->display();
|
||||
// If we have a capability, generate the report.
|
||||
if (count($capabilities) && count($rolestoshow)) {
|
||||
/* @var tool_capability_renderer $renderer */
|
||||
echo $renderer->capability_comparison_table($capabilities, $context->id, $rolestoshow, $onlydiff);
|
||||
echo $renderer->capability_comparison_table($capabilities, $context->id, $rolestoshow);
|
||||
}
|
||||
|
||||
// Footer.
|
||||
@@ -143,7 +138,7 @@ function print_report_tree($contextid, $contexts, $allroles) {
|
||||
// If there are any role overrides here, print them.
|
||||
if (!empty($contexts[$contextid]->rolecapabilities)) {
|
||||
$rowcounter = 0;
|
||||
echo '<table class="generaltable table-striped"><tbody>';
|
||||
echo '<table class="generaltable rolecaps"><tbody>';
|
||||
foreach ($allroles as $role) {
|
||||
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
|
||||
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
|
||||
|
||||
@@ -22,18 +22,15 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['onlydiff'] = 'Show differences only';
|
||||
$string['capabilitylabel'] = 'Capability:';
|
||||
$string['capabilityreport'] = 'Capability overview';
|
||||
$string['eventreportviewed'] = 'Report viewed';
|
||||
$string['filters'] = 'Filter results';
|
||||
$string['forroles'] = 'For roles {$a}';
|
||||
$string['getreport'] = 'Get the overview';
|
||||
$string['changeoverrides'] = 'Change overrides in this context';
|
||||
$string['changeroles'] = 'Change role definitions';
|
||||
$string['intro'] = 'This report shows, for a particular capability, what permission that capability has in the definition of every role (or a selection of roles), and everywhere in the site where that capability is overridden.';
|
||||
$string['pluginname'] = 'Capability overview';
|
||||
$string['nodifferences'] = 'There are no differences to show between selected roles in this context';
|
||||
$string['reportforcapability'] = 'Report for capability \'{$a}\'';
|
||||
$string['reportsettings'] = 'Report settings';
|
||||
$string['roleslabel'] = 'Roles:';
|
||||
|
||||
@@ -72,11 +72,9 @@ class tool_capability_renderer extends plugin_renderer_base {
|
||||
* @param array $capabilities An array of capabilities to show comparison for.
|
||||
* @param int $contextid The context we are displaying for.
|
||||
* @param array $roles An array of roles to show comparison for.
|
||||
* @param bool $onlydiff show only different permissions
|
||||
* @return string
|
||||
*/
|
||||
public function capability_comparison_table(array $capabilities, $contextid, array $roles, $onlydiff=false) {
|
||||
static $capabilitycontexts = array();
|
||||
public function capability_comparison_table(array $capabilities, $contextid, array $roles) {
|
||||
|
||||
$strpermissions = $this->get_permission_strings();
|
||||
$permissionclasses = $this->get_permission_classes();
|
||||
@@ -94,39 +92,25 @@ class tool_capability_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$table->data = array();
|
||||
|
||||
$childcontextsids = [];
|
||||
foreach ($capabilities as $capability) {
|
||||
if (empty($capabilitycontexts[$capability])) {
|
||||
$capabilitycontexts[$capability] = tool_capability_calculate_role_data($capability, $roles);
|
||||
}
|
||||
$contexts = $capabilitycontexts[$capability];
|
||||
|
||||
$contexts = tool_capability_calculate_role_data($capability, $roles);
|
||||
$captitle = new html_table_cell(get_capability_string($capability) . html_writer::span($capability));
|
||||
$captitle->header = true;
|
||||
|
||||
$row = new html_table_row(array($captitle));
|
||||
|
||||
$permissiontypes = array();
|
||||
foreach ($roles as $role) {
|
||||
if (isset($contexts[$contextid]->rolecapabilities[$role->id])) {
|
||||
$permission = $contexts[$contextid]->rolecapabilities[$role->id];
|
||||
} else {
|
||||
$permission = CAP_INHERIT;
|
||||
}
|
||||
if (!in_array($permission, $permissiontypes)) {
|
||||
$permissiontypes[] = $permission;
|
||||
}
|
||||
$cell = new html_table_cell($strpermissions[$permission]);
|
||||
$cell->attributes['class'] = $permissionclasses[$permission];
|
||||
$row->cells[] = $cell;
|
||||
}
|
||||
if (!$onlydiff || count($permissiontypes) > 1) {
|
||||
$table->data[] = $row;
|
||||
}
|
||||
if (!empty($contexts[$contextid]->children)) {
|
||||
$childcontextsids = array_merge($childcontextsids, $contexts[$contextid]->children);
|
||||
$childcontextsids = array_unique($childcontextsids);
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
// Start the list item, and print the context name as a link to the place to make changes.
|
||||
@@ -141,15 +125,11 @@ class tool_capability_renderer extends plugin_renderer_base {
|
||||
$title = get_string('permissionsincontext', 'core_role', $context->get_context_name());
|
||||
|
||||
$html = $this->output->heading(html_writer::link($url, $title), 3);
|
||||
if (!empty($table->data)) {
|
||||
$html .= html_writer::table($table);
|
||||
} else {
|
||||
$html .= html_writer::tag('p', get_string('nodifferences', 'tool_capability'));
|
||||
}
|
||||
$html .= html_writer::table($table);
|
||||
// If there are any child contexts, print them recursively.
|
||||
if (!empty($childcontextsids)) {
|
||||
foreach ($childcontextsids as $childcontextid) {
|
||||
$html .= $this->capability_comparison_table($capabilities, $childcontextid, $roles, $onlydiff);
|
||||
if (!empty($contexts[$contextid]->children)) {
|
||||
foreach ($contexts[$contextid]->children as $childcontextid) {
|
||||
$html .= $this->capability_comparison_table($capabilities, $childcontextid, $roles, true);
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
@tool @tool_capability
|
||||
Feature: show capabilities for selected roles
|
||||
In order to check roles capabilities
|
||||
As an admin
|
||||
I need to be able to customize capabilities report viewing only specific roles and capabilities
|
||||
|
||||
Background:
|
||||
Given the following "roles" exist:
|
||||
| shortname | name | archetype |
|
||||
| studenteq | Studenteq | student |
|
||||
| studentdf | Studentdf | student |
|
||||
And the following "permission overrides" exist:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
| moodle/course:changefullname | Allow | studentdf | System | |
|
||||
| moodle/course:changeshortname | Prohibit | studentdf | System | |
|
||||
| moodle/course:changeidnumber | Prevent | studentdf | System | |
|
||||
And I log in as "admin"
|
||||
And I navigate to "Users > Permissions > Capability overview" in site administration
|
||||
|
||||
Scenario: visualize capabilities table with a limited number of capabilities
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changefullname, moodle/course:changeshortname |
|
||||
| Roles: | Studentdf |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "moodle/course:changefullname" in the "comparisontable" "table"
|
||||
And I should see "moodle/course:changeshortname" in the "comparisontable" "table"
|
||||
And I should not see "moodle/course:changecategory" in the "comparisontable" "table"
|
||||
|
||||
Scenario: visualize an allow capability
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changefullname |
|
||||
| Roles: | Studentdf |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Allow" in the "comparisontable" "table"
|
||||
And I should not see "Prevent" in the "comparisontable" "table"
|
||||
And I should not see "Prohibit" in the "comparisontable" "table"
|
||||
And I should not see "Not set" in the "comparisontable" "table"
|
||||
|
||||
Scenario: visualize a prohibit capability
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changeshortname |
|
||||
| Roles: | Studentdf |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should not see "Allow" in the "comparisontable" "table"
|
||||
And I should not see "Prevent" in the "comparisontable" "table"
|
||||
And I should see "Prohibit" in the "comparisontable" "table"
|
||||
And I should not see "Not set" in the "comparisontable" "table"
|
||||
|
||||
Scenario: visualize a not set capability
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changecategory |
|
||||
| Roles: | Studentdf |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should not see "Allow" in the "comparisontable" "table"
|
||||
And I should not see "Prevent" in the "comparisontable" "table"
|
||||
And I should not see "Prohibit" in the "comparisontable" "table"
|
||||
And I should see "Not set" in the "comparisontable" "table"
|
||||
|
||||
Scenario: visualize more than one role
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changecategory |
|
||||
| Roles: | Student, Studentdf |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Student" in the "comparisontable" "table"
|
||||
And I should see "Studentdf" in the "comparisontable" "table"
|
||||
And I should not see "Teacher" in the "comparisontable" "table"
|
||||
|
||||
Scenario: visualize all roles without selecting any role
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changecategory |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Student" in the "comparisontable" "table"
|
||||
And I should see "Studentdf" in the "comparisontable" "table"
|
||||
And I should see "Teacher" in the "comparisontable" "table"
|
||||
|
||||
Scenario: visualize all roles by selecting All option
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changecategory |
|
||||
| Roles: | All |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Student" in the "comparisontable" "table"
|
||||
And I should see "Studentdf" in the "comparisontable" "table"
|
||||
And I should see "Teacher" in the "comparisontable" "table"
|
||||
|
||||
@javascript
|
||||
Scenario: filter capability list using javascript
|
||||
Given I should see "moodle/site:config" in the "Capability" "field"
|
||||
And I should see "moodle/course:change" in the "Capability" "field"
|
||||
When I wait until the page is ready
|
||||
And I set the field "capabilitysearch" to "moodle/course:change"
|
||||
Then I should see "moodle/course:change" in the "Capability" "field"
|
||||
And I should not see "moodle/site:config" in the "Capability" "field"
|
||||
|
||||
@javascript
|
||||
Scenario: selecting capabilities using filters
|
||||
Given I should see "moodle/course:change" in the "Capability" "field"
|
||||
When I wait until the page is ready
|
||||
And I set the field "capabilitysearch" to "moodle/course:change"
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changecategory |
|
||||
| Roles: | Student |
|
||||
And I set the field "capabilitysearch" to ""
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "moodle/course:changecategory" in the "comparisontable" "table"
|
||||
@@ -1,133 +0,0 @@
|
||||
@tool @tool_capability
|
||||
Feature: Show capabilities for multiple contexts
|
||||
In order to check roles capabilities
|
||||
As an admin
|
||||
I need to be able to see capability overrides on several contexts
|
||||
|
||||
Background:
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
| Course 2 | C2 | 0 |
|
||||
And the following "permission overrides" exist:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
| enrol/category:config | Allow | student | Course | C1 |
|
||||
| enrol/cohort:unenrol | Allow | student | Course | C2 |
|
||||
And I log in as "admin"
|
||||
And I navigate to "Users > Permissions > Capability overview" in site administration
|
||||
|
||||
Scenario: Show capabilities table with one capability with overrides
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:config |
|
||||
| Roles: | Student |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with one capability without overrides
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/cohort:config |
|
||||
| Roles: | Student |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should not see "Permissions in Category: Miscellaneous"
|
||||
And I should not see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with two capabilities, 1st without overrides and 2nd with
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:synchronised, enrol/category:config |
|
||||
| Roles: | Student |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with two capabilities, 1st with overrides and 2nd without
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:config, enrol/cohort:config |
|
||||
| Roles: | Student |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with two capabilities, none with overrides
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:synchronised, enrol/cohort:config |
|
||||
| Roles: | Student |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should not see "Permissions in Category: Miscellaneous"
|
||||
And I should not see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with capability with override and no role selected
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:config |
|
||||
| Roles: | |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with capability without override and no role selected
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/cohort:config |
|
||||
| Roles: | |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should not see "Permissions in Category: Miscellaneous"
|
||||
And I should not see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with capability with two overrides on different contexts
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:config, enrol/cohort:unenrol |
|
||||
| Roles: | |
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with capability with override and only diff
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:config |
|
||||
| Roles: | Student, Teacher |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "There are no differences to show between selected roles in this context"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with capability without override and only diff and same capability
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:synchronised |
|
||||
| Roles: | Student, Teacher |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "There are no differences to show between selected roles in this context"
|
||||
And I should not see "Permissions in Category: Miscellaneous"
|
||||
And I should not see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
|
||||
Scenario: Show capabilities table with two capabilities only one override and only diff checked
|
||||
When I set the following fields to these values:
|
||||
| Capability: | enrol/category:config, enrol/cohort:config |
|
||||
| Roles: | Student, Teacher |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "Permissions in System"
|
||||
And I should see "Permissions in Category: Miscellaneous"
|
||||
And I should see "There are no differences to show between selected roles in this context"
|
||||
And I should see "Permissions in Course: Course 1"
|
||||
And I should not see "Permissions in Course: Course 2"
|
||||
@@ -1,67 +0,0 @@
|
||||
@tool @tool_capability
|
||||
Feature: show only differences between roles for selected capabilities
|
||||
In order to check roles capabilities
|
||||
As an admin
|
||||
I need to be able to filter capabilities report viewing only role differences
|
||||
|
||||
Background:
|
||||
Given the following "roles" exist:
|
||||
| shortname | name | archetype |
|
||||
| studenteq | Studenteq | student |
|
||||
| studentdf | Studentdf | student |
|
||||
And the following "permission overrides" exist:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
| moodle/course:changefullname | Allow | studentdf | System | |
|
||||
| moodle/course:changeshortname | Prohibit | studentdf | System | |
|
||||
And I log in as "admin"
|
||||
And I navigate to "Users > Permissions > Capability overview" in site administration
|
||||
|
||||
Scenario: Compare identical roles
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changefullname, moodle/course:changeshortname, moodle/course:changeidnumber, moodle/course:changesummary |
|
||||
| Roles: | Student, Studenteq |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "There are no differences to show between selected roles in this context"
|
||||
|
||||
Scenario: Compare different roles
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changefullname, moodle/course:changeshortname, moodle/course:changeidnumber, moodle/course:changesummary |
|
||||
| Roles: | Student, Studentdf |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should not see "There are no differences to show between selected roles in this context"
|
||||
And I should see "moodle/course:changefullname" in the "comparisontable" "table"
|
||||
And I should see "moodle/course:changeshortname" in the "comparisontable" "table"
|
||||
And I should not see "moodle/course:changesummary" in the "comparisontable" "table"
|
||||
|
||||
Scenario: Compare different roles but comparing capabilities that are equals on both
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changeidnumber, moodle/course:changesummary |
|
||||
| Roles: | Student, Studentdf |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "There are no differences to show between selected roles in this context"
|
||||
|
||||
Scenario: Compare all roles without selecting specific role
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changefullname, moodle/site:config |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should not see "moodle/site:config" in the "comparisontable" "table"
|
||||
And I should see "moodle/course:changefullname" in the "comparisontable" "table"
|
||||
|
||||
Scenario: Compare all roles without selecting specific role on not defined capability
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/site:config |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "There are no differences to show between selected roles in this context"
|
||||
|
||||
Scenario: Comparing only one role
|
||||
When I set the following fields to these values:
|
||||
| Capability: | moodle/course:changefullname, moodle/course:changeshortname, moodle/course:changeidnumber, moodle/course:changesummary |
|
||||
| Roles: | Student |
|
||||
And I set the field "Show differences only" to "1"
|
||||
And I click on "Get the overview" "button"
|
||||
Then I should see "There are no differences to show between selected roles in this context"
|
||||
admin/tool/capability/yui/build/moodle-tool_capability-search/moodle-tool_capability-search-debug.js
Vendored
+1
-1
@@ -76,7 +76,7 @@ SEARCH.prototype = {
|
||||
this.button = this.form.all('input[type=submit]');
|
||||
this.lastsearch = this.form.one('input[name=search]');
|
||||
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
|
||||
var div = Y.Node.create('<div id="capabilitysearchui"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
|
||||
this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
YUI.add("moodle-tool_capability-search",function(i,t){var e=function(){e.superclass.constructor.apply(this,arguments)};e.prototype={form:null,select:null,selectoptions:{},input:null,button:null,lastsearch:null,initializer:function(){this.form=i.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(t){var e=t.get("value");this.selectoptions[e]=t},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=i.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),e=i.Node.create('<label for="capabilitysearch">'+this.get("strsearch")+"</label>");this.input=i.Node.create('<input type="text" id="capabilitysearch" />'),t.append(e).append(this.input),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",""===this.select.get("value"))},typed:function(){var t,e=this.input.get("value"),i=0,s=null;for(t in this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove(),this.selectoptions)0<=t.indexOf(e)&&(i++,s=this.selectoptions[t],this.select.append(this.selectoptions[t]));0===i?this.input.addClass("error"):(this.input.removeClass("error"),1===i&&s.set("selected",!0)),this.validate()}},i.extend(e,i.Base,e.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(t){new e(t)}},"@VERSION@",{requires:["base","node"]});
|
||||
YUI.add("moodle-tool_capability-search",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};n.prototype={form:null,select:null,selectoptions:{},input:null,button:null,lastsearch:null,initializer:function(){this.form=e.one("#capability-overview-form"),this.select=this.form.one("select[data-search=capability]"),this.select.setStyle("minWidth",this.select.get("offsetWidth")),this.select.get("options").each(function(e){var t=e.get("value");this.selectoptions[t]=e},this),this.button=this.form.all("input[type=submit]"),this.lastsearch=this.form.one("input[name=search]");var t=e.Node.create('<div id="capabilitysearchui"></div>'),n=e.Node.create('<label for="capabilitysearch">'+this.get("strsearch")+"</label>");this.input=e.Node.create('<input type="text" id="capabilitysearch" />'),t.append(n).append(this.input),this.select.insert(t,"before"),this.input.on("keyup",this.typed,this),this.select.on("change",this.validate,this),this.lastsearch&&(this.input.set("value",this.lastsearch.get("value")),this.typed(),this.select.one("option[selected]")&&this.select.set("scrollTop",this.select.one("option[selected]").get("getX"))),this.validate()},validate:function(){this.button.set("disabled",this.select.get("value")==="")},typed:function(){var e=this.input.get("value"),t=0,n=null,r;this.lastsearch&&this.lastsearch.set("value",e),this.select.all("option").remove();for(r in this.selectoptions)r.indexOf(e)>=0&&(t++,n=this.selectoptions[r],this.select.append(this.selectoptions[r]));t===0?this.input.addClass("error"):(this.input.removeClass("error"),t===1&&n.set("selected",!0)),this.validate()}},e.extend(n,e.Base,n.prototype,{NAME:"tool_capability-search",ATTRS:{strsearch:{}}}),M.tool_capability=M.tool_capability||{},M.tool_capability.init_capability_search=function(e){new n(e)}},"@VERSION@",{requires:["base","node"]});
|
||||
|
||||
Vendored
+1
-1
@@ -76,7 +76,7 @@ SEARCH.prototype = {
|
||||
this.button = this.form.all('input[type=submit]');
|
||||
this.lastsearch = this.form.one('input[name=search]');
|
||||
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
|
||||
var div = Y.Node.create('<div id="capabilitysearchui"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
|
||||
this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ SEARCH.prototype = {
|
||||
this.button = this.form.all('input[type=submit]');
|
||||
this.lastsearch = this.form.one('input[name=search]');
|
||||
|
||||
var div = Y.Node.create('<div id="capabilitysearchui" data-fieldtype="text"></div>'),
|
||||
var div = Y.Node.create('<div id="capabilitysearchui"></div>'),
|
||||
label = Y.Node.create('<label for="capabilitysearch">' + this.get('strsearch') + '</label>');
|
||||
this.input = Y.Node.create('<input type="text" id="capabilitysearch" />');
|
||||
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Plugin upgrade code
|
||||
*
|
||||
* @package tool_cohortroles
|
||||
* @copyright 2020 Paul Holden <paulh@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Function to upgrade tool_cohortroles.
|
||||
*
|
||||
* @param int $oldversion the version we are upgrading from
|
||||
* @return bool result
|
||||
*/
|
||||
function xmldb_tool_cohortroles_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
if ($oldversion < 2020020600) {
|
||||
// Delete any tool_cohortroles mappings for roles which no longer exist.
|
||||
$DB->delete_records_select('tool_cohortroles', 'roleid NOT IN (SELECT id FROM {role})');
|
||||
|
||||
// Cohortroles savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2020020600, 'tool', 'cohortroles');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$plugin->version = 2020020600; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2019111800; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2019111200; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_cohortroles'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ defined('MOODLE_INTERNAL') || die();
|
||||
function xmldb_tool_customlang_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
|
||||
// Automatically generated Moodle v3.3.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
// Automatically generated Moodle v3.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
@@ -254,19 +254,20 @@ class tool_customlang_utils {
|
||||
*
|
||||
* @param string $component the name of the component
|
||||
* @param array $strings
|
||||
* @return void
|
||||
*/
|
||||
protected static function dump_strings($lang, $component, $strings) {
|
||||
global $CFG;
|
||||
|
||||
if ($lang !== clean_param($lang, PARAM_LANG)) {
|
||||
throw new moodle_exception('Unable to dump local strings for non-installed language pack .'.s($lang));
|
||||
debugging('Unable to dump local strings for non-installed language pack .'.s($lang));
|
||||
return false;
|
||||
}
|
||||
if ($component !== clean_param($component, PARAM_COMPONENT)) {
|
||||
throw new coding_exception('Incorrect component name');
|
||||
}
|
||||
if (!$filename = self::get_component_filename($component)) {
|
||||
throw new moodle_exception('Unable to find the filename for the component '.s($component));
|
||||
debugging('Unable to find the filename for the component '.s($component));
|
||||
return false;
|
||||
}
|
||||
if ($filename !== clean_param($filename, PARAM_FILE)) {
|
||||
throw new coding_exception('Incorrect file name '.s($filename));
|
||||
@@ -283,7 +284,8 @@ class tool_customlang_utils {
|
||||
}
|
||||
|
||||
if (!$f = fopen($filepath, 'w')) {
|
||||
throw new moodle_exception('Unable to write '.s($filepath));
|
||||
debugging('Unable to write '.s($filepath));
|
||||
return false;
|
||||
}
|
||||
fwrite($f, <<<EOF
|
||||
<?php
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
define ("tool_dataprivacy/myrequestactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates","core/pending"],function(a,b,c,d,e,f,g,h){var j={CANCEL_REQUEST:"[data-action=\"cancel\"]",CONTACT_DPO:"[data-action=\"contactdpo\"]"},k=function(){this.registerEvents()};k.prototype.registerEvents=function(){a(j.CANCEL_REQUEST).click(function(g){g.preventDefault();var h=a(this).data("requestid");d.get_strings([{key:"cancelrequest",component:"tool_dataprivacy"},{key:"cancelrequestconfirmation",component:"tool_dataprivacy"}]).then(function(a){var d=a[0],g=a[1];return e.create({title:d,body:g,type:e.types.SAVE_CANCEL}).then(function(a){a.setSaveButtonText(d);a.getRoot().on(f.save,function(){b.call([{methodname:"tool_dataprivacy_cancel_data_request",args:{requestid:h}}])[0].done(function(a){if(a.result){window.location.reload()}else{c.addNotification({message:a.warnings[0].message,type:"error"})}}).fail(c.exception)});a.getRoot().on(f.hidden,function(){a.destroy()});return a})}).done(function(a){a.show()}).fail(c.exception)});a(j.CONTACT_DPO).click(function(b){var j=new h("dataprivacy/crud:initModal:contactdpo");b.preventDefault();var k=a(this).data("replytoemail"),l="";d.get_strings([{key:"contactdataprotectionofficer",component:"tool_dataprivacy"},{key:"send",component:"tool_dataprivacy"}]).then(function(a){var b=a[0];l=a[1];return e.create({title:b,body:g.render("tool_dataprivacy/contact_dpo",{replytoemail:k}),type:e.types.SAVE_CANCEL,large:!0})}).then(function(b){b.setSaveButtonText(l);b.show();b.getRoot().on(f.save,function(b){var c=a("#message").val().trim();if(0===c.length){b.preventDefault();a("[data-region=\"messageinput\"]").addClass("has-danger notifyproblem");a("#id_error_message").removeAttr("hidden")}else{i(c)}});b.getRoot().on(f.hidden,function(){b.destroy()})}).then(j.resolve).catch(c.exception)})};function i(a){var e="success";b.call([{methodname:"tool_dataprivacy_contact_dpo",args:{message:a}}])[0].then(function(a){if(a.result){return d.get_string("requestsubmitted","tool_dataprivacy")}e="error";return a.warnings.join("<br>")}).done(function(a){c.addNotification({message:a,type:e})}).fail(c.exception)}return{init:function init(){return new k}}});
|
||||
define ("tool_dataprivacy/myrequestactions",["jquery","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events","core/templates"],function(a,b,c,d,e,f,g){var i={CANCEL_REQUEST:"[data-action=\"cancel\"]",CONTACT_DPO:"[data-action=\"contactdpo\"]"},j=function(){this.registerEvents()};j.prototype.registerEvents=function(){a(i.CANCEL_REQUEST).click(function(g){g.preventDefault();var h=a(this).data("requestid");d.get_strings([{key:"cancelrequest",component:"tool_dataprivacy"},{key:"cancelrequestconfirmation",component:"tool_dataprivacy"}]).then(function(a){var d=a[0],g=a[1];return e.create({title:d,body:g,type:e.types.SAVE_CANCEL}).then(function(a){a.setSaveButtonText(d);a.getRoot().on(f.save,function(){b.call([{methodname:"tool_dataprivacy_cancel_data_request",args:{requestid:h}}])[0].done(function(a){if(a.result){window.location.reload()}else{c.addNotification({message:a.warnings[0].message,type:"error"})}}).fail(c.exception)});a.getRoot().on(f.hidden,function(){a.destroy()});return a})}).done(function(a){a.show()}).fail(c.exception)});a(i.CONTACT_DPO).click(function(b){b.preventDefault();var i=a(this).data("replytoemail"),j="";d.get_strings([{key:"contactdataprotectionofficer",component:"tool_dataprivacy"},{key:"send",component:"tool_dataprivacy"}]).then(function(a){var b=a[0];j=a[1];return e.create({title:b,body:g.render("tool_dataprivacy/contact_dpo",{replytoemail:i}),type:e.types.SAVE_CANCEL,large:!0})}).done(function(b){b.setSaveButtonText(j);b.getRoot().on(f.save,function(b){var c=a("#message").val().trim();if(0===c.length){b.preventDefault();a("[data-region=\"messageinput\"]").addClass("has-danger notifyproblem");a("#id_error_message").removeAttr("hidden")}else{h(c)}});b.getRoot().on(f.hidden,function(){b.destroy()});b.show()}).fail(c.exception)})};function h(a){var e="success";b.call([{methodname:"tool_dataprivacy_contact_dpo",args:{message:a}}])[0].then(function(a){if(a.result){return d.get_string("requestsubmitted","tool_dataprivacy")}e="error";return a.warnings.join("<br>")}).done(function(a){c.addNotification({message:a,type:e})}).fail(c.exception)}return{init:function init(){return new j}}});
|
||||
//# sourceMappingURL=myrequestactions.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -28,9 +28,8 @@ define([
|
||||
'core/str',
|
||||
'core/modal_factory',
|
||||
'core/modal_events',
|
||||
'core/templates',
|
||||
'core/pending'],
|
||||
function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Pending) {
|
||||
'core/templates'],
|
||||
function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates) {
|
||||
|
||||
/**
|
||||
* List of action selectors.
|
||||
@@ -119,7 +118,6 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Pendi
|
||||
});
|
||||
|
||||
$(ACTIONS.CONTACT_DPO).click(function(e) {
|
||||
var pendingPromise = new Pending('dataprivacy/crud:initModal:contactdpo');
|
||||
e.preventDefault();
|
||||
|
||||
var replyToEmail = $(this).data('replytoemail');
|
||||
@@ -148,12 +146,9 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Pendi
|
||||
type: ModalFactory.types.SAVE_CANCEL,
|
||||
large: true
|
||||
});
|
||||
}).then(function(modal) {
|
||||
}).done(function(modal) {
|
||||
modal.setSaveButtonText(sendButtonText);
|
||||
|
||||
// Show the modal!
|
||||
modal.show();
|
||||
|
||||
// Handle send event.
|
||||
modal.getRoot().on(ModalEvents.save, function(e) {
|
||||
var message = $('#message').val().trim();
|
||||
@@ -174,9 +169,9 @@ function($, Ajax, Notification, Str, ModalFactory, ModalEvents, Templates, Pendi
|
||||
modal.destroy();
|
||||
});
|
||||
|
||||
return;
|
||||
}).then(pendingPromise.resolve)
|
||||
.catch(Notification.exception);
|
||||
// Show the modal!
|
||||
modal.show();
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -258,20 +258,7 @@ class api {
|
||||
// The user making the request.
|
||||
$datarequest->set('requestedby', $requestinguser);
|
||||
// Set status.
|
||||
$status = self::DATAREQUEST_STATUS_AWAITING_APPROVAL;
|
||||
if (self::is_automatic_request_approval_on($type)) {
|
||||
// Set status to approved if automatic data request approval is enabled.
|
||||
$status = self::DATAREQUEST_STATUS_APPROVED;
|
||||
// Set the privacy officer field if the one making the data request is a privacy officer.
|
||||
if (self::is_site_dpo($requestinguser)) {
|
||||
$datarequest->set('dpo', $requestinguser);
|
||||
}
|
||||
// Mark this request as system approved.
|
||||
$datarequest->set('systemapproved', true);
|
||||
// No need to notify privacy officer(s) about automatically approved data requests.
|
||||
$notify = false;
|
||||
}
|
||||
$datarequest->set('status', $status);
|
||||
$datarequest->set('status', self::DATAREQUEST_STATUS_AWAITING_APPROVAL);
|
||||
// Set request type.
|
||||
$datarequest->set('type', $type);
|
||||
// Set request comments.
|
||||
@@ -282,22 +269,13 @@ class api {
|
||||
// Store subject access request.
|
||||
$datarequest->create();
|
||||
|
||||
// Queue the ad-hoc task for automatically approved data requests.
|
||||
if ($status == self::DATAREQUEST_STATUS_APPROVED) {
|
||||
$userid = null;
|
||||
if ($type == self::DATAREQUEST_TYPE_EXPORT) {
|
||||
$userid = $foruser;
|
||||
}
|
||||
self::queue_data_request_task($datarequest->get('id'), $userid);
|
||||
}
|
||||
|
||||
if ($notify) {
|
||||
// Get the list of the site Data Protection Officers.
|
||||
$dpos = self::get_site_dpos();
|
||||
$dpos = api::get_site_dpos();
|
||||
|
||||
// Email the data request to the Data Protection Officer(s)/Admin(s).
|
||||
foreach ($dpos as $dpo) {
|
||||
self::notify_dpo($dpo, $datarequest);
|
||||
api::notify_dpo($dpo, $datarequest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,11 +624,12 @@ class api {
|
||||
$result = self::update_request_status($requestid, self::DATAREQUEST_STATUS_APPROVED, $USER->id);
|
||||
|
||||
// Fire an ad hoc task to initiate the data request process.
|
||||
$userid = null;
|
||||
$task = new process_data_request_task();
|
||||
$task->set_custom_data(['requestid' => $requestid]);
|
||||
if ($request->get('type') == self::DATAREQUEST_TYPE_EXPORT) {
|
||||
$userid = $request->get('userid');
|
||||
$task->set_userid($request->get('userid'));
|
||||
}
|
||||
self::queue_data_request_task($requestid, $userid);
|
||||
manager::queue_adhoc_task($task, true);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -1298,35 +1277,4 @@ class api {
|
||||
|
||||
return $formattedtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether automatic data request approval is turned on or not for the given request type.
|
||||
*
|
||||
* @param int $type The request type.
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_automatic_request_approval_on(int $type): bool {
|
||||
switch ($type) {
|
||||
case self::DATAREQUEST_TYPE_EXPORT:
|
||||
return !empty(get_config('tool_dataprivacy', 'automaticdataexportapproval'));
|
||||
case self::DATAREQUEST_TYPE_DELETE:
|
||||
return !empty(get_config('tool_dataprivacy', 'automaticdatadeletionapproval'));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ad-hoc task for the data request.
|
||||
*
|
||||
* @param int $requestid The data request ID.
|
||||
* @param int $userid Optional. The user ID to run the task as, if necessary.
|
||||
*/
|
||||
public static function queue_data_request_task(int $requestid, int $userid = null): void {
|
||||
$task = new process_data_request_task();
|
||||
$task->set_custom_data(['requestid' => $requestid]);
|
||||
if ($userid) {
|
||||
$task->set_userid($userid);
|
||||
}
|
||||
manager::queue_adhoc_task($task, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,10 +118,6 @@ class data_request extends persistent {
|
||||
'type' => PARAM_INT,
|
||||
'default' => FORMAT_PLAIN
|
||||
],
|
||||
'systemapproved' => [
|
||||
'default' => false,
|
||||
'type' => PARAM_BOOL,
|
||||
],
|
||||
'creationmethod' => [
|
||||
'default' => self::DATAREQUEST_CREATION_MANUAL,
|
||||
'choices' => [
|
||||
|
||||
@@ -146,20 +146,14 @@ class process_data_request_task extends adhoc_task {
|
||||
mtrace('The processing of the user data request has been completed...');
|
||||
|
||||
// Create message to notify the user regarding the processing results.
|
||||
$dpo = core_user::get_user($request->dpo);
|
||||
$message = new message();
|
||||
$message->courseid = $SITE->id;
|
||||
$message->component = 'tool_dataprivacy';
|
||||
$message->name = 'datarequestprocessingresults';
|
||||
if (empty($request->dpo)) {
|
||||
// Use the no-reply user as the sender if the privacy officer is not set. This is the case for automatically
|
||||
// approved requests.
|
||||
$fromuser = core_user::get_noreply_user();
|
||||
} else {
|
||||
$fromuser = core_user::get_user($request->dpo);
|
||||
$message->replyto = $fromuser->email;
|
||||
$message->replytoname = fullname($fromuser);
|
||||
}
|
||||
$message->userfrom = $fromuser;
|
||||
$message->userfrom = $dpo;
|
||||
$message->replyto = $dpo->email;
|
||||
$message->replytoname = fullname($dpo);
|
||||
|
||||
$typetext = null;
|
||||
// Prepare the context data for the email message body.
|
||||
@@ -225,7 +219,7 @@ class process_data_request_task extends adhoc_task {
|
||||
if ($emailonly) {
|
||||
// Do not sent an email if the user has been deleted. The user email has been previously deleted.
|
||||
if (!$foruser->deleted) {
|
||||
$messagesent = email_to_user($foruser, $fromuser, $subject, $message->fullmessage, $messagehtml);
|
||||
$messagesent = email_to_user($foruser, $dpo, $subject, $message->fullmessage, $messagehtml);
|
||||
}
|
||||
} else {
|
||||
$messagesent = message_send($message);
|
||||
@@ -271,7 +265,7 @@ class process_data_request_task extends adhoc_task {
|
||||
|
||||
// Send message.
|
||||
if ($emailonly) {
|
||||
email_to_user($requestedby, $fromuser, $subject, $message->fullmessage, $messagehtml);
|
||||
email_to_user($requestedby, $dpo, $subject, $message->fullmessage, $messagehtml);
|
||||
} else {
|
||||
message_send($message);
|
||||
}
|
||||
|
||||
@@ -45,22 +45,13 @@ if ($manage) {
|
||||
$context = context_system::instance();
|
||||
// Make sure the user has the proper capability.
|
||||
require_capability('tool/dataprivacy:managedatarequests', $context);
|
||||
navigation_node::override_active_url($returnurl);
|
||||
} else {
|
||||
// For the case where a user makes request for themselves (or for their children if they are the parent).
|
||||
$returnurl = new moodle_url($CFG->wwwroot . '/admin/tool/dataprivacy/mydatarequests.php');
|
||||
$context = context_user::instance($USER->id);
|
||||
}
|
||||
|
||||
$PAGE->set_context($context);
|
||||
|
||||
if (!$manage && $profilenode = $PAGE->settingsnav->find('myprofile', null)) {
|
||||
$profilenode->make_active();
|
||||
}
|
||||
|
||||
$title = get_string('createnewdatarequest', 'tool_dataprivacy');
|
||||
$PAGE->navbar->add($title);
|
||||
|
||||
// If contactdataprotectionofficer is disabled, send the user back to the profile page, or the privacy policy page.
|
||||
// That is, unless you have sufficient capabilities to perform this on behalf of a user.
|
||||
if (!$manage && !\tool_dataprivacy\api::can_contact_dpo()) {
|
||||
@@ -103,16 +94,13 @@ if ($data = $mform->get_data()) {
|
||||
if ($manage) {
|
||||
$foruser = core_user::get_user($data->userid);
|
||||
$redirectmessage = get_string('datarequestcreatedforuser', 'tool_dataprivacy', fullname($foruser));
|
||||
} else if (\tool_dataprivacy\api::is_automatic_request_approval_on($data->type)) {
|
||||
// Let the user know that the request has been submitted and will be processed soon.
|
||||
$redirectmessage = get_string('approvedrequestsubmitted', 'tool_dataprivacy');
|
||||
} else {
|
||||
// Let the user know that the request has been submitted to the privacy officer.
|
||||
$redirectmessage = get_string('requestsubmitted', 'tool_dataprivacy');
|
||||
}
|
||||
redirect($returnurl, $redirectmessage);
|
||||
}
|
||||
|
||||
$title = get_string('createnewdatarequest', 'tool_dataprivacy');
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
$PAGE->set_title($title);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/tool/dataprivacy/db" VERSION="20191217" COMMENT="XMLDB file for Moodle tool/dataprivacy"
|
||||
<XMLDB PATH="admin/tool/dataprivacy/db" VERSION="20181107" COMMENT="XMLDB file for Moodle tool/dataprivacy"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -16,7 +16,6 @@
|
||||
<FIELD NAME="dpo" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="The user ID of the Data Protection Officer who is reviewing th request"/>
|
||||
<FIELD NAME="dpocomment" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="DPO's comments (e.g. reason for rejecting the request, etc.)"/>
|
||||
<FIELD NAME="dpocommentformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="systemapproved" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="usermodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The user who created/modified this request object"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time this data request was created"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The last time this data request was updated"/>
|
||||
|
||||
@@ -322,20 +322,5 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
|
||||
// Automatically generated Moodle v3.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2019121700) {
|
||||
|
||||
// Define field systemapproved to be added to tool_dataprivacy_request.
|
||||
$table = new xmldb_table('tool_dataprivacy_request');
|
||||
$field = new xmldb_field('systemapproved', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'dpocommentformat');
|
||||
|
||||
// Conditionally launch add field systemapproved.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Dataprivacy savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2019121700, 'tool', 'dataprivacy');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,7 @@ $string['addcategory'] = 'Add category';
|
||||
$string['addnewdefaults'] = 'Add a new module default';
|
||||
$string['addpurpose'] = 'Add purpose';
|
||||
$string['approve'] = 'Approve';
|
||||
$string['approvedrequestsubmitted'] = 'Your request has been submitted and will be processed soon.';
|
||||
$string['approverequest'] = 'Approve request';
|
||||
$string['automaticdatadeletionapproval'] = 'Automatic data deletion request approval';
|
||||
$string['automaticdatadeletionapproval_desc'] = 'If enabled, data deletion requests are automatically approved.<br/>Note that the automatic approval will only apply to new data deletion requests with this setting enabled. Existing data deletion requests pending approval will still have to be manually approved by the privacy officer.';
|
||||
$string['automaticdataexportapproval'] = 'Automatic data export request approval';
|
||||
$string['automaticdataexportapproval_desc'] = 'If enabled, data export requests are automatically approved.<br/>Note that the automatic approval will only apply to new data export requests with this setting enabled. Existing data export requests pending approval will still have to be manually approved by the privacy officer.';
|
||||
$string['automaticdeletionrequests'] = 'Create automatic data deletion requests';
|
||||
$string['automaticdeletionrequests_desc'] = 'If enabled, a data deletion request will be created automatically for any user accounts deleted manually.';
|
||||
$string['bulkapproverequests'] = 'Approve requests';
|
||||
|
||||
@@ -42,13 +42,6 @@ if (isguestuser()) {
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
$PAGE->set_context($usercontext);
|
||||
|
||||
if ($profilenode = $PAGE->settingsnav->find('myprofile', null)) {
|
||||
$profilenode->make_active();
|
||||
}
|
||||
|
||||
$title = get_string('datarequests', 'tool_dataprivacy');
|
||||
$PAGE->navbar->add($title);
|
||||
|
||||
// Return URL.
|
||||
$params = ['id' => $USER->id];
|
||||
if ($courseid) {
|
||||
@@ -56,6 +49,7 @@ if ($courseid) {
|
||||
}
|
||||
$returnurl = new moodle_url('/user/profile.php', $params);
|
||||
|
||||
$title = get_string('datarequests', 'tool_dataprivacy');
|
||||
$PAGE->set_heading($title);
|
||||
$PAGE->set_title($title);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
@@ -27,10 +27,12 @@ require_once('../../../config.php');
|
||||
$requestid = required_param('requestid', PARAM_INT);
|
||||
$confirm = optional_param('confirm', null, PARAM_INT);
|
||||
|
||||
$url = new moodle_url('/admin/tool/dataprivacy/resubmitrequest.php', ['requestid' => $requestid]);
|
||||
$title = get_string('resubmitrequestasnew', 'tool_dataprivacy');
|
||||
$PAGE->set_url(new moodle_url('/admin/tool/dataprivacy/resubmitrequest.php', ['requestid' => $requestid]));
|
||||
|
||||
\tool_dataprivacy\page_helper::setup($url, $title, 'datarequests', 'tool/dataprivacy:managedatarequests');
|
||||
require_login();
|
||||
|
||||
$PAGE->set_context(\context_system::instance());
|
||||
require_capability('tool/dataprivacy:managedatarequests', $PAGE->context);
|
||||
|
||||
$manageurl = new moodle_url('/admin/tool/dataprivacy/datarequests.php');
|
||||
|
||||
@@ -51,6 +53,10 @@ if (null !== $confirm && confirm_sesskey()) {
|
||||
redirect($manageurl, get_string('resubmittedrequest', 'tool_dataprivacy', $stringparams));
|
||||
}
|
||||
|
||||
$heading = get_string('resubmitrequest', 'tool_dataprivacy', $stringparams);
|
||||
$PAGE->set_title($heading);
|
||||
$PAGE->set_heading($heading);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$confirmstring = get_string('confirmrequestresubmit', 'tool_dataprivacy', $stringparams);
|
||||
|
||||
@@ -34,16 +34,6 @@ if ($hassiteconfig) {
|
||||
new lang_string('contactdataprotectionofficer_desc', 'tool_dataprivacy'), 0)
|
||||
);
|
||||
|
||||
$privacysettings->add(new admin_setting_configcheckbox('tool_dataprivacy/automaticdataexportapproval',
|
||||
new lang_string('automaticdataexportapproval', 'tool_dataprivacy'),
|
||||
new lang_string('automaticdataexportapproval_desc', 'tool_dataprivacy'), 0)
|
||||
);
|
||||
|
||||
$privacysettings->add(new admin_setting_configcheckbox('tool_dataprivacy/automaticdatadeletionapproval',
|
||||
new lang_string('automaticdatadeletionapproval', 'tool_dataprivacy'),
|
||||
new lang_string('automaticdatadeletionapproval_desc', 'tool_dataprivacy'), 0)
|
||||
);
|
||||
|
||||
// Automatically create delete data request for users upon user deletion.
|
||||
// Automatically create delete data request for pre-existing deleted users.
|
||||
// Enabled by default.
|
||||
|
||||
@@ -34,13 +34,6 @@ $PAGE->set_context($context);
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
|
||||
// If user is logged in, then use profile navigation in breadcrumbs.
|
||||
if ($profilenode = $PAGE->settingsnav->find('myprofile', null)) {
|
||||
$profilenode->make_active();
|
||||
}
|
||||
|
||||
$PAGE->navbar->add($title);
|
||||
|
||||
$output = $PAGE->get_renderer('tool_dataprivacy');
|
||||
echo $output->header();
|
||||
$summarypage = new \tool_dataprivacy\output\summary_page();
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<hr />
|
||||
<div class="p-l-3">
|
||||
<dl class="row">
|
||||
<dt class="col-3">
|
||||
<dt class="col-xs-3">
|
||||
{{#link}}
|
||||
<a href="#{{name}}"><strong style="word-wrap:break-word">{{name}}</strong></a>
|
||||
{{/link}}
|
||||
@@ -84,13 +84,13 @@
|
||||
{{/link}}
|
||||
<div class="small text-muted" style="word-wrap:break-word">{{type}}</div>
|
||||
</dt>
|
||||
<dd class="col-9">{{summary}}</dd>
|
||||
<dd class="col-xs-9">{{summary}}</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
{{#fields}}
|
||||
<div class="row">
|
||||
<dt class="col-3 font-weight-normal" style="word-wrap:break-word">{{field_name}}</dt>
|
||||
<dd class="col-9">{{field_summary}}</dd>
|
||||
<dt class="col-xs-3 font-weight-normal" style="word-wrap:break-word">{{field_name}}</dt>
|
||||
<dd class="col-xs-9">{{field_summary}}</dd>
|
||||
</div>
|
||||
{{/fields}}
|
||||
</dl>
|
||||
@@ -100,7 +100,7 @@
|
||||
<hr />
|
||||
<div class="p-l-3">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="col-xs-12">
|
||||
{{nullprovider}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -555,65 +555,32 @@ class tool_dataprivacy_api_testcase extends advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for data request creation tests.
|
||||
*
|
||||
* @return array
|
||||
* Test for api::create_data_request()
|
||||
*/
|
||||
public function data_request_creation_provider() {
|
||||
return [
|
||||
'Export request by user, automatic approval off' => [
|
||||
false, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', false, 0,
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0
|
||||
],
|
||||
'Export request by user, automatic approval on' => [
|
||||
false, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', true, 0,
|
||||
api::DATAREQUEST_STATUS_APPROVED, 1
|
||||
],
|
||||
'Export request by PO, automatic approval off' => [
|
||||
true, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', false, 0,
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0
|
||||
],
|
||||
'Export request by PO, automatic approval on' => [
|
||||
true, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', true, 'dpo',
|
||||
api::DATAREQUEST_STATUS_APPROVED, 1
|
||||
],
|
||||
'Delete request by user, automatic approval off' => [
|
||||
false, api::DATAREQUEST_TYPE_DELETE, 'automaticdatadeletionapproval', false, 0,
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0
|
||||
],
|
||||
'Delete request by user, automatic approval on' => [
|
||||
false, api::DATAREQUEST_TYPE_DELETE, 'automaticdatadeletionapproval', true, 0,
|
||||
api::DATAREQUEST_STATUS_APPROVED, 1
|
||||
],
|
||||
'Delete request by PO, automatic approval off' => [
|
||||
true, api::DATAREQUEST_TYPE_DELETE, 'automaticdatadeletionapproval', false, 0,
|
||||
api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0
|
||||
],
|
||||
'Delete request by PO, automatic approval on' => [
|
||||
true, api::DATAREQUEST_TYPE_DELETE, 'automaticdatadeletionapproval', true, 'dpo',
|
||||
api::DATAREQUEST_STATUS_APPROVED, 1
|
||||
],
|
||||
];
|
||||
public function test_create_data_request() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$generator = new testing_data_generator();
|
||||
$user = $generator->create_user();
|
||||
$comment = 'sample comment';
|
||||
|
||||
// Login as user.
|
||||
$this->setUser($user->id);
|
||||
|
||||
// Test data request creation.
|
||||
$datarequest = api::create_data_request($user->id, api::DATAREQUEST_TYPE_EXPORT, $comment);
|
||||
$this->assertEquals($user->id, $datarequest->get('userid'));
|
||||
$this->assertEquals($user->id, $datarequest->get('requestedby'));
|
||||
$this->assertEquals(0, $datarequest->get('dpo'));
|
||||
$this->assertEquals(api::DATAREQUEST_TYPE_EXPORT, $datarequest->get('type'));
|
||||
$this->assertEquals(api::DATAREQUEST_STATUS_AWAITING_APPROVAL, $datarequest->get('status'));
|
||||
$this->assertEquals($comment, $datarequest->get('comments'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for api::create_data_request()
|
||||
*
|
||||
* @dataProvider data_request_creation_provider
|
||||
* @param bool $asprivacyofficer Whether the request is made as the Privacy Officer or the user itself.
|
||||
* @param string $type The data request type.
|
||||
* @param string $setting The automatic approval setting.
|
||||
* @param bool $automaticapproval Whether automatic data request approval is turned on or not.
|
||||
* @param int|string $expecteddpoval The expected value for the 'dpo' field. 'dpo' means we'd the expected value would be the
|
||||
* user ID of the privacy officer which happens in the case where a PO requests on behalf of
|
||||
* someone else and automatic data request approval is turned on.
|
||||
* @param int $expectedstatus The expected status of the data request.
|
||||
* @param int $expectedtaskcount The number of expected queued data requests tasks.
|
||||
* @throws coding_exception
|
||||
* @throws invalid_persistent_exception
|
||||
* Test for api::create_data_request() made by DPO.
|
||||
*/
|
||||
public function test_create_data_request($asprivacyofficer, $type, $setting, $automaticapproval, $expecteddpoval,
|
||||
$expectedstatus, $expectedtaskcount) {
|
||||
public function test_create_data_request_by_dpo() {
|
||||
global $USER;
|
||||
|
||||
$this->resetAfterTest();
|
||||
@@ -622,34 +589,16 @@ class tool_dataprivacy_api_testcase extends advanced_testcase {
|
||||
$user = $generator->create_user();
|
||||
$comment = 'sample comment';
|
||||
|
||||
// Login.
|
||||
if ($asprivacyofficer) {
|
||||
$this->setAdminUser();
|
||||
} else {
|
||||
$this->setUser($user->id);
|
||||
}
|
||||
|
||||
// Set the automatic data request approval setting value.
|
||||
set_config($setting, $automaticapproval, 'tool_dataprivacy');
|
||||
|
||||
// If set to 'dpo' use the currently logged-in user's ID (which should be the admin user's ID).
|
||||
if ($expecteddpoval === 'dpo') {
|
||||
$expecteddpoval = $USER->id;
|
||||
}
|
||||
// Login as DPO (Admin is DPO by default).
|
||||
$this->setAdminUser();
|
||||
|
||||
// Test data request creation.
|
||||
$datarequest = api::create_data_request($user->id, $type, $comment);
|
||||
$datarequest = api::create_data_request($user->id, api::DATAREQUEST_TYPE_EXPORT, $comment);
|
||||
$this->assertEquals($user->id, $datarequest->get('userid'));
|
||||
$this->assertEquals($USER->id, $datarequest->get('requestedby'));
|
||||
$this->assertEquals($expecteddpoval, $datarequest->get('dpo'));
|
||||
$this->assertEquals($type, $datarequest->get('type'));
|
||||
$this->assertEquals($expectedstatus, $datarequest->get('status'));
|
||||
$this->assertEquals(api::DATAREQUEST_TYPE_EXPORT, $datarequest->get('type'));
|
||||
$this->assertEquals(api::DATAREQUEST_STATUS_AWAITING_APPROVAL, $datarequest->get('status'));
|
||||
$this->assertEquals($comment, $datarequest->get('comments'));
|
||||
$this->assertEquals($automaticapproval, $datarequest->get('systemapproved'));
|
||||
|
||||
// Test number of queued data request tasks.
|
||||
$datarequesttasks = manager::get_adhoc_tasks(process_data_request_task::class);
|
||||
$this->assertCount($expectedtaskcount, $datarequesttasks);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2306,88 +2255,4 @@ class tool_dataprivacy_api_testcase extends advanced_testcase {
|
||||
set_config('siteadmins', $child->id);
|
||||
$this->assertFalse(api::can_create_data_deletion_request_for_children($child->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider function for testing \tool_dataprivacy\api::queue_data_request_task().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function queue_data_request_task_provider() {
|
||||
return [
|
||||
'With user ID provided' => [true],
|
||||
'Without user ID provided' => [false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for \tool_dataprivacy\api::queue_data_request_task().
|
||||
*
|
||||
* @dataProvider queue_data_request_task_provider
|
||||
* @param bool $withuserid
|
||||
*/
|
||||
public function test_queue_data_request_task(bool $withuserid) {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
if ($withuserid) {
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
api::queue_data_request_task(1, $user->id);
|
||||
$expecteduserid = $user->id;
|
||||
} else {
|
||||
api::queue_data_request_task(1);
|
||||
$expecteduserid = null;
|
||||
}
|
||||
|
||||
// Test number of queued data request tasks.
|
||||
$datarequesttasks = manager::get_adhoc_tasks(process_data_request_task::class);
|
||||
$this->assertCount(1, $datarequesttasks);
|
||||
$requesttask = reset($datarequesttasks);
|
||||
$this->assertEquals($expecteduserid, $requesttask->get_userid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_is_automatic_request_approval_on().
|
||||
*/
|
||||
public function automatic_request_approval_setting_provider() {
|
||||
return [
|
||||
'Data export, not set' => [
|
||||
'automaticdataexportapproval', api::DATAREQUEST_TYPE_EXPORT, null, false
|
||||
],
|
||||
'Data export, turned on' => [
|
||||
'automaticdataexportapproval', api::DATAREQUEST_TYPE_EXPORT, true, true
|
||||
],
|
||||
'Data export, turned off' => [
|
||||
'automaticdataexportapproval', api::DATAREQUEST_TYPE_EXPORT, false, false
|
||||
],
|
||||
'Data deletion, not set' => [
|
||||
'automaticdatadeletionapproval', api::DATAREQUEST_TYPE_DELETE, null, false
|
||||
],
|
||||
'Data deletion, turned on' => [
|
||||
'automaticdatadeletionapproval', api::DATAREQUEST_TYPE_DELETE, true, true
|
||||
],
|
||||
'Data deletion, turned off' => [
|
||||
'automaticdatadeletionapproval', api::DATAREQUEST_TYPE_DELETE, false, false
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for \tool_dataprivacy\api::is_automatic_request_approval_on().
|
||||
*
|
||||
* @dataProvider automatic_request_approval_setting_provider
|
||||
* @param string $setting The automatic approval setting.
|
||||
* @param int $type The data request type.
|
||||
* @param bool $value The setting's value.
|
||||
* @param bool $expected The expected result.
|
||||
*/
|
||||
public function test_is_automatic_request_approval_on($setting, $type, $value, $expected) {
|
||||
$this->resetAfterTest();
|
||||
|
||||
if ($value !== null) {
|
||||
set_config($setting, $value, 'tool_dataprivacy');
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, api::is_automatic_request_approval_on($type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,13 +240,3 @@ Feature: Data delete from the privacy API
|
||||
And I reload the page
|
||||
And I open the action menu in "region-main" "region"
|
||||
Then I should not see "Resubmit as new request"
|
||||
|
||||
Scenario: Request data deletion as student with automatic approval turned on
|
||||
Given the following config values are set as admin:
|
||||
| automaticdatadeletionapproval | 1 | tool_dataprivacy |
|
||||
And I log in as "victim"
|
||||
And I follow "Profile" in the user menu
|
||||
And I follow "Delete my account"
|
||||
When I press "Save changes"
|
||||
Then I should see "Your request has been submitted and will be processed soon."
|
||||
And I should see "Approved" in the "Delete all of my personal data" "table_row"
|
||||
|
||||
@@ -151,13 +151,3 @@ Feature: Data export from the privacy API
|
||||
When I reload the page
|
||||
And I set the field "Search" to "University2"
|
||||
Then I should see "Victim User 2"
|
||||
|
||||
Scenario: Request data export as student with automatic approval turned on
|
||||
Given the following config values are set as admin:
|
||||
| automaticdataexportapproval | 1 | tool_dataprivacy |
|
||||
And I log in as "victim"
|
||||
And I follow "Profile" in the user menu
|
||||
And I follow "Export all of my personal data"
|
||||
When I press "Save changes"
|
||||
Then I should see "Your request has been submitted and will be processed soon."
|
||||
And I should see "Approved" in the "Export all of my personal data" "table_row"
|
||||
|
||||
@@ -12,7 +12,7 @@ Feature: Manage data categories
|
||||
And I press "Add category"
|
||||
And I set the field "Name" to "Category 1"
|
||||
And I set the field "Description" to "Category 1 description"
|
||||
When I click on "Save" "button" in the "Add category" "dialogue"
|
||||
When I click on "Save" "button" in the "Delete category" "dialogue"
|
||||
Then I should see "Category 1" in the "List of data categories" "table"
|
||||
And I should see "Category 1 description" in the "Category 1" "table_row"
|
||||
|
||||
@@ -30,5 +30,5 @@ Feature: Manage data categories
|
||||
And I choose "Delete" in the open action menu
|
||||
And I should see "Delete category"
|
||||
And I should see "Are you sure you want to delete the category 'Category 1'?"
|
||||
When I click on "Delete" "button" in the "Delete category" "dialogue"
|
||||
When I click on "Delete" "button" in the "Confirm" "dialogue"
|
||||
Then I should not see "Category 1" in the "List of data categories" "table"
|
||||
|
||||
@@ -52,5 +52,5 @@ Feature: Manage data storage purposes
|
||||
And I choose "Delete" in the open action menu
|
||||
And I should see "Delete purpose"
|
||||
And I should see "Are you sure you want to delete the purpose 'Purpose 1'?"
|
||||
When I click on "Delete" "button" in the "Delete purpose" "dialogue"
|
||||
When I click on "Delete" "button" in the "Confirm" "dialogue"
|
||||
Then I should not see "Purpose 1" in the "List of data purposes" "table"
|
||||
|
||||
@@ -1,187 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests for the plugin privacy provider
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2020 Paul Holden <paulh@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use core_privacy\local\request\userlist;
|
||||
use core_privacy\local\request\writer;
|
||||
use core_privacy\tests\provider_testcase;
|
||||
use tool_dataprivacy\api;
|
||||
use tool_dataprivacy\local\helper;
|
||||
use tool_dataprivacy\privacy\provider;
|
||||
|
||||
/**
|
||||
* Privacy provider tests
|
||||
*
|
||||
* @package tool_dataprivacy
|
||||
* @copyright 2020 Paul Holden <paulh@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_dataprivacy_privacy_provider_testcase extends provider_testcase {
|
||||
|
||||
/**
|
||||
* Test provider get_contexts_for_userid method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_contexts_for_userid() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$context = context_user::instance($user->id);
|
||||
|
||||
// Returned context list should contain a single item.
|
||||
$contextlist = $this->get_contexts_for_userid($user->id, 'tool_dataprivacy');
|
||||
$this->assertCount(1, $contextlist);
|
||||
|
||||
// We should have the user context of our test user.
|
||||
$this->assertSame($context, $contextlist->current());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test provider get_users_in_context method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_users_in_context() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$context = context_user::instance($user->id);
|
||||
|
||||
$userlist = new userlist($context, 'tool_dataprivacy');
|
||||
provider::get_users_in_context($userlist);
|
||||
|
||||
$this->assertEquals([$user->id], $userlist->get_userids());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test provider get_users_in_context method for a non-user context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_get_users_in_context_non_user_context() {
|
||||
$context = context_system::instance();
|
||||
|
||||
$userlist = new userlist($context, 'tool_dataprivacy');
|
||||
provider::get_users_in_context($userlist);
|
||||
|
||||
$this->assertEmpty($userlist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test provider export_user_data method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_export_user_data() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$context = context_user::instance($user->id);
|
||||
|
||||
$this->setUser($user);
|
||||
|
||||
// Create an export request, approve it.
|
||||
$requestexport = api::create_data_request($user->id, api::DATAREQUEST_TYPE_EXPORT,
|
||||
'Please export my stuff');
|
||||
api::update_request_status($requestexport->get('id'), api::DATAREQUEST_STATUS_APPROVED);
|
||||
|
||||
// Create a deletion request, reject it.
|
||||
$requestdelete = api::create_data_request($user->id, api::DATAREQUEST_TYPE_DELETE);
|
||||
api::update_request_status($requestdelete->get('id'), api::DATAREQUEST_STATUS_REJECTED, 0, 'Nope');
|
||||
|
||||
$this->export_context_data_for_user($user->id, $context, 'tool_dataprivacy');
|
||||
|
||||
/** @var \core_privacy\tests\request\content_writer $writer */
|
||||
$writer = writer::with_context($context);
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
|
||||
/** @var stdClass[] $data */
|
||||
$data = (array) $writer->get_data([
|
||||
get_string('privacyandpolicies', 'admin'),
|
||||
get_string('datarequests', 'tool_dataprivacy'),
|
||||
]);
|
||||
|
||||
$this->assertCount(2, $data);
|
||||
|
||||
$strs = get_strings(['requesttypeexportshort', 'requesttypedeleteshort',
|
||||
'statusapproved', 'statusrejected', 'creationmanual'], 'tool_dataprivacy');
|
||||
|
||||
// First item is the approved export request.
|
||||
$this->assertEquals($strs->requesttypeexportshort, $data[0]->type);
|
||||
$this->assertEquals($strs->statusapproved, $data[0]->status);
|
||||
$this->assertEquals($strs->creationmanual, $data[0]->creationmethod);
|
||||
$this->assertEquals($requestexport->get('comments'), $data[0]->comments);
|
||||
$this->assertEmpty($data[0]->dpocomment);
|
||||
$this->assertNotEmpty($data[0]->timecreated);
|
||||
|
||||
// Next is the rejected deletion request.
|
||||
$this->assertEquals($strs->requesttypedeleteshort, $data[1]->type);
|
||||
$this->assertEquals($strs->statusrejected, $data[1]->status);
|
||||
$this->assertEquals($strs->creationmanual, $data[1]->creationmethod);
|
||||
$this->assertEmpty($data[1]->comments);
|
||||
$this->assertContains('Nope', $data[1]->dpocomment);
|
||||
$this->assertNotEmpty($data[1]->timecreated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test class export_user_preferences method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_export_user_preferences() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$user = $this->getDataGenerator()->create_user();
|
||||
$this->setUser($user);
|
||||
|
||||
// Set filters preference.
|
||||
$filters = [
|
||||
helper::FILTER_TYPE . ':' . api::DATAREQUEST_TYPE_EXPORT,
|
||||
helper::FILTER_STATUS . ':' . api::DATAREQUEST_STATUS_PENDING,
|
||||
];
|
||||
set_user_preference(helper::PREF_REQUEST_FILTERS, json_encode($filters), $user);
|
||||
|
||||
// Set paging preference.
|
||||
set_user_preference(helper::PREF_REQUEST_PERPAGE, 6, $user);
|
||||
|
||||
provider::export_user_preferences($user->id);
|
||||
|
||||
/** @var \core_privacy\tests\request\content_writer $writer */
|
||||
$writer = writer::with_context(context_system::instance());
|
||||
$this->assertTrue($writer->has_any_data());
|
||||
|
||||
/** @var stdClass[] $preferences */
|
||||
$preferences = (array) $writer->get_user_preferences('tool_dataprivacy');
|
||||
$this->assertCount(2, $preferences);
|
||||
|
||||
$this->assertEquals((object) [
|
||||
'value' => '1:1, 2:0',
|
||||
'description' => 'Type: Export, Status: Pending',
|
||||
], $preferences[helper::PREF_REQUEST_FILTERS]);
|
||||
|
||||
$this->assertEquals(6, $preferences[helper::PREF_REQUEST_PERPAGE]->value);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2019121700;
|
||||
$plugin->version = 2019111800;
|
||||
$plugin->requires = 2019111200; // Moodle 3.5dev (Build 2018031600) and upwards.
|
||||
$plugin->component = 'tool_dataprivacy';
|
||||
|
||||
@@ -52,7 +52,7 @@ class tool_filetypes_renderer extends plugin_renderer_base {
|
||||
$out = $this->heading(get_string('pluginname', 'tool_filetypes'));
|
||||
if ($restricted) {
|
||||
$out .= html_writer::div(
|
||||
html_writer::div(get_string('configoverride', 'admin'), 'alert alert-info'),
|
||||
html_writer::div(get_string('configoverride', 'admin'), 'form-overridden'),
|
||||
'', array('id' => 'adminsettings'));
|
||||
}
|
||||
if (count($combined) > 1) {
|
||||
|
||||
@@ -23,3 +23,10 @@
|
||||
.path-admin-tool-filetypes .generaltable .nonstandard {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Spacing around the 'Defined in config.php' stripe */
|
||||
.path-admin-tool-filetypes .form-overridden {
|
||||
display: inline-block;
|
||||
margin-bottom: 1em;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
define ("tool_licensemanager/delete_license",["jquery","core/modal_factory","core/modal_events","core/url","core/str"],function(a,b,c,d,e){var f=a(".delete-license");b.create({type:b.types.SAVE_CANCEL,title:e.get_string("deletelicense","tool_licensemanager"),body:e.get_string("deletelicenseconfirmmessage","tool_licensemanager"),preShowCallback:function preShowCallback(b,c){b=a(b);var e={action:"delete",license:b.data("license")};c.deleteURL=d.relativeUrl("/admin/tool/licensemanager/index.php",e,!0)},large:!0},f).done(function(a){a.getRoot().on(c.save,function(b){b.preventDefault();window.location.href=a.deleteURL})})});
|
||||
//# sourceMappingURL=delete_license.min.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../src/delete_license.js"],"names":["define","$","ModalFactory","ModalEvents","Url","String","trigger","create","type","types","SAVE_CANCEL","title","get_string","body","preShowCallback","triggerElement","modal","params","data","deleteURL","relativeUrl","large","done","getRoot","on","save","e","preventDefault","window","location","href"],"mappings":"AAwBAA,OAAM,sCAAC,CAAC,QAAD,CAAW,oBAAX,CAAiC,mBAAjC,CAAsD,UAAtD,CAAkE,UAAlE,CAAD,CACF,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAuCC,CAAvC,CAA4CC,CAA5C,CAAoD,CAEhD,GAAIC,CAAAA,CAAO,CAAGL,CAAC,CAAC,iBAAD,CAAf,CACAC,CAAY,CAACK,MAAb,CAAoB,CAChBC,IAAI,CAAEN,CAAY,CAACO,KAAb,CAAmBC,WADT,CAEhBC,KAAK,CAAEN,CAAM,CAACO,UAAP,CAAkB,eAAlB,CAAmC,qBAAnC,CAFS,CAGhBC,IAAI,CAAER,CAAM,CAACO,UAAP,CAAkB,6BAAlB,CAAiD,qBAAjD,CAHU,CAIhBE,eAAe,CAAE,yBAASC,CAAT,CAAyBC,CAAzB,CAAgC,CAC7CD,CAAc,CAAGd,CAAC,CAACc,CAAD,CAAlB,CACA,GAAIE,CAAAA,CAAM,CAAG,CACT,OAAU,QADD,CAET,QAAWF,CAAc,CAACG,IAAf,CAAoB,SAApB,CAFF,CAAb,CAIAF,CAAK,CAACG,SAAN,CAAkBf,CAAG,CAACgB,WAAJ,CAAgB,sCAAhB,CAAwDH,CAAxD,IACrB,CAXe,CAYhBI,KAAK,GAZW,CAApB,CAaGf,CAbH,EAcKgB,IAdL,CAcU,SAASN,CAAT,CAAgB,CAClBA,CAAK,CAACO,OAAN,GAAgBC,EAAhB,CAAmBrB,CAAW,CAACsB,IAA/B,CAAqC,SAASC,CAAT,CAAY,CAE7CA,CAAC,CAACC,cAAF,GAEAC,MAAM,CAACC,QAAP,CAAgBC,IAAhB,CAAuBd,CAAK,CAACG,SAChC,CALD,CAMH,CArBL,CAsBH,CA1BC,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Modal for confirming deletion of a custom license.\n *\n * @module tool_licensemanager/delete_license\n * @class delete_license\n * @package tool_licensemanager\n * @copyright 2019 Tom Dickman <tomdickman@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/modal_factory', 'core/modal_events', 'core/url', 'core/str'],\n function($, ModalFactory, ModalEvents, Url, String) {\n\n var trigger = $('.delete-license');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: String.get_string('deletelicense', 'tool_licensemanager'),\n body: String.get_string('deletelicenseconfirmmessage', 'tool_licensemanager'),\n preShowCallback: function(triggerElement, modal) {\n triggerElement = $(triggerElement);\n let params = {\n 'action': 'delete',\n 'license': triggerElement.data('license')\n };\n modal.deleteURL = Url.relativeUrl('/admin/tool/licensemanager/index.php', params, true);\n },\n large: true,\n }, trigger)\n .done(function(modal) {\n modal.getRoot().on(ModalEvents.save, function(e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n // Redirect to delete url.\n window.location.href = modal.deleteURL;\n });\n });\n });\n"],"file":"delete_license.min.js"}
|
||||
@@ -1,51 +0,0 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Modal for confirming deletion of a custom license.
|
||||
*
|
||||
* @module tool_licensemanager/delete_license
|
||||
* @class delete_license
|
||||
* @package tool_licensemanager
|
||||
* @copyright 2019 Tom Dickman <tomdickman@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/modal_factory', 'core/modal_events', 'core/url', 'core/str'],
|
||||
function($, ModalFactory, ModalEvents, Url, String) {
|
||||
|
||||
var trigger = $('.delete-license');
|
||||
ModalFactory.create({
|
||||
type: ModalFactory.types.SAVE_CANCEL,
|
||||
title: String.get_string('deletelicense', 'tool_licensemanager'),
|
||||
body: String.get_string('deletelicenseconfirmmessage', 'tool_licensemanager'),
|
||||
preShowCallback: function(triggerElement, modal) {
|
||||
triggerElement = $(triggerElement);
|
||||
let params = {
|
||||
'action': 'delete',
|
||||
'license': triggerElement.data('license')
|
||||
};
|
||||
modal.deleteURL = Url.relativeUrl('/admin/tool/licensemanager/index.php', params, true);
|
||||
},
|
||||
large: true,
|
||||
}, trigger)
|
||||
.done(function(modal) {
|
||||
modal.getRoot().on(ModalEvents.save, function(e) {
|
||||
// Stop the default save button behaviour which is to close the modal.
|
||||
e.preventDefault();
|
||||
// Redirect to delete url.
|
||||
window.location.href = modal.deleteURL;
|
||||
});
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user