Skip to content

Commit

Permalink
Merge pull request #26 from catalyst/issue19
Browse files Browse the repository at this point in the history
Issue #19: Removed as much _GET use as possible
  • Loading branch information
Peterburnett authored Mar 6, 2020
2 parents bc656f4 + aa443cc commit 7e6271b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function tool_abconfig_after_config() {
$manager = new tool_abconfig_experiment_manager();

// Check if the param to disable ABconfig is present, if so, exit.
if (array_key_exists('abconfig', $_GET) && $_GET['abconfig'] == 'off') {
if (!optional_param('abconfig', true, PARAM_BOOL)) {
if (is_siteadmin()) {
return null;
}
Expand All @@ -42,6 +42,9 @@ function tool_abconfig_after_config() {
$experiments = $manager->get_experiments();
// Check URL params, and fire any experiments in the params.
foreach ($_GET as $experiment => $condition) {
// Experiments and conditions should be cleaned as text.
$experiment = clean_param($experiment, PARAM_TEXT);
$condition = clean_param($condition, PARAM_TEXT);
// First, only admins can fire additional experiments.
if (!is_siteadmin()) {
break;
Expand Down Expand Up @@ -131,7 +134,7 @@ function tool_abconfig_after_require_login() {
$manager = new tool_abconfig_experiment_manager();

// Check if the param to disable ABconfig is present, if so, exit.
if (array_key_exists('abconfig', $_GET) && $_GET['abconfig'] == 'off') {
if (optional_param('abconfig', null, PARAM_TEXT) == 'off') {
if (is_siteadmin()) {
return null;
}
Expand Down Expand Up @@ -269,7 +272,7 @@ function tool_abconfig_execute_command_array($commandsencoded, $shortname, $js =

function tool_abconfig_execute_js($type) {
// Check if the param to disable ABconfig is present, if so, exit.
if (array_key_exists('abconfig', $_GET) && $_GET['abconfig'] == 'off') {
if (optional_param('abconfig', null, PARAM_TEXT) == 'off') {
if (is_siteadmin()) {
return null;
}
Expand Down
5 changes: 2 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2019122000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2019122000; // Same as version.
$plugin->version = 2020030600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2020030600; // Same as version.
$plugin->requires = 2014051217;
$plugin->component = "tool_abconfig";
$plugin->maturity = MATURITY_STABLE;

0 comments on commit 7e6271b

Please sign in to comment.