Compare commits
313 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e90b10ad8 | |||
| 8a646b55f7 | |||
| 72cece6ff4 | |||
| 9b7b6fa33c | |||
| 43bfcff941 | |||
| a4611b9d02 | |||
| 5be009245b | |||
| a50bf852e4 | |||
| 9c3ef35763 | |||
| 562782a48d | |||
| b56324b829 | |||
| 47ee76344e | |||
| 844cb63fed | |||
| a668f57e75 | |||
| 543fc34ed9 | |||
| 0a32dca4bb | |||
| 65a550c484 | |||
| 0f83a143b0 | |||
| 793c431543 | |||
| 2e25f806fb | |||
| f923f7aefe | |||
| cb838a36b2 | |||
| 56f4d0ed80 | |||
| 6c806e8384 | |||
| 5b6e74c85f | |||
| c33a96f676 | |||
| 9910a5d7eb | |||
| 7c8fb69b1c | |||
| ef42830b87 | |||
| 05f8741cee | |||
| 9a1ac11640 | |||
| 04ab55dd4f | |||
| b2e3fb3dc9 | |||
| d72a0aa2c8 | |||
| 2be82d5e13 | |||
| 019cc4eae4 | |||
| 2726d2a6a4 | |||
| 0c49b6c445 | |||
| 83a23ea878 | |||
| f849d1f6fc | |||
| 2e8da707a0 | |||
| f4537d5676 | |||
| 850aa189e4 | |||
| c5e96ad32f | |||
| 9acc49eb93 | |||
| d389a2f7f4 | |||
| 321554d35f | |||
| 102903f7ab | |||
| 181b7f5fea | |||
| e04f57c95b | |||
| b9639c524d | |||
| 56003ca491 | |||
| 192cb8f894 | |||
| 2d7c42275f | |||
| ac41913cea | |||
| 359c790b1c | |||
| 49a66d4b68 | |||
| 1a5a5f8e9c | |||
| 3735e3d289 | |||
| 2c6b79365b | |||
| 1565171e07 | |||
| 0c1be2af21 | |||
| e5d70123c9 | |||
| 3d6b1bf4e3 | |||
| b164a8904a | |||
| 78ac8558e0 | |||
| 363ed37e76 | |||
| 3b800be056 | |||
| ef227f1e0f | |||
| 6606784c3f | |||
| a17b3a200e | |||
| d63a406b02 | |||
| e6a3c6e1a1 | |||
| 356513cc80 | |||
| b1dc798512 | |||
| 697871ddcf | |||
| 602150068a | |||
| eeeac779c8 | |||
| c0333c98ea | |||
| d59467dfc9 | |||
| c731018d50 | |||
| e17644cca3 | |||
| d71b142446 | |||
| b61dd8b299 | |||
| 41bbc35471 | |||
| 0af4bf40ee | |||
| b09c5ac837 | |||
| 3f897939b2 | |||
| 3124654247 | |||
| 9a57563b9f | |||
| 190b5e7cbe | |||
| a8f8537965 | |||
| f938b1a89b | |||
| 2a39a4e01c | |||
| ab7d4ea7ba | |||
| ac4404e0cc | |||
| 0fe16db123 | |||
| 5c0dd1fadd | |||
| a7eec81ec6 | |||
| e03782efdd | |||
| eb2d6a23ab | |||
| a48b376978 | |||
| 544f0f9b11 | |||
| 322af447f5 | |||
| ec39bd51dd | |||
| bbb750e1ba | |||
| 73dd2ee2d5 | |||
| a1ccc146ac | |||
| 7a6f073415 | |||
| 76fa287781 | |||
| 94c5a8fe82 | |||
| d3fdafc358 | |||
| 606c07ae3e | |||
| c6b458edce | |||
| a8ccdd2880 | |||
| 656581fa2c | |||
| 785a713b82 | |||
| cf04387947 | |||
| eddec24752 | |||
| f454c9884f | |||
| 53f7c0c641 | |||
| 2de5b09d84 | |||
| 70c31beef7 | |||
| 901dd625f8 | |||
| 7d3341b000 | |||
| 1f60fe8a23 | |||
| 730271af49 | |||
| 8a35efacd7 | |||
| cfa9c7e1d0 | |||
| acb011dc20 | |||
| a7a1adf4e0 | |||
| e60bae3575 | |||
| ddb5fb5980 | |||
| b70a545c88 | |||
| c383f33bbf | |||
| 13683200d6 | |||
| 7be97bd89d | |||
| cd281ce1b4 | |||
| adc1d7b2a5 | |||
| b4454b133f | |||
| 520a601f14 | |||
| 0409483d5f | |||
| 2d07933c17 | |||
| 6eabdb6d8c | |||
| 291455cecd | |||
| b76204d589 | |||
| e8e9393e76 | |||
| 231f758404 | |||
| e92d664dd2 | |||
| 973fe984cd | |||
| 4548df3155 | |||
| c874cee03a | |||
| caeb7f90b0 | |||
| da264959f2 | |||
| 41e1109c5f | |||
| 209b2f7b3e | |||
| 503325ddcb | |||
| 41575c5571 | |||
| 73f60c1886 | |||
| dc7c91ae67 | |||
| 15dbd27efa | |||
| 9a05bd0f8f | |||
| 524e1ce789 | |||
| 3d4de0bc4e | |||
| 1264dd11a0 | |||
| 599e7fe006 | |||
| b768c6f77a | |||
| 4651e4e464 | |||
| 4c7e6ea021 | |||
| 46b0673732 | |||
| 9c2d41fce2 | |||
| c5148e0ab6 | |||
| 8bd65e7aaa | |||
| 4dbdc18fd8 | |||
| 9789d825c2 | |||
| 8f0019214e | |||
| 45cff73a1b | |||
| aa0cd4a7ef | |||
| 785e3deb4d | |||
| 7a4b7c5e18 | |||
| dc5c56e90c | |||
| 26679bee33 | |||
| 1076d79905 | |||
| 0034f04164 | |||
| 1ff2b56319 | |||
| 4d9b4e9782 | |||
| f51fdc9bb7 | |||
| f1c403dcec | |||
| ab1f9aa3a4 | |||
| 1ce6bdd1dd | |||
| e20e67161c | |||
| c545dcad4f | |||
| 9e9dd64c35 | |||
| c6c7a7be8c | |||
| e958133ca6 | |||
| 9261144beb | |||
| 71cc181bac | |||
| cf617e112f | |||
| 865485fc54 | |||
| a595b4dacb | |||
| 7c431a345f | |||
| 4dbc9b0a64 | |||
| 9242214612 | |||
| 4832c70022 | |||
| 54fdd4c0e9 | |||
| 0324045e4f | |||
| fac9ba991b | |||
| ae5ecea065 | |||
| 6357dd08b6 | |||
| c15b286f88 | |||
| 4afa0b50c7 | |||
| b90b9b83bd | |||
| 79bf1e37ca | |||
| 95ae9d9e5e | |||
| 7027fe4538 | |||
| 50f3d7b5ea | |||
| 22fc0c5e9b | |||
| 6ff1745873 | |||
| 505530eaf5 | |||
| a2630c08ae | |||
| fddbdb79db | |||
| 1c90b9976d | |||
| 35cb0e4a4c | |||
| ada098890b | |||
| 2e8b836243 | |||
| b004c163ee | |||
| 6d0c04c208 | |||
| 29a7d7a1c1 | |||
| eda1d3f37a | |||
| 6466396f38 | |||
| 5b2313c26c | |||
| 473eadfe10 | |||
| 52d4168038 | |||
| c6bd16545e | |||
| 517a2dbe84 | |||
| 88d48cd51f | |||
| a5ff28cc9f | |||
| 1b2cf98bb0 | |||
| 86e28894f4 | |||
| c125bb553d | |||
| 4ac455d9a4 | |||
| 3b7a18f2e5 | |||
| a13a1707bc | |||
| 6812769f8f | |||
| 2f860b4ded | |||
| d84c21dfcc | |||
| 0e3c1231da | |||
| 71e8ee1c33 | |||
| 8938f0848e | |||
| 0e73e16460 | |||
| 9321379b10 | |||
| c91c7fcded | |||
| 0663096dc6 | |||
| 7a9e253405 | |||
| 5e6b64571c | |||
| c446a0fca2 | |||
| 07f89a017c | |||
| b8b1926e2f | |||
| 4d5970ea63 | |||
| 656cea20a6 | |||
| e9f8261131 | |||
| d87a55fc2b | |||
| b0c87306a6 | |||
| 38ab68e6ab | |||
| 0e7cadca03 | |||
| efd08cdc2b | |||
| 7e61737f3d | |||
| 138025470f | |||
| 8b72167d0e | |||
| f92305bfa9 | |||
| 0b4767ca50 | |||
| 1c50e53a05 | |||
| a3301036d6 | |||
| c7a34ab704 | |||
| 1b696de61b | |||
| f4d4c73899 | |||
| da0cf7f883 | |||
| 7c3f70812e | |||
| f5eabd12db | |||
| db1dd3e550 | |||
| f48902e139 | |||
| 7b03292e24 | |||
| 2a6e3435d0 | |||
| 0411eed2cb | |||
| 365ef195b5 | |||
| 8c3547554b | |||
| 324efa55e3 | |||
| 0b7c52dd4c | |||
| cf31390c6f | |||
| 5af62aa90a | |||
| cf839b4396 | |||
| 257a5d1299 | |||
| e6d4708fcf | |||
| f9870842bd | |||
| 2d7173d0c7 | |||
| 4682fc7c38 | |||
| 15a77653e4 | |||
| 9b1f784178 | |||
| 44bfbe1e15 | |||
| 0c767bf6cc | |||
| 81c89dd705 | |||
| b46ee168ef | |||
| e399d32694 | |||
| 606e2c8ebe | |||
| c6e0d385c3 | |||
| 31a3bcc933 | |||
| acade5443f | |||
| 113105bf9c | |||
| dd9f2b1cca | |||
| 90d740364b | |||
| 89bc7e7b6e | |||
| 5c58a540ea | |||
| 325e266e95 |
@@ -30,6 +30,3 @@ phpunit.xml
|
||||
composer.phar
|
||||
composer.lock
|
||||
/vendor/
|
||||
/behat.yml
|
||||
*/yui/build/*/*-coverage.js
|
||||
/lib/yuilib/*/build/*/*-coverage.js
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
{
|
||||
"browser": true,
|
||||
"yui": true,
|
||||
"bitwise": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nomen": false,
|
||||
"onevar": false,
|
||||
"plusplus": false,
|
||||
"regexp": false,
|
||||
"strict": false,
|
||||
"trailing": true,
|
||||
"unused": true,
|
||||
"white": false,
|
||||
"asi": false,
|
||||
"boss": false,
|
||||
"debug": false,
|
||||
"eqnull": false,
|
||||
"es5": false,
|
||||
"esnext": false,
|
||||
"evil": false,
|
||||
"expr": false,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"iterator": false,
|
||||
"lastsemic": false,
|
||||
"laxbreak": true,
|
||||
"laxcomma": false,
|
||||
"loopfunc": false,
|
||||
"multistr": false,
|
||||
"onecase": false,
|
||||
"proto": false,
|
||||
"regexdash": false,
|
||||
"scripturl": false,
|
||||
"shadow": false,
|
||||
"smarttabs": false,
|
||||
"sub": false,
|
||||
"supernew": false,
|
||||
"maxerr": 500,
|
||||
"maxlen": 180,
|
||||
"passfail": false,
|
||||
"latedef": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"coverage": false,
|
||||
"lint": "config",
|
||||
"clean": true
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ a few minutes:
|
||||
1) Move the Moodle files into your web directory.
|
||||
|
||||
2) Create a single database for Moodle to store all
|
||||
its tables in (or choose an existing database).
|
||||
it's tables in (or choose an existing database).
|
||||
|
||||
3) Visit your Moodle site with a browser, you should
|
||||
be taken to the install.php script, which will lead
|
||||
|
||||
+1
-5
@@ -30,9 +30,6 @@
|
||||
$strprotect = get_string('blockprotect', 'admin');
|
||||
$strunprotect = get_string('blockunprotect', 'admin');
|
||||
|
||||
// Purge all caches related to blocks administration.
|
||||
cache::make('core', 'plugininfo_block')->purge();
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) && confirm_sesskey()) {
|
||||
@@ -130,8 +127,7 @@
|
||||
$table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
|
||||
$table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
|
||||
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
|
||||
$table->set_attribute('class', 'admintable blockstable generaltable');
|
||||
$table->set_attribute('id', 'compatibleblockstable');
|
||||
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
|
||||
$table->setup();
|
||||
$tablerows = array();
|
||||
|
||||
|
||||
+19
-18
@@ -97,26 +97,27 @@ foreach ($settingspage->children as $childpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link($childpage->url, $childpage->visiblename), 3);
|
||||
} else if ($childpage instanceof admin_settingpage) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/settings.php', array('section' => $childpage->name)), $childpage->visiblename), 3);
|
||||
// If its a settings page and has settings lets display them.
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
} else if ($childpage instanceof admin_category) {
|
||||
$outputhtml .= $OUTPUT->heading(html_writer::link(new moodle_url('/'.$CFG->admin.'/category.php', array('category' => $childpage->name)), get_string('admincategory', 'admin', $childpage->visiblename)), 3);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (!empty($childpage->settings)) {
|
||||
$outputhtml .= html_writer::start_tag('fieldset', array('class' => 'adminsettings'));
|
||||
foreach ($childpage->settings as $setting) {
|
||||
if (empty($setting->nosave)) {
|
||||
$savebutton = true;
|
||||
}
|
||||
$fullname = $setting->get_full_name();
|
||||
if (array_key_exists($fullname, $adminroot->errors)) {
|
||||
$data = $adminroot->errors[$fullname]->data;
|
||||
} else {
|
||||
$data = $setting->get_setting();
|
||||
}
|
||||
$outputhtml .= html_writer::tag('div', '<!-- -->', array('class' => 'clearer'));
|
||||
$outputhtml .= $setting->output_html($data);
|
||||
}
|
||||
$outputhtml .= html_writer::end_tag('fieldset');
|
||||
}
|
||||
}
|
||||
if ($savebutton) {
|
||||
|
||||
@@ -1,91 +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 script fixed incorrectly deleted users.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2013 Petr Skoda (http://skodak.org)
|
||||
* @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');
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
$help =
|
||||
"Fix incorrectly deleted users.
|
||||
|
||||
This scripts detects users that are marked as deleted instead
|
||||
of calling delete_user().
|
||||
|
||||
Deleted users do not have original username, idnumber or email,
|
||||
we must also delete all roles, enrolments, group memberships, etc.
|
||||
|
||||
Please note this script does not delete any public information
|
||||
such as forum posts.
|
||||
|
||||
Options:
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/fix_deleted_users.php
|
||||
";
|
||||
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
cli_heading('Looking for sloppy user deletes');
|
||||
|
||||
// Look for sloppy deleted users where somebody only flipped the deleted flag.
|
||||
$sql = "SELECT *
|
||||
FROM {user}
|
||||
WHERE deleted = 1 AND email LIKE '%@%' AND username NOT LIKE '%@%'";
|
||||
$rs = $DB->get_recordset_sql($sql);
|
||||
foreach ($rs as $user) {
|
||||
echo "Redeleting user $user->id: $user->username ($user->email)\n";
|
||||
delete_user($user);
|
||||
}
|
||||
|
||||
cli_heading('Deleting all leftovers');
|
||||
|
||||
$DB->set_field('user', 'idnumber', '', array('deleted'=>1));
|
||||
|
||||
$DB->delete_records_select('role_assignments', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('cohort_members', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('groups_members', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_enrolments', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_preferences', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_info_data', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('user_lastaccess', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('external_tokens', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
$DB->delete_records_select('external_services_users', "userid IN (SELECT id FROM {user} WHERE deleted = 1)");
|
||||
|
||||
exit(0);
|
||||
@@ -127,14 +127,14 @@ if (function_exists('date_default_timezone_set') and function_exists('date_defau
|
||||
/** Used by library scripts to check they are being called by Moodle */
|
||||
define('MOODLE_INTERNAL', true);
|
||||
|
||||
// Disables all caching.
|
||||
// Disables caching.. just in case.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.3.3") < 0) {
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -149,7 +149,6 @@ $CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
|
||||
$CFG->admin = array_pop($parts);
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
// extra execution prevention - we can not just require config.php here
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
@@ -56,10 +55,10 @@ Example:
|
||||
";
|
||||
|
||||
// Check that PHP is of a sufficient version
|
||||
if (version_compare(phpversion(), "5.3.3") < 0) {
|
||||
if (version_compare(phpversion(), "5.3.2") < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
|
||||
fwrite(STDERR, "Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
|
||||
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+10
-46
@@ -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,7 +16,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Enable or disable maintenance mode.
|
||||
* Enable or disable maintenance mode
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
@@ -25,13 +26,12 @@
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__.'/../../config.php');
|
||||
require_once("$CFG->libdir/clilib.php");
|
||||
require_once("$CFG->libdir/adminlib.php");
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/clilib.php'); // cli only functions
|
||||
|
||||
|
||||
// Now get cli options.
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'enablelater'=>0, 'enableold'=>false, 'disable'=>false, 'help'=>false),
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'disable'=>false, 'help'=>false),
|
||||
array('h'=>'help'));
|
||||
|
||||
if ($unrecognized) {
|
||||
@@ -45,14 +45,12 @@ if ($options['help']) {
|
||||
Current status displayed if not option specified.
|
||||
|
||||
Options:
|
||||
--enable Enable CLI maintenance mode
|
||||
--enablelater=MINUTES Number of minutes before entering CLI maintenance mode
|
||||
--enableold Enable legacy half-maintenance mode
|
||||
--enable Enable maintenance mode
|
||||
--disable Disable maintenance mode
|
||||
-h, --help Print out this help
|
||||
|
||||
Example:
|
||||
\$ sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
\$sudo -u www-data /usr/bin/php admin/cli/maintenance.php
|
||||
"; //TODO: localize - to be translated later when everything is finished
|
||||
|
||||
echo $help;
|
||||
@@ -61,52 +59,18 @@ Example:
|
||||
|
||||
cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
|
||||
|
||||
if ($options['enablelater']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// Already enabled, sorry.
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
$time = time() + ($options['enablelater']*60);
|
||||
set_config('maintenance_later', $time);
|
||||
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($time))."\n";
|
||||
return 0;
|
||||
|
||||
} else if ($options['enable']) {
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
// The maintenance is already enabled, nothing to do.
|
||||
} else {
|
||||
enable_cli_maintenance_mode();
|
||||
}
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceoncli', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['enableold']) {
|
||||
if ($options['enable']) {
|
||||
set_config('maintenance_enabled', 1);
|
||||
unset_config('maintenance_later');
|
||||
echo get_string('sitemaintenanceon', 'admin')."\n";
|
||||
exit(0);
|
||||
|
||||
} else if ($options['disable']) {
|
||||
set_config('maintenance_enabled', 0);
|
||||
unset_config('maintenance_later');
|
||||
if (file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
unlink("$CFG->dataroot/climaintenance.html");
|
||||
}
|
||||
echo get_string('sitemaintenanceoff', 'admin')."\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (!empty($CFG->maintenance_enabled) or file_exists("$CFG->dataroot/climaintenance.html")) {
|
||||
if (!empty($CFG->maintenance_enabled)) {
|
||||
echo get_string('clistatusenabled', 'admin')."\n";
|
||||
|
||||
} else if (isset($CFG->maintenance_later)) {
|
||||
echo get_string('clistatusenabledlater', 'admin', userdate($CFG->maintenance_later))."\n";
|
||||
|
||||
} else {
|
||||
echo get_string('clistatusdisabled', 'admin')."\n";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
|
||||
require(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
@@ -151,12 +150,6 @@ if ($interactive) {
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) {
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
set_config('release', $release);
|
||||
|
||||
@@ -40,7 +40,8 @@ require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
|
||||
|
||||
$formatplugins = plugin_manager::instance()->get_plugins_of_type('format');
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
$formatplugins = $allplugins['format'];
|
||||
$sortorder = array_flip(array_keys($formatplugins));
|
||||
|
||||
if (!isset($formatplugins[$formatname])) {
|
||||
|
||||
+20
-374
@@ -227,7 +227,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -237,7 +237,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -277,12 +277,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -344,7 +344,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -354,7 +354,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -394,12 +394,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -454,7 +454,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -464,7 +464,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -504,12 +504,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -569,7 +569,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -579,7 +579,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -619,12 +619,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -685,7 +685,7 @@
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
<ON_CHECK message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
@@ -695,7 +695,7 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
<ON_CHECK message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
@@ -735,12 +735,12 @@
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
<ON_CHECK message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
<ON_CHECK message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
@@ -776,358 +776,4 @@
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.5" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="odbc_mssql" version="9.0" />
|
||||
<VENDOR name="mssql_n" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
<VENDOR name="sqlite" version="2.0" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.3" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="40M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.6" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="5.1.33" />
|
||||
<VENDOR name="postgres" version="8.3" />
|
||||
<VENDOR name="mssql" version="9.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.3.3" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="optional">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="64M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="safe_mode" value="0" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingsafemode" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
</MOODLE>
|
||||
<MOODLE version="2.7" requires="2.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.5.31" />
|
||||
<VENDOR name="postgres" version="9.1" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="10.2" />
|
||||
</DATABASE>
|
||||
<PHP version="5.4.4" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opensslrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="intlrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+36
-18
@@ -35,7 +35,7 @@
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_SAFEDIR);
|
||||
$filterpath = optional_param('filterpath', '', PARAM_PATH);
|
||||
|
||||
require_login();
|
||||
$systemcontext = context_system::instance();
|
||||
@@ -44,9 +44,6 @@
|
||||
$returnurl = "$CFG->wwwroot/$CFG->admin/filters.php";
|
||||
admin_externalpage_setup('managefilters');
|
||||
|
||||
// Purge all caches related to filter administration.
|
||||
cache::make('core', 'plugininfo_filter')->purge();
|
||||
|
||||
$filters = filter_get_global_states();
|
||||
|
||||
// In case any new filters have been installed, but not put in the table yet.
|
||||
@@ -87,22 +84,39 @@
|
||||
|
||||
case 'down':
|
||||
if (isset($filters[$filterpath])) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, 1);
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
if ($oldpos <= count($filters)) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos + 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'up':
|
||||
if (isset($filters[$filterpath])) {
|
||||
$oldpos = $filters[$filterpath]->sortorder;
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, -1);
|
||||
if ($oldpos >= 1) {
|
||||
filter_set_global_state($filterpath, $filters[$filterpath]->active, $oldpos - 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if (!empty($filternames[$filterpath])) {
|
||||
$filtername = $filternames[$filterpath];
|
||||
} else {
|
||||
$filtername = $filterpath;
|
||||
}
|
||||
|
||||
if (substr($filterpath, 0, 4) == 'mod/') {
|
||||
$mod = basename($filterpath);
|
||||
$a = new stdClass;
|
||||
$a->filter = $filtername;
|
||||
$a->module = get_string('modulename', $mod);
|
||||
print_error('cannotdeletemodfilter', 'admin', $returnurl, $a);
|
||||
}
|
||||
|
||||
// If not yet confirmed, display a confirmation message.
|
||||
if (!optional_param('confirm', '', PARAM_BOOL)) {
|
||||
$filtername = filter_get_name($filterpath);
|
||||
|
||||
$title = get_string('deletefilterareyousure', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
@@ -115,7 +129,7 @@
|
||||
}
|
||||
|
||||
// Do the deletion.
|
||||
$title = get_string('deletingfilter', 'admin', $filterpath);
|
||||
$title = get_string('deletingfilter', 'admin', $filtername);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($title);
|
||||
|
||||
@@ -123,8 +137,8 @@
|
||||
filter_delete_all_for_filter($filterpath);
|
||||
|
||||
$a = new stdClass;
|
||||
$a->filter = $filterpath;
|
||||
$a->directory = "$CFG->dirroot/filter/$filterpath";
|
||||
$a->filter = $filtername;
|
||||
$a->directory = $filterpath;
|
||||
echo $OUTPUT->box(get_string('deletefilterfiles', 'admin', $a), 'generalbox', 'notice');
|
||||
echo $OUTPUT->continue_button($returnurl);
|
||||
echo $OUTPUT->footer();
|
||||
@@ -171,9 +185,8 @@
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('filter'), get_string('isactive', 'filters'),
|
||||
get_string('order'), get_string('applyto', 'filters'), get_string('settings'), get_string('delete'));
|
||||
$table->colclasses = array ('leftalign', 'leftalign', 'centeralign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->id = 'filterssetting';
|
||||
$table->align = array('left', 'left', 'center', 'left', 'left');
|
||||
$table->width = '100%';
|
||||
$table->data = array();
|
||||
|
||||
$lastactive = null;
|
||||
@@ -228,7 +241,7 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
|
||||
}
|
||||
|
||||
// Disable/off/on
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . $filter);
|
||||
$select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . basename($filter));
|
||||
$select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide'));
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
@@ -250,20 +263,25 @@ function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
|
||||
$row[] = $updown;
|
||||
|
||||
// Apply to strings.
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter);
|
||||
$select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . basename($filter));
|
||||
$select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide'));
|
||||
$select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
|
||||
$row[] = $OUTPUT->render($select);
|
||||
|
||||
// Settings link, if required
|
||||
if (filter_has_global_settings($filter)) {
|
||||
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . $filter . '">' . get_string('settings') . '</a>';
|
||||
$row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' .
|
||||
str_replace('/', '',$filter) . '">' . get_string('settings') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
// Delete
|
||||
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
|
||||
if (substr($filter, 0, 4) != 'mod/') {
|
||||
$row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
|
||||
} else {
|
||||
$row[] = '';
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
+45
-131
@@ -30,10 +30,10 @@ if (!file_exists('../config.php')) {
|
||||
}
|
||||
|
||||
// Check that PHP is of a sufficient version as soon as possible
|
||||
if (version_compare(phpversion(), '5.3.3') < 0) {
|
||||
if (version_compare(phpversion(), '5.3.2') < 0) {
|
||||
$phpversion = phpversion();
|
||||
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
|
||||
echo "Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version $phpversion).<br />";
|
||||
echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
|
||||
echo "Please upgrade your server software or install older Moodle version.";
|
||||
die();
|
||||
}
|
||||
@@ -45,25 +45,8 @@ if (!function_exists('iconv')) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Make sure php5-json is available.
|
||||
if (!function_exists('json_encode') || !function_exists('json_decode')) {
|
||||
// This also shouldn't happen.
|
||||
echo 'Moodle requires the json PHP extension. Please install or enable the json extension.';
|
||||
die();
|
||||
}
|
||||
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
if ((isset($_GET['cache']) and $_GET['cache'] === '0')
|
||||
or (isset($_POST['cache']) and $_POST['cache'] === '0')
|
||||
or (!isset($_POST['cache']) and !isset($_GET['cache']) and empty($_GET['sesskey']) and empty($_POST['sesskey']))) {
|
||||
// Prevent caching at all cost when visiting this page directly,
|
||||
// we redirect to self once we known no upgrades are necessary.
|
||||
// Note: $_GET and $_POST are used here intentionally because our param cleaning is not loaded yet.
|
||||
// Note2: the sesskey is present in all block editing hacks, we can not redirect there, so enable caching.
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
}
|
||||
|
||||
require('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php'); // various admin-only functions
|
||||
require_once($CFG->libdir.'/upgradelib.php'); // general upgrade/install related functions
|
||||
@@ -76,34 +59,14 @@ $confirmplugins = optional_param('confirmplugincheck', 0, PARAM_BOOL);
|
||||
$showallplugins = optional_param('showallplugins', 0, PARAM_BOOL);
|
||||
$agreelicense = optional_param('agreelicense', 0, PARAM_BOOL);
|
||||
$fetchupdates = optional_param('fetchupdates', 0, PARAM_BOOL);
|
||||
$newaddonreq = optional_param('installaddonrequest', null, PARAM_RAW);
|
||||
$cache = optional_param('cache', 0, PARAM_BOOL);
|
||||
|
||||
// Set up PAGE.
|
||||
$url = new moodle_url('/admin/index.php');
|
||||
$url->param('cache', $cache);
|
||||
$PAGE->set_url($url);
|
||||
unset($url);
|
||||
|
||||
// Are we returning from an add-on installation request at moodle.org/plugins?
|
||||
if ($newaddonreq and !$cache and empty($CFG->disableonclickaddoninstall)) {
|
||||
$target = new moodle_url('/admin/tool/installaddon/index.php', array(
|
||||
'installaddonrequest' => $newaddonreq,
|
||||
'confirm' => 0));
|
||||
if (!isloggedin() or isguestuser()) {
|
||||
// Login and go the the add-on tool page.
|
||||
$SESSION->wantsurl = $target->out();
|
||||
redirect(get_login_url());
|
||||
}
|
||||
redirect($target);
|
||||
}
|
||||
// Check some PHP server settings
|
||||
|
||||
$PAGE->set_url('/admin/index.php');
|
||||
$PAGE->set_pagelayout('admin'); // Set a default pagelayout
|
||||
|
||||
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
|
||||
|
||||
// Check some PHP server settings
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
|
||||
}
|
||||
@@ -228,56 +191,33 @@ if (empty($CFG->version)) {
|
||||
print_error('missingconfigversion', 'debug');
|
||||
}
|
||||
|
||||
// Detect config cache inconsistency, this happens when you switch branches on dev servers.
|
||||
if ($cache) {
|
||||
if ($CFG->version != $DB->get_field('config', 'value', array('name'=>'version'))) {
|
||||
purge_all_caches();
|
||||
redirect(new moodle_url('/admin/index.php'), 'Config cache inconsistency detected, resetting caches...');
|
||||
}
|
||||
}
|
||||
|
||||
if ($version > $CFG->version) { // upgrade
|
||||
|
||||
// Warning about upgrading a test site.
|
||||
$testsite = false;
|
||||
if (defined('BEHAT_SITE_RUNNING')) {
|
||||
$testsite = 'behat';
|
||||
}
|
||||
|
||||
// We purge all of MUC's caches here.
|
||||
// Caches are disabled for upgrade by CACHE_DISABLE_ALL so we must set the first arg to true.
|
||||
// This ensures a real config object is loaded and the stores will be purged.
|
||||
// This is the only way we can purge custom caches such as memcache or APC.
|
||||
// Note: all other calls to caches will still used the disabled API.
|
||||
cache_helper::purge_all(true);
|
||||
// We then purge the regular caches.
|
||||
purge_all_caches();
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
if (upgrade_stale_php_files_present()) {
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_stale_php_files_page();
|
||||
die();
|
||||
}
|
||||
|
||||
if (empty($confirmupgrade)) {
|
||||
$a = new stdClass();
|
||||
$a->oldversion = "$CFG->release (".sprintf('%.2f', $CFG->version).")";
|
||||
$a->newversion = "$release (".sprintf('%.2f', $version).")";
|
||||
$a->oldversion = "$CFG->release ($CFG->version)";
|
||||
$a->newversion = "$release ($version)";
|
||||
$strdatabasechecking = get_string('databasechecking', '', $a);
|
||||
|
||||
$PAGE->set_title($stradministration);
|
||||
$PAGE->set_heading($strdatabasechecking);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmrelease)){
|
||||
@@ -290,6 +230,7 @@ if ($version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
|
||||
@@ -303,22 +244,31 @@ if ($version > $CFG->version) { // upgrade
|
||||
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1));
|
||||
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
if ($fetchupdates) {
|
||||
$updateschecker = available_update_checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||
$updateschecker->fetch();
|
||||
// no sesskey support guaranteed here
|
||||
if (empty($CFG->disableupdatenotifications)) {
|
||||
available_update_checker::instance()->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($reloadurl, $reloadurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
// No sesskey support guaranteed here, because sessions might not work yet.
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
@@ -330,18 +280,7 @@ if ($version > $CFG->version) { // upgrade
|
||||
die();
|
||||
|
||||
} else {
|
||||
// Always verify plugin dependencies!
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0));
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// Launch main upgrade.
|
||||
// Launch main upgrade
|
||||
upgrade_core($version, true);
|
||||
}
|
||||
} else if ($version < $CFG->version) {
|
||||
@@ -361,10 +300,6 @@ if ($branch <> $CFG->branch) { // Update the branch
|
||||
if (moodle_needs_upgrading()) {
|
||||
if (!$PAGE->headerprinted) {
|
||||
// means core upgrade or installation was not already done
|
||||
|
||||
/** @var core_admin_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
@@ -376,44 +311,39 @@ if (moodle_needs_upgrading()) {
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
if ($fetchupdates) {
|
||||
$updateschecker = available_update_checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
require_sesskey();
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
redirect($reloadurl);
|
||||
// no sesskey support guaranteed here
|
||||
available_update_checker::instance()->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$deployer->initialize($PAGE->url, $PAGE->url);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
require_sesskey();
|
||||
echo $output->upgrade_plugin_confirm_deploy_page($deployer, $deploydata);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// Show plugins info.
|
||||
// check plugin dependencies first
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $PAGE->url);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
|
||||
// dependencies check passed, let's rock!
|
||||
echo $output->upgrade_plugin_check_page(plugin_manager::instance(), available_update_checker::instance(),
|
||||
$version, $showallplugins,
|
||||
new moodle_url($PAGE->url),
|
||||
new moodle_url('/admin/index.php', array('confirmplugincheck'=>1)));
|
||||
die();
|
||||
}
|
||||
|
||||
// Always verify plugin dependencies!
|
||||
$failed = array();
|
||||
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
$PAGE->set_popup_notification_allowed(false);
|
||||
$reloadurl = new moodle_url('/admin/index.php', array('cache' => 0));
|
||||
echo $output->unsatisfied_dependencies_page($version, $failed, $reloadurl);
|
||||
die();
|
||||
}
|
||||
unset($failed);
|
||||
}
|
||||
// install/upgrade all plugins and other parts
|
||||
upgrade_noncore(true);
|
||||
@@ -474,30 +404,8 @@ if (during_initial_install()) {
|
||||
upgrade_finished('upgradesettings.php');
|
||||
}
|
||||
|
||||
if (has_capability('moodle/site:config', context_system::instance())) {
|
||||
if ($fetchupdates) {
|
||||
$updateschecker = available_update_checker::instance();
|
||||
if ($updateschecker->enabled()) {
|
||||
require_sesskey();
|
||||
$updateschecker->fetch();
|
||||
}
|
||||
redirect(new moodle_url('/admin/index.php', array('cache' => 0)));
|
||||
}
|
||||
}
|
||||
|
||||
// Now we can be sure everything was upgraded and caches work fine,
|
||||
// redirect if necessary to make sure caching is enabled.
|
||||
if (!$cache and !optional_param('sesskey', '', PARAM_RAW)) {
|
||||
redirect(new moodle_url($PAGE->url, array('cache' => 1)));
|
||||
}
|
||||
|
||||
// Check for valid admin user - no guest autologin
|
||||
require_login(0, false);
|
||||
if (isguestuser()) {
|
||||
// Login as real user!
|
||||
$SESSION->wantsurl = (string)new moodle_url('/admin/index.php');
|
||||
redirect(get_login_url());
|
||||
}
|
||||
$context = context_system::instance();
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
@@ -568,6 +476,12 @@ $registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOOD
|
||||
|
||||
admin_externalpage_setup('adminnotifications');
|
||||
|
||||
if ($fetchupdates) {
|
||||
require_sesskey();
|
||||
$updateschecker->fetch();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed,
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
|
||||
@@ -35,5 +35,16 @@ function admin_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
'admin-*' => get_string('page-admin-x', 'pagetype'),
|
||||
$pagetype => get_string('page-admin-current', 'pagetype')
|
||||
);
|
||||
// Add the missing * (any page) option for them. MDL-30340
|
||||
// TODO: These pages are really 'pagetype-varying' - MDL-30564 -
|
||||
// and some day we should stop behaving that way, so proper pagetypes
|
||||
// can be specified for it (like course-category-* or so).
|
||||
// Luckly... the option we are introducing '*' is independent
|
||||
// of that varying behavior, so will work.
|
||||
if ($pagetype == 'admin-course-category') {
|
||||
$array += array(
|
||||
'*' => get_string('page-x', 'pagetype')
|
||||
);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ $table->define_columns(array('name', 'version', 'delete'));
|
||||
$table->define_headers(array(get_string('plugin'), get_string('version'), get_string('delete')));
|
||||
$table->define_baseurl($PAGE->url);
|
||||
$table->set_attribute('id', 'localplugins');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
$plugins = array();
|
||||
|
||||
@@ -16,6 +16,8 @@ require_login();
|
||||
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
}
|
||||
@@ -63,11 +65,9 @@ if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
if ($accessctrl == 'allow') {
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
} else if ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user' => $idrec->username,
|
||||
'host' => $mnethosts[$idrec->mnet_host_id])));
|
||||
redirect('access_control.php', get_string('ssl_acl_allow','mnet', array('uset'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
} elseif ($accessctrl == 'deny') {
|
||||
redirect('access_control.php', get_string('ssl_acl_deny','mnet', array('user'=>$idrec->username, 'host'=>$mnethosts[$idrec->mnet_host_id])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -118,8 +118,6 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Explain
|
||||
echo $OUTPUT->box(get_string('ssoacldescr','mnet'));
|
||||
// Are the needed bits enabled?
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
echo $OUTPUT->header();
|
||||
?>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
@@ -106,7 +106,7 @@
|
||||
</table>
|
||||
</form>
|
||||
<form method="post" action="index.php">
|
||||
<table align="center" width="635" class="generaltable" border="0" cellpadding="5" cellspacing="0">
|
||||
<table align="center" width="635" class="generalbox" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<table cellpadding="9" cellspacing="0" >
|
||||
|
||||
@@ -78,13 +78,9 @@ class mnet_review_host_form extends moodleform {
|
||||
$mnet_peer = $this->_customdata['peer'];
|
||||
|
||||
$mform->addElement('hidden', 'last_connect_time');
|
||||
$mform->setType('last_connect_time', PARAM_INT);
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('hidden', 'applicationid');
|
||||
$mform->setType('applicationid', PARAM_INT);
|
||||
$mform->addElement('hidden', 'oldpublickey');
|
||||
$mform->setType('oldpublickey', PARAM_PEM);
|
||||
|
||||
$mform->addElement('text', 'name', get_string('site'), array('maxlength' => 80, 'size' => 50));
|
||||
$mform->setType('name', PARAM_NOTAGS);
|
||||
@@ -152,7 +148,6 @@ class mnet_review_host_form extends moodleform {
|
||||
$mform->addGroup($radioarray, 'radioar', get_string('deleted'), array(' ', ' '), false);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'deleted');
|
||||
$mform->setType('deleted', PARAM_BOOL);
|
||||
}
|
||||
|
||||
// finished with static stuff, print save button
|
||||
|
||||
@@ -50,8 +50,6 @@ class mnet_profile_form extends moodleform {
|
||||
}
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $this->_customdata['hostid']);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$fields = mnet_profile_field_options();
|
||||
|
||||
// Fields to import ----------------------------------------------------
|
||||
|
||||
@@ -39,7 +39,6 @@ class mnet_services_form extends moodleform {
|
||||
$myservices = mnet_get_service_info($mnet_peer);
|
||||
|
||||
$mform->addElement('hidden', 'hostid', $mnet_peer->id);
|
||||
$mform->setType('hostid', PARAM_INT);
|
||||
|
||||
$count = 0;
|
||||
foreach ($myservices as $name => $versions) {
|
||||
@@ -56,8 +55,6 @@ class mnet_services_form extends moodleform {
|
||||
$mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
|
||||
|
||||
$mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
|
||||
// Temporary fix until MDL-38885 gets integrated.
|
||||
$mform->setType('exists', PARAM_BOOL);
|
||||
|
||||
$pubstr = get_string('publish','mnet');
|
||||
if (!empty($version['hostsubscribes'])) {
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
$stractivitymodule = get_string("activitymodule");
|
||||
$strshowmodulecourse = get_string('showmodulecourse');
|
||||
|
||||
// Purge all caches related to activity modules administration.
|
||||
cache::make('core', 'plugininfo_mod')->purge();
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
|
||||
+4
-101
@@ -18,15 +18,6 @@
|
||||
/**
|
||||
* UI for general plugins management
|
||||
*
|
||||
* Supported HTTP parameters:
|
||||
*
|
||||
* ?fetchremote=1 - check for available updates
|
||||
* ?updatesonly=1 - display plugins with available update only
|
||||
* ?contribonly=1 - display non-standard add-ons only
|
||||
* ?uninstall=foo_bar - uninstall the given plugin
|
||||
* ?delete=foo_bar - delete the plugin folder (it must not be installed)
|
||||
* &confirm=1 - confirm the uninstall or delete action
|
||||
*
|
||||
* @package core
|
||||
* @subpackage admin
|
||||
* @copyright 2011 David Mudrak <david@moodle.com>
|
||||
@@ -36,105 +27,15 @@
|
||||
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->libdir . '/pluginlib.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
admin_externalpage_setup('pluginsoverview');
|
||||
|
||||
$fetchremote = optional_param('fetchremote', false, PARAM_BOOL);
|
||||
$updatesonly = optional_param('updatesonly', false, PARAM_BOOL);
|
||||
$contribonly = optional_param('contribonly', false, PARAM_BOOL);
|
||||
$uninstall = optional_param('uninstall', '', PARAM_COMPONENT);
|
||||
$delete = optional_param('delete', '', PARAM_COMPONENT);
|
||||
$confirmed = optional_param('confirm', false, PARAM_BOOL);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$pluginman = plugin_manager::instance();
|
||||
|
||||
if ($uninstall) {
|
||||
require_sesskey();
|
||||
$pluginfo = $pluginman->get_plugin_info($uninstall);
|
||||
|
||||
// Make sure we know the plugin.
|
||||
if (is_null($pluginfo)) {
|
||||
throw new moodle_exception('err_uninstalling_unknown_plugin', 'core_plugin', '', array('plugin' => $uninstall),
|
||||
'plugin_manager::get_plugin_info() returned null for the plugin to be uninstalled');
|
||||
}
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
$PAGE->set_title($pluginname);
|
||||
$PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
if (!$pluginman->can_uninstall_plugin($pluginfo->component)) {
|
||||
throw new moodle_exception('err_cannot_uninstall_plugin', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component),
|
||||
'plugin_manager::can_uninstall_plugin() returned false');
|
||||
}
|
||||
|
||||
if (!$confirmed) {
|
||||
$continueurl = new moodle_url($PAGE->url, array('uninstall' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
|
||||
echo $output->plugin_uninstall_confirm_page($pluginman, $pluginfo, $continueurl);
|
||||
exit();
|
||||
|
||||
} else {
|
||||
$progress = new progress_trace_buffer(new text_progress_trace(), false);
|
||||
$pluginman->uninstall_plugin($pluginfo->component, $progress);
|
||||
$progress->finished();
|
||||
|
||||
if ($pluginman->is_plugin_folder_removable($pluginfo->component)) {
|
||||
$continueurl = new moodle_url($PAGE->url, array('delete' => $pluginfo->component, 'sesskey' => sesskey(), 'confirm' => 1));
|
||||
echo $output->plugin_uninstall_results_removable_page($pluginman, $pluginfo, $progress, $continueurl);
|
||||
exit();
|
||||
|
||||
} else {
|
||||
echo $output->plugin_uninstall_results_page($pluginman, $pluginfo, $progress);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete and $confirmed) {
|
||||
require_sesskey();
|
||||
$pluginfo = $pluginman->get_plugin_info($delete);
|
||||
|
||||
// Make sure we know the plugin.
|
||||
if (is_null($pluginfo)) {
|
||||
throw new moodle_exception('err_removing_unknown_plugin', 'core_plugin', '', array('plugin' => $delete),
|
||||
'plugin_manager::get_plugin_info() returned null for the plugin to be deleted');
|
||||
}
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
$PAGE->set_title($pluginname);
|
||||
$PAGE->navbar->add(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
// Make sure it is not installed.
|
||||
if (!is_null($pluginfo->versiondb)) {
|
||||
throw new moodle_exception('err_removing_installed_plugin', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'versiondb' => $pluginfo->versiondb),
|
||||
'plugin_manager::get_plugin_info() returned not-null versiondb for the plugin to be deleted');
|
||||
}
|
||||
|
||||
// Make sure the folder is removable.
|
||||
if (!$pluginman->is_plugin_folder_removable($pluginfo->component)) {
|
||||
throw new moodle_exception('err_removing_unremovable_folder', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir),
|
||||
'plugin root folder is not removable as expected');
|
||||
}
|
||||
|
||||
// Make sure the folder is within Moodle installation tree.
|
||||
if (strpos($pluginfo->rootdir, $CFG->dirroot) !== 0) {
|
||||
throw new moodle_exception('err_unexpected_plugin_rootdir', 'core_plugin', '',
|
||||
array('plugin' => $pluginfo->component, 'rootdir' => $pluginfo->rootdir, 'dirroot' => $CFG->dirroot),
|
||||
'plugin root folder not in the moodle dirroot');
|
||||
}
|
||||
|
||||
// So long, and thanks for all the bugs.
|
||||
fulldelete($pluginfo->rootdir);
|
||||
cache::make('core', 'pluginlist')->purge();
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
|
||||
$checker = available_update_checker::instance();
|
||||
|
||||
// Filtering options.
|
||||
@@ -149,10 +50,12 @@ if ($fetchremote) {
|
||||
redirect(new moodle_url($PAGE->url, $options));
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
$deployer = available_update_deployer::instance();
|
||||
if ($deployer->enabled()) {
|
||||
$myurl = new moodle_url($PAGE->url, array('updatesonly' => $updatesonly, 'contribonly' => $contribonly));
|
||||
$deployer->initialize($myurl, new moodle_url('/admin'));
|
||||
$deployer->initialize($myurl, $myurl);
|
||||
|
||||
$deploydata = $deployer->submitted_data();
|
||||
if (!empty($deploydata)) {
|
||||
|
||||
@@ -43,9 +43,6 @@ $configstr = get_string('manageportfolios', 'portfolio');
|
||||
|
||||
$return = true; // direct back to the main page
|
||||
|
||||
// Purge all caches related to portfolio administration.
|
||||
cache::make('core', 'plugininfo_portfolio')->purge();
|
||||
|
||||
/**
|
||||
* Helper function that generates a moodle_url object
|
||||
* relevant to the portfolio
|
||||
|
||||
+30
-30
@@ -27,37 +27,37 @@ require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
|
||||
// If we have got here as a confirmed aciton, do it.
|
||||
if ($confirm && isloggedin() && confirm_sesskey()) {
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
// Valid request. Purge, and redirect the user back to where they came from.
|
||||
purge_all_caches();
|
||||
|
||||
if ($returnurl) {
|
||||
$returnurl = $CFG->wwwroot . $returnurl;
|
||||
} else {
|
||||
$returnurl = new moodle_url('/admin/purgecaches.php');
|
||||
}
|
||||
redirect($returnurl, get_string('purgecachesfinished', 'admin'));
|
||||
}
|
||||
|
||||
// Otherwise, show a button to actually purge the caches.
|
||||
admin_externalpage_setup('purgecaches');
|
||||
|
||||
$actionurl = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
|
||||
if ($returnurl) {
|
||||
$actionurl->param('returnurl', $returnurl);
|
||||
require_login();
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
|
||||
if ($confirm) {
|
||||
require_sesskey();
|
||||
|
||||
// Valid request. Purge, and redisplay the form so it is easy to purge again
|
||||
// in the near future.
|
||||
purge_all_caches();
|
||||
redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
|
||||
|
||||
} else {
|
||||
// Show a confirm form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
|
||||
|
||||
$url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
|
||||
$button = new single_button($url, get_string('purgecaches','admin'), 'post');
|
||||
|
||||
// Cancel button takes them back to the page the were on, if possible,
|
||||
// otherwise to the site home page.
|
||||
$return = new moodle_url('/');
|
||||
if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
|
||||
if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
|
||||
$return = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
}
|
||||
|
||||
echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
|
||||
echo $OUTPUT->footer();
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
|
||||
|
||||
echo $OUTPUT->box_start('generalbox', 'notice');
|
||||
echo html_writer::tag('p', get_string('purgecachesconfirm', 'admin'));
|
||||
echo $OUTPUT->single_button($actionurl, get_string('purgecaches', 'admin'), 'post');
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ $table->define_headers(array(get_string('questiontype', 'question'), get_string(
|
||||
get_string('version'), get_string('requires', 'admin'), get_string('availableq', 'question'),
|
||||
get_string('delete'), get_string('settings')));
|
||||
$table->set_attribute('id', 'qtypes');
|
||||
$table->set_attribute('class', 'admintable generaltable');
|
||||
$table->set_attribute('class', 'generaltable generalbox boxaligncenter boxwidthwide');
|
||||
$table->setup();
|
||||
|
||||
// Add a row for each question type.
|
||||
|
||||
@@ -49,10 +49,8 @@ class site_unregistration_form extends moodleform {
|
||||
$unregisterlabel = get_string('unregister', 'hub');
|
||||
$mform->addElement('checkbox', 'unpublishalladvertisedcourses', '',
|
||||
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
|
||||
$mform->setType('unpublishalladvertisedcourses', PARAM_INT);
|
||||
$mform->addElement('checkbox', 'unpublishalluploadedcourses', '',
|
||||
' ' . get_string('unpublishalluploadedcourses', 'hub'));
|
||||
$mform->setType('unpublishalluploadedcourses', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
@@ -84,6 +82,7 @@ class site_clean_registration_data_form extends moodleform {
|
||||
$unregisterlabel = get_string('forceunregister', 'hub');
|
||||
$mform->addElement('static', '', get_string('warning', 'hub'), get_string('forceunregisterconfirmation', 'hub', $hubname));
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'confirm', 1);
|
||||
$mform->setType('confirm', PARAM_INT);
|
||||
$mform->addElement('hidden', 'unregistration', 1);
|
||||
@@ -150,7 +149,6 @@ class hub_selector_form extends moodleform {
|
||||
if (!empty($hubs)) {
|
||||
$mform->addElement('select', 'publichub', get_string('publichub', 'hub'),
|
||||
$options, array("size" => 15));
|
||||
$mform->setType('publichub', PARAM_URL);
|
||||
}
|
||||
|
||||
$mform->addElement('static', 'or', '', get_string('orenterprivatehub', 'hub'));
|
||||
@@ -158,10 +156,8 @@ class hub_selector_form extends moodleform {
|
||||
//Private hub
|
||||
$mform->addElement('text', 'unlistedurl', get_string('privatehuburl', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('unlistedurl', PARAM_URL);
|
||||
$mform->addElement('text', 'password', get_string('password'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
$this->add_action_buttons(false, get_string('selecthub', 'hub'));
|
||||
}
|
||||
@@ -175,8 +171,11 @@ class hub_selector_form extends moodleform {
|
||||
|
||||
$unlistedurl = $this->_form->_submitValues['unlistedurl'];
|
||||
|
||||
if (empty($unlistedurl)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
if (!empty($unlistedurl)) {
|
||||
$unlistedurltotest = clean_param($unlistedurl, PARAM_URL);
|
||||
if (empty($unlistedurltotest)) {
|
||||
$errors['unlistedurl'] = get_string('badurlformat', 'hub');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
@@ -244,11 +243,7 @@ class site_registration_form extends moodleform {
|
||||
$postsnumber = get_config('hub', 'site_postsnumber_' . $cleanhuburl);
|
||||
$questionsnumber = get_config('hub', 'site_questionsnumber_' . $cleanhuburl);
|
||||
$resourcesnumber = get_config('hub', 'site_resourcesnumber_' . $cleanhuburl);
|
||||
$badgesnumber = get_config('hub', 'site_badges_' . $cleanhuburl);
|
||||
$issuedbadgesnumber = get_config('hub', 'site_issuedbadges_' . $cleanhuburl);
|
||||
$mediancoursesize = get_config('hub', 'site_mediancoursesize_' . $cleanhuburl);
|
||||
$participantnumberaveragecfg = get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl);
|
||||
$modulenumberaveragecfg = get_config('hub', 'site_modulenumberaverage_' . $cleanhuburl);
|
||||
|
||||
//hidden parameters
|
||||
$mform->addElement('hidden', 'huburl', $huburl);
|
||||
@@ -275,7 +270,6 @@ class site_registration_form extends moodleform {
|
||||
$options[HUB_SITELINKPUBLISHED] = $registrationmanager->get_site_privacy_string(HUB_SITELINKPUBLISHED);
|
||||
$mform->addElement('select', 'privacy', get_string('siteprivacy', 'hub'), $options);
|
||||
$mform->setDefault('privacy', $privacy);
|
||||
$mform->setType('privacy', PARAM_ALPHA);
|
||||
$mform->addHelpButton('privacy', 'privacy', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -309,13 +303,11 @@ class site_registration_form extends moodleform {
|
||||
$countries = get_string_manager()->get_list_of_countries();
|
||||
$mform->addElement('select', 'countrycode', get_string('sitecountry', 'hub'), $countries);
|
||||
$mform->setDefault('countrycode', $country);
|
||||
$mform->setType('countrycode', PARAM_ALPHANUMEXT);
|
||||
$mform->addHelpButton('countrycode', 'sitecountry', 'hub');
|
||||
|
||||
$mform->addElement('text', 'geolocation', get_string('sitegeolocation', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->setDefault('geolocation', $geolocation);
|
||||
$mform->setType('geolocation', PARAM_RAW);
|
||||
$mform->addHelpButton('geolocation', 'sitegeolocation', 'hub');
|
||||
|
||||
$mform->addElement('text', 'contactname', get_string('siteadmin', 'hub'),
|
||||
@@ -333,7 +325,7 @@ class site_registration_form extends moodleform {
|
||||
$mform->addElement('text', 'contactemail', get_string('siteemail', 'hub'),
|
||||
array('class' => 'registration_textfield'));
|
||||
$mform->addRule('contactemail', $strrequired, 'required', null, 'client');
|
||||
$mform->setType('contactemail', PARAM_EMAIL);
|
||||
$mform->setType('contactemail', PARAM_TEXT);
|
||||
$mform->setDefault('contactemail', $contactemail);
|
||||
$mform->addHelpButton('contactemail', 'siteemail', 'hub');
|
||||
|
||||
@@ -342,7 +334,6 @@ class site_registration_form extends moodleform {
|
||||
$options[1] = get_string("registrationcontactyes");
|
||||
$mform->addElement('select', 'contactable', get_string('siteregistrationcontact', 'hub'), $options);
|
||||
$mform->setDefault('contactable', $contactable);
|
||||
$mform->setType('contactable', PARAM_INT);
|
||||
$mform->addHelpButton('contactable', 'siteregistrationcontact', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -351,7 +342,6 @@ class site_registration_form extends moodleform {
|
||||
$options[1] = get_string("registrationyes");
|
||||
$mform->addElement('select', 'emailalert', get_string('siteregistrationemail', 'hub'), $options);
|
||||
$mform->setDefault('emailalert', $emailalert);
|
||||
$mform->setType('emailalert', PARAM_INT);
|
||||
$mform->addHelpButton('emailalert', 'siteregistrationemail', 'hub');
|
||||
unset($options);
|
||||
|
||||
@@ -382,111 +372,80 @@ class site_registration_form extends moodleform {
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
$participantnumberaverage = number_format(average_number_of_participants(), 2);
|
||||
$modulenumberaverage = number_format(average_number_of_courses_modules(), 2);
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
|
||||
$issuedbadges = $DB->count_records('badge_issued');
|
||||
|
||||
if (HUB_MOODLEORGHUBURL != $huburl) {
|
||||
$mform->addElement('checkbox', 'courses', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->setDefault('courses', $coursesnumber != -1);
|
||||
$mform->setType('courses', PARAM_INT);
|
||||
$mform->setDefault('courses', true);
|
||||
$mform->addHelpButton('courses', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('checkbox', 'users', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->setDefault('users', $usersnumber != -1);
|
||||
$mform->setType('users', PARAM_INT);
|
||||
$mform->setDefault('users', true);
|
||||
|
||||
$mform->addElement('checkbox', 'roleassignments', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->setDefault('roleassignments', $roleassignmentsnumber != -1);
|
||||
$mform->setType('roleassignments', PARAM_INT);
|
||||
$mform->setDefault('roleassignments', true);
|
||||
|
||||
$mform->addElement('checkbox', 'posts', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->setDefault('posts', $postsnumber != -1);
|
||||
$mform->setType('posts', PARAM_INT);
|
||||
$mform->setDefault('posts', true);
|
||||
|
||||
$mform->addElement('checkbox', 'questions', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->setDefault('questions', $questionsnumber != -1);
|
||||
$mform->setType('questions', PARAM_INT);
|
||||
$mform->setDefault('questions', true);
|
||||
|
||||
$mform->addElement('checkbox', 'resources', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->setDefault('resources', $resourcesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'badges', '',
|
||||
" " . get_string('badgesnumber', 'hub', $badges));
|
||||
$mform->setDefault('badges', $badgesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('checkbox', 'issuedbadges', '',
|
||||
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
|
||||
$mform->setDefault('issuedbadges', $issuedbadgesnumber != -1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
$mform->setDefault('resources', true);
|
||||
|
||||
$mform->addElement('checkbox', 'participantnumberaverage', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->setDefault('participantnumberaverage', $participantnumberaveragecfg != -1);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
$mform->setDefault('participantnumberaverage', true);
|
||||
|
||||
$mform->addElement('checkbox', 'modulenumberaverage', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->setDefault('modulenumberaverage', $modulenumberaveragecfg != -1);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
$mform->setDefault('modulenumberaverage', true);
|
||||
} else {
|
||||
$mform->addElement('static', 'courseslabel', get_string('sendfollowinginfo', 'hub'),
|
||||
" " . get_string('coursesnumber', 'hub', $coursecount));
|
||||
$mform->addElement('hidden', 'courses', 1);
|
||||
$mform->setType('courses', PARAM_INT);
|
||||
$mform->addElement('hidden', 'courses', true);
|
||||
$mform->setType('courses', PARAM_FLOAT);
|
||||
$mform->addHelpButton('courseslabel', 'sendfollowinginfo', 'hub');
|
||||
|
||||
$mform->addElement('static', 'userslabel', '',
|
||||
" " . get_string('usersnumber', 'hub', $usercount));
|
||||
$mform->addElement('hidden', 'users', 1);
|
||||
$mform->setType('users', PARAM_INT);
|
||||
$mform->addElement('hidden', 'users', true);
|
||||
$mform->setType('users', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'roleassignmentslabel', '',
|
||||
" " . get_string('roleassignmentsnumber', 'hub', $roleassigncount));
|
||||
$mform->addElement('hidden', 'roleassignments', 1);
|
||||
$mform->setType('roleassignments', PARAM_INT);
|
||||
$mform->addElement('hidden', 'roleassignments', true);
|
||||
$mform->setType('roleassignments', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'postslabel', '',
|
||||
" " . get_string('postsnumber', 'hub', $postcount));
|
||||
$mform->addElement('hidden', 'posts', 1);
|
||||
$mform->setType('posts', PARAM_INT);
|
||||
$mform->addElement('hidden', 'posts', true);
|
||||
$mform->setType('posts', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'questionslabel', '',
|
||||
" " . get_string('questionsnumber', 'hub', $questioncount));
|
||||
$mform->addElement('hidden', 'questions', 1);
|
||||
$mform->setType('questions', PARAM_INT);
|
||||
$mform->addElement('hidden', 'questions', true);
|
||||
$mform->setType('questions', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'resourceslabel', '',
|
||||
" " . get_string('resourcesnumber', 'hub', $resourcecount));
|
||||
$mform->addElement('hidden', 'resources', 1);
|
||||
$mform->setType('resources', PARAM_INT);
|
||||
|
||||
$mform->addElement('static', 'badgeslabel', '',
|
||||
" " . get_string('badgesnumber', 'hub', $badges));
|
||||
$mform->addElement('hidden', 'badges', 1);
|
||||
$mform->setType('badges', PARAM_INT);
|
||||
|
||||
$mform->addElement('static', 'issuedbadgeslabel', '',
|
||||
" " . get_string('issuedbadgesnumber', 'hub', $issuedbadges));
|
||||
$mform->addElement('hidden', 'issuedbadges', true);
|
||||
$mform->setType('issuedbadges', PARAM_INT);
|
||||
$mform->addElement('hidden', 'resources', true);
|
||||
$mform->setType('resources', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'participantnumberaveragelabel', '',
|
||||
" " . get_string('participantnumberaverage', 'hub', $participantnumberaverage));
|
||||
$mform->addElement('hidden', 'participantnumberaverage', 1);
|
||||
$mform->addElement('hidden', 'participantnumberaverage', true);
|
||||
$mform->setType('participantnumberaverage', PARAM_FLOAT);
|
||||
|
||||
$mform->addElement('static', 'modulenumberaveragelabel', '',
|
||||
" " . get_string('modulenumberaverage', 'hub', $modulenumberaverage));
|
||||
$mform->addElement('hidden', 'modulenumberaverage', 1);
|
||||
$mform->addElement('hidden', 'modulenumberaverage', true);
|
||||
$mform->setType('modulenumberaverage', PARAM_FLOAT);
|
||||
}
|
||||
|
||||
|
||||
@@ -247,20 +247,6 @@ class registration_manager {
|
||||
$resourcecount = $DB->count_records('resource');
|
||||
}
|
||||
$siteinfo['resources'] = $resourcecount;
|
||||
// Badge statistics.
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
if (get_config('hub', 'site_badges_' . $cleanhuburl) == -1) {
|
||||
$badges = -1;
|
||||
} else {
|
||||
$badges = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
|
||||
}
|
||||
$siteinfo['badges'] = $badges;
|
||||
if (get_config('hub', 'site_issuedbadges_' . $cleanhuburl) == -1) {
|
||||
$issuedbadges = -1;
|
||||
} else {
|
||||
$issuedbadges = $DB->count_records('badge_issued');
|
||||
}
|
||||
$siteinfo['issuedbadges'] = $issuedbadges;
|
||||
//TODO
|
||||
require_once($CFG->dirroot . "/course/lib.php");
|
||||
if (get_config('hub', 'site_participantnumberaverage_' . $cleanhuburl) == -1) {
|
||||
|
||||
@@ -62,18 +62,7 @@ $siteregistrationform = new site_registration_form('',
|
||||
$fromform = $siteregistrationform->get_data();
|
||||
|
||||
if (!empty($fromform) and confirm_sesskey()) {
|
||||
|
||||
// Set to -1 all optional data marked as "don't send" by the admin.
|
||||
// The function get_site_info() will not calculate the optional data if config is set to -1.
|
||||
$inputnames = array('courses', 'users', 'roleassignments', 'posts', 'questions', 'resources',
|
||||
'badges', 'issuedbadges', 'modulenumberaverage', 'participantnumberaverage');
|
||||
foreach ($inputnames as $inputname) {
|
||||
if (empty($fromform->{$inputname})) {
|
||||
$fromform->{$inputname} = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the settings.
|
||||
//save the settings
|
||||
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
|
||||
set_config('site_name_' . $cleanhuburl, $fromform->name, 'hub');
|
||||
set_config('site_description_' . $cleanhuburl, $fromform->description, 'hub');
|
||||
@@ -95,8 +84,6 @@ if (!empty($fromform) and confirm_sesskey()) {
|
||||
set_config('site_postsnumber_' . $cleanhuburl, $fromform->posts, 'hub');
|
||||
set_config('site_questionsnumber_' . $cleanhuburl, $fromform->questions, 'hub');
|
||||
set_config('site_resourcesnumber_' . $cleanhuburl, $fromform->resources, 'hub');
|
||||
set_config('site_badges_' . $cleanhuburl, $fromform->badges, 'hub');
|
||||
set_config('site_issuedbadges_' . $cleanhuburl, $fromform->issuedbadges, 'hub');
|
||||
set_config('site_modulenumberaverage_' . $cleanhuburl, $fromform->modulenumberaverage, 'hub');
|
||||
set_config('site_participantnumberaverage_' . $cleanhuburl, $fromform->participantnumberaverage, 'hub');
|
||||
}
|
||||
@@ -126,21 +113,6 @@ if ($update and confirm_sesskey()) {
|
||||
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
|
||||
|
||||
if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked
|
||||
|
||||
// Retrieve the optional info (specially course number, user number, module number average...).
|
||||
$siteinfo = $registrationmanager->get_site_info($huburl);
|
||||
$fromform->courses = $siteinfo['courses'];
|
||||
$fromform->users = $siteinfo['users'];
|
||||
$fromform->enrolments = $siteinfo['enrolments'];
|
||||
$fromform->posts = $siteinfo['posts'];
|
||||
$fromform->questions = $siteinfo['questions'];
|
||||
$fromform->resources = $siteinfo['resources'];
|
||||
$fromform->badges = $siteinfo['badges'];
|
||||
$fromform->issuedbadges = $siteinfo['issuedbadges'];
|
||||
$fromform->modulenumberaverage = $siteinfo['modulenumberaverage'];
|
||||
$fromform->participantnumberaverage = $siteinfo['participantnumberaverage'];
|
||||
$fromform->street = $siteinfo['street'];
|
||||
|
||||
$params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name)
|
||||
|
||||
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
|
||||
|
||||
@@ -38,7 +38,7 @@ class core_register_renderer extends plugin_renderer_base {
|
||||
public function moodleorg_registration_message() {
|
||||
$moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
|
||||
$moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
|
||||
$moochurl = html_writer::link(HUB_MOODLEORGHUBURL, get_string('moodleorghubname', 'admin'));
|
||||
$moochurl = html_writer::link(HUB_MOODLEORGHUBURL, 'MOOCH');
|
||||
$moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
|
||||
$items = array(get_string('registermoodleorgli1', 'admin'),
|
||||
get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
|
||||
@@ -92,4 +92,4 @@ class core_register_renderer extends plugin_renderer_base {
|
||||
return html_writer::table($table);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+34
-143
@@ -135,10 +135,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* during upgrade.
|
||||
* @param string $strnewversion
|
||||
* @param int $maturity
|
||||
* @param string $testsite
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function upgrade_confirm_page($strnewversion, $maturity, $testsite) {
|
||||
public function upgrade_confirm_page($strnewversion, $maturity) {
|
||||
$output = '';
|
||||
|
||||
$continueurl = new moodle_url('index.php', array('confirmupgrade' => 1));
|
||||
@@ -146,7 +145,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
$output .= $this->header();
|
||||
$output .= $this->maturity_warning($maturity);
|
||||
$output .= $this->test_site_warning($testsite);
|
||||
$output .= $this->confirm(get_string('upgradesure', 'admin', $strnewversion), $continueurl, $cancelurl);
|
||||
$output .= $this->footer();
|
||||
|
||||
@@ -170,7 +168,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->environment_check_table($envstatus, $environment_results);
|
||||
|
||||
if (!$envstatus) {
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1, 'cache' => 0));
|
||||
$output .= $this->upgrade_reload(new moodle_url('/admin/index.php'), array('confirmupgrade' => 1));
|
||||
|
||||
} else {
|
||||
$output .= $this->notification(get_string('environmentok', 'admin'), 'notifysuccess');
|
||||
@@ -179,7 +177,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->box(get_string('langpackwillbeupdated', 'admin'), 'generalbox', 'notice');
|
||||
}
|
||||
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1, 'cache' => 0)));
|
||||
$output .= $this->continue_button(new moodle_url('/admin/index.php', array('confirmupgrade' => 1, 'confirmrelease' => 1)));
|
||||
}
|
||||
|
||||
$output .= $this->footer();
|
||||
@@ -281,10 +279,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->output->container(get_string('updatepluginconfirmexternal', 'core_plugin', $repotype), 'updatepluginconfirmexternal');
|
||||
}
|
||||
|
||||
$widget = $deployer->make_execution_widget($data['updateinfo'], $data['returnurl']);
|
||||
$widget = $deployer->make_execution_widget($data['updateinfo']);
|
||||
$output .= $this->output->render($widget);
|
||||
|
||||
$output .= $this->output->single_button($data['callerurl'], get_string('cancel', 'core'), 'get');
|
||||
$output .= $this->output->single_button($data['returnurl'], get_string('cancel', 'core'), 'get');
|
||||
|
||||
$output .= $this->container_end();
|
||||
$output .= $this->footer();
|
||||
@@ -373,88 +371,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page to confirm the plugin uninstallation.
|
||||
*
|
||||
* @param plugin_manager $pluginman
|
||||
* @param plugin_info $pluginfo
|
||||
* @param moodle_url $continueurl URL to continue after confirmation
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_confirm_page(plugin_manager $pluginman, plugininfo_base $pluginfo, moodle_url $continueurl) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
$output .= $this->output->confirm(get_string('uninstallconfirm', 'core_plugin', array('name' => $pluginname)),
|
||||
$continueurl, $this->page->url);
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with results of plugin uninstallation and offer removal of plugin files.
|
||||
*
|
||||
* @param plugin_manager $pluginman
|
||||
* @param plugin_info $pluginfo
|
||||
* @param progress_trace_buffer $progress
|
||||
* @param moodle_url $continueurl URL to continue to remove the plugin folder
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_results_removable_page(plugin_manager $pluginman, plugininfo_base $pluginfo,
|
||||
progress_trace_buffer $progress, moodle_url $continueurl) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
$output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
|
||||
|
||||
$confirm = $this->output->container(get_string('uninstalldeleteconfirm', 'core_plugin',
|
||||
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'uninstalldeleteconfirm');
|
||||
|
||||
if ($repotype = $pluginman->plugin_external_source($pluginfo->component)) {
|
||||
$confirm .= $this->output->container(get_string('uninstalldeleteconfirmexternal', 'core_plugin', $repotype),
|
||||
'uninstalldeleteconfirmexternal');
|
||||
}
|
||||
|
||||
$output .= $this->output->confirm($confirm, $continueurl, $this->page->url);
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with results of plugin uninstallation and inform about the need to remove plugin files manually.
|
||||
*
|
||||
* @param plugin_manager $pluginman
|
||||
* @param plugin_info $pluginfo
|
||||
* @param progress_trace_buffer $progress
|
||||
* @return string
|
||||
*/
|
||||
public function plugin_uninstall_results_page(plugin_manager $pluginman, plugininfo_base $pluginfo, progress_trace_buffer $progress) {
|
||||
$output = '';
|
||||
|
||||
$pluginname = $pluginman->plugin_name($pluginfo->component);
|
||||
|
||||
$output .= $this->output->header();
|
||||
$output .= $this->output->heading(get_string('uninstalling', 'core_plugin', array('name' => $pluginname)));
|
||||
|
||||
$output .= $this->output->box($progress->get_buffer(), 'generalbox uninstallresultmessage');
|
||||
|
||||
$output .= $this->output->box(get_string('uninstalldelete', 'core_plugin',
|
||||
array('name' => $pluginname, 'rootdir' => $pluginfo->rootdir)), 'generalbox uninstalldelete');
|
||||
$output .= $this->output->continue_button($this->page->url);
|
||||
$output .= $this->output->footer();
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the plugin management page (admin/environment.php).
|
||||
* @param array $versions
|
||||
@@ -606,24 +522,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
'generalbox maturitywarning');
|
||||
}
|
||||
|
||||
/*
|
||||
* If necessary, displays a warning about upgrading a test site.
|
||||
*
|
||||
* @param string $testsite
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function test_site_warning($testsite) {
|
||||
|
||||
if (!$testsite) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->box(
|
||||
$this->container(get_string('testsiteupgradewarning', 'admin', $testsite)),
|
||||
'generalbox testsitewarning'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the copyright notice.
|
||||
* @return string HTML to output.
|
||||
@@ -701,8 +599,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
$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'));
|
||||
$updateinfo .= $this->single_button(new moodle_url($this->page->url, array('fetchupdates' => 1)), get_string('checkforupdates', 'core_plugin'));
|
||||
if ($fetch) {
|
||||
$updateinfo .= $this->container(get_string('checkforupdateslast', 'core_plugin',
|
||||
userdate($fetch, get_string('strftimedatetime', 'core_langconfig'))));
|
||||
@@ -917,7 +814,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else if ($statusisboring and $dependenciesok and empty($availableupdates)) {
|
||||
} else if ($isstandard and $statusisboring and $dependenciesok and empty($availableupdates)) {
|
||||
// no change is going to happen to the plugin - display it only
|
||||
// if the user wants to see the full list
|
||||
if (empty($options['full'])) {
|
||||
@@ -952,7 +849,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->heading(get_string('nonehighlighted', 'core_plugin'));
|
||||
if (empty($options['full'])) {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
||||
get_string('nonehighlightedinfo', 'core_plugin'));
|
||||
}
|
||||
$out .= $this->output->container_end();
|
||||
@@ -962,11 +859,11 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= $this->output->heading(get_string('somehighlighted', 'core_plugin', $sumofhighlighted));
|
||||
if (empty($options['full'])) {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 1)),
|
||||
get_string('somehighlightedinfo', 'core_plugin'));
|
||||
} else {
|
||||
$out .= html_writer::link(new moodle_url('/admin/index.php',
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0, 'cache' => 0)),
|
||||
array('confirmupgrade' => 1, 'confirmrelease' => 1, 'showallplugins' => 0)),
|
||||
get_string('somehighlightedonly', 'core_plugin'));
|
||||
}
|
||||
$out .= $this->output->container_end();
|
||||
@@ -1021,11 +918,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$str = 'otherplugin';
|
||||
}
|
||||
$componenturl = new moodle_url('https://moodle.org/plugins/view.php?plugin='.$component);
|
||||
$componenturl = html_writer::tag('a', $component, array('href' => $componenturl->out()));
|
||||
$requires[] = html_writer::tag('li',
|
||||
get_string($str, 'core_plugin',
|
||||
array('component' => $componenturl, 'version' => $requiredversion)),
|
||||
array('component' => $component, 'version' => $requiredversion)),
|
||||
array('class' => $class));
|
||||
}
|
||||
|
||||
@@ -1170,23 +1065,22 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('actions', 'core_plugin'),
|
||||
get_string('notes','core_plugin'),
|
||||
);
|
||||
$table->headspan = array(1, 1, 1, 1, 2, 1);
|
||||
$table->colclasses = array(
|
||||
'pluginname', 'source', 'version', 'availability', 'settings', 'uninstall', 'notes'
|
||||
'pluginname', 'source', 'version', 'availability', 'actions', 'notes'
|
||||
);
|
||||
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
|
||||
$header = new html_table_cell($pluginman->plugintype_name_plural($type));
|
||||
$header->header = true;
|
||||
$header->colspan = array_sum($table->headspan);
|
||||
$header->colspan = count($table->head);
|
||||
$header = new html_table_row(array($header));
|
||||
$header->attributes['class'] = 'plugintypeheader type-' . $type;
|
||||
$table->data[] = $header;
|
||||
|
||||
if (empty($plugins)) {
|
||||
$msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
|
||||
$msg->colspan = array_sum($table->headspan);
|
||||
$msg->colspan = count($table->head);
|
||||
$row = new html_table_row(array($msg));
|
||||
$row->attributes['class'] .= 'msg msg-noneinstalled';
|
||||
$table->data[] = $row;
|
||||
@@ -1202,12 +1096,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'icon pluginicon noicon'));
|
||||
}
|
||||
$status = $plugin->get_status();
|
||||
$row->attributes['class'] .= ' status-'.$status;
|
||||
if ($status === plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'statusmsg'));
|
||||
} else if ($status === plugin_manager::PLUGIN_STATUS_NEW) {
|
||||
$msg = html_writer::tag('span', get_string('status_new', 'core_plugin'), array('class' => 'statusmsg'));
|
||||
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
|
||||
$row->attributes['class'] .= ' missingfromdisk';
|
||||
} else {
|
||||
$msg = '';
|
||||
}
|
||||
@@ -1236,21 +1127,19 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$availability = new html_table_cell(get_string('plugindisabled', 'core_plugin'));
|
||||
}
|
||||
|
||||
$actions = array();
|
||||
|
||||
$settingsurl = $plugin->get_settings_url();
|
||||
if (!is_null($settingsurl)) {
|
||||
$settings = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
|
||||
} else {
|
||||
$settings = '';
|
||||
$actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
|
||||
}
|
||||
$settings = new html_table_cell($settings);
|
||||
|
||||
if ($pluginman->can_uninstall_plugin($plugin->component)) {
|
||||
$uninstallurl = $plugin->get_uninstall_url();
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'));
|
||||
} else {
|
||||
$uninstall = '';
|
||||
$uninstallurl = $plugin->get_uninstall_url();
|
||||
if (!is_null($uninstallurl)) {
|
||||
$actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
|
||||
}
|
||||
$uninstall = new html_table_cell($uninstall);
|
||||
|
||||
$actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
|
||||
|
||||
$requriedby = $pluginman->other_plugins_that_require($plugin->component);
|
||||
if ($requriedby) {
|
||||
@@ -1270,7 +1159,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$notes = new html_table_cell($requiredby.$updateinfo);
|
||||
|
||||
$row->cells = array(
|
||||
$pluginname, $source, $version, $availability, $settings, $uninstall, $notes
|
||||
$pluginname, $source, $version, $availability, $actions, $notes
|
||||
);
|
||||
$table->data[] = $row;
|
||||
}
|
||||
@@ -1356,9 +1245,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('report'),
|
||||
get_string('status'),
|
||||
);
|
||||
$servertable->colclasses = array('centeralign name', 'centeralign status', 'leftalign report', 'centeralign info');
|
||||
$servertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$servertable->id = 'serverstatus';
|
||||
$servertable->align = array('center', 'center', 'left', 'center');
|
||||
$servertable->wrap = array('nowrap', '', '', 'nowrap');
|
||||
$servertable->size = array('10', 10, '100%', '10');
|
||||
$servertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
@@ -1368,9 +1258,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
get_string('report'),
|
||||
get_string('status'),
|
||||
);
|
||||
$othertable->colclasses = array('aligncenter info', 'alignleft report', 'aligncenter status');
|
||||
$othertable->attributes['class'] = 'admintable environmenttable generaltable';
|
||||
$othertable->id = 'otherserverstatus';
|
||||
$othertable->align = array('center', 'left', 'center');
|
||||
$othertable->wrap = array('', '', 'nowrap');
|
||||
$othertable->size = array(10, '100%', '10');
|
||||
$othertable->attributes['class'] = 'environmenttable generaltable';
|
||||
|
||||
$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());
|
||||
|
||||
|
||||
+11
-20
@@ -61,9 +61,6 @@ if (!empty($action)) {
|
||||
require_sesskey();
|
||||
}
|
||||
|
||||
// Purge all caches related to repositories administration.
|
||||
cache::make('core', 'plugininfo_repository')->purge();
|
||||
|
||||
/**
|
||||
* Helper function that generates a moodle_url object
|
||||
* relevant to the repository
|
||||
@@ -143,10 +140,8 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$success = $repositorytype->update_options($settings);
|
||||
} else {
|
||||
$type = new repository_type($plugin, (array)$fromform, $visible);
|
||||
$type->create();
|
||||
$success = true;
|
||||
if (!$repoid = $type->create()) {
|
||||
$success = false;
|
||||
}
|
||||
$data = data_submitted();
|
||||
}
|
||||
if ($success) {
|
||||
@@ -286,20 +281,17 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
// Table to list plug-ins
|
||||
$table = new html_table();
|
||||
$table->head = array(get_string('name'), get_string('isactive', 'repository'), get_string('order'), $settingsstr);
|
||||
|
||||
$table->colclasses = array('leftalign', 'centeralign', 'centeralign', 'centeralign', 'centeralign');
|
||||
$table->id = 'repositoriessetting';
|
||||
$table->align = array('left', 'center', 'center', 'center', 'center');
|
||||
$table->data = array();
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
|
||||
// Get list of used plug-ins
|
||||
$repositorytypes = repository::get_types();
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
if (!empty($repositorytypes)) {
|
||||
$totalrepositorytypes = count($repositorytypes);
|
||||
$instances = repository::get_types();
|
||||
if (!empty($instances)) {
|
||||
// Array to store plugins being used
|
||||
$alreadyplugins = array();
|
||||
$totalinstances = count($instances);
|
||||
$updowncount = 1;
|
||||
foreach ($repositorytypes as $i) {
|
||||
foreach ($instances as $i) {
|
||||
$settings = '';
|
||||
$typename = $i->get_typename();
|
||||
// Display edit link only if you can config the type or if it has multiple instances (e.g. has instance config)
|
||||
@@ -322,10 +314,9 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$userinstances = array();
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
$repocontext = context::instance_by_id($instance->instance->contextid);
|
||||
if ($repocontext->contextlevel == CONTEXT_COURSE) {
|
||||
if ($instance->context->contextlevel == CONTEXT_COURSE) {
|
||||
$courseinstances[] = $instance;
|
||||
} else if ($repocontext->contextlevel == CONTEXT_USER) {
|
||||
} else if ($instance->context->contextlevel == CONTEXT_USER) {
|
||||
$userinstances[] = $instance;
|
||||
}
|
||||
}
|
||||
@@ -373,7 +364,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
else {
|
||||
$updown .= $spacer;
|
||||
}
|
||||
if ($updowncount < $totalrepositorytypes) {
|
||||
if ($updowncount < $totalinstances) {
|
||||
$updown .= "<a href=\"$sesskeyurl&action=movedown&repos=".$typename."\">";
|
||||
$updown .= "<img src=\"" . $OUTPUT->pix_url('t/down') . "\" alt=\"down\" /></a>";
|
||||
}
|
||||
|
||||
@@ -62,9 +62,6 @@ $return = true;
|
||||
if (!empty($edit) || !empty($new)) {
|
||||
if (!empty($edit)) {
|
||||
$instance = repository::get_instance($edit);
|
||||
if (!$instance->can_be_edited_by_user()) {
|
||||
throw new repository_exception('nopermissiontoaccess', 'repository');
|
||||
}
|
||||
$instancetype = repository::get_type_by_id($instance->options['typeid']);
|
||||
$classname = 'repository_' . $instancetype->get_typename();
|
||||
$configs = $instance->get_instance_option_names();
|
||||
@@ -121,12 +118,10 @@ if (!empty($edit) || !empty($new)) {
|
||||
$return = true;
|
||||
} else if (!empty($delete)) {
|
||||
$instance = repository::get_instance($delete);
|
||||
//if you try to delete an instance set as readonly, display an error message
|
||||
if ($instance->readonly) {
|
||||
// If you try to delete an instance set as readonly, display an error message.
|
||||
throw new repository_exception('readonlyinstance', 'repository');
|
||||
} else if (!$instance->can_be_edited_by_user()) {
|
||||
throw new repository_exception('nopermissiontoaccess', 'repository');
|
||||
}
|
||||
throw new repository_exception('readonlyinstance', 'repository');
|
||||
}
|
||||
if ($sure) {
|
||||
if ($instance->delete($downloadcontents)) {
|
||||
$deletedstr = get_string('instancedeleted', 'repository');
|
||||
|
||||
@@ -189,7 +189,7 @@ $assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
<form id="assignform" method="post" action="<?php echo $assignurl ?>"><div>
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
|
||||
<table id="assigningrole" summary="" class="admintable roleassigntable generaltable" cellspacing="0">
|
||||
<table summary="" class="roleassigntable generaltable generalbox boxaligncenter" cellspacing="0">
|
||||
<tr>
|
||||
<td id="existingcell">
|
||||
<p><label for="removeselect"><?php print_string('extusers', 'role'); ?></label></p>
|
||||
@@ -278,13 +278,15 @@ $assignurl = new moodle_url($PAGE->url, array('roleid'=>$roleid));
|
||||
|
||||
// Print overview table
|
||||
$table = new html_table();
|
||||
$table->id = 'assignrole';
|
||||
$table->tablealign = 'center';
|
||||
$table->width = '60%';
|
||||
$table->head = array(get_string('role'), get_string('description'), get_string('userswiththisrole', 'role'));
|
||||
$table->colclasses = array('leftalign role', 'leftalign', 'centeralign userrole');
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->wrap = array('nowrap', '', 'nowrap');
|
||||
$table->align = array('left', 'left', 'center');
|
||||
if ($showroleholders) {
|
||||
$table->headspan = array(1, 1, 2);
|
||||
$table->colclasses[] = 'leftalign roleholder';
|
||||
$table->wrap[] = 'nowrap';
|
||||
$table->align[] = 'left';
|
||||
}
|
||||
|
||||
foreach ($assignableroles as $roleid => $rolename) {
|
||||
|
||||
+11
-113
@@ -661,7 +661,7 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
public function make_copy() {
|
||||
$this->roleid = 0;
|
||||
unset($this->role->id);
|
||||
$this->role->name = role_get_name($this->role, null, ROLENAME_ORIGINAL) . ' ' . get_string('copyasnoun');
|
||||
$this->role->name .= ' ' . get_string('copyasnoun');
|
||||
$this->role->shortname .= 'copy';
|
||||
}
|
||||
|
||||
@@ -738,56 +738,6 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of roles of the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_allow_roles_list($type) {
|
||||
global $DB;
|
||||
|
||||
if ($type !== 'assign' and $type !== 'switch' and $type !== 'override') {
|
||||
debugging('Invalid role allowed type specified', DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
if (empty($this->roleid)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$sql = "SELECT r.*
|
||||
FROM {role} r
|
||||
JOIN {role_allow_{$type}} a ON a.allow{$type} = r.id
|
||||
WHERE a.roleid = :roleid
|
||||
ORDER BY r.sortorder ASC";
|
||||
return $DB->get_records_sql($sql, array('roleid'=>$this->roleid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of roles with the allowed type.
|
||||
*
|
||||
* @param string $type Must be one of: assign, switch, or override.
|
||||
* @return array Am array of role names with the allowed type
|
||||
*/
|
||||
protected function get_allow_role_control($type) {
|
||||
if ($roles = $this->get_allow_roles_list($type)) {
|
||||
$roles = role_fix_names($roles, null, ROLENAME_ORIGINAL, true);
|
||||
return implode(', ', $roles);
|
||||
} else {
|
||||
return get_string('none');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the risks associated with a role.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_role_risks_info() {
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function print_field($name, $caption, $field) {
|
||||
global $OUTPUT;
|
||||
// Attempt to generate HTML like formslib.
|
||||
@@ -831,12 +781,6 @@ class define_role_table_advanced extends capability_table_with_risks {
|
||||
$this->print_field('edit-description', get_string('customroledescription', 'role').' '.$OUTPUT->help_icon('customroledescription', 'role'), $this->get_description_field('description'));
|
||||
$this->print_field('menuarchetype', get_string('archetype', 'role').' '.$OUTPUT->help_icon('archetype', 'role'), $this->get_archetype_field('archetype'));
|
||||
$this->print_field('', get_string('maybeassignedin', 'role'), $this->get_assignable_levels_control());
|
||||
$this->print_field('', get_string('allowassign', 'role'), $this->get_allow_role_control('assign'));
|
||||
$this->print_field('', get_string('allowoverride', 'role'), $this->get_allow_role_control('override'));
|
||||
$this->print_field('', get_string('allowswitch', 'role'), $this->get_allow_role_control('switch'));
|
||||
if ($risks = $this->get_role_risks_info()) {
|
||||
$this->print_field('', get_string('rolerisks', 'role'), $risks);
|
||||
}
|
||||
echo "</div>";
|
||||
|
||||
$this->print_show_hide_advanced_button();
|
||||
@@ -938,57 +882,6 @@ class view_role_definition_table extends define_role_table_advanced {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML risk icons.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_role_risks_info() {
|
||||
global $OUTPUT;
|
||||
|
||||
if (empty($this->roleid)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$risks = array();
|
||||
$allrisks = get_all_risks();
|
||||
foreach ($this->capabilities as $capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
if ($perm != CAP_ALLOW) {
|
||||
continue;
|
||||
}
|
||||
foreach ($allrisks as $type=>$risk) {
|
||||
if ($risk & (int)$capability->riskbitmask) {
|
||||
$risks[$type] = $risk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$risksurl = new moodle_url(get_docs_url(s(get_string('risks', 'role'))));
|
||||
foreach ($risks as $type=>$risk) {
|
||||
$pixicon = new pix_icon('/i/' . str_replace('risk', 'risk_', $type), get_string($type . 'short', 'admin'));
|
||||
$risks[$type] = $OUTPUT->action_icon($risksurl, $pixicon, new popup_action('click', $risksurl));
|
||||
}
|
||||
|
||||
return implode(' ', $risks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the row should be skipped.
|
||||
*
|
||||
* @param string $capability
|
||||
* @return bool
|
||||
*/
|
||||
protected function skip_row($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
if ($perm == CAP_INHERIT) {
|
||||
// Do not print empty rows in role overview, admins need to know quickly what is allowed and prohibited,
|
||||
// if they want to see the list of all capabilities they can go to edit role page.
|
||||
return true;
|
||||
}
|
||||
parent::skip_row($capability);
|
||||
}
|
||||
|
||||
protected function add_permission_cells($capability) {
|
||||
$perm = $this->permissions[$capability->name];
|
||||
$permname = $this->allpermissions[$perm];
|
||||
@@ -1089,6 +982,8 @@ class override_permissions_table_advanced extends capability_table_with_risks {
|
||||
* Base class to avoid duplicating code.
|
||||
*/
|
||||
abstract class role_assign_user_selector_base extends user_selector_base {
|
||||
const MAX_USERS_PER_PAGE = 100;
|
||||
|
||||
protected $roleid;
|
||||
protected $context;
|
||||
|
||||
@@ -1157,7 +1052,7 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
if ($potentialmemberscount > role_assign_user_selector_base::MAX_USERS_PER_PAGE) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
@@ -1185,6 +1080,9 @@ class potential_assignees_below_course extends role_assign_user_selector_base {
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
*/
|
||||
class role_check_users_selector extends user_selector_base {
|
||||
const MAX_ENROLLED_PER_PAGE = 100;
|
||||
const MAX_POTENTIAL_PER_PAGE = 100;
|
||||
|
||||
/** @var bool limit listing of users to enrolled only */
|
||||
var $onlyenrolled;
|
||||
|
||||
@@ -1265,7 +1163,7 @@ class role_check_users_selector extends user_selector_base {
|
||||
|
||||
if ($sql1) {
|
||||
$enrolleduserscount = $DB->count_records_sql($countfields . $sql1, $params);
|
||||
if (!$this->is_validating() and $enrolleduserscount > $this->maxusersperpage) {
|
||||
if (!$this->is_validating() and $enrolleduserscount > $this::MAX_ENROLLED_PER_PAGE) {
|
||||
$result[$groupname1] = array();
|
||||
$toomany = $this->too_many_results($search, $enrolleduserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
@@ -1282,7 +1180,7 @@ class role_check_users_selector extends user_selector_base {
|
||||
}
|
||||
if ($sql2) {
|
||||
$otheruserscount = $DB->count_records_sql($countfields . $sql2, $params);
|
||||
if (!$this->is_validating() and $otheruserscount > $this->maxusersperpage) {
|
||||
if (!$this->is_validating() and $otheruserscount > $this::MAX_POTENTIAL_PER_PAGE) {
|
||||
$result[$groupname2] = array();
|
||||
$toomany = $this->too_many_results($search, $otheruserscount);
|
||||
$result[implode(' - ', array_keys($toomany))] = array();
|
||||
@@ -1335,7 +1233,7 @@ class potential_assignees_course_and_above extends role_assign_user_selector_bas
|
||||
|
||||
if (!$this->is_validating()) {
|
||||
$potentialmemberscount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialmemberscount > $this->maxusersperpage) {
|
||||
if ($potentialmemberscount > role_assign_user_selector_base::MAX_USERS_PER_PAGE) {
|
||||
return $this->too_many_results($search, $potentialmemberscount);
|
||||
}
|
||||
}
|
||||
@@ -1760,7 +1658,7 @@ class admins_potential_selector extends user_selector_base {
|
||||
// Check to see if there are too many to show sensibly.
|
||||
if (!$this->is_validating()) {
|
||||
$potentialcount = $DB->count_records_sql($countfields . $sql, $params);
|
||||
if ($potentialcount > $this->maxusersperpage) {
|
||||
if ($potentialcount > 100) {
|
||||
return $this->too_many_results($search, $potentialcount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@
|
||||
$a->id = $roleid;
|
||||
$a->name = $roles[$roleid]->name;
|
||||
$a->shortname = $roles[$roleid]->shortname;
|
||||
$a->count = $DB->count_records_select('role_assignments',
|
||||
'roleid = ?', array($roleid), 'COUNT(DISTINCT userid)');
|
||||
$a->count = $DB->count_records('role_assignments', array('roleid'=>$roleid));
|
||||
|
||||
$formcontinue = new single_button(new moodle_url($baseurl, $optionsyes), get_string('yes'));
|
||||
$formcancel = new single_button(new moodle_url($baseurl), get_string('no'), 'get');
|
||||
@@ -187,9 +186,10 @@
|
||||
|
||||
/// Initialise table.
|
||||
$table = new html_table();
|
||||
$table->colclasses = array('leftalign', 'leftalign', 'leftalign', 'leftalign');
|
||||
$table->id = 'roles';
|
||||
$table->attributes['class'] = 'admintable generaltable';
|
||||
$table->tablealign = 'center';
|
||||
$table->align = array('left', 'left', 'left', 'left');
|
||||
$table->wrap = array('nowrap', '', 'nowrap','nowrap');
|
||||
$table->width = '90%';
|
||||
$table->head = array(
|
||||
get_string('role') . ' ' . $OUTPUT->help_icon('roles', 'role'),
|
||||
get_string('description'),
|
||||
|
||||
@@ -33,6 +33,7 @@ $toprow[] = new tabobject('manage', new moodle_url('/admin/roles/manage.php'), g
|
||||
$toprow[] = new tabobject('assign', new moodle_url('/admin/roles/allow.php', array('mode'=>'assign')), get_string('allowassign', 'role'));
|
||||
$toprow[] = new tabobject('override', new moodle_url('/admin/roles/allow.php', array('mode'=>'override')), get_string('allowoverride', 'role'));
|
||||
$toprow[] = new tabobject('switch', new moodle_url('/admin/roles/allow.php', array('mode'=>'switch')), get_string('allowswitch', 'role'));
|
||||
$tabs = array($toprow);
|
||||
|
||||
echo $OUTPUT->tabtree($toprow, $currenttab);
|
||||
print_tabs($tabs, $currenttab);
|
||||
|
||||
|
||||
@@ -67,21 +67,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('calendar_maxevents',new lang_string('configmaxevents','admin'),new lang_string('helpupcomingmaxevents', 'admin'),10,$options));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecalendarexport', new lang_string('enablecalendarexport', 'admin'), new lang_string('configenablecalendarexport','admin'), 1));
|
||||
|
||||
// Calendar custom export settings.
|
||||
$days = array(365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
150 => new lang_string('numdays', '', 150),
|
||||
120 => new lang_string('numdays', '', 120),
|
||||
90 => new lang_string('numdays', '', 90),
|
||||
60 => new lang_string('numdays', '', 60),
|
||||
30 => new lang_string('numdays', '', 30),
|
||||
5 => new lang_string('numdays', '', 5));
|
||||
$temp->add(new admin_setting_configcheckbox('calendar_customexport', new lang_string('configcalendarcustomexport', 'admin'), new lang_string('helpcalendarcustomexport','admin'), 1));
|
||||
$temp->add(new admin_setting_configselect('calendar_exportlookahead', new lang_string('configexportlookahead','admin'), new lang_string('helpexportlookahead', 'admin'), 365, $days));
|
||||
$temp->add(new admin_setting_configselect('calendar_exportlookback', new lang_string('configexportlookback','admin'), new lang_string('helpexportlookback', 'admin'), 5, $days));
|
||||
$temp->add(new admin_setting_configtext('calendar_exportsalt', new lang_string('calendarexportsalt','admin'), new lang_string('configcalendarexportsalt', 'admin'), random_string(60)));
|
||||
$temp->add(new admin_setting_configcheckbox('calendar_showicalsource', new lang_string('configshowicalsource', 'admin'), new lang_string('helpshowicalsource','admin'), 1));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
// blog
|
||||
@@ -110,17 +96,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
);
|
||||
$temp->add(new admin_setting_configselect('defaulthomepage', new lang_string('defaulthomepage', 'admin'), new lang_string('configdefaulthomepage', 'admin'), HOMEPAGE_SITE, $choices));
|
||||
$temp->add(new admin_setting_configcheckbox('allowguestmymoodle', new lang_string('allowguestmymoodle', 'admin'), new lang_string('configallowguestmymoodle', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowfullcoursenames', new lang_string('navshowfullcoursenames', 'admin'), new lang_string('navshowfullcoursenames_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0));
|
||||
$sortoptions = array(
|
||||
'sortorder' => new lang_string('sort_sortorder', 'admin'),
|
||||
'fullname' => new lang_string('sort_fullname', 'admin'),
|
||||
'shortname' => new lang_string('sort_shortname', 'admin'),
|
||||
'idnumber' => new lang_string('sort_idnumber', 'admin'),
|
||||
);
|
||||
$temp->add(new admin_setting_configselect('navsortmycoursessort', new lang_string('navsortmycoursessort', 'admin'), new lang_string('navsortmycoursessort_help', 'admin'), 'sortorder', $sortoptions));
|
||||
$temp->add(new admin_setting_configtext('navcourselimit',new lang_string('navcourselimit','admin'),new lang_string('confignavcourselimit', 'admin'),20,PARAM_INT));
|
||||
$temp->add(new admin_setting_configcheckbox('usesitenameforsitepages', new lang_string('usesitenameforsitepages', 'admin'), new lang_string('configusesitenameforsitepages', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('linkadmincategories', new lang_string('linkadmincategories', 'admin'), new lang_string('linkadmincategories_help', 'admin'), 0));
|
||||
@@ -200,10 +178,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
new lang_string('courselistshortnames_desc', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('coursesperpage', new lang_string('coursesperpage', 'admin'), new lang_string('configcoursesperpage', 'admin'), 20, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('courseswithsummarieslimit', new lang_string('courseswithsummarieslimit', 'admin'), new lang_string('configcourseswithsummarieslimit', 'admin'), 10, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('courseoverviewfileslimit', new lang_string('courseoverviewfileslimit'),
|
||||
new lang_string('configcourseoverviewfileslimit', 'admin'), 1, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('courseoverviewfilesext', new lang_string('courseoverviewfilesext'),
|
||||
new lang_string('configcourseoverviewfilesext', 'admin'), '.jpg,.gif,.png'));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$temp = new admin_settingpage('ajax', new lang_string('ajaxuse'));
|
||||
|
||||
@@ -1,94 +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 settingpages and externalpages under the "badges" section
|
||||
*
|
||||
* @package core
|
||||
* @subpackage badges
|
||||
* @copyright 2012 onwards Totara Learning Solutions Ltd {@link http://www.totaralms.com/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
|
||||
*/
|
||||
|
||||
global $SITE;
|
||||
|
||||
if (($hassiteconfig || has_any_capability(array(
|
||||
'moodle/badges:viewawarded',
|
||||
'moodle/badges:createbadge',
|
||||
'moodle/badges:manageglobalsettings',
|
||||
'moodle/badges:awardbadge',
|
||||
'moodle/badges:configurecriteria',
|
||||
'moodle/badges:configuremessages',
|
||||
'moodle/badges:configuredetails',
|
||||
'moodle/badges:deletebadge'), $systemcontext))) {
|
||||
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
$globalsettings = new admin_settingpage('badgesettings', new lang_string('badgesettings', 'badges'),
|
||||
array('moodle/badges:manageglobalsettings'), empty($CFG->enablebadges));
|
||||
|
||||
$globalsettings->add(new admin_setting_configtext('badges_defaultissuername',
|
||||
new lang_string('defaultissuername', 'badges'),
|
||||
new lang_string('defaultissuername_desc', 'badges'),
|
||||
$SITE->fullname ? $SITE->fullname : $SITE->shortname, PARAM_TEXT));
|
||||
|
||||
$globalsettings->add(new admin_setting_configtext('badges_defaultissuercontact',
|
||||
new lang_string('defaultissuercontact', 'badges'),
|
||||
new lang_string('defaultissuercontact_desc', 'badges'),
|
||||
get_config('moodle','supportemail'), PARAM_EMAIL));
|
||||
|
||||
$globalsettings->add(new admin_setting_configtext('badges_badgesalt',
|
||||
new lang_string('badgesalt', 'badges'),
|
||||
new lang_string('badgesalt_desc', 'badges'),
|
||||
'badges' . $SITE->timecreated, PARAM_ALPHANUM));
|
||||
|
||||
$globalsettings->add(new admin_setting_configcheckbox('badges_allowexternalbackpack',
|
||||
new lang_string('allowexternalbackpack', 'badges'),
|
||||
new lang_string('allowexternalbackpack_desc', 'badges'), 1));
|
||||
|
||||
$globalsettings->add(new admin_setting_configcheckbox('badges_allowcoursebadges',
|
||||
new lang_string('allowcoursebadges', 'badges'),
|
||||
new lang_string('allowcoursebadges_desc', 'badges'), 1));
|
||||
|
||||
$ADMIN->add('badges', $globalsettings);
|
||||
|
||||
$ADMIN->add('badges',
|
||||
new admin_externalpage('managebadges',
|
||||
new lang_string('managebadges', 'badges'),
|
||||
new moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE)),
|
||||
array(
|
||||
'moodle/badges:viewawarded',
|
||||
'moodle/badges:createbadge',
|
||||
'moodle/badges:awardbadge',
|
||||
'moodle/badges:configurecriteria',
|
||||
'moodle/badges:configuremessages',
|
||||
'moodle/badges:configuredetails',
|
||||
'moodle/badges:deletebadge'
|
||||
),
|
||||
empty($CFG->enablebadges)
|
||||
)
|
||||
);
|
||||
|
||||
$ADMIN->add('badges',
|
||||
new admin_externalpage('newbadge',
|
||||
new lang_string('newbadge', 'badges'),
|
||||
new moodle_url('/badges/newbadge.php', array('type' => BADGE_TYPE_SITE)),
|
||||
array('moodle/badges:createbadge'), empty($CFG->enablebadges)
|
||||
)
|
||||
);
|
||||
}
|
||||
+40
-75
@@ -8,80 +8,33 @@ if ($hassiteconfig
|
||||
or has_capability('moodle/course:create', $systemcontext)
|
||||
or has_capability('moodle/site:approvecourse', $systemcontext)) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/manage.php',
|
||||
$ADMIN->add('courses', new admin_externalpage('coursemgmt', new lang_string('coursemgmt', 'admin'), $CFG->wwwroot . '/course/index.php?categoryedit=on',
|
||||
array('moodle/category:manage', 'moodle/course:create')));
|
||||
|
||||
// Course Default Settings Page.
|
||||
// NOTE: these settings must be applied after all other settings because they depend on them.
|
||||
|
||||
|
||||
// Main course settings.
|
||||
/// Course Default Settings Page
|
||||
/// NOTE: these settings must be applied after all other settings because they depend on them
|
||||
///main course settings
|
||||
$temp = new admin_settingpage('coursesettings', new lang_string('coursesettings'));
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('hide');
|
||||
$choices['1'] = new lang_string('show');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), new lang_string('visible_help'),
|
||||
1, $choices));
|
||||
|
||||
|
||||
// Course format.
|
||||
$temp->add(new admin_setting_heading('courseformathdr', new lang_string('type_format', 'plugin'), ''));
|
||||
|
||||
$courseformats = get_sorted_course_formats(true);
|
||||
$formcourseformats = array();
|
||||
foreach ($courseformats as $courseformat) {
|
||||
$formcourseformats[$courseformat] = new lang_string('pluginname', "format_$courseformat");
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'),
|
||||
'weeks',$formcourseformats));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/format', new lang_string('format'), new lang_string('coursehelpformat'), 'weeks',$formcourseformats));
|
||||
|
||||
$temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'),
|
||||
new lang_string('maxnumberweeks_desc'), 52));
|
||||
$temp->add(new admin_setting_configtext('moodlecourse/maxsections', new lang_string('maxnumberweeks'), new lang_string('maxnumberweeks_desc'), 52));
|
||||
|
||||
$temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'),
|
||||
new lang_string('coursehelpnumberweeks'), 10));
|
||||
$temp->add(new admin_settings_num_course_sections('moodlecourse/numsections', new lang_string('numberweeks'), new lang_string('coursehelpnumberweeks'), 10));
|
||||
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('hiddensectionscollapsed');
|
||||
$choices['1'] = new lang_string('hiddensectionsinvisible');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'),
|
||||
new lang_string('coursehelphiddensections'), 0, $choices));
|
||||
|
||||
$choices = array();
|
||||
$choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
|
||||
$choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'),
|
||||
new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
|
||||
|
||||
|
||||
// Appearance.
|
||||
$temp->add(new admin_setting_heading('appearancehdr', new lang_string('appearance'), ''));
|
||||
|
||||
$languages = array();
|
||||
$languages[''] = new lang_string('forceno');
|
||||
$languages += get_string_manager()->get_list_of_translations();
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '', key($languages),
|
||||
$languages));
|
||||
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/hiddensections', new lang_string('hiddensections'), new lang_string('coursehelphiddensections'), 0,$choices));
|
||||
$options = range(0, 10);
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'),
|
||||
new lang_string('coursehelpnewsitemsnumber'), 5, $options));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'),
|
||||
new lang_string('coursehelpshowgrades'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,
|
||||
array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
|
||||
// Files and uploads.
|
||||
$temp->add(new admin_setting_heading('filesanduploadshdr', new lang_string('filesanduploads'), ''));
|
||||
|
||||
if (!empty($CFG->legacyfilesinnewcourses)) {
|
||||
$choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'),
|
||||
new lang_string('courselegacyfiles_help'), key($choices), $choices));
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/newsitems', new lang_string('newsitemsnumber'), new lang_string('coursehelpnewsitemsnumber'), 5,$options));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showgrades', new lang_string('showgrades'), new lang_string('coursehelpshowgrades'), 1,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/showreports', new lang_string('showreports'), '', 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
$currentmaxbytes = get_config('moodlecourse', 'maxbytes');
|
||||
if (isset($CFG->maxbytes)) {
|
||||
@@ -89,17 +42,18 @@ if ($hassiteconfig
|
||||
} else {
|
||||
$choices = get_max_upload_sizes(0, 0, 0, $currentmaxbytes);
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'),
|
||||
new lang_string('coursehelpmaximumupload'), key($choices), $choices));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/maxbytes', new lang_string('maximumupload'), new lang_string('coursehelpmaximumupload'), key($choices), $choices));
|
||||
|
||||
if (!empty($CFG->legacyfilesinnewcourses)) {
|
||||
$choices = array('0'=>new lang_string('no'), '2'=>new lang_string('yes'));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/legacyfiles', new lang_string('courselegacyfiles'), new lang_string('courselegacyfiles_help'), key($choices), $choices));
|
||||
}
|
||||
|
||||
// Completion tracking.
|
||||
$temp->add(new admin_setting_heading('progress', new lang_string('completion','completion'), ''));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
|
||||
new lang_string('enablecompletion_help', 'completion'), 0, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
$choices = array();
|
||||
$choices[COURSE_DISPLAY_SINGLEPAGE] = new lang_string('coursedisplay_single');
|
||||
$choices[COURSE_DISPLAY_MULTIPAGE] = new lang_string('coursedisplay_multi');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/coursedisplay', new lang_string('coursedisplay'), new lang_string('coursedisplay_help'), COURSE_DISPLAY_SINGLEPAGE, $choices));
|
||||
|
||||
|
||||
// Groups.
|
||||
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
|
||||
$choices = array();
|
||||
$choices[NOGROUPS] = new lang_string('groupsnone', 'group');
|
||||
@@ -108,10 +62,28 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/groupmode', new lang_string('groupmode'), '', key($choices),$choices));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/groupmodeforce', new lang_string('force'), new lang_string('coursehelpforce'), 0,array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||
|
||||
|
||||
$temp->add(new admin_setting_heading('availability', new lang_string('availability'), ''));
|
||||
$choices = array();
|
||||
$choices['0'] = new lang_string('courseavailablenot');
|
||||
$choices['1'] = new lang_string('courseavailable');
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/visible', new lang_string('visible'), '', 1,$choices));
|
||||
|
||||
|
||||
$temp->add(new admin_setting_heading('language', new lang_string('language'), ''));
|
||||
$languages=array();
|
||||
$languages[''] = new lang_string('forceno');
|
||||
$languages += get_string_manager()->get_list_of_translations();
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/lang', new lang_string('forcelanguage'), '',key($languages),$languages));
|
||||
|
||||
$temp->add(new admin_setting_heading('progress', new lang_string('progress','completion'), ''));
|
||||
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion','completion'), '',
|
||||
0, array(0 => new lang_string('completiondisabled','completion'), 1 => new lang_string('completionenabled','completion'))));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('moodlecourse/completionstartonenrol', new lang_string('completionstartonenrol','completion'), new lang_string('completionstartonenrolhelp', 'completion'), 0));
|
||||
$ADMIN->add('courses', $temp);
|
||||
|
||||
|
||||
// "courserequests" settingpage.
|
||||
/// "courserequests" settingpage
|
||||
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
|
||||
$temp->add(new admin_setting_configcheckbox('enablecourserequests', new lang_string('enablecourserequests', 'admin'), new lang_string('configenablecourserequests', 'admin'), 0));
|
||||
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory', new lang_string('defaultrequestcategory', 'admin'), new lang_string('configdefaultrequestcategory', 'admin'), 1));
|
||||
@@ -158,17 +130,11 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), array('value'=>1,'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', new lang_string('generallogs','backup'), new lang_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for general import configuration and defaults.
|
||||
$temp = new admin_settingpage('importgeneralsettings', new lang_string('importgeneralsettings', 'backup'), 'moodle/backup:backupcourse');
|
||||
$temp->add(new admin_setting_configtext('backup/import_general_maxresults', new lang_string('importgeneralmaxresults', 'backup'), new lang_string('importgeneralmaxresults_desc', 'backup'), 10));
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for automated backups configuration and defaults.
|
||||
$temp = new admin_settingpage('automated', new lang_string('automatedsetup','backup'), 'moodle/backup:backupcourse');
|
||||
|
||||
@@ -232,7 +198,6 @@ if ($hassiteconfig
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blocks', new lang_string('generalblocks','backup'), new lang_string('configgeneralblocks','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_filters', new lang_string('generalfilters','backup'), new lang_string('configgeneralfilters','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_comments', new lang_string('generalcomments','backup'), new lang_string('configgeneralcomments','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_badges', new lang_string('generalbadges','backup'), new lang_string('configgeneralbadges','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_userscompletion', new lang_string('generaluserscompletion','backup'), new lang_string('configgeneraluserscompletion','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
|
||||
|
||||
@@ -32,46 +32,44 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configcheckbox('debugpageinfo', new lang_string('debugpageinfo', 'admin'), new lang_string('configdebugpageinfo', 'admin'), 0));
|
||||
$ADMIN->add('development', $temp);
|
||||
|
||||
// "Profiling" settingpage (conditionally if the 'xhprof' extension is available only).
|
||||
$xhprofenabled = extension_loaded('xhprof') && function_exists('xhprof_enable');
|
||||
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'), 'moodle/site:config', !$xhprofenabled);
|
||||
// Main profiling switch.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
||||
// List of URLs that will be automatically profiled.
|
||||
$temp->add(new admin_setting_configtextarea('profilingincluded', new lang_string('profilingincluded', 'admin'), new lang_string('profilingincluded_help', 'admin'), ''));
|
||||
// List of URLs that won't be profiled ever.
|
||||
$temp->add(new admin_setting_configtextarea('profilingexcluded', new lang_string('profilingexcluded', 'admin'), new lang_string('profilingexcluded_help', 'admin'), ''));
|
||||
// Allow random profiling each XX requests.
|
||||
$temp->add(new admin_setting_configtext('profilingautofrec', new lang_string('profilingautofrec', 'admin'), new lang_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
|
||||
// Allow PROFILEME/DONTPROFILEME GPC.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
|
||||
// Allow PROFILEALL/PROFILEALLSTOP GPC.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
|
||||
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
|
||||
// TODO: Allow to skip call_user functions (ignored_functions array)
|
||||
// Specify the life time (in minutes) of profiling runs.
|
||||
$temp->add(new admin_setting_configselect('profilinglifetime', new lang_string('profilinglifetime', 'admin'), new lang_string('profilinglifetime_help', 'admin'), 24*60, array(
|
||||
0 => new lang_string('neverdeleteruns', 'admin'),
|
||||
30*24*60 => new lang_string('numdays', '', 30),
|
||||
15*24*60 => new lang_string('numdays', '', 15),
|
||||
7*24*60 => new lang_string('numdays', '', 7),
|
||||
4*24*60 => new lang_string('numdays', '', 4),
|
||||
2*24*60 => new lang_string('numdays', '', 2),
|
||||
24*60 => new lang_string('numhours', '', 24),
|
||||
16*80 => new lang_string('numhours', '', 16),
|
||||
8*60 => new lang_string('numhours', '', 8),
|
||||
4*60 => new lang_string('numhours', '', 4),
|
||||
2*60 => new lang_string('numhours', '', 2),
|
||||
60 => new lang_string('numminutes', '', 60),
|
||||
30 => new lang_string('numminutes', '', 30),
|
||||
15 => new lang_string('numminutes', '', 15))));
|
||||
// Define the prefix to be added to imported profiling runs.
|
||||
$temp->add(new admin_setting_configtext('profilingimportprefix',
|
||||
new lang_string('profilingimportprefix', 'admin'),
|
||||
new lang_string('profilingimportprefix_desc', 'admin'), '(I)', PARAM_TAG, 10));
|
||||
// "profiling" settingpage (conditionally if the 'xhprof' extension is available only)
|
||||
if (extension_loaded('xhprof') && function_exists('xhprof_enable')) {
|
||||
$temp = new admin_settingpage('profiling', new lang_string('profiling', 'admin'));
|
||||
// Main profiling switch
|
||||
$temp->add(new admin_setting_configcheckbox('profilingenabled', new lang_string('profilingenabled', 'admin'), new lang_string('profilingenabled_help', 'admin'), false));
|
||||
// List of URLs that will be automatically profiled
|
||||
$temp->add(new admin_setting_configtextarea('profilingincluded', new lang_string('profilingincluded', 'admin'), new lang_string('profilingincluded_help', 'admin'), ''));
|
||||
// List of URLs that won't be profiled ever
|
||||
$temp->add(new admin_setting_configtextarea('profilingexcluded', new lang_string('profilingexcluded', 'admin'), new lang_string('profilingexcluded_help', 'admin'), ''));
|
||||
// Allow random profiling each XX requests
|
||||
$temp->add(new admin_setting_configtext('profilingautofrec', new lang_string('profilingautofrec', 'admin'), new lang_string('profilingautofrec_help', 'admin'), 0, PARAM_INT));
|
||||
// Allow PROFILEME/DONTPROFILEME GPC
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
|
||||
// Allow PROFILEALL/PROFILEALLSTOP GPC
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
|
||||
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
|
||||
// TODO: Allow to skip call_user functions (ignored_functions array)
|
||||
// Specify the life time (in minutes) of profiling runs
|
||||
$temp->add(new admin_setting_configselect('profilinglifetime', new lang_string('profilinglifetime', 'admin'), new lang_string('profilinglifetime_help', 'admin'), 24*60, array(
|
||||
0 => new lang_string('neverdeleteruns', 'admin'),
|
||||
30*24*60 => new lang_string('numdays', '', 30),
|
||||
15*24*60 => new lang_string('numdays', '', 15),
|
||||
7*24*60 => new lang_string('numdays', '', 7),
|
||||
4*24*60 => new lang_string('numdays', '', 4),
|
||||
2*24*60 => new lang_string('numdays', '', 2),
|
||||
24*60 => new lang_string('numhours', '', 24),
|
||||
16*80 => new lang_string('numhours', '', 16),
|
||||
8*60 => new lang_string('numhours', '', 8),
|
||||
4*60 => new lang_string('numhours', '', 4),
|
||||
2*60 => new lang_string('numhours', '', 2),
|
||||
60 => new lang_string('numminutes', '', 60),
|
||||
30 => new lang_string('numminutes', '', 30),
|
||||
15 => new lang_string('numminutes', '', 15))));
|
||||
|
||||
// Add the 'profiling' page to admin block
|
||||
$ADMIN->add('development', $temp);
|
||||
}
|
||||
|
||||
// Add the 'profiling' page to admin block.
|
||||
$ADMIN->add('development', $temp);
|
||||
|
||||
// Web service test clients DO NOT COMMIT : THE EXTERNAL WEB PAGE IS NOT AN ADMIN PAGE !!!!!
|
||||
$ADMIN->add('development', new admin_externalpage('testclient', new lang_string('testclient', 'webservice'), "$CFG->wwwroot/$CFG->admin/webservice/testclient.php"));
|
||||
|
||||
@@ -32,9 +32,7 @@ if (!during_initial_install()) { //do not use during installation
|
||||
for ($i=1; $i<100; $i++) {
|
||||
$options[$i] = $i;
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('maxcategorydepth', new lang_string('configsitemaxcategorydepth','admin'), new lang_string('configsitemaxcategorydepthhelp','admin'), 2, $options));
|
||||
|
||||
$temp->add(new admin_setting_configtext('frontpagecourselimit', new lang_string('configfrontpagecourselimit','admin'), new lang_string('configfrontpagecourselimithelp','admin'), 200, PARAM_INT));
|
||||
$temp->add(new admin_setting_configselect('maxcategorydepth', new lang_string('configsitemaxcategorydepth','admin'), new lang_string('configsitemaxcategorydepthhelp','admin'), 0, $options));
|
||||
|
||||
$temp->add(new admin_setting_sitesetcheckbox('numsections', new lang_string('sitesection'), new lang_string('sitesectionhelp','admin'), 1));
|
||||
$temp->add(new admin_setting_sitesetselect('newsitems', new lang_string('newsitemsnumber'), '', 3,
|
||||
|
||||
+16
-58
@@ -196,9 +196,9 @@ if ($hassiteconfig) {
|
||||
50, PARAM_INT, 3));
|
||||
|
||||
$ADMIN->add('portfoliosettings', $temp);
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true));
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true));
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true));
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', new lang_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', new lang_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
|
||||
$ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', new lang_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
|
||||
|
||||
foreach (portfolio_instances(false, false) as $portfolio) {
|
||||
require_once($CFG->dirroot . '/portfolio/' . $portfolio->get('plugin') . '/lib.php');
|
||||
@@ -210,7 +210,9 @@ if ($hassiteconfig) {
|
||||
$portfolio->get('name'),
|
||||
$url . '?action=edit&pf=' . $portfolio->get('id'),
|
||||
'moodle/site:config'
|
||||
)
|
||||
),
|
||||
$portfolio->get('name'),
|
||||
$url . '?action=edit&pf=' . $portfolio->get('id')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -232,15 +234,20 @@ if ($hassiteconfig) {
|
||||
$temp->add(new admin_setting_configcheckbox('legacyfilesinnewcourses', new lang_string('legacyfilesinnewcourses', 'admin'), new lang_string('legacyfilesinnewcourses_help', 'admin'), 0));
|
||||
$ADMIN->add('repositorysettings', $temp);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositorynew',
|
||||
new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('addplugin', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositorydelete',
|
||||
new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('deleterepository', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositorycontroller',
|
||||
new lang_string('manage', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('manage', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstancenew',
|
||||
new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
|
||||
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
|
||||
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true),
|
||||
'', $url);
|
||||
foreach ($allplugins['repository'] as $repositorytype) {
|
||||
$repositorytype->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
|
||||
}
|
||||
@@ -309,7 +316,6 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
require_once("$CFG->libdir/pluginlib.php");
|
||||
$allplugins = plugin_manager::instance()->get_plugins();
|
||||
}
|
||||
|
||||
// Question behaviour settings.
|
||||
$ADMIN->add('modules', new admin_category('qbehavioursettings', new lang_string('questionbehaviours', 'admin')));
|
||||
$ADMIN->add('qbehavioursettings', new admin_page_manageqbehaviours());
|
||||
@@ -317,54 +323,6 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
// Question type settings.
|
||||
$ADMIN->add('modules', new admin_category('qtypesettings', new lang_string('questiontypes', 'admin')));
|
||||
$ADMIN->add('qtypesettings', new admin_page_manageqtypes());
|
||||
|
||||
// Question preview defaults.
|
||||
$settings = new admin_settingpage('qdefaultsetting',
|
||||
get_string('questionpreviewdefaults', 'question'),
|
||||
'moodle/question:config');
|
||||
$ADMIN->add('qtypesettings', $settings);
|
||||
|
||||
$settings->add(new admin_setting_heading('qdefaultsetting_preview_options',
|
||||
'', get_string('questionpreviewdefaults_desc', 'question')));
|
||||
|
||||
// These keys are question_display_options::HIDDEN and VISIBLE.
|
||||
$hiddenofvisible = array(
|
||||
0 => get_string('notshown', 'question'),
|
||||
1 => get_string('shown', 'question'),
|
||||
);
|
||||
|
||||
$settings->add(new admin_setting_question_behaviour('question_preview/behaviour',
|
||||
get_string('howquestionsbehave', 'question'), '',
|
||||
'deferredfeedback'));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/correctness',
|
||||
get_string('whethercorrect', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
// These keys are question_display_options::HIDDEN, MARK_ONLY and MARK_AND_MAX.
|
||||
$marksoptions = array(
|
||||
0 => get_string('notshown', 'question'),
|
||||
1 => get_string('showmaxmarkonly', 'question'),
|
||||
2 => get_string('showmarkandmax', 'question'),
|
||||
);
|
||||
$settings->add(new admin_setting_configselect('question_preview/marks',
|
||||
get_string('marks', 'question'), '', 1, $marksoptions));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/markdp',
|
||||
get_string('decimalplacesingrades', 'question'), '', 2, array(0, 1, 2, 3, 4, 5, 6, 7)));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/feedback',
|
||||
get_string('specificfeedback', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/generalfeedback',
|
||||
get_string('generalfeedback', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/rightanswer',
|
||||
get_string('rightanswer', 'question'), '', 1, $hiddenofvisible));
|
||||
|
||||
$settings->add(new admin_setting_configselect('question_preview/history',
|
||||
get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
|
||||
|
||||
// Settings for particular question types.
|
||||
foreach ($allplugins['qtype'] as $qtype) {
|
||||
$qtype->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
@@ -23,12 +23,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
new lang_string('configprofileroles', 'admin'),
|
||||
array('student', 'teacher', 'editingteacher')));
|
||||
|
||||
$maxbytes = 0;
|
||||
if (!empty($CFG->maxbytes)) {
|
||||
$maxbytes = $CFG->maxbytes;
|
||||
}
|
||||
$max_upload_choices = get_max_upload_sizes(0, 0, 0, $maxbytes);
|
||||
$max_upload_choices = get_max_upload_sizes();
|
||||
// maxbytes set to 0 will allow the maximum server limit for uploads
|
||||
$max_upload_choices[0] = new lang_string('serverlimit', 'admin');
|
||||
$temp->add(new admin_setting_configselect('maxbytes', new lang_string('maxbytes', 'admin'), new lang_string('configmaxbytes', 'admin'), 0, $max_upload_choices));
|
||||
// 100MB
|
||||
$defaultuserquota = 104857600;
|
||||
@@ -62,11 +59,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configcheckbox('cronclionly', new lang_string('cronclionly', 'admin'), new lang_string('configcronclionly', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configpasswordunmask('cronremotepassword', new lang_string('cronremotepassword', 'admin'), new lang_string('configcronremotepassword', 'admin'), ''));
|
||||
|
||||
$options = array(0=>get_string('no'), 3=>3, 5=>5, 7=>7, 10=>10, 20=>20, 30=>30, 50=>50, 100=>100);
|
||||
$temp->add(new admin_setting_configselect('lockoutthreshold', new lang_string('lockoutthreshold', 'admin'), new lang_string('lockoutthreshold_desc', 'admin'), 0, $options));
|
||||
$temp->add(new admin_setting_configduration('lockoutwindow', new lang_string('lockoutwindow', 'admin'), new lang_string('lockoutwindow_desc', 'admin'), 60*30));
|
||||
$temp->add(new admin_setting_configduration('lockoutduration', new lang_string('lockoutduration', 'admin'), new lang_string('lockoutduration_desc', 'admin'), 60*30));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('passwordpolicy', new lang_string('passwordpolicy', 'admin'), new lang_string('configpasswordpolicy', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('minpasswordlength', new lang_string('minpasswordlength', 'admin'), new lang_string('configminpasswordlength', 'admin'), 8, PARAM_INT));
|
||||
$temp->add(new admin_setting_configtext('minpassworddigits', new lang_string('minpassworddigits', 'admin'), new lang_string('configminpassworddigits', 'admin'), 1, PARAM_INT));
|
||||
|
||||
@@ -7,7 +7,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
// "systempaths" settingpage
|
||||
$temp = new admin_settingpage('systempaths', new lang_string('systempaths','admin'));
|
||||
|
||||
$temp->add(new admin_setting_configselect('gdversion', new lang_string('gdversion','admin'), new lang_string('configgdversion', 'admin'), check_gd_version(), array('0' => new lang_string('gdnot'),
|
||||
'1' => new lang_string('gd1'),
|
||||
'2' => new lang_string('gd2'))));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodu', new lang_string('pathtodu', 'admin'), new lang_string('configpathtodu', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('aspellpath', new lang_string('aspellpath', 'admin'), new lang_string('edhelpaspellpath'), ''));
|
||||
$temp->add(new admin_setting_configexecutable('pathtodot', new lang_string('pathtodot', 'admin'), new lang_string('pathtodot_help', 'admin'), ''));
|
||||
@@ -175,6 +177,8 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo
|
||||
// "performance" settingpage
|
||||
$temp = new admin_settingpage('performance', new lang_string('performance', 'admin'));
|
||||
|
||||
$temp->add(new admin_setting_configtext('numcoursesincombo', new lang_string('numcoursesincombo', 'admin'), new lang_string('numcoursesincombo_help', 'admin'), 500));
|
||||
|
||||
$temp->add(new admin_setting_configselect('extramemorylimit', new lang_string('extramemorylimit', 'admin'),
|
||||
new lang_string('configextramemorylimit', 'admin'), '512M',
|
||||
// if this option is set to 0, default 128M will be used
|
||||
|
||||
@@ -41,6 +41,4 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$checkbox->set_affects_modinfo(true);
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('enableplagiarism', new lang_string('enableplagiarism','plagiarism'), new lang_string('configenableplagiarism','plagiarism'), 0));
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('enablebadges', new lang_string('enablebadges', 'badges'), new lang_string('configenablebadges', 'badges'), 1));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ if ($hassiteconfig) {
|
||||
$ADMIN->add('root', new admin_category('users', new lang_string('users','admin')));
|
||||
$ADMIN->add('root', new admin_category('courses', new lang_string('courses','admin')));
|
||||
$ADMIN->add('root', new admin_category('grades', new lang_string('grades')));
|
||||
$ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empty($CFG->enablebadges)));
|
||||
$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('modules', new lang_string('plugins', 'admin')));
|
||||
|
||||
@@ -150,7 +150,6 @@ if ($hassiteconfig
|
||||
'department' => new lang_string('department'),
|
||||
'institution' => new lang_string('institution'),
|
||||
)));
|
||||
$temp->add(new admin_setting_configtext('maxusersperpage', new lang_string('maxusersperpage','admin'), new lang_string('configmaxusersperpage','admin'), 100, PARAM_INT));
|
||||
$temp->add(new admin_setting_configcheckbox('enablegravatar', new lang_string('enablegravatar', 'admin'), new lang_string('enablegravatar_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configtext('gravatardefaulturl', new lang_string('gravatardefaulturl', 'admin'), new lang_string('gravatardefaulturl_help', 'admin'), 'mm'));
|
||||
}
|
||||
|
||||
@@ -1,127 +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/>.
|
||||
|
||||
/**
|
||||
* Steps definitions related with administration.
|
||||
*
|
||||
* @package core_admin
|
||||
* @category test
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
|
||||
require_once(__DIR__ . '/../../../lib/behat/behat_base.php');
|
||||
require_once(__DIR__ . '/../../../lib/behat/behat_field_manager.php');
|
||||
|
||||
use Behat\Gherkin\Node\TableNode as TableNode,
|
||||
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
|
||||
/**
|
||||
* Site administration level steps definitions.
|
||||
*
|
||||
* @package core_admin
|
||||
* @category test
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_admin extends behat_base {
|
||||
|
||||
/**
|
||||
* Sets the specified site settings. A table with | Setting label | value | is expected.
|
||||
*
|
||||
* @Given /^I set the following administration settings values:$/
|
||||
* @param TableNode $table
|
||||
*/
|
||||
public function i_set_the_following_administration_settings_values(TableNode $table) {
|
||||
|
||||
if (!$data = $table->getRowsHash()) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($data as $label => $value) {
|
||||
|
||||
// We expect admin block to be visible, otherwise go to homepage.
|
||||
if (!$this->getSession()->getPage()->find('css', '.block_settings')) {
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
$this->wait(self::TIMEOUT, '(document.readyState === "complete")');
|
||||
}
|
||||
|
||||
// Search by label.
|
||||
$searchbox = $this->find_field(get_string('searchinsettings', 'admin'));
|
||||
$searchbox->setValue($label);
|
||||
$submitsearch = $this->find('css', 'form.adminsearchform input[type=submit]');
|
||||
$submitsearch->press();
|
||||
|
||||
$this->wait(self::TIMEOUT, '(document.readyState === "complete")');
|
||||
|
||||
// Admin settings does not use the same DOM structure than other moodle forms
|
||||
// but we also need to use lib/behat/form_field/* to deal with the different moodle form elements.
|
||||
$exception = new ElementNotFoundException($this->getSession(), '"' . $label . '" administration setting ');
|
||||
|
||||
// The argument should be converted to an xpath literal.
|
||||
$label = $this->getSession()->getSelectorsHandler()->xpathLiteral($label);
|
||||
|
||||
// Single element settings.
|
||||
try {
|
||||
$fieldxpath = "//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" .
|
||||
"[@id=//label[contains(normalize-space(.), $label)]/@for]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath, $exception);
|
||||
|
||||
$formfieldtypenode = $this->find('xpath', $fieldxpath . "/ancestor::div[@class='form-setting']" .
|
||||
"/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div");
|
||||
|
||||
} catch (ElementNotFoundException $e) {
|
||||
|
||||
// Multi element settings, interacting only the first one.
|
||||
$fieldxpath = "//descendant::label[.= $label]/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' form-item ')]" .
|
||||
"/descendant::div[@class='form-group']/descendant::*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath);
|
||||
|
||||
// It is the same one that contains the type.
|
||||
$formfieldtypenode = $fieldnode;
|
||||
}
|
||||
|
||||
// Getting the class which contains the field type.
|
||||
$classes = explode(' ', $formfieldtypenode->getAttribute('class'));
|
||||
foreach ($classes as $class) {
|
||||
if (substr($class, 0, 5) == 'form-') {
|
||||
$type = substr($class, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiating the appropiate field type.
|
||||
$field = behat_field_manager::get_field_instance($type, $fieldnode, $this->getSession());
|
||||
$field->set_value($value);
|
||||
|
||||
$this->find_button(get_string('savechanges'))->press();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits with the provided params if we are running a JS session.
|
||||
*
|
||||
* @param int $timeout
|
||||
* @param string $javascript
|
||||
* @return void
|
||||
*/
|
||||
protected function wait($timeout, $javascript = false) {
|
||||
if ($this->running_javascript()) {
|
||||
$this->getSession()->wait($timeout, $javascript);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
@core @core_admin
|
||||
Feature: Display extended course names
|
||||
In order to display more info about the courses
|
||||
As an admin
|
||||
I need to display courses short names along with courses full names
|
||||
|
||||
Background:
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course fullname | C_shortname | 0 |
|
||||
And I log in as "admin"
|
||||
|
||||
Scenario: Courses list without extended course names (default value)
|
||||
Then I should see "Course fullname"
|
||||
And I should not see "C_shortname Course fullname"
|
||||
|
||||
Scenario: Courses list with extended course names
|
||||
Given I click on "Courses" "link" in the "//div[@id='settingsnav']/descendant::li[contains(concat(' ', normalize-space(@class), ' '), ' type_setting ')][not(contains(., 'Site administration'))][contains(., 'Appearance')]" "xpath_element"
|
||||
And I check "Display extended course names"
|
||||
When I press "Save changes"
|
||||
And I am on homepage
|
||||
Then I should see "C_shortname Course fullname"
|
||||
@@ -1,69 +0,0 @@
|
||||
@core @core_admin
|
||||
Feature: An administrator can filter user accounts by role, cohort and other profile fields
|
||||
In order to find the user accounts I am looking for
|
||||
As an admin
|
||||
I need to filter the users account list using different filter
|
||||
|
||||
Background:
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email | auth | confirmed |
|
||||
| user1 | User | One | one@asd.com | manual | 0 |
|
||||
| user2 | User | Two | one@asd.com | ldap | 1 |
|
||||
| user3 | User | Three | one@asd.com | manual | 1 |
|
||||
| user4 | User | Four | one@asd.com | ldap | 0 |
|
||||
And the following "cohorts" exists:
|
||||
| name | idnumber |
|
||||
| Cohort 1 | CH1 |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| user1 | C1 | student |
|
||||
| user2 | C1 | student |
|
||||
| user3 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I add "user2" user to "CH1" cohort
|
||||
And I add "user3" user to "CH1" cohort
|
||||
And I follow "Browse list of users"
|
||||
|
||||
@javascript
|
||||
Scenario: Filter user accounts by role and cohort
|
||||
When I fill the moodle form with:
|
||||
| courserole_rl | Student |
|
||||
| courserole_ct | any category |
|
||||
| courserole | C1 |
|
||||
And I press "Add filter"
|
||||
Then I should see "User One"
|
||||
And I should see "User Two"
|
||||
And I should see "User Three"
|
||||
And I should not see "User Four"
|
||||
And I fill the moodle form with:
|
||||
| cohort | CH1 |
|
||||
And I press "Add filter"
|
||||
And I should not see "User One"
|
||||
And I should see "User Two"
|
||||
And I should see "User Three"
|
||||
And I should not see "User Four"
|
||||
And I press "Remove all filters"
|
||||
And I should see "User One"
|
||||
And I should see "User Two"
|
||||
And I should see "User Three"
|
||||
And I should see "User Four"
|
||||
|
||||
@javascript
|
||||
Scenario: Filter user accounts by confirm and authentication method
|
||||
When I fill the moodle form with:
|
||||
| Confirmed | No |
|
||||
And I press "Add filter"
|
||||
Then I should see "User One"
|
||||
And I should not see "User Two"
|
||||
And I should not see "User Three"
|
||||
And I should see "User Four"
|
||||
And I fill the moodle form with:
|
||||
| Authentication | manual |
|
||||
And I press "Add filter"
|
||||
And I should see "User One"
|
||||
And I should not see "User Two"
|
||||
And I should not see "User Three"
|
||||
And I should not see "User Four"
|
||||
@@ -1,46 +0,0 @@
|
||||
@core @core_admin @_only_local @_file_upload
|
||||
Feature: Upload users
|
||||
In order to add users to the system
|
||||
As an admin
|
||||
I need to upload files containing the users data
|
||||
|
||||
@javascript
|
||||
Scenario: Upload users enrolling them on courses and groups
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Maths | math102 | 0 |
|
||||
And the following "groups" exists:
|
||||
| name | course | idnumber |
|
||||
| Section 1 | math102 | S1 |
|
||||
| Section 3 | math102 | S3 |
|
||||
And I log in as "admin"
|
||||
And I collapse "Front page settings" node
|
||||
And I expand "Site administration" node
|
||||
And I expand "Users" node
|
||||
And I expand "Accounts" node
|
||||
And I follow "Upload users"
|
||||
When I upload "lib/tests/fixtures/upload_users.csv" file to "File" filepicker
|
||||
And I press "Upload users"
|
||||
Then I should see "Upload users preview"
|
||||
And I should see "Tom"
|
||||
And I should see "Jones"
|
||||
And I should see "verysecret"
|
||||
And I should see "jonest@someplace.edu"
|
||||
And I should see "Reznor"
|
||||
And I should see "course1"
|
||||
And I should see "math102"
|
||||
And I should see "group1"
|
||||
And I should see "Section 1"
|
||||
And I press "Upload users"
|
||||
And I press "Continue"
|
||||
And I follow "Browse list of users"
|
||||
And I should see "Tom Jones"
|
||||
And I should see "Trent Reznor"
|
||||
And I should see "reznor@someplace.edu"
|
||||
And I am on homepage
|
||||
And I follow "Maths"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
And I select "Section 1 (1)" from "groups"
|
||||
And I wait "4" seconds
|
||||
And the "members" select box should contain "Tom Jones"
|
||||
@@ -32,7 +32,7 @@ require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradable
|
||||
|
||||
require_sesskey();
|
||||
|
||||
// This calls require_login and checks moodle/site:config.
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('batchupgrade'));
|
||||
|
||||
$PAGE->set_pagelayout('maintenance');
|
||||
@@ -46,8 +46,7 @@ if (!$confirm) {
|
||||
die();
|
||||
}
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
// Release session.
|
||||
session_get_instance()->write_close();
|
||||
session_get_instance()->write_close(); // release session
|
||||
|
||||
echo $renderer->header();
|
||||
echo $renderer->heading(get_string('batchupgrade', 'tool_assignmentupgrade'));
|
||||
@@ -63,8 +62,7 @@ $total = count($assignmentids);
|
||||
foreach ($assignmentids as $assignmentid) {
|
||||
list($summary, $success, $log) = tool_assignmentupgrade_upgrade_assignment($assignmentid);
|
||||
$current += 1;
|
||||
$params = array('current'=>$current, 'total'=>$total);
|
||||
echo $renderer->heading(get_string('upgradeprogress', 'tool_assignmentupgrade', $params), 3);
|
||||
echo $renderer->heading(get_string('upgradeprogress', 'tool_assignmentupgrade', array('current'=>$current, 'total'=>$total)), 3);
|
||||
echo $renderer->convert_assignment_result($summary, $success, $log);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ require_once(dirname(__FILE__) . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/locallib.php');
|
||||
|
||||
// This calls require_login and checks moodle/site:config.
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade');
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
|
||||
|
||||
@@ -29,7 +29,7 @@ require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradable
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/upgradableassignmentsbatchform.php');
|
||||
require_once($CFG->dirroot . '/'.$CFG->admin.'/tool/assignmentupgrade/paginationform.php');
|
||||
|
||||
// This calls require_login and checks moodle/site:config.
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('listnotupgraded'));
|
||||
$PAGE->navbar->add(get_string('listnotupgraded', 'tool_assignmentupgrade'));
|
||||
|
||||
@@ -57,3 +57,4 @@ if ($data && $data->selectedassignments != '' || $data && isset($data->upgradeal
|
||||
echo $renderer->assignment_list_page($assignments, $batchform, $paginationform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,24 +51,17 @@ class tool_assignmentupgrade_batchoperationconfirm implements renderable {
|
||||
* Constructor for this class
|
||||
* @param stdClass $data - The data from the previous batch form
|
||||
*/
|
||||
public function __construct($data) {
|
||||
function __construct($data) {
|
||||
if (isset($data->upgradeselected)) {
|
||||
$this->continuemessage = get_string('upgradeselectedcount',
|
||||
'tool_assignmentupgrade',
|
||||
count(explode(',', $data->selectedassignments)));
|
||||
$urlparams = array('upgradeselected'=>'1',
|
||||
'confirm'=>'1',
|
||||
'sesskey'=>sesskey(),
|
||||
'selected'=>$data->selectedassignments);
|
||||
$this->continueurl = new moodle_url('/admin/tool/assignmentupgrade/batchupgrade.php', $urlparams);
|
||||
$this->continuemessage = get_string('upgradeselectedcount', 'tool_assignmentupgrade', count(explode(',', $data->selectedassignments)));
|
||||
$this->continueurl = new moodle_url('/admin/tool/assignmentupgrade/batchupgrade.php', array('upgradeselected'=>'1', 'confirm'=>'1', 'sesskey'=>sesskey(), 'selected'=>$data->selectedassignments));
|
||||
} else if (isset($data->upgradeall)) {
|
||||
if (!tool_assignmentupgrade_any_upgradable_assignments()) {
|
||||
$this->continuemessage = get_string('noassignmentstoupgrade', 'tool_assignmentupgrade');
|
||||
$this->continueurl = '';
|
||||
} else {
|
||||
$this->continuemessage = get_string('upgradeallconfirm', 'tool_assignmentupgrade');
|
||||
$urlparams = array('upgradeall'=>'1', 'confirm'=>'1', 'sesskey'=>sesskey());
|
||||
$this->continueurl = new moodle_url('/admin/tool/assignmentupgrade/batchupgrade.php', $urlparams);
|
||||
$this->continueurl = new moodle_url('/admin/tool/assignmentupgrade/batchupgrade.php', array('upgradeall'=>'1', 'confirm'=>'1', 'sesskey'=>sesskey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,8 +86,7 @@ class tool_assignmentupgrade_action {
|
||||
/**
|
||||
* Constructor to set the fields.
|
||||
*
|
||||
* In order to create a new tool_assignmentupgrade_action instance you must use
|
||||
* the tool_assignmentupgrade_action::make
|
||||
* In order to create a new tool_assignmentupgrade_action instance you must use the tool_assignmentupgrade_action::make
|
||||
* method.
|
||||
*
|
||||
* @param string $name the name of this action.
|
||||
@@ -128,13 +120,8 @@ class tool_assignmentupgrade_action {
|
||||
function tool_assignmentupgrade_any_upgradable_assignments() {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
// First find all the unique assignment types.
|
||||
$types = $DB->get_records_sql('SELECT plugin AS assignmenttype,
|
||||
value AS version
|
||||
FROM {config_plugins}
|
||||
WHERE
|
||||
name = ? AND
|
||||
plugin LIKE ?', array('version', 'assignment_%'));
|
||||
// first find all the unique assignment types
|
||||
$types = $DB->get_records_sql('SELECT plugin AS assignmenttype, value AS version FROM {config_plugins} WHERE name = ? AND plugin LIKE ?', array('version', 'assignment_%'));
|
||||
|
||||
$upgradabletypes = array();
|
||||
|
||||
@@ -146,7 +133,7 @@ function tool_assignmentupgrade_any_upgradable_assignments() {
|
||||
}
|
||||
list($sql, $params) = $DB->get_in_or_equal($upgradabletypes);
|
||||
|
||||
$count = $DB->count_records_sql('SELECT COUNT(id) FROM {assignment} WHERE assignmenttype ' . $sql, $params);
|
||||
$count = $DB->count_records_sql('SELECT COUNT(id) from {assignment} where assignmenttype ' . $sql, $params);
|
||||
|
||||
return $count > 0;
|
||||
}
|
||||
@@ -158,14 +145,8 @@ function tool_assignmentupgrade_any_upgradable_assignments() {
|
||||
function tool_assignmentupgrade_load_all_upgradable_assignmentids() {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
// First find all the unique assignment types.
|
||||
$types = $DB->get_records_sql('SELECT
|
||||
plugin AS assignmenttype,
|
||||
value AS version
|
||||
FROM {config_plugins}
|
||||
WHERE
|
||||
name = ? AND
|
||||
plugin LIKE ?', array('version', 'assignment_%'));
|
||||
// first find all the unique assignment types
|
||||
$types = $DB->get_records_sql('SELECT plugin AS assignmenttype, value AS version FROM {config_plugins} WHERE name = ? AND plugin LIKE ?', array('version', 'assignment_%'));
|
||||
|
||||
$upgradabletypes = array();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
M.tool_assignmentupgrade = {
|
||||
init_upgrade_table: function(Y) {
|
||||
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/** Include formslib.php */
|
||||
require_once ($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Assignment upgrade table display options
|
||||
@@ -37,20 +39,20 @@ class tool_assignmentupgrade_pagination_form extends moodleform {
|
||||
/**
|
||||
* Define this form - called from the parent constructor
|
||||
*/
|
||||
public function definition() {
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
$instance = $this->_customdata;
|
||||
|
||||
$mform->addElement('header', 'general', get_string('assignmentsperpage', 'tool_assignmentupgrade'));
|
||||
// Visible elements.
|
||||
// visible elements
|
||||
$options = array(10=>'10', 20=>'20', 50=>'50', 100=>'100');
|
||||
$mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options);
|
||||
|
||||
// Hidden params.
|
||||
// hidden params
|
||||
$mform->addElement('hidden', 'action', 'saveoptions');
|
||||
$mform->setType('action', PARAM_ALPHA);
|
||||
|
||||
// Buttons.
|
||||
// buttons
|
||||
$this->add_action_buttons(false, get_string('updatetable', 'tool_assignmentupgrade'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +100,7 @@ class tool_assignmentupgrade_renderer extends plugin_renderer_base {
|
||||
$output = '';
|
||||
|
||||
if ($confirm->continueurl) {
|
||||
$output .= $this->output->confirm($confirm->continuemessage,
|
||||
$confirm->continueurl,
|
||||
tool_assignmentupgrade_url('listnotupgraded'));
|
||||
$output .= $this->output->confirm($confirm->continuemessage, $confirm->continueurl, tool_assignmentupgrade_url('listnotupgraded'));
|
||||
} else {
|
||||
$output .= $this->output->box($confirm->continuemessage);
|
||||
$output .= $this->output->continue_button(tool_assignmentupgrade_url('listnotupgraded'));
|
||||
@@ -117,9 +115,7 @@ class tool_assignmentupgrade_renderer extends plugin_renderer_base {
|
||||
* @param tool_assignmentupgrade_pagination_form $paginationform Form which contains the preferences for paginating the table
|
||||
* @return string html to output.
|
||||
*/
|
||||
public function assignment_list_page(tool_assignmentupgrade_assignments_table $assignments,
|
||||
tool_assignmentupgrade_batchoperations_form $batchform,
|
||||
tool_assignmentupgrade_pagination_form $paginationform) {
|
||||
public function assignment_list_page(tool_assignmentupgrade_assignments_table $assignments, tool_assignmentupgrade_batchoperations_form $batchform, tool_assignmentupgrade_pagination_form $paginationform) {
|
||||
$output = '';
|
||||
$output .= $this->header();
|
||||
$this->page->requires->js_init_call('M.tool_assignmentupgrade.init_upgrade_table', array());
|
||||
@@ -165,8 +161,7 @@ class tool_assignmentupgrade_renderer extends plugin_renderer_base {
|
||||
$output .= $this->container(get_string('conversionfailed', 'tool_assignmentupgrade', $log));
|
||||
} else {
|
||||
$output .= $this->container(get_string('upgradeassignmentsuccess', 'tool_assignmentupgrade'));
|
||||
$url = new moodle_url('/course/view.php', array('id'=>$assignmentsummary->courseid));
|
||||
$output .= $this->container(html_writer::link($url, get_string('viewcourse', 'tool_assignmentupgrade')));
|
||||
$output .= $this->container(html_writer::link(new moodle_url('/course/view.php', array('id'=>$assignmentsummary->courseid)) ,get_string('viewcourse', 'tool_assignmentupgrade')));
|
||||
}
|
||||
$output .= $this->container_end();
|
||||
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($hassiteconfig) {
|
||||
// Needs this condition or there is error on login page.
|
||||
if ($hassiteconfig) { // needs this condition or there is error on login page
|
||||
$ADMIN->add('root', new admin_externalpage('assignmentupgrade',
|
||||
get_string('pluginname', 'tool_assignmentupgrade'),
|
||||
new moodle_url('/admin/tool/assignmentupgrade/index.php')));
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,12 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/** Include formslib.php */
|
||||
require_once ($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Assignment upgrade batch operations form.
|
||||
* Assignment upgrade batch operations form
|
||||
*
|
||||
* @package tool_assignmentupgrade
|
||||
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
|
||||
@@ -35,16 +37,15 @@ require_once($CFG->libdir.'/formslib.php');
|
||||
*/
|
||||
class tool_assignmentupgrade_batchoperations_form extends moodleform {
|
||||
/**
|
||||
* Define this form - is called from parent constructor.
|
||||
* Define this form - is called from parent constructor
|
||||
*/
|
||||
public function definition() {
|
||||
function definition() {
|
||||
$mform = $this->_form;
|
||||
$instance = $this->_customdata;
|
||||
|
||||
$mform->addElement('header', 'general', get_string('batchoperations', 'tool_assignmentupgrade'));
|
||||
// Visible elements.
|
||||
// visible elements
|
||||
$mform->addElement('hidden', 'selectedassignments', '', array('class'=>'selectedassignments'));
|
||||
$mform->setType('selectedassignments', PARAM_SEQUENCE);
|
||||
|
||||
$mform->addElement('submit', 'upgradeselected', get_string('upgradeselected', 'tool_assignmentupgrade'));
|
||||
$mform->addElement('submit', 'upgradeall', get_string('upgradeall', 'tool_assignmentupgrade'));
|
||||
|
||||
@@ -36,7 +36,6 @@ require_once($CFG->dirroot.'/mod/assign/locallib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_assignmentupgrade_assignments_table extends table_sql implements renderable {
|
||||
|
||||
/** @var int $perpage */
|
||||
private $perpage = 10;
|
||||
/** @var int $rownum (global index of current row in table) */
|
||||
@@ -47,13 +46,12 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
public $anyupgradableassignments = false;
|
||||
|
||||
/**
|
||||
* This table loads a list of the old assignment instances and tests them to see
|
||||
* if they can be upgraded
|
||||
* This table loads a list of the old assignment instances and tests them to see if they can be upgraded
|
||||
*
|
||||
* @param int $perpage How many per page
|
||||
* @param int $rowoffset The starting row for pagination
|
||||
*/
|
||||
public function __construct($perpage, $rowoffset=0) {
|
||||
function __construct($perpage, $rowoffset=0) {
|
||||
global $PAGE;
|
||||
parent::__construct('tool_assignmentupgrade_assignments');
|
||||
$this->perpage = $perpage;
|
||||
@@ -63,17 +61,12 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
|
||||
$this->anyupgradableassignments = tool_assignmentupgrade_any_upgradable_assignments();
|
||||
|
||||
// Do some business - then set the sql.
|
||||
// do some business - then set the sql
|
||||
if ($rowoffset) {
|
||||
$this->rownum = $rowoffset - 1;
|
||||
}
|
||||
|
||||
$fields = 'a.id as id,
|
||||
a.name as name,
|
||||
a.assignmenttype as type,
|
||||
c.shortname as courseshortname,
|
||||
c.id as courseid,
|
||||
COUNT(s.id) as submissioncount';
|
||||
$fields = 'a.id as id, a.name as name, a.assignmenttype as type, c.shortname as courseshortname, c.id as courseid, COUNT(s.id) as submissioncount';
|
||||
$from = '{assignment} a JOIN {course} c ON a.course = c.id ' .
|
||||
' LEFT JOIN {assignment_submissions} s ON a.id = s.assignment';
|
||||
|
||||
@@ -87,10 +80,7 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
$headers = array();
|
||||
|
||||
$columns[] = 'select';
|
||||
$headers[] = get_string('select', 'tool_assignmentupgrade') .
|
||||
'<div class="selectall">' .
|
||||
'<input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/>' .
|
||||
'</div>';
|
||||
$headers[] = get_string('select', 'tool_assignmentupgrade') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
|
||||
$columns[] = 'upgradable';
|
||||
$headers[] = get_string('upgradable', 'tool_assignmentupgrade');
|
||||
$columns[] = 'id';
|
||||
@@ -104,7 +94,7 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
$columns[] = 'submissioncount';
|
||||
$headers[] = get_string('submissions', 'tool_assignmentupgrade');
|
||||
|
||||
// Set the columns.
|
||||
// set the columns
|
||||
$this->define_columns($columns);
|
||||
$this->define_headers($headers);
|
||||
$this->no_sorting('upgradable');
|
||||
@@ -116,7 +106,7 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
*
|
||||
* @return int The number of rows per page
|
||||
*/
|
||||
public function get_rows_per_page() {
|
||||
function get_rows_per_page() {
|
||||
return $this->perpage;
|
||||
}
|
||||
|
||||
@@ -126,9 +116,9 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
* @param stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_name(stdClass $row) {
|
||||
$url = new moodle_url('/mod/assignment/view.php', array('a' => $row->id));
|
||||
return html_writer::link($url, $row->name);
|
||||
function col_name(stdClass $row) {
|
||||
return html_writer::link(new moodle_url('/mod/assignment/view.php',
|
||||
array('a' => $row->id)), $row->name);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,11 +128,10 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
* @param stdClass $row (contains cached result from previous upgradable check)
|
||||
* @return string
|
||||
*/
|
||||
public function col_upgradable(stdClass $row) {
|
||||
function col_upgradable(stdClass $row) {
|
||||
if ($row->upgradable) {
|
||||
$urlparams = array('id' => $row->id, 'sesskey' => sesskey());
|
||||
$url = new moodle_url('/admin/tool/assignmentupgrade/upgradesingleconfirm.php', $urlparams);
|
||||
return html_writer::link($url, get_string('supported', 'tool_assignmentupgrade'));
|
||||
return html_writer::link(new moodle_url('/admin/tool/assignmentupgrade/upgradesingleconfirm.php',
|
||||
array('id' => $row->id, 'sesskey' => sesskey())), get_string('supported', 'tool_assignmentupgrade'));
|
||||
} else {
|
||||
return get_string('notsupported', 'tool_assignmentupgrade');
|
||||
}
|
||||
@@ -154,7 +143,7 @@ class tool_assignmentupgrade_assignments_table extends table_sql implements rend
|
||||
* @param stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_select(stdClass $row) {
|
||||
function col_select(stdClass $row) {
|
||||
global $CFG;
|
||||
$version = get_config('assignment_' . $row->type, 'version');
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
|
||||
@@ -30,11 +30,8 @@ require_sesskey();
|
||||
|
||||
$assignmentid = required_param('id', PARAM_INT);
|
||||
|
||||
// This calls require_login and checks moodle/site:config.
|
||||
admin_externalpage_setup('assignmentupgrade',
|
||||
'',
|
||||
array(),
|
||||
tool_assignmentupgrade_url('upgradesingle', array('id' => $assignmentid)));
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('upgradesingle', array('id' => $assignmentid)));
|
||||
|
||||
$PAGE->navbar->add(get_string('upgradesingle', 'tool_assignmentupgrade'));
|
||||
$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
|
||||
|
||||
@@ -30,11 +30,8 @@ require_sesskey();
|
||||
|
||||
$assignmentid = required_param('id', PARAM_INT);
|
||||
|
||||
// This calls require_login and checks moodle/site:config.
|
||||
admin_externalpage_setup('assignmentupgrade',
|
||||
'',
|
||||
array(),
|
||||
tool_assignmentupgrade_url('upgradesingle', array('id' => $assignmentid)));
|
||||
// admin_externalpage_setup calls require_login and checks moodle/site:config
|
||||
admin_externalpage_setup('assignmentupgrade', '', array(), tool_assignmentupgrade_url('upgradesingle', array('id' => $assignmentid)));
|
||||
|
||||
$PAGE->navbar->add(get_string('upgradesingle', 'tool_assignmentupgrade'));
|
||||
$renderer = $PAGE->get_renderer('tool_assignmentupgrade');
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050100;
|
||||
$plugin->requires = 2013050100;
|
||||
$plugin->version = 2012112900;
|
||||
$plugin->requires = 2012112900;
|
||||
$plugin->component = 'tool_assignmentupgrade';
|
||||
$plugin->dependencies = array('mod_assign' => 2013050100);
|
||||
$plugin->dependencies = array('mod_assign' => 2012112900);
|
||||
|
||||
@@ -1,94 +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 script to set up all the behat test environment.
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
die(); // No access from web!
|
||||
}
|
||||
|
||||
// Is not really necessary but adding it as is a CLI_SCRIPT.
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
// Basic functions.
|
||||
require_once(__DIR__ . '/../../../../lib/clilib.php');
|
||||
require_once(__DIR__ . '/../../../../lib/behat/lib.php');
|
||||
|
||||
// Changing the cwd to admin/tool/behat/cli.
|
||||
chdir(__DIR__);
|
||||
$output = null;
|
||||
exec("php util.php --diag", $output, $code);
|
||||
if ($code == 0) {
|
||||
echo "Behat test environment already installed\n";
|
||||
|
||||
} else if ($code == BEHAT_EXITCODE_INSTALL) {
|
||||
|
||||
testing_update_composer_dependencies();
|
||||
|
||||
// Behat and dependencies are installed and we need to install the test site.
|
||||
chdir(__DIR__);
|
||||
passthru("php util.php --install", $code);
|
||||
if ($code != 0) {
|
||||
exit($code);
|
||||
}
|
||||
|
||||
} else if ($code == BEHAT_EXITCODE_REINSTALL) {
|
||||
|
||||
testing_update_composer_dependencies();
|
||||
|
||||
// Test site data is outdated.
|
||||
chdir(__DIR__);
|
||||
passthru("php util.php --drop", $code);
|
||||
if ($code != 0) {
|
||||
exit($code);
|
||||
}
|
||||
|
||||
passthru("php util.php --install", $code);
|
||||
if ($code != 0) {
|
||||
exit($code);
|
||||
}
|
||||
|
||||
} else if ($code == BEHAT_EXITCODE_COMPOSER) {
|
||||
// Missing Behat dependencies.
|
||||
|
||||
testing_update_composer_dependencies();
|
||||
|
||||
// Returning to admin/tool/behat/cli.
|
||||
chdir(__DIR__);
|
||||
passthru("php util.php --install", $code);
|
||||
if ($code != 0) {
|
||||
exit($code);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Generic error, we just output it.
|
||||
echo implode("\n", $output)."\n";
|
||||
exit($code);
|
||||
}
|
||||
|
||||
// Enable editing mode according to config.php vars.
|
||||
passthru("php util.php --enable", $code);
|
||||
if ($code != 0) {
|
||||
exit($code);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
@@ -1,198 +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 with utilities to manage Behat integration in Moodle
|
||||
*
|
||||
* All CLI utilities uses $CFG->behat_dataroot and $CFG->prefix_dataroot as
|
||||
* $CFG->dataroot and $CFG->prefix
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
die(); // No access from web!.
|
||||
}
|
||||
|
||||
// Basic functions.
|
||||
require_once(__DIR__ . '/../../../../lib/clilib.php');
|
||||
require_once(__DIR__ . '/../../../../lib/behat/lib.php');
|
||||
|
||||
|
||||
// CLI options.
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'help' => false,
|
||||
'install' => false,
|
||||
'drop' => false,
|
||||
'enable' => false,
|
||||
'disable' => false,
|
||||
'diag' => false
|
||||
),
|
||||
array(
|
||||
'h' => 'help'
|
||||
)
|
||||
);
|
||||
|
||||
if ($options['install'] or $options['drop']) {
|
||||
define('CACHE_DISABLE_ALL', true);
|
||||
}
|
||||
|
||||
// Checking util.php CLI script usage.
|
||||
$help = "
|
||||
Behat utilities to manage the test environment
|
||||
|
||||
Options:
|
||||
--install Installs the test environment for acceptance tests
|
||||
--drop Drops the database tables and the dataroot contents
|
||||
--enable Enables test environment and updates tests list
|
||||
--disable Disables test environment
|
||||
--diag Get behat test environment status code
|
||||
|
||||
-h, --help Print out this help
|
||||
|
||||
Example from Moodle root directory:
|
||||
\$ php admin/tool/behat/cli/util.php --enable
|
||||
|
||||
More info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests
|
||||
";
|
||||
|
||||
if (!empty($options['help'])) {
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
// Checking $CFG->behat_* vars and values.
|
||||
define('BEHAT_UTIL', true);
|
||||
define('CLI_SCRIPT', true);
|
||||
define('ABORT_AFTER_CONFIG', true);
|
||||
define('NO_OUTPUT_BUFFERING', true);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('log_errors', '1');
|
||||
|
||||
// Getting $CFG data.
|
||||
require_once(__DIR__ . '/../../../../config.php');
|
||||
|
||||
// When we use the utilities we don't know how the site
|
||||
// will be accessed, so if neither $CFG->behat_switchcompletely or
|
||||
// $CFG->behat_wwwroot are set we must think that the site will
|
||||
// be accessed using the built-in server which is set by default
|
||||
// to localhost:8000. We need to do this to prevent uses of the production
|
||||
// wwwroot when the site is being installed / dropped...
|
||||
$CFG->behat_wwwroot = behat_get_wwwroot();
|
||||
|
||||
// Checking the integrity of the provided $CFG->behat_* vars
|
||||
// to prevent conflicts with production and phpunit environments.
|
||||
behat_check_config_vars();
|
||||
|
||||
// Create behat_dataroot if it doesn't exists.
|
||||
if (!file_exists($CFG->behat_dataroot)) {
|
||||
if (!mkdir($CFG->behat_dataroot, $CFG->directorypermissions)) {
|
||||
behat_error(BEHAT_EXITCODE_PERMISSIONS, '$CFG->behat_dataroot directory can not be created');
|
||||
}
|
||||
}
|
||||
if (!is_dir($CFG->behat_dataroot) || !is_writable($CFG->behat_dataroot)) {
|
||||
behat_error(BEHAT_EXITCODE_PERMISSIONS, '$CFG->behat_dataroot directory has no permissions or is not a directory');
|
||||
}
|
||||
|
||||
// Check that the directory does not contains other things.
|
||||
if (!file_exists("$CFG->behat_dataroot/behattestdir.txt")) {
|
||||
if ($dh = opendir($CFG->behat_dataroot)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file === 'behat' or $file === '.' or $file === '..' or $file === '.DS_Store') {
|
||||
continue;
|
||||
}
|
||||
behat_error(BEHAT_EXITCODE_CONFIG, '$CFG->behat_dataroot directory is not empty, ensure this is the directory where you want to install behat test dataroot');
|
||||
}
|
||||
closedir($dh);
|
||||
unset($dh);
|
||||
unset($file);
|
||||
}
|
||||
|
||||
// Now we create dataroot directory structure for behat tests.
|
||||
testing_initdataroot($CFG->behat_dataroot, 'behat');
|
||||
}
|
||||
|
||||
// Overrides vars with behat-test ones.
|
||||
$vars = array('wwwroot', 'prefix', 'dataroot');
|
||||
foreach ($vars as $var) {
|
||||
$CFG->{$var} = $CFG->{'behat_' . $var};
|
||||
}
|
||||
|
||||
// Clean $CFG extra values before performing any action.
|
||||
behat_clean_init_config();
|
||||
|
||||
$CFG->noemailever = true;
|
||||
$CFG->passwordsaltmain = 'moodle';
|
||||
|
||||
$CFG->themerev = 1;
|
||||
$CFG->jsrev = 1;
|
||||
|
||||
// Unset cache and temp directories to reset them again with the new $CFG->dataroot.
|
||||
unset($CFG->cachedir);
|
||||
unset($CFG->tempdir);
|
||||
|
||||
// Continues setup.
|
||||
define('ABORT_AFTER_CONFIG_CANCEL', true);
|
||||
require("$CFG->dirroot/lib/setup.php");
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/upgradelib.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
require_once($CFG->libdir.'/pluginlib.php');
|
||||
require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/testing/classes/test_lock.php');
|
||||
|
||||
if ($unrecognized) {
|
||||
$unrecognized = implode("\n ", $unrecognized);
|
||||
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
|
||||
}
|
||||
|
||||
// Behat utilities.
|
||||
require_once($CFG->libdir . '/behat/classes/util.php');
|
||||
require_once($CFG->libdir . '/behat/classes/behat_command.php');
|
||||
|
||||
// Run command (only one per time).
|
||||
if ($options['install']) {
|
||||
behat_util::install_site();
|
||||
mtrace("Acceptance tests site installed");
|
||||
} else if ($options['drop']) {
|
||||
// Ensure no tests are running.
|
||||
test_lock::acquire('behat');
|
||||
behat_util::drop_site();
|
||||
mtrace("Acceptance tests site dropped");
|
||||
} else if ($options['enable']) {
|
||||
behat_util::start_test_mode();
|
||||
$runtestscommand = behat_command::get_behat_command(true) .
|
||||
' --config ' . behat_config_manager::get_behat_cli_config_filepath();
|
||||
mtrace("Acceptance tests environment enabled, to run the tests use:\n " . $runtestscommand);
|
||||
} else if ($options['disable']) {
|
||||
behat_util::stop_test_mode();
|
||||
mtrace("Acceptance tests environment disabled");
|
||||
} else if ($options['diag']) {
|
||||
$code = behat_util::get_behat_status();
|
||||
exit($code);
|
||||
} else {
|
||||
echo $help;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
@@ -1,60 +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/>.
|
||||
|
||||
/**
|
||||
* Web interface to list and filter steps
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/behat/locallib.php');
|
||||
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
|
||||
|
||||
// This page usually takes an exceedingly long time to load, so we need to
|
||||
// increase the time limit. At present it takes about a minute on some
|
||||
// systems, but let's allow room for expansion.
|
||||
set_time_limit(300);
|
||||
|
||||
$filter = optional_param('filter', '', PARAM_ALPHANUMEXT);
|
||||
$type = optional_param('type', false, PARAM_ALPHAEXT);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
admin_externalpage_setup('toolbehat');
|
||||
|
||||
// Getting available steps definitions from behat.
|
||||
$steps = tool_behat::stepsdefinitions($type, $component, $filter);
|
||||
|
||||
// Form.
|
||||
$componentswithsteps = array('' => get_string('allavailablesteps', 'tool_behat'));
|
||||
|
||||
// Complete the components list with the moodle steps definitions.
|
||||
$components = behat_config_manager::get_components_steps_definitions();
|
||||
if ($components) {
|
||||
foreach ($components as $component => $filepath) {
|
||||
// TODO Use a class static attribute instead of the class name.
|
||||
$componentswithsteps[$component] = 'Moodle ' . substr($component, 6);
|
||||
}
|
||||
}
|
||||
$form = new steps_definitions_form(null, array('components' => $componentswithsteps));
|
||||
|
||||
// Output contents.
|
||||
$renderer = $PAGE->get_renderer('tool_behat');
|
||||
echo $renderer->render_stepsdefinitions($steps, $form);
|
||||
|
||||
@@ -1,46 +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/>.
|
||||
|
||||
/**
|
||||
* Strings for tool_behat
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['aim'] = 'This administration tool helps developers and test writers to create .feature files describing Moodle\'s functionalities and run them automatically.';
|
||||
$string['allavailablesteps'] = 'All the available steps definitions';
|
||||
$string['giveninfo'] = 'Given. Processes to set up the environment';
|
||||
$string['infoheading'] = 'Info';
|
||||
$string['installinfo'] = 'Read {$a} for installation and tests execution info';
|
||||
$string['moreinfoin'] = 'More info in {$a}';
|
||||
$string['newstepsinfo'] = 'Read {$a} for info about how to add new steps definitions';
|
||||
$string['newtestsinfo'] = 'Read {$a} for info about how to write new tests';
|
||||
$string['nostepsdefinitions'] = 'There aren\'t steps definitions matching this filters';
|
||||
$string['pluginname'] = 'Acceptance testing';
|
||||
$string['runclitool'] = 'To list the steps definitions you need to run the Behat CLI tool to create the $CFG->behat_dataroot directory. Go to your moodle dirroot and run "{$a}"';
|
||||
$string['stepsdefinitionscomponent'] = 'Area';
|
||||
$string['stepsdefinitionscontains'] = 'Contains';
|
||||
$string['stepsdefinitionsfilters'] = 'Steps definitions';
|
||||
$string['stepsdefinitionstype'] = 'Type';
|
||||
$string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones';
|
||||
$string['unknownexceptioninfo'] = 'There was a problem with Selenium or your browser. Please ensure you are using the latest version of Selenium. Error:';
|
||||
$string['viewsteps'] = 'Filter';
|
||||
$string['wheninfo'] = 'When. Actions that provokes an event';
|
||||
$string['wrongbehatsetup'] = 'Something is wrong with behat setup, ensure:<ul>
|
||||
<li>You ran "php admin/tool/behat/cli/init.php" from your moodle root directory</li>
|
||||
<li>vendor/bin/behat file has execution permissions</li></ul>';
|
||||
@@ -1,76 +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/>.
|
||||
|
||||
/**
|
||||
* Behat commands
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/behat/classes/behat_command.php');
|
||||
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/behat/steps_definitions_form.php');
|
||||
|
||||
/**
|
||||
* Behat commands manager
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_behat {
|
||||
|
||||
/**
|
||||
* Lists the available steps definitions
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $component
|
||||
* @param string $filter
|
||||
* @return array System steps or empty array if case there are no steps
|
||||
*/
|
||||
public static function stepsdefinitions($type, $component, $filter) {
|
||||
|
||||
// We don't require the test environment to be enabled to list the steps definitions
|
||||
// so test writers can more easily set up the environment.
|
||||
behat_command::behat_setup_problem();
|
||||
|
||||
// The loaded steps depends on the component specified.
|
||||
behat_config_manager::update_config_file($component, false);
|
||||
|
||||
// The Moodle\BehatExtension\HelpPrinter\MoodleDefinitionsPrinter will parse this search format.
|
||||
if ($type) {
|
||||
$filter .= '&&' . $type;
|
||||
}
|
||||
|
||||
if ($filter) {
|
||||
$filteroption = ' -d "' . $filter . '"';
|
||||
} else {
|
||||
$filteroption = ' -di';
|
||||
}
|
||||
|
||||
// Get steps definitions from Behat.
|
||||
$options = ' --config="'.behat_config_manager::get_steps_list_config_filepath(). '" '.$filteroption;
|
||||
list($steps, $code) = behat_command::run($options);
|
||||
|
||||
return $steps;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,117 +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/>.
|
||||
|
||||
/**
|
||||
* Behat tool renderer
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/behat/classes/behat_selectors.php');
|
||||
|
||||
/**
|
||||
* Renderer for behat tool web features
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_behat_renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Renders the list of available steps according to the submitted filters.
|
||||
*
|
||||
* @param mixed $stepsdefinitions Available steps array.
|
||||
* @param moodleform $form
|
||||
* @return string HTML code
|
||||
*/
|
||||
public function render_stepsdefinitions($stepsdefinitions, $form) {
|
||||
|
||||
$title = get_string('pluginname', 'tool_behat');
|
||||
|
||||
// Header.
|
||||
$html = $this->output->header();
|
||||
$html .= $this->output->heading($title);
|
||||
|
||||
// Info.
|
||||
$installurl = behat_command::DOCS_URL . '#Installation';
|
||||
$installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank'));
|
||||
$writetestsurl = behat_command::DOCS_URL . '#Writting_features';
|
||||
$writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank'));
|
||||
$writestepsurl = behat_command::DOCS_URL . '#Adding_steps_definitions';
|
||||
$writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank'));
|
||||
$infos = array(
|
||||
get_string('installinfo', 'tool_behat', $installlink),
|
||||
get_string('newtestsinfo', 'tool_behat', $writetestslink),
|
||||
get_string('newstepsinfo', 'tool_behat', $writestepslink)
|
||||
);
|
||||
|
||||
// List of steps.
|
||||
$html .= $this->output->box_start();
|
||||
$html .= html_writer::tag('h1', 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');
|
||||
$html .= html_writer::start_tag('li');
|
||||
$html .= implode(html_writer::end_tag('li') . html_writer::start_tag('li'), $infos);
|
||||
$html .= html_writer::end_tag('li');
|
||||
$html .= html_writer::end_tag('ul');
|
||||
$html .= html_writer::end_tag('div');
|
||||
$html .= $this->output->box_end();
|
||||
|
||||
// Form.
|
||||
ob_start();
|
||||
$form->display();
|
||||
$html .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if (empty($stepsdefinitions)) {
|
||||
$stepsdefinitions = get_string('nostepsdefinitions', 'tool_behat');
|
||||
} else {
|
||||
|
||||
$stepsdefinitions = implode('', $stepsdefinitions);
|
||||
|
||||
// Replace text selector type arguments with a user-friendly select.
|
||||
$stepsdefinitions = preg_replace_callback('/(TEXT_SELECTOR\d?_STRING)/',
|
||||
function ($matches) {
|
||||
return html_writer::select(behat_selectors::get_allowed_text_selectors(), uniqid());
|
||||
},
|
||||
$stepsdefinitions
|
||||
);
|
||||
|
||||
// Replace selector type arguments with a user-friendly select.
|
||||
$stepsdefinitions = preg_replace_callback('/(SELECTOR\d?_STRING)/',
|
||||
function ($matches) {
|
||||
return html_writer::select(behat_selectors::get_allowed_selectors(), uniqid());
|
||||
},
|
||||
$stepsdefinitions
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Steps definitions.
|
||||
$html .= html_writer::tag('div', $stepsdefinitions, array('class' => 'steps-definitions'));
|
||||
|
||||
$html .= $this->output->footer();
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +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/>.
|
||||
|
||||
/**
|
||||
* Adds behat tests link in admin tree
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($hassiteconfig) {
|
||||
$url = $CFG->wwwroot . '/' . $CFG->admin . '/tool/behat/index.php';
|
||||
$ADMIN->add('development', new admin_externalpage('toolbehat', get_string('pluginname', 'tool_behat'), $url));
|
||||
}
|
||||
@@ -1,68 +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/>.
|
||||
|
||||
/**
|
||||
* Steps definitions form
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Form to display the available steps definitions
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class steps_definitions_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Form definition
|
||||
* @return void
|
||||
*/
|
||||
public function definition() {
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'filters', get_string('stepsdefinitionsfilters', 'tool_behat'));
|
||||
|
||||
$types = array(
|
||||
'' => get_string('allavailablesteps', 'tool_behat'),
|
||||
'given' => get_string('giveninfo', 'tool_behat'),
|
||||
'when' => get_string('wheninfo', 'tool_behat'),
|
||||
'then' => get_string('theninfo', 'tool_behat')
|
||||
);
|
||||
$mform->addElement('select', 'type', get_string('stepsdefinitionstype', 'tool_behat'), $types);
|
||||
|
||||
$mform->addElement(
|
||||
'select',
|
||||
'component',
|
||||
get_string('stepsdefinitionscomponent', 'tool_behat'),
|
||||
$this->_customdata['components']
|
||||
);
|
||||
|
||||
$mform->addElement('text', 'filter', get_string('stepsdefinitionscontains', 'tool_behat'));
|
||||
$mform->setType('filter', PARAM_NOTAGS);
|
||||
|
||||
$mform->addElement('submit', 'submit', get_string('viewsteps', 'tool_behat'));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
.steps-definitions{border-style:solid;border-width:1px;border-color:#BBB;padding:5px;margin:auto;width:50%;}
|
||||
.steps-definitions .step{margin: 10px 0px 10px 0px;}
|
||||
.steps-definitions .stepdescription{color:#bf8c12;}
|
||||
.steps-definitions .steptype{color:#1467a6;margin-right: 5px;}
|
||||
.steps-definitions .stepregex{color:#060;}
|
||||
@@ -1,49 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: Page contents assertions
|
||||
In order to write good tests
|
||||
As a tests writer
|
||||
I need to check the page contents
|
||||
|
||||
@javascript
|
||||
Scenario: Basic contents assertions
|
||||
Given I log in as "admin"
|
||||
And I am on homepage
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
And I press "Create group"
|
||||
And I fill the moodle form with:
|
||||
| Group name | I'm the name |
|
||||
| Group description | I'm the description |
|
||||
And I press "Save changes"
|
||||
When I follow "Overview"
|
||||
And I wait until the page is ready
|
||||
And I wait "2" seconds
|
||||
And I hover "#region-main .generaltable td span" "css_element"
|
||||
Then I should see "I'm the description"
|
||||
And I should see "Filter groups by"
|
||||
And I should not see "Filter groupssss by"
|
||||
And I should see "Group members" in the "#region-main table th.c1" "css_element"
|
||||
And I should not see "Group membersssss" in the "#region-main table th.c1" "css_element"
|
||||
And I follow "Groups"
|
||||
And the "#groupeditform #showcreateorphangroupform" "css_element" should be enabled
|
||||
And the "#groupeditform #showeditgroupsettingsform" "css_element" should be disabled
|
||||
|
||||
@javascript
|
||||
Scenario: Locators inside specific DOM nodes using CSS selectors
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
When I click on "Move this to the dock" "button" in the "Administration" "block"
|
||||
Then I should not see "Question bank" in the "region-pre" "region"
|
||||
And I click on "//div[@id='dock']/descendant::h2[normalize-space(.)='Administration']" "xpath_element"
|
||||
|
||||
@javascript
|
||||
Scenario: Locators inside specific DOM nodes using XPath
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
When I click on "Move this to the dock" "button" in the "Administration" "block"
|
||||
Then I should not see "Turn editing on" in the "region-pre" "region"
|
||||
@@ -1,210 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: Set up contextual data for tests
|
||||
In order to write tests quickly
|
||||
As a developer
|
||||
I need to fill the database with fixtures
|
||||
|
||||
Scenario: Add a bunch of users
|
||||
Given the following "users" exists:
|
||||
| username | password | firstname | lastname |
|
||||
| testuser | testuser | | |
|
||||
| testuser2 | testuser2 | TestFirstname | TestLastname |
|
||||
And I log in as "testuser"
|
||||
And I log out
|
||||
When I log in as "testuser2"
|
||||
Then I should see "TestFirstname"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a bunch of courses and categories
|
||||
Given the following "categories" exists:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
| Cat 2 | CAT1 | CAT2 |
|
||||
| Cat 3 | CAT1 | CAT3 |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | COURSE1 | CAT3 |
|
||||
| Course 2 | COURSE2 | CAT3 |
|
||||
| Course 3 | COURSE3 | 0 |
|
||||
When I log in as "admin"
|
||||
Then I should see "Course 1"
|
||||
And I should see "Course 2"
|
||||
And I should see "Course 3"
|
||||
And I go to the courses management page
|
||||
And I follow "Cat 1"
|
||||
And I should see "Cat 2"
|
||||
And I should see "Cat 3"
|
||||
And I follow "Cat 3"
|
||||
And I should see "Course 1"
|
||||
And I should see "Course 2"
|
||||
And I select "Cat 1 / Cat 2" from "Course categories:"
|
||||
And I should see "No courses in this category"
|
||||
And I select "Miscellaneous" from "Course categories:"
|
||||
And I should see "Course 3"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a bunch of groups and groupings
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "groups" exists:
|
||||
| name | course | idnumber |
|
||||
| Group 1 | C1 | G1 |
|
||||
| Group 2 | C1 | G2 |
|
||||
And the following "groupings" exists:
|
||||
| name | course | idnumber |
|
||||
| Grouping 1 | C1 | GG1 |
|
||||
| Grouping 2 | C1 | GG2 |
|
||||
When I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
Then I should see "Group 1"
|
||||
And I should see "Group 2"
|
||||
And I follow "Groupings"
|
||||
And I should see "Grouping 1"
|
||||
And I should see "Grouping 2"
|
||||
|
||||
@javascript
|
||||
Scenario: Role overrides
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
And the following "categories" exists:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
And the following "permission overrides" exists:
|
||||
| capability | permission | role | contextlevel | reference |
|
||||
| mod/forum:editanypost | Allow | student | Course | C1 |
|
||||
| mod/forum:replynews | Prevent | editingteacher | Course | C1 |
|
||||
When I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Permissions"
|
||||
And I select "Student (1)" from "Advanced role override"
|
||||
Then "mod/forum:editanypost" capability has "Allow" permission
|
||||
And I press "Cancel"
|
||||
And I select "Teacher (1)" from "Advanced role override"
|
||||
And "mod/forum:replynews" capability has "Prevent" permission
|
||||
And I press "Cancel"
|
||||
|
||||
Scenario: Add course enrolments
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
When I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
Then I should see "Topic 1"
|
||||
|
||||
Scenario: Add role assigns
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| user1 | User | 1 | user1@moodlemoodle.com |
|
||||
| user2 | User | 2 | user2@moodlemoodle.com |
|
||||
| user3 | User | 3 | user3@moodlemoodle.com |
|
||||
And the following "categories" exists:
|
||||
| name | category | idnumber |
|
||||
| Cat 1 | 0 | CAT1 |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | CAT1 |
|
||||
And the following "role assigns" exists:
|
||||
| user | role | contextlevel | reference |
|
||||
| user1 | manager | System | |
|
||||
| user2 | editingteacher | Category | CAT1 |
|
||||
| user3 | editingteacher | Course | C1 |
|
||||
When I log in as "user1"
|
||||
Then I should see "Front page settings"
|
||||
And I log out
|
||||
And I log in as "user2"
|
||||
And I follow "Course 1"
|
||||
And I should see "Turn editing on"
|
||||
And I log out
|
||||
And I log in as "user3"
|
||||
And I follow "Course 1"
|
||||
And I should see "Turn editing on"
|
||||
|
||||
Scenario: Add modules
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "activities" exists:
|
||||
| activity | name | intro | course | idnumber |
|
||||
| assign | Test assignment name | Test assignment description | C1 | assign1 |
|
||||
| assignment | Test assignment22 name | Test assignment22 description | C1 | assignment1 |
|
||||
| data | Test database name | Test database description | C1 | data1 |
|
||||
| forum | Test forum name | Test forum description | C1 | forum1 |
|
||||
| label | Test label name | Test label description | C1 | label1 |
|
||||
| lti | Test lti name | Test lti description | C1 | lti1 |
|
||||
| page | Test page name | Test page description | C1 | page1 |
|
||||
| quiz | Test quiz name | Test quiz description | C1 | quiz1 |
|
||||
| resource | Test resource name | Test resource description | C1 | resource1 |
|
||||
When I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
Then I should see "Test assignment name"
|
||||
# Assignment 2.2 is disabled by default:
|
||||
# And I should see "Test assignment22 name"
|
||||
And I should see "Test database name"
|
||||
And I should see "Test forum name"
|
||||
# User can see label description instead of name on the course page:
|
||||
And I should see "Test label description"
|
||||
And I should see "Test lti name"
|
||||
And I should see "Test page name"
|
||||
And I should see "Test quiz name"
|
||||
And I should see "Test resource name"
|
||||
And I follow "Test assignment name"
|
||||
And I should see "Test assignment description"
|
||||
|
||||
@javascript
|
||||
Scenario: Add relations between users and groups
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@asd.com |
|
||||
| student2 | Student | 2 | student2@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname |
|
||||
| Course 1 | C1 |
|
||||
And the following "groups" exists:
|
||||
| name | course | idnumber |
|
||||
| Group 1 | C1 | G1 |
|
||||
| Group 2 | C1 | G2 |
|
||||
And the following "groupings" exists:
|
||||
| name | course | idnumber |
|
||||
| Grouping 1 | C1 | GG1 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And the following "group members" exists:
|
||||
| user | group |
|
||||
| student1 | G1 |
|
||||
| student2 | G2 |
|
||||
And the following "grouping groups" exists:
|
||||
| grouping | group |
|
||||
| GG1 | G1 |
|
||||
When I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
Then the "groups" select box should contain "Group 1 (1)"
|
||||
And the "groups" select box should contain "Group 2 (1)"
|
||||
And I select "Group 1 (1)" from "groups"
|
||||
And I wait "5" seconds
|
||||
And the "members" select box should contain "Student 1"
|
||||
And I select "Group 2 (1)" from "groups"
|
||||
And I wait "5" seconds
|
||||
And the "members" select box should contain "Student 2"
|
||||
@@ -1,65 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: Edit capabilities
|
||||
In order to extend and restrict moodle features
|
||||
As an admin or a teacher
|
||||
I need to allow/deny the existing capabilities at different levels
|
||||
|
||||
Background:
|
||||
Given the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
|
||||
@javascript
|
||||
Scenario: Default system capabilities modification
|
||||
Given I log in as "admin"
|
||||
And I set the following system permissions of "Teacher" role:
|
||||
| capability | permission |
|
||||
| block/mnet_hosts:myaddinstance | Allow |
|
||||
| moodle/community:add | Inherit |
|
||||
| moodle/grade:managesharedforms | Prevent |
|
||||
| moodle/course:request | Prohibit |
|
||||
When I follow "Edit Teacher role"
|
||||
Then "block/mnet_hosts:myaddinstance" capability has "Allow" permission
|
||||
And "moodle/community:add" capability has "Not set" permission
|
||||
And "moodle/grade:managesharedforms" capability has "Prevent" permission
|
||||
And "moodle/course:request" capability has "Prohibit" permission
|
||||
|
||||
@javascript
|
||||
Scenario: Course capabilities overrides
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Permissions"
|
||||
And I override the system permissions of "Student" role with:
|
||||
| mod/forum:deleteanypost | Prohibit |
|
||||
| mod/forum:editanypost | Prevent |
|
||||
| mod/forum:addquestion | Allow |
|
||||
When I select "Student (3)" from "Advanced role override"
|
||||
Then "mod/forum:deleteanypost" capability has "Prohibit" permission
|
||||
And "mod/forum:editanypost" capability has "Prevent" permission
|
||||
And "mod/forum:addquestion" capability has "Allow" permission
|
||||
|
||||
@javascript
|
||||
Scenario: Module capabilities overrides
|
||||
Given I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | I'm the name |
|
||||
| Description | I'm the introduction |
|
||||
And I follow "I'm the name"
|
||||
And I follow "Permissions"
|
||||
And I override the system permissions of "Student" role with:
|
||||
| mod/forum:deleteanypost | Prohibit |
|
||||
| mod/forum:editanypost | Prevent |
|
||||
| mod/forum:addquestion | Allow |
|
||||
When I select "Student (3)" from "Advanced role override"
|
||||
Then "mod/forum:deleteanypost" capability has "Prohibit" permission
|
||||
And "mod/forum:editanypost" capability has "Prevent" permission
|
||||
And "mod/forum:addquestion" capability has "Allow" permission
|
||||
@@ -1,179 +0,0 @@
|
||||
@tool_behat
|
||||
Feature: Verify that all form fields values can be get and set
|
||||
In order to use behat steps definitions
|
||||
As a test writer
|
||||
I need to verify it all works in real moodle forms
|
||||
|
||||
Background:
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "users" exists:
|
||||
| username | email | firstname | lastname |
|
||||
| student1 | s1@asd.com | Student | 1 |
|
||||
| student2 | s2@asd.com | Student | 2 |
|
||||
| student3 | s3@asd.com | Student | 3 |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
| student3 | C1 | student |
|
||||
| admin | C1 | editingteacher |
|
||||
And the following "groups" exists:
|
||||
| name | description | course | idnumber |
|
||||
| Group 1 | G1 description | C1 | G1 |
|
||||
| Group 2 | G1 description | C1 | G2 |
|
||||
And the following "group members" exists:
|
||||
| user | group |
|
||||
| student1 | G1 |
|
||||
| student2 | G1 |
|
||||
| student2 | G2 |
|
||||
| student3 | G2 |
|
||||
And I log in as "admin"
|
||||
And I expand "Site administration" node
|
||||
And I expand "Appearance" node
|
||||
And I follow "Manage tags"
|
||||
# Select (multi-select) - We will check "I fill in...".
|
||||
And I fill in "otagsadd" with "OT1, OT2, OT3, OT4, OT5"
|
||||
And I press "Add official tags"
|
||||
And I am on homepage
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Wiki" to section "1" and I fill the form with:
|
||||
| Wiki name | Test this one |
|
||||
| Description | Test this one |
|
||||
| First page name | Test this one |
|
||||
| Wiki mode | Collaborative wiki |
|
||||
| Visible | Hide |
|
||||
And I follow "Test this one"
|
||||
And I press "Create page"
|
||||
# Select (multi-select) - Checking "the select box should contain".
|
||||
And the "tags[officialtags][]" select box should contain "OT1"
|
||||
And the "tags[officialtags][]" select box should contain "OT2"
|
||||
And the "tags[officialtags][]" select box should contain "OT3"
|
||||
And the "tags[officialtags][]" select box should contain "OT4"
|
||||
And the "tags[officialtags][]" select box should contain "OT5"
|
||||
And the "tags[officialtags][]" select box should contain "OT1, OT2, OT3, OT4, OT5"
|
||||
And the "tags[officialtags][]" select box should contain "OT5, OT4, OT3, OT2, OT1"
|
||||
And the "tags[officialtags][]" select box should not contain "OT6"
|
||||
And the "tags[officialtags][]" select box should not contain "OT7"
|
||||
And the "tags[officialtags][]" select box should not contain "OT6, OT7"
|
||||
# Text (textarea & editor) & Select (multi-select) - Checking "I fill the moodle form with".
|
||||
When I fill the moodle form with:
|
||||
| HTML format | Student page contents to be tagged |
|
||||
| tags[officialtags][] | OT1, OT3, OT5 |
|
||||
And I press "Save"
|
||||
Then I should see "Student page contents to be tagged" in the "region-main" "region"
|
||||
And I should see "OT1" in the ".wiki-tags" "css_element"
|
||||
And I should see "OT3" in the ".wiki-tags" "css_element"
|
||||
And I should see "OT5" in the ".wiki-tags" "css_element"
|
||||
And I should not see "OT2" in the ".wiki-tags" "css_element"
|
||||
And I should not see "OT4" in the ".wiki-tags" "css_element"
|
||||
And I follow "Edit"
|
||||
# Select (multi-select) - Checking "I select from".
|
||||
And I select "OT2, OT4" from "tags[officialtags][]"
|
||||
And I press "Save"
|
||||
And I should see "OT2" in the ".wiki-tags" "css_element"
|
||||
And I should see "OT4" in the ".wiki-tags" "css_element"
|
||||
And I should not see "OT1" in the ".wiki-tags" "css_element"
|
||||
And I should not see "OT3" in the ".wiki-tags" "css_element"
|
||||
And I should not see "OT5" in the ".wiki-tags" "css_element"
|
||||
And I follow "Edit"
|
||||
# Select (multi-select) - Checking "the field should match" and "the field does not match value".
|
||||
And the "tags[officialtags][]" field should match "OT2, OT4" value
|
||||
And the field "tags[officialtags][]" does not match value "OT4"
|
||||
And the field "tags[officialtags][]" does not match value "OT2"
|
||||
And the field "tags[officialtags][]" does not match value "OT1, OT3, OT5"
|
||||
And I press "Cancel"
|
||||
And I follow "Edit settings"
|
||||
And I expand all fieldsets
|
||||
# Checkbox - Checking "I check".
|
||||
And I check "Display description on course page"
|
||||
# Checkbox - Checking "I fill the moodle form with:".
|
||||
And I fill the moodle form with:
|
||||
| Force format | 1 |
|
||||
# Checkbox - Checking "the field should match" and "the field does not match value".
|
||||
And the "Display description on course page" field should match "1" value
|
||||
And the field "Display description on course page" does not match value ""
|
||||
And I press "Save and return to course"
|
||||
And I should see "Test this one"
|
||||
And I follow "Test this one"
|
||||
And I follow "Edit settings"
|
||||
# Checkbox - Checking "the field should match" and "the following fields match these values".
|
||||
And the following fields match these values:
|
||||
| Display description on course page | 1 |
|
||||
| Default format | HTML |
|
||||
| Wiki name | Test this one |
|
||||
And the "Force format" field should match "1" value
|
||||
# Select (simple) - Checking "I fill the moodle form with:".
|
||||
And I fill the moodle form with:
|
||||
| Default format | NWiki |
|
||||
| Display description on course page | |
|
||||
# Checkbox - Checking "I uncheck".
|
||||
And I uncheck "Force format"
|
||||
# Select (simple) - Checking "I select from".
|
||||
And I select "Separate groups" from "Group mode"
|
||||
And I press "Save and display"
|
||||
And I follow "Edit settings"
|
||||
And the following fields match these values:
|
||||
| Default format | NWiki |
|
||||
| Group mode | Separate groups |
|
||||
| Display description on course page | |
|
||||
| Force format | |
|
||||
# All fields - Checking "the following fields do not match these values".
|
||||
And the following fields do not match these values:
|
||||
| Wiki name | Test this one baby |
|
||||
| Default format | HTML |
|
||||
| Force format | 1 |
|
||||
And I press "Cancel"
|
||||
And I follow "Course 1"
|
||||
# Radio - Checking "I check" and "the field should match".
|
||||
And I add a "Choice" to section "1" and I fill the form with:
|
||||
| Choice name | Test choice name |
|
||||
| Description | Test choice description |
|
||||
| Allow choice to be updated | Yes |
|
||||
| Option 1 | one |
|
||||
| Option 2 | two |
|
||||
| Option 3 | three |
|
||||
And I follow "Test choice name"
|
||||
And I check "one"
|
||||
And I press "Save my choice"
|
||||
And the "one" field should match "1" value
|
||||
And the "two" field should match "" value
|
||||
|
||||
Scenario: with JS disabled all form fields getters and setters works as expected
|
||||
|
||||
@javascript
|
||||
Scenario: with JS enabled all form fields getters and setters works as expected
|
||||
Then I follow "Course 1"
|
||||
And I expand "Users" node
|
||||
And I follow "Groups"
|
||||
# Select (multi-select & AJAX) - Checking "I select from" and "select box should contain".
|
||||
And I select "Group 2" from "groups"
|
||||
And I wait "5" seconds
|
||||
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 select "Group 1" from "groups"
|
||||
And I wait "5" seconds
|
||||
And the "members" select box should contain "Student 2"
|
||||
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 check" and "I fill the moodle form with".
|
||||
And I follow "Course 1"
|
||||
And I add a "Lesson" to section "1"
|
||||
And I fill the moodle form with:
|
||||
| Name | Test lesson |
|
||||
| available[enabled] | 1 |
|
||||
And I check "deadline[enabled]"
|
||||
# Checkbox (AJAX) - Checking "field should match" before saving.
|
||||
And the "available[enabled]" field should match "1" value
|
||||
And the "available[day]" "field" should be enabled
|
||||
And the "deadline[enabled]" field should match "1" value
|
||||
And I press "Save and display"
|
||||
And I follow "Edit settings"
|
||||
And the "available[enabled]" field should match "1" value
|
||||
And the "available[day]" "field" should be enabled
|
||||
And the "deadline[enabled]" field should match "1" value
|
||||
And I press "Cancel"
|
||||
@@ -1,31 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: List the system steps definitions
|
||||
In order to create new tests
|
||||
As a tests writer
|
||||
I need to list and filter the system steps definitions
|
||||
|
||||
Background:
|
||||
Given I am on homepage
|
||||
And I log in as "admin"
|
||||
And I expand "Site administration" node
|
||||
And I expand "Development" node
|
||||
And I follow "Acceptance testing"
|
||||
|
||||
@javascript
|
||||
Scenario: Accessing the list
|
||||
Then I should see "Steps definitions"
|
||||
And I should not see "There aren't steps definitions matching this filter"
|
||||
|
||||
@javascript
|
||||
Scenario: Filtering by type
|
||||
Given I select "Then. Checkings to ensure the outcomes are the expected ones" from "Type"
|
||||
When I press "Filter"
|
||||
Then I should see "Checks, that page contains specified text."
|
||||
And I should not see "Opens Moodle homepage."
|
||||
|
||||
@javascript
|
||||
Scenario: Filtering by keyword
|
||||
Given I fill in "Contains" with "homepage"
|
||||
When I press "Filter"
|
||||
Then I should see "Opens Moodle homepage."
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: Forms manipulation
|
||||
In order to interact with Moodle
|
||||
As a user
|
||||
I need to set forms values
|
||||
|
||||
@javascript
|
||||
Scenario: Basic forms manipulation
|
||||
Given I log in as "admin"
|
||||
And I follow "Admin User"
|
||||
And I follow "Edit profile"
|
||||
When I fill in "First name" with "Field value"
|
||||
And I select "Use standard web forms" from "When editing text"
|
||||
And I check "Unmask"
|
||||
Then the "First name" field should match "Field value" value
|
||||
And the "When editing text" select box should contain "Use standard web forms"
|
||||
And the "Unmask" checkbox should be checked
|
||||
And I uncheck "Unmask"
|
||||
And the "Unmask" checkbox should not be checked
|
||||
And I press "Update profile"
|
||||
|
||||
@javascript
|
||||
Scenario: Expand all fieldsets and advanced elements
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Quiz" to section "1"
|
||||
When I expand all fieldsets
|
||||
Then I should see "Close the quiz"
|
||||
And I should see "Group mode"
|
||||
And I should see "Grouping"
|
||||
And I should not see "Show more..." in the "region-main" "region"
|
||||
And I should see "Show less..."
|
||||
@@ -1,60 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: Transform steps arguments
|
||||
In order to write tests with complex nasty arguments
|
||||
As a tests writer
|
||||
I need to apply some transformations to the steps arguments
|
||||
|
||||
Background:
|
||||
Given I am on homepage
|
||||
And the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And I log in as "admin"
|
||||
And I follow "Admin User"
|
||||
And I follow "Edit profile"
|
||||
|
||||
Scenario: Use nasty strings on steps arguments
|
||||
When I fill in "Surname" with "$NASTYSTRING1"
|
||||
And I fill in "Description" with "$NASTYSTRING2"
|
||||
And I fill in "City/town" with "$NASTYSTRING3"
|
||||
And I press "Update profile"
|
||||
And I follow "Edit profile"
|
||||
Then I should not see "NASTYSTRING"
|
||||
And the "Surname" field should match "$NASTYSTRING1" value
|
||||
And the "City/town" field should match "$NASTYSTRING3" value
|
||||
|
||||
Scenario: Use nasty strings on table nodes
|
||||
When I fill the moodle form with:
|
||||
| Surname | $NASTYSTRING1 |
|
||||
| Description | $NASTYSTRING2 |
|
||||
| City/town | $NASTYSTRING3 |
|
||||
And I press "Update profile"
|
||||
And I follow "Edit profile"
|
||||
Then I should not see "NASTYSTRING"
|
||||
And the "Surname" field should match "$NASTYSTRING1" value
|
||||
And the "City/town" field should match "$NASTYSTRING3" value
|
||||
|
||||
Scenario: Use double quotes
|
||||
When I fill the moodle form with:
|
||||
| First name | va"lue1 |
|
||||
| Description | va\"lue2 |
|
||||
And I fill in "City/town" with "va\"lue3"
|
||||
And I press "Update profile"
|
||||
And I follow "Edit profile"
|
||||
Then I should not see "NASTYSTRING"
|
||||
And the "First name" field should match "va\"lue1" value
|
||||
And the "Description" field should match "va\\"lue2" value
|
||||
And the "City/town" field should match "va\"lue3" value
|
||||
|
||||
@javascript
|
||||
Scenario: Nasty strings with other contents
|
||||
When I fill in "First name" with "My Firstname $NASTYSTRING1"
|
||||
And I fill the moodle form with:
|
||||
| Surname | My Surname $NASTYSTRING2 |
|
||||
And I press "Update profile"
|
||||
And I follow "Edit profile"
|
||||
Then I should not see "NASTYSTRING"
|
||||
And I should see "My Firstname"
|
||||
And I should see "My Surname"
|
||||
And the "First name" field should match "My Firstname $NASTYSTRING1" value
|
||||
And the "Surname" field should match "My Surname $NASTYSTRING2" value
|
||||
@@ -1,9 +0,0 @@
|
||||
@tool @tool_behat
|
||||
Feature: Set up the testing environment
|
||||
In order to execute automated acceptance tests
|
||||
As a developer
|
||||
I need to use the test environment instead of the regular environment
|
||||
|
||||
Scenario: Accessing the site
|
||||
When I am on homepage
|
||||
Then I should see "Acceptance test site"
|
||||
@@ -1,194 +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/>.
|
||||
|
||||
/**
|
||||
* Unit tests for admin/tool/behat.
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin .'/tool/behat/locallib.php');
|
||||
require_once($CFG->libdir . '/behat/classes/util.php');
|
||||
require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
|
||||
|
||||
/**
|
||||
* Allows access to internal methods without exposing them.
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class testable_behat_config_manager extends behat_config_manager {
|
||||
|
||||
/**
|
||||
* Allow access to protected method
|
||||
* @see parent::merge_config()
|
||||
* @param mixed $config
|
||||
* @param mixed $localconfig
|
||||
* @return mixed
|
||||
*/
|
||||
public static function merge_config($config, $localconfig) {
|
||||
return parent::merge_config($config, $localconfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow access to protected method
|
||||
* @see parent::get_config_file_contents()
|
||||
* @param array $features
|
||||
* @param array $stepsdefinitions
|
||||
* @return string
|
||||
*/
|
||||
public static function get_config_file_contents($features, $stepsdefinitions) {
|
||||
return parent::get_config_file_contents($features, $stepsdefinitions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tool behat tests.
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_behat_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* behat_config_manager tests.
|
||||
*/
|
||||
public function test_merge_configs() {
|
||||
|
||||
// Simple default config.
|
||||
$array1 = array(
|
||||
'the' => 'same',
|
||||
'simple' => 'value',
|
||||
'array' => array(
|
||||
'one' => 'arrayvalue1',
|
||||
'two' => 'arrayvalue2'
|
||||
)
|
||||
);
|
||||
|
||||
// Simple override.
|
||||
$array2 = array(
|
||||
'simple' => 'OVERRIDDEN1',
|
||||
'array' => array(
|
||||
'one' => 'OVERRIDDEN2'
|
||||
),
|
||||
'newprofile' => array(
|
||||
'anotherlevel' => array(
|
||||
'andanotherone' => array(
|
||||
'list1',
|
||||
'list2'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$array = testable_behat_config_manager::merge_config($array1, $array2);
|
||||
|
||||
// Overriddes are applied.
|
||||
$this->assertEquals('OVERRIDDEN1', $array['simple']);
|
||||
$this->assertEquals('OVERRIDDEN2', $array['array']['one']);
|
||||
|
||||
// Other values are respected.
|
||||
$this->assertNotEmpty($array['array']['two']);
|
||||
|
||||
// Completely new nodes are added.
|
||||
$this->assertNotEmpty($array['newprofile']);
|
||||
$this->assertNotEmpty($array['newprofile']['anotherlevel']['andanotherone']);
|
||||
$this->assertEquals('list1', $array['newprofile']['anotherlevel']['andanotherone'][0]);
|
||||
$this->assertEquals('list2', $array['newprofile']['anotherlevel']['andanotherone'][1]);
|
||||
|
||||
// Complex override changing vectors to scalars and scalars to vectors.
|
||||
$array2 = array(
|
||||
'simple' => array(
|
||||
'simple' => 'should',
|
||||
'be' => 'overridden',
|
||||
'by' => 'this-array'
|
||||
),
|
||||
'array' => 'one'
|
||||
);
|
||||
|
||||
$array = testable_behat_config_manager::merge_config($array1, $array2);
|
||||
|
||||
// Overrides applied.
|
||||
$this->assertNotEmpty($array['simple']);
|
||||
$this->assertNotEmpty($array['array']);
|
||||
$this->assertTrue(is_array($array['simple']));
|
||||
$this->assertFalse(is_array($array['array']));
|
||||
|
||||
// Other values are maintained.
|
||||
$this->assertEquals('same', $array['the']);
|
||||
}
|
||||
|
||||
/**
|
||||
* behat_config_manager tests.
|
||||
*/
|
||||
public function test_config_file_contents() {
|
||||
global $CFG;
|
||||
|
||||
// Skip tests if behat is not installed.
|
||||
$vendorpath = $CFG->dirroot . '/vendor';
|
||||
if (!file_exists($vendorpath . '/autoload.php') || !is_dir($vendorpath . '/behat')) {
|
||||
$this->markTestSkipped('Behat not installed.');
|
||||
}
|
||||
|
||||
// To avoid user value at config.php level.
|
||||
unset($CFG->behat_config);
|
||||
|
||||
// List.
|
||||
$features = array(
|
||||
'feature1',
|
||||
'feature2',
|
||||
'feature3'
|
||||
);
|
||||
|
||||
// Associative array.
|
||||
$stepsdefinitions = array(
|
||||
'micarro' => '/me/lo/robaron',
|
||||
'anoche' => '/cuando/yo/dormia'
|
||||
);
|
||||
|
||||
$contents = testable_behat_config_manager::get_config_file_contents($features, $stepsdefinitions);
|
||||
|
||||
// YAML decides when is is necessary to wrap strings between single quotes, so not controlled
|
||||
// values like paths should not be asserted including the key name as they would depend on the
|
||||
// directories values.
|
||||
$this->assertContains($CFG->dirroot . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . 'features', $contents);
|
||||
|
||||
// If it was empty should be filled by behat_config_manager::get_config_file_contents().
|
||||
$this->assertNotNull($CFG->behat_wwwroot);
|
||||
|
||||
// Not quoted strings.
|
||||
$this->assertContains('micarro: /me/lo/robaron', $contents);
|
||||
$this->assertContains('class: behat_init_context', $contents);
|
||||
|
||||
// YAML uses single quotes to wrap URL strings.
|
||||
$this->assertContains("base_url: '" . $CFG->behat_wwwroot . "'", $contents);
|
||||
|
||||
// Lists.
|
||||
$this->assertContains('- feature1', $contents);
|
||||
$this->assertContains('- feature3', $contents);
|
||||
|
||||
unset($CFG->behat_wwwroot);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +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/>.
|
||||
|
||||
/**
|
||||
* tool_behat version info
|
||||
*
|
||||
* @package tool_behat
|
||||
* @copyright 2012 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050102;
|
||||
$plugin->requires = 2013050100; // Requires Moodle 2.5.
|
||||
$plugin->component = 'tool_behat';
|
||||
@@ -139,15 +139,9 @@ if ($capability) {
|
||||
// Put the contexts into a tree structure.
|
||||
foreach ($contexts as $conid => $con) {
|
||||
$context = context::instance_by_id($conid);
|
||||
try {
|
||||
$parentcontext = $context->get_parent_context();
|
||||
if ($parentcontext) { // Will be false if $context is the system context.
|
||||
$contexts[$parentcontext->id]->children[] = $conid;
|
||||
}
|
||||
} catch (dml_missing_record_exception $e) {
|
||||
// Ignore corrupt context tree structure here. Don't let it break
|
||||
// showing the rest of the report.
|
||||
continue;
|
||||
$parentcontextid = get_parent_contextid($context);
|
||||
if ($parentcontextid) {
|
||||
$contexts[$parentcontextid]->children[] = $conid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2013050100; // Requires this Moodle version
|
||||
$plugin->version = 2012112900; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2012112900; // Requires this Moodle version
|
||||
$plugin->component = 'tool_capability'; // Full name of the plugin (used for diagnostics)
|
||||
|
||||
@@ -4,33 +4,33 @@
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
<TABLES>
|
||||
<TABLE NAME="tool_customlang" COMMENT="Contains the working checkout of all strings and their customization">
|
||||
<TABLE NAME="tool_customlang" COMMENT="Contains the working checkout of all strings and their customization" NEXT="tool_customlang_components">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="lang" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The code of the language this string belongs to. Like en, cs or es"/>
|
||||
<FIELD NAME="componentid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The id of the component"/>
|
||||
<FIELD NAME="stringid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The identifier of the string"/>
|
||||
<FIELD NAME="original" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false" COMMENT="English original of the string"/>
|
||||
<FIELD NAME="master" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Master translation of the string as is distributed in the official lang pack, null if not translated"/>
|
||||
<FIELD NAME="local" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Local customization of the string, null if not customized"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The timestamp of when the original or master was recently modified"/>
|
||||
<FIELD NAME="timecustomized" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The timestamp of when the value of the local translation was recently modified, null if not customized yet"/>
|
||||
<FIELD NAME="outdated" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Either the English original or the master translation changed and the customization may be outdated"/>
|
||||
<FIELD NAME="modified" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Has the string been modified via the translator?"/>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="lang"/>
|
||||
<FIELD NAME="lang" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The code of the language this string belongs to. Like en, cs or es" PREVIOUS="id" NEXT="componentid"/>
|
||||
<FIELD NAME="componentid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The id of the component" PREVIOUS="lang" NEXT="stringid"/>
|
||||
<FIELD NAME="stringid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The identifier of the string" PREVIOUS="componentid" NEXT="original"/>
|
||||
<FIELD NAME="original" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false" COMMENT="English original of the string" PREVIOUS="stringid" NEXT="master"/>
|
||||
<FIELD NAME="master" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Master translation of the string as is distributed in the official lang pack, null if not translated" PREVIOUS="original" NEXT="local"/>
|
||||
<FIELD NAME="local" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Local customization of the string, null if not customized" PREVIOUS="master" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The timestamp of when the original or master was recently modified" PREVIOUS="local" NEXT="timecustomized"/>
|
||||
<FIELD NAME="timecustomized" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The timestamp of when the value of the local translation was recently modified, null if not customized yet" PREVIOUS="timemodified" NEXT="outdated"/>
|
||||
<FIELD NAME="outdated" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Either the English original or the master translation changed and the customization may be outdated" PREVIOUS="timecustomized" NEXT="modified"/>
|
||||
<FIELD NAME="modified" TYPE="int" LENGTH="3" NOTNULL="false" DEFAULT="0" SEQUENCE="false" COMMENT="Has the string been modified via the translator?" PREVIOUS="outdated"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
<KEY NAME="fk_component" TYPE="foreign" FIELDS="componentid" REFTABLE="tool_customlang_components" REFFIELDS="id"/>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_component"/>
|
||||
<KEY NAME="fk_component" TYPE="foreign" FIELDS="componentid" REFTABLE="tool_customlang_components" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
<INDEXES>
|
||||
<INDEX NAME="uq_lang_component_string" UNIQUE="true" FIELDS="lang, componentid, stringid" COMMENT="For a given language and component, string identifiers must be unique"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="tool_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack">
|
||||
<TABLE NAME="tool_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack" PREVIOUS="tool_customlang">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The checked out version of the plugin, null if the version is unknown"/>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" NEXT="name"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
|
||||
<FIELD NAME="version" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The checked out version of the plugin, null if the version is unknown" PREVIOUS="name"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
||||
@@ -38,9 +38,5 @@ function xmldb_tool_customlang_upgrade($oldversion) {
|
||||
// Put any upgrade step following this
|
||||
|
||||
|
||||
// Moodle v2.5.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ $lng = required_param('lng', PARAM_LANG);
|
||||
$currentpage = optional_param('p', 0, PARAM_INT);
|
||||
$translatorsubmitted = optional_param('translatorsubmitted', 0, PARAM_BOOL);
|
||||
|
||||
$PAGE->set_pagelayout('report'); // Allows for wide page contents.
|
||||
$PAGE->set_pagelayout('standard');
|
||||
$PAGE->set_url('/admin/tool/customlang/edit.php', array('lng' => $lng));
|
||||
navigation_node::override_active_url(new moodle_url('/admin/tool/customlang/index.php'));
|
||||
$PAGE->set_title(get_string('pluginname', 'tool_customlang'));
|
||||
|
||||
@@ -60,8 +60,8 @@ class tool_customlang_filter_form extends moodleform {
|
||||
|
||||
// Modified only
|
||||
$mform->addElement('advcheckbox', 'modified', get_string('filtermodified', 'tool_customlang'));
|
||||
$mform->setType('modified', PARAM_BOOL);
|
||||
$mform->setDefault('modified', 0);
|
||||
$mform->setType('filtermodified', PARAM_BOOL);
|
||||
$mform->setDefault('filtermodified', 0);
|
||||
|
||||
// Substring
|
||||
$mform->addElement('text', 'substring', get_string('filtersubstring', 'tool_customlang'));
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050100;
|
||||
$plugin->requires = 2013050100;
|
||||
$plugin->version = 2012112900;
|
||||
$plugin->requires = 2012112900;
|
||||
$plugin->component = 'tool_customlang'; // Full name of the plugin (used for diagnostics)
|
||||
|
||||
@@ -43,7 +43,6 @@ class database_export_form extends moodleform {
|
||||
|
||||
$mform->addElement('header', 'database', get_string('dbexport', 'tool_dbtransfer'));
|
||||
$mform->addElement('textarea', 'description', get_string('description'), array('rows'=>5, 'cols'=>60));
|
||||
$mform->setType('description', PARAM_TEXT);
|
||||
|
||||
$this->add_action_buttons(false, get_string('exportdata', 'tool_dbtransfer'));
|
||||
}
|
||||
|
||||
@@ -52,32 +52,17 @@ class database_transfer_form extends moodleform {
|
||||
$drivers = array_reverse($drivers, true);
|
||||
|
||||
$mform->addElement('select', 'driver', get_string('dbtype', 'install'), $drivers);
|
||||
$mform->setType('driver', PARAM_RAW);
|
||||
|
||||
$mform->addElement('text', 'dbhost', get_string('databasehost', 'install'));
|
||||
$mform->setType('dbhost', PARAM_HOST);
|
||||
|
||||
$mform->addElement('text', 'dbname', get_string('databasename', 'install'));
|
||||
$mform->setType('dbname', PARAM_ALPHANUMEXT);
|
||||
|
||||
$mform->addElement('text', 'dbuser', get_string('databaseuser', 'install'));
|
||||
$mform->setType('dbuser', PARAM_ALPHANUMEXT);
|
||||
|
||||
$mform->addElement('passwordunmask', 'dbpass', get_string('databasepass', 'install'));
|
||||
$mform->setType('dbpass', PARAM_RAW);
|
||||
|
||||
$mform->addElement('text', 'prefix', get_string('dbprefix', 'install'));
|
||||
$mform->setType('prefix', PARAM_ALPHANUMEXT);
|
||||
|
||||
$mform->addElement('text', 'dbport', get_string('dbport', 'install'));
|
||||
$mform->setType('dbport', PARAM_INT);
|
||||
|
||||
if ($CFG->ostype !== 'WINDOWS') {
|
||||
$mform->addElement('text', 'dbsocket', get_string('databasesocket', 'install'));
|
||||
} else {
|
||||
$mform->addElement('hidden', 'dbsocket');
|
||||
}
|
||||
$mform->setType('dbsocket', PARAM_RAW);
|
||||
|
||||
$mform->addRule('driver', get_string('required'), 'required', null);
|
||||
$mform->addRule('dbhost', get_string('required'), 'required', null);
|
||||
@@ -91,7 +76,6 @@ class database_transfer_form extends moodleform {
|
||||
$mform->addElement('header', 'database', get_string('options', 'tool_dbtransfer'));
|
||||
|
||||
$mform->addElement('advcheckbox', 'enablemaintenance', get_string('enablemaintenance', 'tool_dbtransfer'));
|
||||
$mform->setType('enablemaintenance', PARAM_BOOL);
|
||||
$mform->addHelpButton('enablemaintenance', 'enablemaintenance', 'tool_dbtransfer');
|
||||
|
||||
$this->add_action_buttons(false, get_string('transferdata', 'tool_dbtransfer'));
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2013050100; // Requires this Moodle version.
|
||||
$plugin->version = 2012112900; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2012112900; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_dbtransfer'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
@@ -1,199 +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/>.
|
||||
|
||||
/**
|
||||
* Backend generic code.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Backend generic code for all tool_generator commands.
|
||||
*
|
||||
* @abstract
|
||||
* @package tool_generator
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
abstract class tool_generator_backend {
|
||||
/**
|
||||
* @var int Lowest (smallest) size index
|
||||
*/
|
||||
const MIN_SIZE = 0;
|
||||
/**
|
||||
* @var int Highest (largest) size index
|
||||
*/
|
||||
const MAX_SIZE = 5;
|
||||
/**
|
||||
* @var int Default size index
|
||||
*/
|
||||
const DEFAULT_SIZE = 3;
|
||||
|
||||
/**
|
||||
* @var bool True if we want a fixed dataset or false to generate random data
|
||||
*/
|
||||
protected $fixeddataset;
|
||||
|
||||
/**
|
||||
* @var int|bool Maximum number of bytes for file.
|
||||
*/
|
||||
protected $filesizelimit;
|
||||
|
||||
/**
|
||||
* @var bool True if displaying progress
|
||||
*/
|
||||
protected $progress;
|
||||
|
||||
/**
|
||||
* @var int Epoch time at which last dot was displayed
|
||||
*/
|
||||
protected $lastdot;
|
||||
|
||||
/**
|
||||
* @var int Epoch time at which last percentage was displayed
|
||||
*/
|
||||
protected $lastpercentage;
|
||||
|
||||
/**
|
||||
* @var int Epoch time at which current step (current set of dots) started
|
||||
*/
|
||||
protected $starttime;
|
||||
|
||||
/**
|
||||
* @var int Size code (index in the above arrays)
|
||||
*/
|
||||
protected $size;
|
||||
|
||||
/**
|
||||
* Generic generator class
|
||||
*
|
||||
* @param int $size Size as numeric index
|
||||
* @param bool $fixeddataset To use fixed or random data
|
||||
* @param int|bool $filesizelimit The max number of bytes for a generated file
|
||||
* @param bool $progress True if progress information should be displayed
|
||||
* @throws coding_exception If parameters are invalid
|
||||
*/
|
||||
public function __construct($size, $fixeddataset = false, $filesizelimit = false, $progress = true) {
|
||||
|
||||
// Check parameter.
|
||||
if ($size < self::MIN_SIZE || $size > self::MAX_SIZE) {
|
||||
throw new coding_exception('Invalid size');
|
||||
}
|
||||
|
||||
// Set parameters.
|
||||
$this->size = $size;
|
||||
$this->fixeddataset = $fixeddataset;
|
||||
$this->filesizelimit = $filesizelimit;
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a size name into the numeric constant.
|
||||
*
|
||||
* @param string $sizename Size name e.g. 'L'
|
||||
* @return int Numeric version
|
||||
* @throws coding_exception If the size name is not known
|
||||
*/
|
||||
public static function size_for_name($sizename) {
|
||||
for ($size = self::MIN_SIZE; $size <= self::MAX_SIZE; $size++) {
|
||||
if ($sizename == get_string('shortsize_' . $size, 'tool_generator')) {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
throw new coding_exception("Unknown size name '$sizename'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays information as part of progress.
|
||||
* @param string $langstring Part of langstring (after progress_)
|
||||
* @param mixed $a Optional lang string parameters
|
||||
* @param bool $leaveopen If true, doesn't close LI tag (ready for dots)
|
||||
*/
|
||||
protected function log($langstring, $a = null, $leaveopen = false) {
|
||||
if (!$this->progress) {
|
||||
return;
|
||||
}
|
||||
if (CLI_SCRIPT) {
|
||||
echo '* ';
|
||||
} else {
|
||||
echo html_writer::start_tag('li');
|
||||
}
|
||||
echo get_string('progress_' . $langstring, 'tool_generator', $a);
|
||||
if (!$leaveopen) {
|
||||
if (CLI_SCRIPT) {
|
||||
echo "\n";
|
||||
} else {
|
||||
echo html_writer::end_tag('li');
|
||||
}
|
||||
} else {
|
||||
echo ': ';
|
||||
$this->lastdot = time();
|
||||
$this->lastpercentage = $this->lastdot;
|
||||
$this->starttime = microtime(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs dots. There is up to one dot per second. Once a minute, it
|
||||
* displays a percentage.
|
||||
* @param int $number Number of completed items
|
||||
* @param int $total Total number of items to complete
|
||||
*/
|
||||
protected function dot($number, $total) {
|
||||
if (!$this->progress) {
|
||||
return;
|
||||
}
|
||||
$now = time();
|
||||
if ($now == $this->lastdot) {
|
||||
return;
|
||||
}
|
||||
$this->lastdot = $now;
|
||||
if (CLI_SCRIPT) {
|
||||
echo '.';
|
||||
} else {
|
||||
echo ' . ';
|
||||
}
|
||||
if ($now - $this->lastpercentage >= 30) {
|
||||
echo round(100.0 * $number / $total, 1) . '%';
|
||||
$this->lastpercentage = $now;
|
||||
}
|
||||
|
||||
// Update time limit so PHP doesn't time out.
|
||||
if (!CLI_SCRIPT) {
|
||||
set_time_limit(120);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends a log string that was started using log function with $leaveopen.
|
||||
*/
|
||||
protected function end_log() {
|
||||
if (!$this->progress) {
|
||||
return;
|
||||
}
|
||||
echo get_string('done', 'tool_generator', round(microtime(true) - $this->starttime, 1));
|
||||
if (CLI_SCRIPT) {
|
||||
echo "\n";
|
||||
} else {
|
||||
echo html_writer::end_tag('li');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,544 +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/>.
|
||||
|
||||
/**
|
||||
* tool_generator course backend code.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(__DIR__ . '/backend.php');
|
||||
|
||||
/**
|
||||
* Backend code for the 'make large course' tool.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_generator_course_backend extends tool_generator_backend {
|
||||
/**
|
||||
* @var array Number of sections in course
|
||||
*/
|
||||
private static $paramsections = array(1, 10, 100, 500, 1000, 2000);
|
||||
/**
|
||||
* @var array Number of Page activities in course
|
||||
*/
|
||||
private static $parampages = array(1, 50, 200, 1000, 5000, 10000);
|
||||
/**
|
||||
* @var array Number of students enrolled in course
|
||||
*/
|
||||
private static $paramusers = array(1, 100, 1000, 10000, 50000, 100000);
|
||||
/**
|
||||
* Total size of small files: 1KB, 1MB, 10MB, 100MB, 1GB, 2GB.
|
||||
*
|
||||
* @var array Number of small files created in a single file activity
|
||||
*/
|
||||
private static $paramsmallfilecount = array(1, 64, 128, 1024, 16384, 32768);
|
||||
/**
|
||||
* @var array Size of small files (to make the totals into nice numbers)
|
||||
*/
|
||||
private static $paramsmallfilesize = array(1024, 16384, 81920, 102400, 65536, 65536);
|
||||
/**
|
||||
* Total size of big files: 8KB, 8MB, 80MB, 800MB, 8GB, 16GB.
|
||||
*
|
||||
* @var array Number of big files created as individual file activities
|
||||
*/
|
||||
private static $parambigfilecount = array(1, 2, 5, 10, 10, 10);
|
||||
/**
|
||||
* @var array Size of each large file
|
||||
*/
|
||||
private static $parambigfilesize = array(8192, 4194304, 16777216, 83886080,
|
||||
858993459, 1717986918);
|
||||
/**
|
||||
* @var array Number of forum discussions
|
||||
*/
|
||||
private static $paramforumdiscussions = array(1, 10, 100, 500, 1000, 2000);
|
||||
/**
|
||||
* @var array Number of forum posts per discussion
|
||||
*/
|
||||
private static $paramforumposts = array(2, 2, 5, 10, 10, 10);
|
||||
|
||||
/**
|
||||
* @var string Course shortname
|
||||
*/
|
||||
private $shortname;
|
||||
|
||||
/**
|
||||
* @var testing_data_generator Data generator
|
||||
*/
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* @var stdClass Course object
|
||||
*/
|
||||
private $course;
|
||||
|
||||
/**
|
||||
* @var array Array from test user number (1...N) to userid in database
|
||||
*/
|
||||
private $userids;
|
||||
|
||||
/**
|
||||
* Constructs object ready to create course.
|
||||
*
|
||||
* @param string $shortname Course shortname
|
||||
* @param int $size Size as numeric index
|
||||
* @param bool $fixeddataset To use fixed or random data
|
||||
* @param int|bool $filesizelimit The max number of bytes for a generated file
|
||||
* @param bool $progress True if progress information should be displayed
|
||||
*/
|
||||
public function __construct($shortname, $size, $fixeddataset = false, $filesizelimit = false, $progress = true) {
|
||||
|
||||
// Set parameters.
|
||||
$this->shortname = $shortname;
|
||||
|
||||
parent::__construct($size, $fixeddataset, $filesizelimit, $progress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relation between users and course sizes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_users_per_size() {
|
||||
return self::$paramusers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of size choices supported by this backend.
|
||||
*
|
||||
* @return array List of size (int) => text description for display
|
||||
*/
|
||||
public static function get_size_choices() {
|
||||
$options = array();
|
||||
for ($size = self::MIN_SIZE; $size <= self::MAX_SIZE; $size++) {
|
||||
$options[$size] = get_string('coursesize_' . $size, 'tool_generator');
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a shortname is available (unused).
|
||||
*
|
||||
* @param string $shortname Proposed course shortname
|
||||
* @return string An error message if the name is unavailable or '' if OK
|
||||
*/
|
||||
public static function check_shortname_available($shortname) {
|
||||
global $DB;
|
||||
$fullname = $DB->get_field('course', 'fullname',
|
||||
array('shortname' => $shortname), IGNORE_MISSING);
|
||||
if ($fullname !== false) {
|
||||
// I wanted to throw an exception here but it is not possible to
|
||||
// use strings from moodle.php in exceptions, and I didn't want
|
||||
// to duplicate the string in tool_generator, so I changed this to
|
||||
// not use exceptions.
|
||||
return get_string('shortnametaken', 'moodle', $fullname);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the entire 'make' process.
|
||||
*
|
||||
* @return int Course id
|
||||
*/
|
||||
public function make() {
|
||||
global $DB, $CFG;
|
||||
require_once($CFG->dirroot . '/lib/phpunit/classes/util.php');
|
||||
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
if ($this->progress && !CLI_SCRIPT) {
|
||||
echo html_writer::start_tag('ul');
|
||||
}
|
||||
|
||||
$entirestart = microtime(true);
|
||||
|
||||
// Start transaction.
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
// Get generator.
|
||||
$this->generator = phpunit_util::get_data_generator();
|
||||
|
||||
// Make course.
|
||||
$this->course = $this->create_course();
|
||||
$this->create_users();
|
||||
$this->create_pages();
|
||||
$this->create_small_files();
|
||||
$this->create_big_files();
|
||||
$this->create_forum();
|
||||
|
||||
// Log total time.
|
||||
$this->log('coursecompleted', round(microtime(true) - $entirestart, 1));
|
||||
|
||||
if ($this->progress && !CLI_SCRIPT) {
|
||||
echo html_writer::end_tag('ul');
|
||||
}
|
||||
|
||||
// Commit transaction and finish.
|
||||
$transaction->allow_commit();
|
||||
return $this->course->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the actual course.
|
||||
*
|
||||
* @return stdClass Course record
|
||||
*/
|
||||
private function create_course() {
|
||||
$this->log('createcourse', $this->shortname);
|
||||
$courserecord = array('shortname' => $this->shortname,
|
||||
'fullname' => get_string('fullname', 'tool_generator',
|
||||
array('size' => get_string('shortsize_' . $this->size, 'tool_generator'))),
|
||||
'numsections' => self::$paramsections[$this->size]);
|
||||
return $this->generator->create_course($courserecord, array('createsections' => true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a number of user accounts and enrols them on the course.
|
||||
* Note: Existing user accounts that were created by this system are
|
||||
* reused if available.
|
||||
*/
|
||||
private function create_users() {
|
||||
global $DB;
|
||||
|
||||
// Work out total number of users.
|
||||
$count = self::$paramusers[$this->size];
|
||||
|
||||
// Get existing users in order. We will 'fill up holes' in this up to
|
||||
// the required number.
|
||||
$this->log('checkaccounts', $count);
|
||||
$nextnumber = 1;
|
||||
$rs = $DB->get_recordset_select('user', $DB->sql_like('username', '?'),
|
||||
array('tool_generator_%'), 'username', 'id, username');
|
||||
foreach ($rs as $rec) {
|
||||
// Extract number from username.
|
||||
$matches = array();
|
||||
if (!preg_match('~^tool_generator_([0-9]{6})$~', $rec->username, $matches)) {
|
||||
continue;
|
||||
}
|
||||
$number = (int)$matches[1];
|
||||
|
||||
// Create missing users in range up to this.
|
||||
if ($number != $nextnumber) {
|
||||
$this->create_user_accounts($nextnumber, min($number - 1, $count));
|
||||
} else {
|
||||
$this->userids[$number] = (int)$rec->id;
|
||||
}
|
||||
|
||||
// Stop if we've got enough users.
|
||||
$nextnumber = $number + 1;
|
||||
if ($number >= $count) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
// Create users from end of existing range.
|
||||
if ($nextnumber <= $count) {
|
||||
$this->create_user_accounts($nextnumber, $count);
|
||||
}
|
||||
|
||||
// Assign all users to course.
|
||||
$this->log('enrol', $count, true);
|
||||
|
||||
$enrolplugin = enrol_get_plugin('manual');
|
||||
$instances = enrol_get_instances($this->course->id, true);
|
||||
foreach ($instances as $instance) {
|
||||
if ($instance->enrol === 'manual') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($instance->enrol !== 'manual') {
|
||||
throw new coding_exception('No manual enrol plugin in course');
|
||||
}
|
||||
$role = $DB->get_record('role', array('shortname' => 'student'), '*', MUST_EXIST);
|
||||
|
||||
for ($number = 1; $number <= $count; $number++) {
|
||||
// Enrol user.
|
||||
$enrolplugin->enrol_user($instance, $this->userids[$number], $role->id);
|
||||
$this->dot($number, $count);
|
||||
}
|
||||
|
||||
// Sets the pointer at the beginning to be aware of the users we use.
|
||||
reset($this->userids);
|
||||
|
||||
$this->end_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates user accounts with a numeric range.
|
||||
*
|
||||
* @param int $first Number of first user
|
||||
* @param int $last Number of last user
|
||||
*/
|
||||
private function create_user_accounts($first, $last) {
|
||||
global $CFG;
|
||||
|
||||
$this->log('createaccounts', (object)array('from' => $first, 'to' => $last), true);
|
||||
$count = $last - $first + 1;
|
||||
$done = 0;
|
||||
for ($number = $first; $number <= $last; $number++, $done++) {
|
||||
// Work out username with 6-digit number.
|
||||
$textnumber = (string)$number;
|
||||
while (strlen($textnumber) < 6) {
|
||||
$textnumber = '0' . $textnumber;
|
||||
}
|
||||
$username = 'tool_generator_' . $textnumber;
|
||||
|
||||
// Create user account.
|
||||
$record = array('firstname' => get_string('firstname', 'tool_generator'),
|
||||
'lastname' => $number, 'username' => $username);
|
||||
|
||||
// We add a user password if it has been specified.
|
||||
if (!empty($CFG->tool_generator_users_password)) {
|
||||
$record['password'] = $CFG->tool_generator_users_password;
|
||||
}
|
||||
|
||||
$user = $this->generator->create_user($record);
|
||||
$this->userids[$number] = (int)$user->id;
|
||||
$this->dot($done, $count);
|
||||
}
|
||||
$this->end_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a number of Page activities.
|
||||
*/
|
||||
private function create_pages() {
|
||||
// Set up generator.
|
||||
$pagegenerator = $this->generator->get_plugin_generator('mod_page');
|
||||
|
||||
// Create pages.
|
||||
$number = self::$parampages[$this->size];
|
||||
$this->log('createpages', $number, true);
|
||||
for ($i = 0; $i < $number; $i++) {
|
||||
$record = array('course' => $this->course->id);
|
||||
$options = array('section' => $this->get_target_section());
|
||||
$pagegenerator->create_instance($record, $options);
|
||||
$this->dot($i, $number);
|
||||
}
|
||||
|
||||
$this->end_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates one resource activity with a lot of small files.
|
||||
*/
|
||||
private function create_small_files() {
|
||||
$count = self::$paramsmallfilecount[$this->size];
|
||||
$this->log('createsmallfiles', $count, true);
|
||||
|
||||
// Create resource with default textfile only.
|
||||
$resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
|
||||
$record = array('course' => $this->course->id,
|
||||
'name' => get_string('smallfiles', 'tool_generator'));
|
||||
$options = array('section' => 0);
|
||||
$resource = $resourcegenerator->create_instance($record, $options);
|
||||
|
||||
// Add files.
|
||||
$fs = get_file_storage();
|
||||
$context = context_module::instance($resource->cmid);
|
||||
$filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
|
||||
'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/');
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$filerecord['filename'] = 'smallfile' . $i . '.dat';
|
||||
|
||||
// Generate random binary data (different for each file so it
|
||||
// doesn't compress unrealistically).
|
||||
$data = self::get_random_binary($this->limit_filesize(self::$paramsmallfilesize[$this->size]));
|
||||
|
||||
$fs->create_file_from_string($filerecord, $data);
|
||||
$this->dot($i, $count);
|
||||
}
|
||||
|
||||
$this->end_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a string of random binary data. The start of the string includes
|
||||
* the current time, in an attempt to avoid large-scale repetition.
|
||||
*
|
||||
* @param int $length Number of bytes
|
||||
* @return Random data
|
||||
*/
|
||||
private static function get_random_binary($length) {
|
||||
|
||||
$data = microtime(true);
|
||||
if (strlen($data) > $length) {
|
||||
// Use last digits of data.
|
||||
return substr($data, -$length);
|
||||
}
|
||||
$length -= strlen($data);
|
||||
for ($j = 0; $j < $length; $j++) {
|
||||
$data .= chr(rand(1, 255));
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a number of resource activities with one big file each.
|
||||
*/
|
||||
private function create_big_files() {
|
||||
global $CFG;
|
||||
|
||||
// Work out how many files and how many blocks to use (up to 64KB).
|
||||
$count = self::$parambigfilecount[$this->size];
|
||||
$filesize = $this->limit_filesize(self::$parambigfilesize[$this->size]);
|
||||
$blocks = ceil($filesize / 65536);
|
||||
$blocksize = floor($filesize / $blocks);
|
||||
|
||||
$this->log('createbigfiles', $count, true);
|
||||
|
||||
// Prepare temp area.
|
||||
$tempfolder = make_temp_directory('tool_generator');
|
||||
$tempfile = $tempfolder . '/' . rand();
|
||||
|
||||
// Create resources and files.
|
||||
$fs = get_file_storage();
|
||||
$resourcegenerator = $this->generator->get_plugin_generator('mod_resource');
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
// Create resource.
|
||||
$record = array('course' => $this->course->id,
|
||||
'name' => get_string('bigfile', 'tool_generator', $i));
|
||||
$options = array('section' => $this->get_target_section());
|
||||
$resource = $resourcegenerator->create_instance($record, $options);
|
||||
|
||||
// Write file.
|
||||
$handle = fopen($tempfile, 'w');
|
||||
if (!$handle) {
|
||||
throw new coding_exception('Failed to open temporary file');
|
||||
}
|
||||
for ($j = 0; $j < $blocks; $j++) {
|
||||
$data = self::get_random_binary($blocksize);
|
||||
fwrite($handle, $data);
|
||||
$this->dot($i * $blocks + $j, $count * $blocks);
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
// Add file.
|
||||
$context = context_module::instance($resource->cmid);
|
||||
$filerecord = array('component' => 'mod_resource', 'filearea' => 'content',
|
||||
'contextid' => $context->id, 'itemid' => 0, 'filepath' => '/',
|
||||
'filename' => 'bigfile' . $i . '.dat');
|
||||
$fs->create_file_from_pathname($filerecord, $tempfile);
|
||||
}
|
||||
|
||||
unlink($tempfile);
|
||||
$this->end_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates one forum activity with a bunch of posts.
|
||||
*/
|
||||
private function create_forum() {
|
||||
global $DB;
|
||||
|
||||
$discussions = self::$paramforumdiscussions[$this->size];
|
||||
$posts = self::$paramforumposts[$this->size];
|
||||
$totalposts = $discussions * $posts;
|
||||
|
||||
$this->log('createforum', $totalposts, true);
|
||||
|
||||
// Create empty forum.
|
||||
$forumgenerator = $this->generator->get_plugin_generator('mod_forum');
|
||||
$record = array('course' => $this->course->id,
|
||||
'name' => get_string('pluginname', 'forum'));
|
||||
$options = array('section' => 0);
|
||||
$forum = $forumgenerator->create_instance($record, $options);
|
||||
|
||||
// Add discussions and posts.
|
||||
$sofar = 0;
|
||||
for ($i = 0; $i < $discussions; $i++) {
|
||||
$record = array('forum' => $forum->id, 'course' => $this->course->id,
|
||||
'userid' => $this->get_target_user());
|
||||
$discussion = $forumgenerator->create_discussion($record);
|
||||
$parentid = $DB->get_field('forum_posts', 'id', array('discussion' => $discussion->id), MUST_EXIST);
|
||||
$sofar++;
|
||||
for ($j = 0; $j < $posts - 1; $j++, $sofar++) {
|
||||
$record = array('discussion' => $discussion->id,
|
||||
'userid' => $this->get_target_user(), 'parent' => $parentid);
|
||||
$forumgenerator->create_post($record);
|
||||
$this->dot($sofar, $totalposts);
|
||||
}
|
||||
}
|
||||
|
||||
$this->end_log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a section number.
|
||||
*
|
||||
* Depends on $this->fixeddataset.
|
||||
*
|
||||
* @return int A section number from 1 to the number of sections
|
||||
*/
|
||||
private function get_target_section() {
|
||||
|
||||
if (!$this->fixeddataset) {
|
||||
$key = rand(1, self::$paramsections[$this->size]);
|
||||
} else {
|
||||
// Using section 1.
|
||||
$key = 1;
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a user id.
|
||||
*
|
||||
* Depends on $this->fixeddataset.
|
||||
*
|
||||
* @return int A user id for a random created user
|
||||
*/
|
||||
private function get_target_user() {
|
||||
|
||||
if (!$this->fixeddataset) {
|
||||
$userid = $this->userids[rand(1, self::$paramusers[$this->size])];
|
||||
} else if ($userid = current($this->userids)) {
|
||||
// Moving pointer to the next user.
|
||||
next($this->userids);
|
||||
} else {
|
||||
// Returning to the beginning if we reached the end.
|
||||
$userid = reset($this->userids);
|
||||
}
|
||||
|
||||
return $userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restricts the binary file size if necessary
|
||||
*
|
||||
* @param int $length The total length
|
||||
* @return int The limited length if a limit was specified.
|
||||
*/
|
||||
private function limit_filesize($length) {
|
||||
|
||||
// Limit to $this->filesizelimit.
|
||||
if (is_numeric($this->filesizelimit) && $length > $this->filesizelimit) {
|
||||
$length = floor($this->filesizelimit);
|
||||
}
|
||||
|
||||
return $length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +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/>.
|
||||
|
||||
/**
|
||||
* Course form.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/generator/classes/course_backend.php');
|
||||
|
||||
/**
|
||||
* Form with options for creating large course.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_generator_make_course_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Course generation tool form definition.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('select', 'size', get_string('size', 'tool_generator'),
|
||||
tool_generator_course_backend::get_size_choices());
|
||||
$mform->setDefault('size', tool_generator_course_backend::DEFAULT_SIZE);
|
||||
|
||||
$mform->addElement('text', 'shortname', get_string('shortnamecourse'));
|
||||
$mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client');
|
||||
$mform->setType('shortname', PARAM_TEXT);
|
||||
|
||||
$mform->addElement('submit', 'submit', get_string('createcourse', 'tool_generator'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $files
|
||||
* @return void
|
||||
*/
|
||||
public function validation($data, $files) {
|
||||
global $DB;
|
||||
$errors = array();
|
||||
|
||||
// Check course doesn't already exist.
|
||||
if (!empty($data['shortname'])) {
|
||||
// Check shortname.
|
||||
$error = tool_generator_course_backend::check_shortname_available($data['shortname']);
|
||||
if ($error) {
|
||||
$errors['shortname'] = $error;
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
|
||||
/**
|
||||
* Test plan form.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/generator/classes/testplan_backend.php');
|
||||
require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/generator/classes/course_backend.php');
|
||||
|
||||
/**
|
||||
* Form with options for creating large course.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_generator_make_testplan_form extends moodleform {
|
||||
|
||||
/**
|
||||
* Test plan form definition.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('select', 'size', get_string('size', 'tool_generator'),
|
||||
tool_generator_testplan_backend::get_size_choices());
|
||||
$mform->setDefault('size', tool_generator_testplan_backend::DEFAULT_SIZE);
|
||||
|
||||
$mform->addElement('select', 'courseid', get_string('targetcourse', 'tool_generator'),
|
||||
tool_generator_testplan_backend::get_course_options());
|
||||
|
||||
$mform->addElement('advcheckbox', 'updateuserspassword', get_string('updateuserspassword', 'tool_generator'));
|
||||
$mform->addHelpButton('updateuserspassword', 'updateuserspassword', 'tool_generator');
|
||||
|
||||
$mform->addElement('submit', 'submit', get_string('createtestplan', 'tool_generator'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the submitted data allows us to create a test plan.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $files
|
||||
* @return array An array of errors
|
||||
*/
|
||||
public function validation($data, $files) {
|
||||
global $CFG;
|
||||
|
||||
$errors = array();
|
||||
if (empty($CFG->tool_generator_users_password) || is_bool($CFG->tool_generator_users_password)) {
|
||||
$errors['updateuserspassword'] = get_string('error_nouserspassword', 'tool_generator');
|
||||
}
|
||||
|
||||
// Better to repeat here the query than to do it afterwards and end up with an exception.
|
||||
if ($courseerrors = tool_generator_testplan_backend::has_selected_course_any_problem($data['courseid'], $data['size'])) {
|
||||
$errors = array_merge($errors, $courseerrors);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,214 +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/>.
|
||||
|
||||
/**
|
||||
* tool_generator site backend.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(__DIR__ . '/backend.php');
|
||||
|
||||
/**
|
||||
* Backend code for the site generator.
|
||||
*
|
||||
* @package tool_generator
|
||||
* @copyright 2013 David Monllaó
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_generator_site_backend extends tool_generator_backend {
|
||||
|
||||
/**
|
||||
* @var string The course's shortname prefix.
|
||||
*/
|
||||
const SHORTNAMEPREFIX = 'testcourse_';
|
||||
|
||||
/**
|
||||
* @var bool If the debugging level checking was skipped.
|
||||
*/
|
||||
protected $bypasscheck;
|
||||
|
||||
/**
|
||||
* @var array Multidimensional array where the first level is the course size and the second the site size.
|
||||
*/
|
||||
protected static $sitecourses = array(
|
||||
array(2, 8, 64, 256, 1024, 4096),
|
||||
array(1, 4, 8, 16, 32, 64),
|
||||
array(0, 0, 1, 4, 8, 16),
|
||||
array(0, 0, 0, 1, 0, 0),
|
||||
array(0, 0, 0, 0, 1, 0),
|
||||
array(0, 0, 0, 0, 0, 1)
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructs object ready to make the site.
|
||||
*
|
||||
* @param int $size Size as numeric index
|
||||
* @param bool $bypasscheck If debugging level checking was skipped.
|
||||
* @param bool $fixeddataset To use fixed or random data
|
||||
* @param int|bool $filesizelimit The max number of bytes for a generated file
|
||||
* @param bool $progress True if progress information should be displayed
|
||||
* @return int Course id
|
||||
*/
|
||||
public function __construct($size, $bypasscheck, $fixeddataset = false, $filesizelimit = false, $progress = true) {
|
||||
|
||||
// Set parameters.
|
||||
$this->bypasscheck = $bypasscheck;
|
||||
|
||||
parent::__construct($size, $fixeddataset, $filesizelimit, $progress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of size choices supported by this backend.
|
||||
*
|
||||
* @return array List of size (int) => text description for display
|
||||
*/
|
||||
public static function get_size_choices() {
|
||||
$options = array();
|
||||
for ($size = self::MIN_SIZE; $size <= self::MAX_SIZE; $size++) {
|
||||
$options[$size] = get_string('sitesize_' . $size, 'tool_generator');
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the entire 'make' process.
|
||||
*
|
||||
* @return int Course id
|
||||
*/
|
||||
public function make() {
|
||||
global $DB, $CFG;
|
||||
|
||||
raise_memory_limit(MEMORY_EXTRA);
|
||||
|
||||
if ($this->progress && !CLI_SCRIPT) {
|
||||
echo html_writer::start_tag('ul');
|
||||
}
|
||||
|
||||
$entirestart = microtime(true);
|
||||
|
||||
// Create courses.
|
||||
$prevchdir = getcwd();
|
||||
chdir($CFG->dirroot);
|
||||
$ncourse = self::get_last_testcourse_id();
|
||||
foreach (self::$sitecourses as $coursesize => $ncourses) {
|
||||
for ($i = 1; $i <= $ncourses[$this->size]; $i++) {
|
||||
// Non language-dependant shortname.
|
||||
$ncourse++;
|
||||
$this->run_create_course(self::SHORTNAMEPREFIX . $ncourse, $coursesize);
|
||||
}
|
||||
}
|
||||
chdir($prevchdir);
|
||||
|
||||
// Store last course id to return it (will be the bigger one).
|
||||
$lastcourseid = $DB->get_field('course', 'id', array('shortname' => self::SHORTNAMEPREFIX . $ncourse));
|
||||
|
||||
// Log total time.
|
||||
$this->log('sitecompleted', round(microtime(true) - $entirestart, 1));
|
||||
|
||||
if ($this->progress && !CLI_SCRIPT) {
|
||||
echo html_writer::end_tag('ul');
|
||||
}
|
||||
|
||||
return $lastcourseid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a course with the specified shortname, coursesize and the provided maketestsite options.
|
||||
*
|
||||
* @param string $shortname The course shortname
|
||||
* @param int $coursesize One of the possible course sizes.
|
||||
* @return void
|
||||
*/
|
||||
protected function run_create_course($shortname, $coursesize) {
|
||||
|
||||
// We are in $CFG->dirroot.
|
||||
$command = 'php admin/tool/generator/cli/maketestcourse.php';
|
||||
|
||||
$options = array(
|
||||
'--shortname="' . $shortname . '"',
|
||||
'--size="' . get_string('shortsize_' . $coursesize, 'tool_generator') . '"'
|
||||
);
|
||||
|
||||
if (!$this->progress) {
|
||||
$options[] = '--quiet';
|
||||
}
|
||||
|
||||
// Extend options.
|
||||
$optionstoextend = array(
|
||||
'fixeddataset' => 'fixeddataset',
|
||||
'bypasscheck' => 'bypasscheck',
|
||||
);
|
||||
|
||||
if ($this->filesizelimit) {
|
||||
$options[] = '--filesizelimit="' . $this->filesizelimit . '"';
|
||||
}
|
||||
|
||||
// Getting an options string.
|
||||
foreach ($optionstoextend as $attribute => $option) {
|
||||
if (!empty($this->{$attribute})) {
|
||||
$options[] = '--' . $option;
|
||||
}
|
||||
}
|
||||
$options = implode(' ', $options);
|
||||
if ($this->progress) {
|
||||
system($command . ' ' . $options, $exitcode);
|
||||
} else {
|
||||
passthru($command . ' ' . $options, $exitcode);
|
||||
}
|
||||
|
||||
if ($exitcode != 0) {
|
||||
exit($exitcode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the last unique sufix (numeric) using the test course prefix.
|
||||
*
|
||||
* @return int The last generated numeric value.
|
||||
*/
|
||||
protected static function get_last_testcourse_id() {
|
||||
global $DB;
|
||||
|
||||
$params = array();
|
||||
$params['shortnameprefix'] = $DB->sql_like_escape(self::SHORTNAMEPREFIX) . '%';
|
||||
$like = $DB->sql_like('shortname', ':shortnameprefix');
|
||||
|
||||
if (!$testcourses = $DB->get_records_select('course', $like, $params, '', 'shortname')) {
|
||||
return 0;
|
||||
}
|
||||
// SQL order by is not appropiate here as is ordering strings.
|
||||
$shortnames = array_keys($testcourses);
|
||||
collatorlib::asort($shortnames, collatorlib::SORT_NATURAL);
|
||||
$shortnames = array_reverse($shortnames);
|
||||
|
||||
// They come ordered by shortname DESC, so non-numeric values will be the first ones.
|
||||
$prefixnchars = strlen(self::SHORTNAMEPREFIX);
|
||||
foreach ($shortnames as $shortname) {
|
||||
$sufix = substr($shortname, $prefixnchars);
|
||||
if (preg_match('/^[\d]+$/', $sufix)) {
|
||||
return $sufix;
|
||||
}
|
||||
}
|
||||
// If all sufixes are not numeric this is the first make test site run.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user