Skip to content

Commit

Permalink
Replace optional and required_param by new \core\param equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Mar 22, 2024
1 parent 5c86a7c commit 7b82919
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion activeprocesses.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// Cache handling.
$cachekey = 'activeprocesses_filter';
$cache = cache::make('tool_lifecycle', 'mformdata');
if ($search = optional_param('search', null, PARAM_RAW)) {
if ($search = \core\param::RAW->optional_param('search', null)) {
$obj = new stdClass();
$obj->fullname = $search;
$obj->courseid = null;
Expand Down
4 changes: 2 additions & 2 deletions activeworkflows.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

$PAGE->set_url(new \moodle_url(urls::ACTIVE_WORKFLOWS));

$action = optional_param('action', null, PARAM_TEXT);
$action = \core\param::TEXT->optional_param('action', null);
if ($action) {
$wfid = required_param('workflowid', PARAM_INT);
$wfid = \core\param::INT->required_param('workflowid');
\tool_lifecycle\local\manager\workflow_manager::handle_action($action, $wfid);
redirect($PAGE->url);
}
Expand Down
2 changes: 1 addition & 1 deletion createworkflowfromexisting.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

global $OUTPUT, $PAGE, $DB;

$workflowid = optional_param('wf', null, PARAM_INT);
$workflowid = \core\param::INT->optional_param('wf', null);

\tool_lifecycle\permission_and_navigation::setup_draft();

Expand Down
4 changes: 2 additions & 2 deletions deactivatedworkflows.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
$PAGE->set_title(get_string('deactivated_workflows_list_header', 'tool_lifecycle'));
$PAGE->set_heading(get_string('deactivated_workflows_list_header', 'tool_lifecycle'));

$workflowid = optional_param('workflowid', null, PARAM_INT);
$action = optional_param('action', null, PARAM_TEXT);
$workflowid = \core\param::INT->optional_param('workflowid', null);
$action = \core\param::TEXT->optional_param('action', null);
if ($workflowid && $action) {
\tool_lifecycle\local\manager\workflow_manager::handle_action($action, $workflowid);
}
Expand Down
12 changes: 6 additions & 6 deletions delayedcourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
admin_externalpage_setup('tool_lifecycle_delayed_courses');

// Action handling (delete, bulk-delete).
$action = optional_param('action', null, PARAM_ALPHANUMEXT);
$action = \core\param::ALPHANUMEXT->optional_param('action', null);
if ($action) {
global $DB;
require_sesskey();
if ($action == 'delete') {
$cid = required_param('cid', PARAM_INT);
$workflow = optional_param('workflow', null, PARAM_ALPHANUM);
$cid = \core\param::INT->required_param('cid');
$workflow = \core\param::ALPHANUM->optional_param('workflow', null);
if ($workflow) {
if (is_number($workflow)) {
$DB->delete_records('tool_lifecycle_delayed_workf', ['courseid' => $cid, 'workflowid' => $workflow]);
Expand All @@ -55,7 +55,7 @@
$DB->delete_records('tool_lifecycle_delayed_workf', ['courseid' => $cid]);
}
} else if ($action == 'bulk-delete') {
$workflow = optional_param('workflow', null, PARAM_ALPHANUM);
$workflow = \core\param::ALPHANUM->optional_param('workflow', null);
$deleteglobal = true;
$deleteseperate = true;
$workflowfilterid = null;
Expand All @@ -70,8 +70,8 @@
}
}

$coursename = optional_param('coursename', null, PARAM_TEXT);
$categoryid = optional_param('catid', null, PARAM_INT);
$coursename = \core\param::TEXT->optional_param('coursename', null);
$categoryid = \core\param::INT->optional_param('catid', null);

$params = [];
$whereforcourse = [];
Expand Down
2 changes: 1 addition & 1 deletion downloadbackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
require_login();
require_capability('moodle/site:config', context_system::instance());

$backupid = required_param('backupid', PARAM_INT);
$backupid = \core\param::INT->required_param('backupid');

$backuprecord = $DB->get_record('tool_lifecycle_backups', ['id' => $backupid], 'backupfile', MUST_EXIST);
$source = get_config('tool_lifecycle', 'backup_path') . DIRECTORY_SEPARATOR . $backuprecord->backupfile;
Expand Down
8 changes: 4 additions & 4 deletions editelement.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@

global $OUTPUT, $PAGE, $DB;

$type = required_param('type', PARAM_ALPHA);
$elementid = optional_param('elementid', null, PARAM_INT);
$type = \core\param::ALPHA->required_param('type');
$elementid = \core\param::INT->optional_param('elementid', null);

if ($type === settings_type::STEP) {
$isstep = true;
Expand All @@ -62,8 +62,8 @@
$workflowid = $element->workflowid;
$subplugin = $element->subpluginname;
} else {
$workflowid = required_param('wf', PARAM_INT);
$subplugin = required_param('subplugin', PARAM_ALPHANUMEXT);
$workflowid = \core\param::INT->required_param('wf');
$subplugin = \core\param::ALPHANUMEXT->required_param('subplugin');
$element = null;
}

Expand Down
2 changes: 1 addition & 1 deletion editworkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

global $OUTPUT, $PAGE, $DB;

$workflowid = optional_param('wf', null, PARAM_INT);
$workflowid = \core\param::INT->optional_param('wf', null);

if ($workflowid) {
$workflow = workflow_manager::get_workflow($workflowid);
Expand Down
2 changes: 1 addition & 1 deletion errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$PAGE->set_url(new \moodle_url('/admin/tool/lifecycle/errors.php'));

// Action handling (delete, bulk-delete).
$action = optional_param('action', null, PARAM_ALPHANUMEXT);
$action = \core\param::ALPHANUMEXT->optional_param('action', null);
if ($action) {
global $DB;
require_sesskey();
Expand Down
2 changes: 1 addition & 1 deletion restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
require_login(null, false);
require_capability('moodle/site:config', context_system::instance());

$backupid = required_param('backupid', PARAM_INT);
$backupid = \core\param::INT->required_param('backupid');

backup_manager::restore_course_backup($backupid);
10 changes: 5 additions & 5 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
$PAGE->url);

// Interaction params.
$action = optional_param('action', null, PARAM_ALPHA);
$processid = optional_param('processid', null, PARAM_INT);
$stepid = optional_param('stepid', null, PARAM_INT);
$action = \core\param::ALPHA->optional_param('action', null);
$processid = \core\param::INT->optional_param('processid', null);
$stepid = \core\param::INT->optional_param('stepid', null);

// Manual trigger params.
$triggerid = optional_param('triggerid', null, PARAM_INT);
$courseid = optional_param('courseid', null, PARAM_INT);
$triggerid = \core\param::INT->optional_param('triggerid', null);
$courseid = \core\param::INT->optional_param('courseid', null);

$PAGE->set_title(get_string('viewheading', 'tool_lifecycle'));
$PAGE->set_heading(get_string('viewheading', 'tool_lifecycle'));
Expand Down
4 changes: 2 additions & 2 deletions workflowdrafts.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

$PAGE->set_url(new \moodle_url(urls::WORKFLOW_DRAFTS));

$action = optional_param('action', null, PARAM_TEXT);
$action = \core\param::TEXT->optional_param('action', null);
if ($action) {
$wfid = required_param('workflowid', PARAM_INT);
$wfid = \core\param::INT->required_param('workflowid');
\tool_lifecycle\local\manager\workflow_manager::handle_action($action, $wfid);
redirect($PAGE->url);
}
Expand Down
14 changes: 7 additions & 7 deletions workflowoverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@

global $OUTPUT, $PAGE, $DB;

$workflowid = required_param('wf', PARAM_INT);
$workflowid = \core\param::INT->required_param('wf');

$workflow = \tool_lifecycle\local\manager\workflow_manager::get_workflow($workflowid);
\tool_lifecycle\permission_and_navigation::setup_workflow($workflow);

$iseditable = workflow_manager::is_editable($workflow->id);

$stepid = optional_param('step', null, PARAM_INT);
$stepid = \core\param::INT->optional_param('step', null);

$params = ['wf' => $workflow->id];
$nosteplink = new moodle_url(urls::WORKFLOW_DETAILS, $params);
Expand All @@ -54,12 +54,12 @@
$PAGE->set_title($workflow->title);
$PAGE->set_heading($workflow->title);

$action = optional_param('action', null, PARAM_TEXT);
$action = \core\param::TEXT->optional_param('action', null);

if ($action) {
step_manager::handle_action($action, optional_param('actionstep', null, PARAM_INT), $workflow->id);
trigger_manager::handle_action($action, optional_param('actiontrigger', null, PARAM_INT), $workflow->id);
$processid = optional_param('processid', null, PARAM_INT);
step_manager::handle_action($action, \core\param::INT->optional_param('actionstep', null), $workflow->id);
trigger_manager::handle_action($action, \core\param::INT->optional_param('actiontrigger', null), $workflow->id);
$processid = \core\param::INT->optional_param('processid', null);
if ($processid) {
$process = \tool_lifecycle\local\manager\process_manager::get_process_by_id($processid);
if ($action === 'rollback') {
Expand Down Expand Up @@ -175,7 +175,7 @@
if ($stepid) {
$step = step_manager::get_step_instance($stepid);
$table = new \tool_lifecycle\local\table\courses_in_step_table($step,
optional_param('courseid', null, PARAM_INT));
\core\param::INT->optional_param('courseid', null));
ob_start();
$table->out(20, false);
$out = ob_get_contents();
Expand Down

0 comments on commit 7b82919

Please sign in to comment.