diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 4e2026f2..18b9a7ec 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -8,8 +8,8 @@ jobs: strategy: matrix: - php: ['8.1'] - moodle-branch: ['MOODLE_402_STABLE'] + php: ['8.2'] + moodle-branch: ['MOODLE_403_STABLE'] database: ['pgsql'] steps: @@ -107,9 +107,12 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0', '8.1'] - moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE'] + php: ['8.0', '8.1', '8.2'] + moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE'] database: ['mariadb', 'pgsql'] + exclude: + - php: '8.2' + moodle-branch: 'MOODLE_401_STABLE' include: - php: '7.4' moodle-branch: 'MOODLE_39_STABLE' diff --git a/activeworkflows.php b/activeworkflows.php index 9ce9c0a2..aca0133d 100644 --- a/activeworkflows.php +++ b/activeworkflows.php @@ -56,7 +56,7 @@ 'inputname' => 'search', 'extraclasses' => 'mb-3', 'inform' => false, - 'searchstring' => 'Search for courses' + 'searchstring' => 'Search for courses', ]); echo $OUTPUT->heading(get_string('active_automatic_workflows_heading', 'tool_lifecycle')); diff --git a/classes/event/process_proceeded.php b/classes/event/process_proceeded.php index c3c9ac93..5aada6de 100644 --- a/classes/event/process_proceeded.php +++ b/classes/event/process_proceeded.php @@ -53,15 +53,15 @@ class process_proceeded extends \core\event\base { * @throws \dml_exception */ public static function event_from_process($process) { - $data = array( + $data = [ 'context' => \context_system::instance(), - 'other' => array( + 'other' => [ 'processid' => $process->id, 'workflowid' => $process->workflowid, 'stepindex' => $process->stepindex, - 'courseid' => $process->courseid - ) - ); + 'courseid' => $process->courseid, + ], + ]; return self::create($data); } diff --git a/classes/event/process_rollback.php b/classes/event/process_rollback.php index 5fadca09..cafc1031 100644 --- a/classes/event/process_rollback.php +++ b/classes/event/process_rollback.php @@ -53,15 +53,15 @@ class process_rollback extends \core\event\base { * @throws \dml_exception */ public static function event_from_process($process) { - $data = array( + $data = [ 'context' => \context_system::instance(), - 'other' => array( + 'other' => [ 'processid' => $process->id, 'workflowid' => $process->workflowid, 'stepindex' => $process->stepindex, - 'courseid' => $process->courseid - ) - ); + 'courseid' => $process->courseid, + ], + ]; return self::create($data); } diff --git a/classes/event/process_triggered.php b/classes/event/process_triggered.php index 0648b501..a71507ad 100644 --- a/classes/event/process_triggered.php +++ b/classes/event/process_triggered.php @@ -52,14 +52,14 @@ class process_triggered extends \core\event\base { * @throws \dml_exception */ public static function event_from_process($process) { - $data = array( + $data = [ 'context' => \context_system::instance(), - 'other' => array( + 'other' => [ 'processid' => $process->id, 'workflowid' => $process->workflowid, - 'courseid' => $process->courseid - ) - ); + 'courseid' => $process->courseid, + ], + ]; return self::create($data); } diff --git a/classes/local/form/form_courses_filter.php b/classes/local/form/form_courses_filter.php index f589bcea..a7b52ba9 100644 --- a/classes/local/form/form_courses_filter.php +++ b/classes/local/form/form_courses_filter.php @@ -53,11 +53,11 @@ public function definition() { $mform->setType('fullname', PARAM_TEXT); // Edited from $this->add_action_buttons to allow custom cancel text. - $buttonarray = array(); + $buttonarray = []; $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('apply', 'tool_lifecycle')); $buttonarray[] = &$mform->createElement('cancel', 'cancel', get_string('reset')); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $mform->addGroup($buttonarray, 'buttonar', '', [' '], false); $mform->closeHeaderBefore('buttonar'); } diff --git a/classes/local/form/form_delays_filter.php b/classes/local/form/form_delays_filter.php index 845e2163..3abcf120 100644 --- a/classes/local/form/form_delays_filter.php +++ b/classes/local/form/form_delays_filter.php @@ -48,7 +48,7 @@ public function definition() { $activeworkflows = workflow_manager::get_active_workflows(); $workflowoptions = [ '' => get_string('all_delays', 'tool_lifecycle'), - 'global' => get_string('globally', 'tool_lifecycle') + 'global' => get_string('globally', 'tool_lifecycle'), ]; foreach ($activeworkflows as $activeworkflow) { // Only show non-static workflows. diff --git a/classes/local/form/form_step_instance.php b/classes/local/form/form_step_instance.php index f080413d..647df64c 100644 --- a/classes/local/form/form_step_instance.php +++ b/classes/local/form/form_step_instance.php @@ -139,9 +139,9 @@ private function add_cancel_button() { $mform =& $this->_form; // Add a group 'buttonar' to allow excluding it from freezing. - $buttonarray = array(); + $buttonarray = []; $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $mform->addGroup($buttonarray, 'buttonar', '', [' '], false); $mform->closeHeaderBefore('buttonar'); } diff --git a/classes/local/form/form_trigger_instance.php b/classes/local/form/form_trigger_instance.php index 0ac8f901..69d11327 100644 --- a/classes/local/form/form_trigger_instance.php +++ b/classes/local/form/form_trigger_instance.php @@ -144,9 +144,9 @@ public function definition() { private function add_cancel_button() { $mform =& $this->_form; - $buttonarray = array(); + $buttonarray = []; $buttonarray[] = &$mform->createElement('cancel'); - $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); + $mform->addGroup($buttonarray, 'buttonar', '', [' '], false); $mform->closeHeaderBefore('buttonar'); } diff --git a/classes/local/form/form_upload_workflow.php b/classes/local/form/form_upload_workflow.php index 5ce328c7..5ccd6aec 100644 --- a/classes/local/form/form_upload_workflow.php +++ b/classes/local/form/form_upload_workflow.php @@ -42,7 +42,7 @@ public function definition() { $mform = $this->_form; $mform->addElement('filepicker', 'backupfile', get_string('file'), null, - array('accepted_types' => 'xml')); + ['accepted_types' => 'xml']); $this->add_action_buttons('true', get_string('upload')); } diff --git a/classes/local/manager/backup_manager.php b/classes/local/manager/backup_manager.php index f7752b45..4ad70e31 100644 --- a/classes/local/manager/backup_manager.php +++ b/classes/local/manager/backup_manager.php @@ -102,7 +102,7 @@ public static function create_course_backup($courseid) { */ public static function restore_course_backup($backupid) { global $DB, $CFG; - $backuprecord = $DB->get_record('tool_lifecycle_backups', array('id' => $backupid)); + $backuprecord = $DB->get_record('tool_lifecycle_backups', ['id' => $backupid]); // Check if backup tmp dir exists. $backuptmpdir = $CFG->tempdir . DIRECTORY_SEPARATOR . 'backup'; @@ -125,10 +125,10 @@ public static function restore_course_backup($backupid) { $context = \context_system::instance(); $restoreurl = new \moodle_url('/backup/restore.php', - array( + [ 'contextid' => $context->id, 'filename' => $targetfilename, - ) + ] ); redirect($restoreurl); diff --git a/classes/local/manager/delayed_courses_manager.php b/classes/local/manager/delayed_courses_manager.php index b2520a9b..37d112f5 100644 --- a/classes/local/manager/delayed_courses_manager.php +++ b/classes/local/manager/delayed_courses_manager.php @@ -60,7 +60,7 @@ public static function set_course_delayed_for_workflow($courseid, $becauserollba } else { $delayeduntil = time() + $duration; $record = $DB->get_record('tool_lifecycle_delayed_workf', - array('courseid' => $courseid, 'workflowid' => $workflow->id)); + ['courseid' => $courseid, 'workflowid' => $workflow->id]); if (!$record) { $record = new \stdClass(); $record->courseid = $courseid; @@ -86,7 +86,7 @@ public static function set_course_delayed_for_workflow($courseid, $becauserollba public static function get_delayed_courses_for_workflow($workflowid) { global $DB; $sql = 'SELECT courseid FROM {tool_lifecycle_delayed_workf} WHERE delayeduntil > :now AND workflowid = :workflowid'; - return $DB->get_fieldset_sql($sql, array('now' => time(), 'workflowid' => $workflowid)); + return $DB->get_fieldset_sql($sql, ['now' => time(), 'workflowid' => $workflowid]); } /** @@ -98,7 +98,7 @@ public static function get_delayed_courses_for_workflow($workflowid) { public static function set_course_delayed($courseid, $duration) { global $DB; $delayeduntil = time() + $duration; - $record = $DB->get_record('tool_lifecycle_delayed', array('courseid' => $courseid)); + $record = $DB->get_record('tool_lifecycle_delayed', ['courseid' => $courseid]); if (!$record) { $record = new \stdClass(); $record->courseid = $courseid; @@ -120,7 +120,7 @@ public static function set_course_delayed($courseid, $duration) { */ public static function get_course_delayed($courseid) { global $DB; - $record = $DB->get_record('tool_lifecycle_delayed', array('courseid' => $courseid)); + $record = $DB->get_record('tool_lifecycle_delayed', ['courseid' => $courseid]); if ($record) { return $record->delayeduntil; } else { @@ -134,8 +134,8 @@ public static function get_course_delayed($courseid) { */ public static function get_course_delayed_wheresql() { $where = "{course}.id IN (SELECT courseid FROM {tool_lifecycle_delayed} WHERE delayeduntil > :now)"; - $params = array("now" => time()); - return array($where, $params); + $params = ["now" => time()]; + return [$where, $params]; } /** @@ -146,7 +146,7 @@ public static function get_course_delayed_wheresql() { public static function get_globally_delayed_courses() { global $DB; $sql = 'SELECT courseid FROM {tool_lifecycle_delayed} WHERE delayeduntil > :now'; - return $DB->get_fieldset_sql($sql, array('now' => time())); + return $DB->get_fieldset_sql($sql, ['now' => time()]); } /** @@ -156,6 +156,6 @@ public static function get_globally_delayed_courses() { */ public static function remove_delay_entry($courseid) { global $DB; - $DB->delete_records('tool_lifecycle_delayed', array('courseid' => $courseid)); + $DB->delete_records('tool_lifecycle_delayed', ['courseid' => $courseid]); } } diff --git a/classes/local/manager/process_data_manager.php b/classes/local/manager/process_data_manager.php index 722e2a6a..ce06ae64 100644 --- a/classes/local/manager/process_data_manager.php +++ b/classes/local/manager/process_data_manager.php @@ -53,10 +53,10 @@ class process_data_manager { */ public static function get_process_data($processid, $stepid, $key) { global $DB; - $params = array( + $params = [ 'processid' => $processid, 'keyname' => $key, - ); + ]; if (step_manager::is_process_data_instance_dependent($stepid)) { $params['stepid'] = $stepid; } else { @@ -78,10 +78,10 @@ public static function get_process_data($processid, $stepid, $key) { */ public static function set_process_data($processid, $stepid, $key, $value) { global $DB; - $entry = array( + $entry = [ 'processid' => $processid, 'keyname' => $key, - ); + ]; if (step_manager::is_process_data_instance_dependent($stepid)) { $entry['stepid'] = $stepid; } else { diff --git a/classes/local/manager/process_manager.php b/classes/local/manager/process_manager.php index b0b92039..ca92f0de 100644 --- a/classes/local/manager/process_manager.php +++ b/classes/local/manager/process_manager.php @@ -88,7 +88,7 @@ public static function manually_trigger_process($courseid, $triggerid) { public static function get_processes() { global $DB; $records = $DB->get_records('tool_lifecycle_process'); - $processes = array(); + $processes = []; foreach ($records as $record) { $processes[] = process::from_record($record); } @@ -103,7 +103,7 @@ public static function get_processes() { */ public static function get_process_by_id($processid) { global $DB; - $record = $DB->get_record('tool_lifecycle_process', array('id' => $processid)); + $record = $DB->get_record('tool_lifecycle_process', ['id' => $processid]); if ($record) { return process::from_record($record); } else { @@ -119,7 +119,7 @@ public static function get_process_by_id($processid) { */ public static function count_processes_by_workflow($workflowid) { global $DB; - return $DB->count_records('tool_lifecycle_process', array('workflowid' => $workflowid)); + return $DB->count_records('tool_lifecycle_process', ['workflowid' => $workflowid]); } /** @@ -130,8 +130,8 @@ public static function count_processes_by_workflow($workflowid) { */ public static function get_processes_by_workflow($workflowid) { global $DB; - $records = $DB->get_records('tool_lifecycle_process', array('workflowid' => $workflowid)); - $processes = array(); + $records = $DB->get_records('tool_lifecycle_process', ['workflowid' => $workflowid]); + $processes = []; foreach ($records as $record) { $processes[] = process::from_record($record); } @@ -201,7 +201,7 @@ public static function rollback_process($process) { */ private static function remove_process($process) { global $DB; - $DB->delete_records('tool_lifecycle_procdata', array('processid' => $process->id)); + $DB->delete_records('tool_lifecycle_procdata', ['processid' => $process->id]); $DB->delete_records('tool_lifecycle_process', (array) $process); } @@ -213,7 +213,7 @@ private static function remove_process($process) { */ public static function get_process_by_course_id($courseid) { global $DB; - $record = $DB->get_record('tool_lifecycle_process', array('courseid' => $courseid)); + $record = $DB->get_record('tool_lifecycle_process', ['courseid' => $courseid]); if ($record) { return process::from_record($record); } else { diff --git a/classes/local/manager/settings_manager.php b/classes/local/manager/settings_manager.php index 4db7be7e..6f0aade4 100644 --- a/classes/local/manager/settings_manager.php +++ b/classes/local/manager/settings_manager.php @@ -109,10 +109,10 @@ public static function save_settings($instanceid, $type, $subpluginname, $data, $cleanedvalue = clean_param($value, $setting->paramtype); } $record = $DB->get_record('tool_lifecycle_settings', - array( + [ 'instanceid' => $instanceid, 'type' => $type, - 'name' => $setting->name) + 'name' => $setting->name, ] ); if ($record) { if ($record->value != $cleanedvalue) { @@ -164,11 +164,11 @@ public static function get_settings($instanceid, $type) { $lib = lib_manager::get_step_lib($instance->subpluginname); } - $settingsvalues = array(); + $settingsvalues = []; foreach ($lib->instance_settings() as $setting) { - $record = $DB->get_record('tool_lifecycle_settings', array('instanceid' => $instanceid, + $record = $DB->get_record('tool_lifecycle_settings', ['instanceid' => $instanceid, 'type' => $type, - 'name' => $setting->name)); + 'name' => $setting->name, ]); if ($record) { $value = clean_param($record->value, $setting->paramtype); $settingsvalues[$setting->name] = $value; @@ -189,8 +189,8 @@ public static function remove_settings($instanceid, $type) { self::validate_type($type); $DB->delete_records('tool_lifecycle_settings', - array('instanceid' => $instanceid, - 'type' => $type)); + ['instanceid' => $instanceid, + 'type' => $type, ]); } /** diff --git a/classes/local/manager/step_manager.php b/classes/local/manager/step_manager.php index cd58d1a5..c82c9cec 100644 --- a/classes/local/manager/step_manager.php +++ b/classes/local/manager/step_manager.php @@ -44,7 +44,7 @@ class step_manager extends subplugin_manager { */ public static function get_step_instance($stepinstanceid) { global $DB; - $record = $DB->get_record('tool_lifecycle_step', array('id' => $stepinstanceid)); + $record = $DB->get_record('tool_lifecycle_step', ['id' => $stepinstanceid]); if ($record) { $subplugin = step_subplugin::from_record($record); return $subplugin; @@ -63,9 +63,9 @@ public static function get_step_instance($stepinstanceid) { public static function get_step_instance_by_workflow_index($workflowid, $sortindex) { global $DB; $record = $DB->get_record('tool_lifecycle_step', - array( + [ 'workflowid' => $workflowid, - 'sortindex' => $sortindex) + 'sortindex' => $sortindex, ] ); if ($record) { $subplugin = step_subplugin::from_record($record); @@ -118,7 +118,7 @@ public static function remove_all_instances($subpluginname) { private static function remove($stepinstanceid) { global $DB; $transaction = $DB->start_delegated_transaction(); - if ($record = $DB->get_record('tool_lifecycle_step', array('id' => $stepinstanceid))) { + if ($record = $DB->get_record('tool_lifecycle_step', ['id' => $stepinstanceid])) { $step = step_subplugin::from_record($record); self::remove_from_sortindex($step); settings_manager::remove_settings($step->id, settings_type::STEP); @@ -138,7 +138,7 @@ private static function remove_from_sortindex(&$toberemoved) { if (isset($toberemoved->sortindex)) { $subplugins = $DB->get_records_select('tool_lifecycle_step', "sortindex > $toberemoved->sortindex", - array('workflowid' => $toberemoved->workflowid)); + ['workflowid' => $toberemoved->workflowid]); foreach ($subplugins as $record) { $subplugin = step_subplugin::from_record($record); $subplugin->sortindex--; @@ -174,9 +174,9 @@ public static function change_sortindex($stepid, $up) { $transaction = $DB->start_delegated_transaction(); $otherrecord = $DB->get_record('tool_lifecycle_step', - array( + [ 'sortindex' => $otherindex, - 'workflowid' => $step->workflowid) + 'workflowid' => $step->workflowid, ] ); $otherstep = step_subplugin::from_record($otherrecord); @@ -196,10 +196,10 @@ public static function change_sortindex($stepid, $up) { */ public static function get_step_instances($workflowid) { global $DB; - $records = $DB->get_records('tool_lifecycle_step', array( - 'workflowid' => $workflowid - ), 'sortindex'); - $steps = array(); + $records = $DB->get_records('tool_lifecycle_step', [ + 'workflowid' => $workflowid, + ], 'sortindex'); + $steps = []; foreach ($records as $id => $record) { $steps[$id] = step_subplugin::from_record($record); } @@ -214,8 +214,8 @@ public static function get_step_instances($workflowid) { */ public static function get_step_instances_by_subpluginname($subpluginname) { global $DB; - $records = $DB->get_records('tool_lifecycle_step', array('subpluginname' => $subpluginname)); - $steps = array(); + $records = $DB->get_records('tool_lifecycle_step', ['subpluginname' => $subpluginname]); + $steps = []; foreach ($records as $id => $record) { $steps[$id] = step_subplugin::from_record($record); } @@ -229,7 +229,7 @@ public static function get_step_instances_by_subpluginname($subpluginname) { */ public static function get_step_types() { $subplugins = \core_component::get_plugin_list('lifecyclestep'); - $result = array(); + $result = []; foreach (array_keys($subplugins) as $plugin) { $result[$plugin] = get_string('pluginname', 'lifecyclestep_' . $plugin); } @@ -291,7 +291,7 @@ public static function is_process_data_instance_dependent($stepid) { public static function count_steps_of_workflow($workflowid) { global $DB; return $DB->count_records('tool_lifecycle_step', - array('workflowid' => $workflowid) + ['workflowid' => $workflowid] ); } @@ -307,7 +307,7 @@ public static function remove_instances_of_workflow($workflowid) { foreach ($instances as $instance) { settings_manager::remove_settings($instance->id, settings_type::STEP); } - $DB->delete_records('tool_lifecycle_step', array('workflowid' => $workflowid)); + $DB->delete_records('tool_lifecycle_step', ['workflowid' => $workflowid]); } /** diff --git a/classes/local/manager/trigger_manager.php b/classes/local/manager/trigger_manager.php index dc33b086..20f20a21 100644 --- a/classes/local/manager/trigger_manager.php +++ b/classes/local/manager/trigger_manager.php @@ -74,8 +74,8 @@ public static function get_instance($instanceid) { */ public static function get_instances($subpluginname) { global $DB; - $result = array(); - $records = $DB->get_records('tool_lifecycle_trigger', array('subpluginname' => $subpluginname)); + $result = []; + $records = $DB->get_records('tool_lifecycle_trigger', ['subpluginname' => $subpluginname]); foreach ($records as $record) { $subplugin = trigger_subplugin::from_record($record); $result[] = $subplugin; @@ -91,7 +91,7 @@ public static function get_instances($subpluginname) { */ private static function get_subplugin_by_id($subpluginid) { global $DB; - $record = $DB->get_record('tool_lifecycle_trigger', array('id' => $subpluginid)); + $record = $DB->get_record('tool_lifecycle_trigger', ['id' => $subpluginid]); if ($record) { $subplugin = trigger_subplugin::from_record($record); return $subplugin; @@ -142,7 +142,7 @@ public static function remove_all_instances($subpluginname) { private static function remove($triggerinstanceid) { global $DB; $transaction = $DB->start_delegated_transaction(); - if ($record = $DB->get_record('tool_lifecycle_trigger', array('id' => $triggerinstanceid))) { + if ($record = $DB->get_record('tool_lifecycle_trigger', ['id' => $triggerinstanceid])) { $trigger = trigger_subplugin::from_record($record); self::remove_from_sortindex($trigger); settings_manager::remove_settings($trigger->id, settings_type::TRIGGER); @@ -160,8 +160,8 @@ private static function remove($triggerinstanceid) { */ public static function get_triggers_for_workflow($workflowid) { global $DB; - $records = $DB->get_records('tool_lifecycle_trigger', array('workflowid' => $workflowid), 'sortindex'); - $output = array(); + $records = $DB->get_records('tool_lifecycle_trigger', ['workflowid' => $workflowid], 'sortindex'); + $output = []; foreach ($records as $record) { $subplugin = trigger_subplugin::from_record($record); $output[] = $subplugin; @@ -180,7 +180,7 @@ private static function remove_from_sortindex(&$toberemoved) { if (isset($toberemoved->sortindex)) { $subplugins = $DB->get_records_select('tool_lifecycle_trigger', "sortindex > $toberemoved->sortindex", - array('workflowid' => $toberemoved->workflowid)); + ['workflowid' => $toberemoved->workflowid]); foreach ($subplugins as $record) { $subplugin = trigger_subplugin::from_record($record); $subplugin->sortindex--; @@ -216,9 +216,9 @@ public static function change_sortindex($triggerid, $up) { $transaction = $DB->start_delegated_transaction(); $otherrecord = $DB->get_record('tool_lifecycle_trigger', - array( + [ 'sortindex' => $otherindex, - 'workflowid' => $trigger->workflowid) + 'workflowid' => $trigger->workflowid, ] ); $othertrigger = trigger_subplugin::from_record($otherrecord); @@ -237,7 +237,7 @@ public static function change_sortindex($triggerid, $up) { */ public static function get_trigger_types() { $subplugins = \core_component::get_plugin_list('lifecycletrigger'); - $result = array(); + $result = []; foreach (array_keys($subplugins) as $plugin) { $result[$plugin] = get_string('pluginname', 'lifecycletrigger_' . $plugin); } @@ -251,7 +251,7 @@ public static function get_trigger_types() { */ public static function get_chooseable_trigger_types() { $triggers = self::get_trigger_types(); - $result = array(); + $result = []; foreach ($triggers as $id => $trigger) { $lib = lib_manager::get_trigger_lib($id); if ($lib->has_multiple_instances()) { @@ -300,7 +300,7 @@ public static function handle_action($action, $subpluginid, $workflowid) { public static function count_triggers_of_workflow($workflowid) { global $DB; return $DB->count_records('tool_lifecycle_trigger', - array('workflowid' => $workflowid) + ['workflowid' => $workflowid] ); } @@ -316,7 +316,7 @@ public static function remove_instances_of_workflow($workflowid) { foreach ($instances as $instance) { settings_manager::remove_settings($instance->id, settings_type::TRIGGER); } - $DB->delete_records('tool_lifecycle_trigger', array('workflowid' => $workflowid)); + $DB->delete_records('tool_lifecycle_trigger', ['workflowid' => $workflowid]); } /** diff --git a/classes/local/manager/workflow_manager.php b/classes/local/manager/workflow_manager.php index 13d5cae6..97465f54 100644 --- a/classes/local/manager/workflow_manager.php +++ b/classes/local/manager/workflow_manager.php @@ -70,7 +70,7 @@ public static function remove($workflowid, $hard = false) { if ($hard || self::is_removable($workflowid)) { trigger_manager::remove_instances_of_workflow($workflowid); step_manager::remove_instances_of_workflow($workflowid); - $DB->delete_records('tool_lifecycle_workflow', array('id' => $workflowid)); + $DB->delete_records('tool_lifecycle_workflow', ['id' => $workflowid]); } } @@ -114,7 +114,7 @@ public static function abortprocesses($workflowid) { */ public static function get_workflow($workflowid) { global $DB; - $record = $DB->get_record('tool_lifecycle_workflow', array('id' => $workflowid)); + $record = $DB->get_record('tool_lifecycle_workflow', ['id' => $workflowid]); if ($record) { $workflow = workflow::from_record($record); return $workflow; @@ -131,7 +131,7 @@ public static function get_workflow($workflowid) { */ public static function get_workflows() { global $DB; - $result = array(); + $result = []; $records = $DB->get_records('tool_lifecycle_workflow'); foreach ($records as $record) { $result[] = workflow::from_record($record); @@ -150,7 +150,7 @@ public static function get_active_workflows() { $records = $DB->get_records_sql( 'SELECT * FROM {tool_lifecycle_workflow} WHERE timeactive IS NOT NULL ORDER BY sortindex'); - $result = array(); + $result = []; foreach ($records as $record) { $result[] = workflow::from_record($record); } @@ -168,8 +168,8 @@ public static function get_active_automatic_workflows() { $records = $DB->get_records_sql( 'SELECT * FROM {tool_lifecycle_workflow} WHERE timeactive IS NOT NULL AND - manual = ? ORDER BY sortindex', array(false)); - $result = array(); + manual = ? ORDER BY sortindex', [false]); + $result = []; foreach ($records as $record) { $result[] = workflow::from_record($record); } @@ -186,8 +186,8 @@ public static function get_active_manual_workflow_triggers() { global $DB; $sql = 'SELECT t.* FROM {tool_lifecycle_workflow} w JOIN {tool_lifecycle_trigger} t ON t.workflowid = w.id' . ' WHERE w.timeactive IS NOT NULL AND w.manual = ?'; - $records = $DB->get_records_sql($sql, array(true)); - $result = array(); + $records = $DB->get_records_sql($sql, [true]); + $result = []; foreach ($records as $record) { $result[] = trigger_subplugin::from_record($record); } @@ -204,7 +204,7 @@ public static function get_active_manual_workflow_triggers() { */ public static function get_manual_trigger_tools_for_active_workflows() { $triggers = self::get_active_manual_workflow_triggers(); - $tools = array(); + $tools = []; foreach ($triggers as $trigger) { $settings = settings_manager::get_settings($trigger->id, settings_type::TRIGGER); $tools[] = new manual_trigger_tool($trigger->id, $settings['icon'], $settings['displayname'], $settings['capability']); @@ -325,8 +325,8 @@ public static function change_sortindex($workflowid, $up) { $transaction = $DB->start_delegated_transaction(); $otherrecord = $DB->get_record('tool_lifecycle_workflow', - array( - 'sortindex' => $otherindex) + [ + 'sortindex' => $otherindex, ] ); $otherworkflow = workflow::from_record($otherrecord); diff --git a/classes/local/table/active_processes_table.php b/classes/local/table/active_processes_table.php index 2c2a3c70..3e3a7a40 100644 --- a/classes/local/table/active_processes_table.php +++ b/classes/local/table/active_processes_table.php @@ -89,7 +89,7 @@ public function __construct($uniqueid, $filterdata) { get_string('fullnamecourse'), get_string('workflow', 'tool_lifecycle'), get_string('step', 'tool_lifecycle'), - get_string('tools', 'tool_lifecycle')]); + get_string('tools', 'tool_lifecycle'), ]); $this->column_nosort = ['tools']; } diff --git a/classes/local/table/active_workflows_table.php b/classes/local/table/active_workflows_table.php index c3142d03..d0bd1222 100644 --- a/classes/local/table/active_workflows_table.php +++ b/classes/local/table/active_workflows_table.php @@ -56,9 +56,9 @@ public function col_tools($row) { $alt = get_string('viewsteps', 'tool_lifecycle'); $icon = 't/viewdetails'; $overviewurl = new \moodle_url(urls::WORKFLOW_DETAILS, - array('wf' => $row->id)); - $output .= $OUTPUT->action_icon($overviewurl, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), - null, array('title' => $alt)); + ['wf' => $row->id]); + $output .= $OUTPUT->action_icon($overviewurl, new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), + null, ['title' => $alt]); if (workflow_manager::is_disableable($row->id)) { $action = action::WORKFLOW_BACKUP; @@ -69,22 +69,22 @@ public function col_tools($row) { $alt = get_string('disableworkflow', 'tool_lifecycle'); $icon = 't/disable'; $url = new \moodle_url(urls::DEACTIVATED_WORKFLOWS, - array('workflowid' => $row->id, 'action' => action::WORKFLOW_DISABLE, 'sesskey' => sesskey())); + ['workflowid' => $row->id, 'action' => action::WORKFLOW_DISABLE, 'sesskey' => sesskey()]); $confirmaction = new \confirm_action(get_string('disableworkflow_confirm', 'tool_lifecycle')); $output .= $OUTPUT->action_icon($url, - new \pix_icon($icon, $alt, 'tool_lifecycle', array('title' => $alt)), + new \pix_icon($icon, $alt, 'tool_lifecycle', ['title' => $alt]), $confirmaction, - array('title' => $alt)); + ['title' => $alt]); $alt = get_string('abortdisableworkflow', 'tool_lifecycle'); $icon = 't/stop'; $url = new \moodle_url(urls::DEACTIVATED_WORKFLOWS, - array('workflowid' => $row->id, 'action' => action::WORKFLOW_ABORTDISABLE, 'sesskey' => sesskey())); + ['workflowid' => $row->id, 'action' => action::WORKFLOW_ABORTDISABLE, 'sesskey' => sesskey()]); $confirmaction = new \confirm_action(get_string('abortdisableworkflow_confirm', 'tool_lifecycle')); $output .= $OUTPUT->action_icon($url, - new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), + new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), $confirmaction, - array('title' => $alt) + ['title' => $alt] ); } diff --git a/classes/local/table/course_backups_table.php b/classes/local/table/course_backups_table.php index 6444969a..0739ab3c 100644 --- a/classes/local/table/course_backups_table.php +++ b/classes/local/table/course_backups_table.php @@ -86,7 +86,7 @@ public function init() { get_string('fullnamecourse'), get_string('backupcreated', 'tool_lifecycle'), get_string('download', 'tool_lifecycle'), - get_string('restore', 'tool_lifecycle')]); + get_string('restore', 'tool_lifecycle'), ]); $this->setup(); } @@ -147,7 +147,7 @@ public function col_backupcreated($row) { */ public function col_download($row) { return \html_writer::link( - new \moodle_url('/admin/tool/lifecycle/downloadbackup.php', array('backupid' => $row->id)), + new \moodle_url('/admin/tool/lifecycle/downloadbackup.php', ['backupid' => $row->id]), get_string('download', 'tool_lifecycle') ); } @@ -161,7 +161,7 @@ public function col_download($row) { */ public function col_restore($row) { return \html_writer::link( - new \moodle_url('/admin/tool/lifecycle/restore.php', array('backupid' => $row->id)), + new \moodle_url('/admin/tool/lifecycle/restore.php', ['backupid' => $row->id]), get_string('restore', 'tool_lifecycle') ); } diff --git a/classes/local/table/courses_in_step_table.php b/classes/local/table/courses_in_step_table.php index f23d1ef0..d14a57ae 100644 --- a/classes/local/table/courses_in_step_table.php +++ b/classes/local/table/courses_in_step_table.php @@ -73,7 +73,7 @@ public function __construct($step, $courseid) { $where = "p.stepindex = :stepindex AND p.workflowid = :wfid"; - $this->column_nosort = array('status', 'tools'); + $this->column_nosort = ['status', 'tools']; $this->set_sql($fields, $from, $where, ['stepindex' => $step->sortindex, 'wfid' => $step->workflowid]); if ($courseid) { $this->set_sortdata([]); diff --git a/classes/local/table/deactivated_workflows_table.php b/classes/local/table/deactivated_workflows_table.php index e6d3d182..37f867e5 100644 --- a/classes/local/table/deactivated_workflows_table.php +++ b/classes/local/table/deactivated_workflows_table.php @@ -89,20 +89,20 @@ public function col_tools($row) { $alt = get_string('viewsteps', 'tool_lifecycle'); $icon = 't/viewdetails'; $url = new \moodle_url(urls::WORKFLOW_DETAILS, - array('wf' => $row->id)); - $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), - null, array('title' => $alt)); + ['wf' => $row->id]); + $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), + null, ['title' => $alt]); if (workflow_manager::is_abortable($row->id)) { $alt = get_string('abortprocesses', 'tool_lifecycle'); $icon = 't/stop'; $url = new \moodle_url(urls::DEACTIVATED_WORKFLOWS, - array('workflowid' => $row->id, 'action' => action::WORKFLOW_ABORT, 'sesskey' => sesskey())); + ['workflowid' => $row->id, 'action' => action::WORKFLOW_ABORT, 'sesskey' => sesskey()]); $confirmaction = new \confirm_action(get_string('abortprocesses_confirm', 'tool_lifecycle')); $output .= $OUTPUT->action_icon($url, - new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), + new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), $confirmaction, - array('title' => $alt) + ['title' => $alt] ); } @@ -110,12 +110,12 @@ public function col_tools($row) { $alt = get_string('deleteworkflow', 'tool_lifecycle'); $icon = 't/delete'; $url = new \moodle_url(urls::DEACTIVATED_WORKFLOWS, - array('workflowid' => $row->id, 'action' => action::WORKFLOW_DELETE, 'sesskey' => sesskey())); + ['workflowid' => $row->id, 'action' => action::WORKFLOW_DELETE, 'sesskey' => sesskey()]); $confirmaction = new \confirm_action(get_string('deleteworkflow_confirm', 'tool_lifecycle')); $output .= $OUTPUT->action_icon($url, - new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), + new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), $confirmaction, - array('title' => $alt) + ['title' => $alt] ); } diff --git a/classes/local/table/delayed_courses_table.php b/classes/local/table/delayed_courses_table.php index fe2c1e9b..b87e9c7c 100644 --- a/classes/local/table/delayed_courses_table.php +++ b/classes/local/table/delayed_courses_table.php @@ -145,7 +145,7 @@ public function __construct($filterdata) { get_string('coursename', 'tool_lifecycle'), get_string('category'), get_string('delays', 'tool_lifecycle'), - get_string('tools', 'tool_lifecycle') + get_string('tools', 'tool_lifecycle'), ]); } @@ -175,13 +175,13 @@ public function col_workflow($row) { $dateformat = get_string('strftimedatetimeshort', 'core_langconfig'); $date = userdate($row->workflowdelay, $dateformat); $text = get_string('delayed_for_workflow_until', 'tool_lifecycle', - array('name' => $row->workflow, 'date' => $date)); + ['name' => $row->workflow, 'date' => $date]); } else { $text = get_string('delayed_for_workflows', 'tool_lifecycle', $row->workflowcount); } } - return \html_writer::start_span('tool_lifecycle-hint', array('title' => $this->get_mouseover($row))) . + return \html_writer::start_span('tool_lifecycle-hint', ['title' => $this->get_mouseover($row)]) . $text . \html_writer::end_span(); } @@ -205,7 +205,7 @@ private function get_mouseover($row) { if ($row->workflowcount == 1) { $date = userdate($row->workflowdelay, $dateformat); $text .= get_string('name_until_date', 'tool_lifecycle', - array('name' => $row->workflow, 'date' => $date)) . ' '; + ['name' => $row->workflow, 'date' => $date]) . ' '; } else if ($row->workflowcount > 1) { $sql = 'SELECT dw.id, dw.delayeduntil, w.title FROM {tool_lifecycle_delayed_workf} dw @@ -216,7 +216,7 @@ private function get_mouseover($row) { foreach ($records as $record) { $date = userdate($record->delayeduntil, $dateformat); $text .= get_string('name_until_date', 'tool_lifecycle', - array('name' => $record->title, 'date' => $date)) . ' '; + ['name' => $record->title, 'date' => $date]) . ' '; } } return $text; @@ -233,11 +233,11 @@ private function get_mouseover($row) { public function col_tools($row) { global $PAGE, $OUTPUT; - $params = array( + $params = [ 'action' => 'delete', 'cid' => $row->courseid, - 'sesskey' => sesskey() - ); + 'sesskey' => sesskey(), + ]; if ($this->workflow) { $params['workflow'] = $this->workflow; diff --git a/classes/local/table/interaction_attention_table.php b/classes/local/table/interaction_attention_table.php index 6cf8c504..2624831d 100644 --- a/classes/local/table/interaction_attention_table.php +++ b/classes/local/table/interaction_attention_table.php @@ -84,7 +84,7 @@ public function __construct($uniqueid, $courseids, $filterdata = null) { } } - $this->column_nosort = array('status', 'tools'); + $this->column_nosort = ['status', 'tools']; $this->set_sql($fields, $from, join(" AND ", $where), $params); $this->define_baseurl($PAGE->url); $this->init(); @@ -155,12 +155,12 @@ private function format_icon_link($action, $processid, $stepinstanceid, $alt) { global $PAGE, $OUTPUT; $button = new \single_button(new \moodle_url($PAGE->url, - array( + [ 'stepid' => $stepinstanceid, 'action' => $action, 'processid' => $processid, - 'sesskey' => sesskey() - )), $alt + 'sesskey' => sesskey(), + ]), $alt ); return $OUTPUT->render($button); } diff --git a/classes/local/table/interaction_remaining_table.php b/classes/local/table/interaction_remaining_table.php index 039dc7e5..710ffa68 100644 --- a/classes/local/table/interaction_remaining_table.php +++ b/classes/local/table/interaction_remaining_table.php @@ -89,7 +89,7 @@ public function __construct($uniqueid, $courseids) { $where = 'c.id IN ('. $ids . ')'; } - $this->column_nosort = array('status', 'tools'); + $this->column_nosort = ['status', 'tools']; $this->sortable(true, 'lastmodified', 'DESC'); $this->set_sql($fields, $from, $where, []); $this->set_count_sql("SELECT COUNT(1) FROM {course} c WHERE $where"); @@ -131,9 +131,9 @@ public function col_tools($row) { foreach ($this->availabletools as $tool) { if (has_capability($tool->capability, \context_course::instance($row->courseid), null, false)) { $actions[$tool->triggerid] = new \action_menu_link_secondary( - new \moodle_url($PAGE->url, array('triggerid' => $tool->triggerid, - 'courseid' => $row->courseid, 'sesskey' => sesskey())), - new \pix_icon($tool->icon, $tool->displayname, 'moodle', array('class' => 'iconsmall', 'title' => '')), + new \moodle_url($PAGE->url, ['triggerid' => $tool->triggerid, + 'courseid' => $row->courseid, 'sesskey' => sesskey(), ]), + new \pix_icon($tool->icon, $tool->displayname, 'moodle', ['class' => 'iconsmall', 'title' => '']), $tool->displayname ); } diff --git a/classes/local/table/process_errors_table.php b/classes/local/table/process_errors_table.php index 545a883d..d7463d17 100644 --- a/classes/local/table/process_errors_table.php +++ b/classes/local/table/process_errors_table.php @@ -53,7 +53,7 @@ public function __construct() { $this->strings = [ 'proceed' => get_string('proceed', 'tool_lifecycle'), - 'rollback' => get_string('rollback', 'tool_lifecycle') + 'rollback' => get_string('rollback', 'tool_lifecycle'), ]; $fields = 'c.fullname as course, w.title as workflow, s.instancename as step, pe.*'; @@ -80,7 +80,7 @@ public function __construct() { get_string('courseid', 'tool_lifecycle'), get_string('course'), get_string('error'), - get_string('tools', 'tool_lifecycle') + get_string('tools', 'tool_lifecycle'), ]); } @@ -94,9 +94,9 @@ public function __construct() { */ public function col_error($row) { return "
" . - nl2br(htmlentities($row->errormessage)) . + nl2br(htmlentities($row->errormessage, ENT_COMPAT)) . "" . - nl2br(htmlentities($row->errortrace)) . + nl2br(htmlentities($row->errortrace, ENT_COMPAT)) . "
"; } diff --git a/classes/local/table/workflow_definition_table.php b/classes/local/table/workflow_definition_table.php index b394d3bb..e2db1356 100644 --- a/classes/local/table/workflow_definition_table.php +++ b/classes/local/table/workflow_definition_table.php @@ -87,9 +87,9 @@ public function col_timeactive($row) { } if (workflow_manager::is_valid($row->id)) { return $OUTPUT->single_button(new \moodle_url(urls::ACTIVE_WORKFLOWS, - array('action' => action::WORKFLOW_ACTIVATE, + ['action' => action::WORKFLOW_ACTIVATE, 'sesskey' => sesskey(), - 'workflowid' => $row->id)), + 'workflowid' => $row->id, ]), get_string('activateworkflow', 'tool_lifecycle')); } else { return $OUTPUT->pix_icon('i/warning', get_string('invalid_workflow_details', 'tool_lifecycle')) . @@ -111,9 +111,9 @@ public function col_tools($row) { $alt = get_string('viewsteps', 'tool_lifecycle'); $icon = 't/viewdetails'; $url = new \moodle_url(urls::WORKFLOW_DETAILS, - array('wf' => $row->id)); - $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), - null, array('title' => $alt)); + ['wf' => $row->id]); + $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), + null, ['title' => $alt]); $trigger = trigger_manager::get_triggers_for_workflow($row->id); if (!empty($trigger)) { diff --git a/classes/local/table/workflow_table.php b/classes/local/table/workflow_table.php index 88e237d9..1763c0a5 100644 --- a/classes/local/table/workflow_table.php +++ b/classes/local/table/workflow_table.php @@ -73,9 +73,9 @@ public function col_timeactive($row) { return userdate($row->timeactive, get_string('strftimedatetime'), 0); } return $OUTPUT->single_button(new \moodle_url($PAGE->url, - array('action' => action::WORKFLOW_ACTIVATE, + ['action' => action::WORKFLOW_ACTIVATE, 'sesskey' => sesskey(), - 'workflowid' => $row->id)), + 'workflowid' => $row->id, ]), get_string('activateworkflow', 'tool_lifecycle')); } @@ -133,9 +133,9 @@ public function col_tools($row) { $alt = get_string('viewsteps', 'tool_lifecycle'); $icon = 't/viewdetails'; $url = new \moodle_url(urls::WORKFLOW_DETAILS, - array('wf' => $row->id)); - $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), - null, array('title' => $alt)); + ['wf' => $row->id]); + $output .= $OUTPUT->action_icon($url, new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), + null, ['title' => $alt]); return $output; } @@ -154,11 +154,11 @@ protected function format_icon_link($action, $workflowid, $icon, $alt) { global $OUTPUT, $PAGE; return $OUTPUT->action_icon(new \moodle_url($PAGE->url, - array('action' => $action, + ['action' => $action, 'workflowid' => $workflowid, - 'sesskey' => sesskey())), - new \pix_icon($icon, $alt, 'moodle', array('title' => $alt)), - null , array('title' => $alt)) . ' '; + 'sesskey' => sesskey(), ]), + new \pix_icon($icon, $alt, 'moodle', ['title' => $alt]), + null , ['title' => $alt]) . ' '; } } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index d320f46c..96745bb4 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -59,15 +59,15 @@ class provider implements */ public static function get_metadata(collection $collection): collection { $collection->add_database_table('tool_lifecycle_action_log', - array( + [ 'processid' => 'privacy:metadata:tool_lifecycle_action_log:processid', 'workflowid' => 'privacy:metadata:tool_lifecycle_action_log:workflowid', 'courseid' => 'privacy:metadata:tool_lifecycle_action_log:courseid', 'stepindex' => 'privacy:metadata:tool_lifecycle_action_log:stepindex', 'time' => 'privacy:metadata:tool_lifecycle_action_log:time', 'userid' => 'privacy:metadata:tool_lifecycle_action_log:userid', - 'action' => 'privacy:metadata:tool_lifecycle_action_log:action' - ), + 'action' => 'privacy:metadata:tool_lifecycle_action_log:action', + ], 'privacy:metadata:tool_lifecycle_action_log'); return $collection; } @@ -81,7 +81,7 @@ public static function get_metadata(collection $collection): collection { public static function get_contexts_for_userid(int $userid): contextlist { global $DB; $contextlist = new contextlist(); - if ($DB->record_exists('tool_lifecycle_action_log', array('userid' => $userid))) { + if ($DB->record_exists('tool_lifecycle_action_log', ['userid' => $userid])) { $contextlist->add_system_context(); } return $contextlist; @@ -96,7 +96,7 @@ public static function export_user_data(approved_contextlist $contextlist) { global $DB; foreach ($contextlist->get_contexts() as $context) { if ($context instanceof context_system) { - $records = $DB->get_records('tool_lifecycle_action_log', array('userid' => $contextlist->get_user()->id)); + $records = $DB->get_records('tool_lifecycle_action_log', ['userid' => $contextlist->get_user()->id]); $writer = writer::with_context($contextlist->current()); foreach ($records as $record) { $step = step_manager::get_step_instance_by_workflow_index($record->workflowid, $record->stepindex); @@ -105,7 +105,7 @@ public static function export_user_data(approved_contextlist $contextlist) { $record->step = $step->instancename; $record->workflow = $workflow->displaytitle; $subcontext = ['tool_lifecycle', 'action_log', "process_$record->processid", $step->instancename, - "action_$record->action"]; + "action_$record->action", ]; $writer->export_data($subcontext, $record); } } @@ -139,7 +139,7 @@ public static function delete_data_for_user(approved_contextlist $contextlist) { $sql = "UPDATE {tool_lifecycle_action_log} SET userid = -1 WHERE userid = :userid"; - $DB->execute($sql, array('userid' => $contextlist->get_user()->id)); + $DB->execute($sql, ['userid' => $contextlist->get_user()->id]); } } } @@ -154,7 +154,7 @@ public static function get_users_in_context(userlist $userlist) { if ($context instanceof context_system) { $sql = "SELECT userid FROM {tool_lifecycle_action_log}"; - $userlist->add_from_sql('userid', $sql, array()); + $userlist->add_from_sql('userid', $sql, []); } } diff --git a/classes/processor.php b/classes/processor.php index bf4f9ce4..81a0e73f 100644 --- a/classes/processor.php +++ b/classes/processor.php @@ -49,7 +49,7 @@ class processor { */ public function call_trigger() { $activeworkflows = workflow_manager::get_active_automatic_workflows(); - $exclude = array(); + $exclude = []; foreach ($activeworkflows as $workflow) { $countcourses = 0; @@ -203,7 +203,7 @@ public function get_course_recordset($triggers, $exclude) { global $DB; $where = 'true'; - $whereparams = array(); + $whereparams = []; foreach ($triggers as $trigger) { $lib = lib_manager::get_automatic_trigger_lib($trigger->subpluginname); list($sql, $params) = $lib->get_course_recordset_where($trigger->id); diff --git a/classes/task/lifecycle_cleanup_task.php b/classes/task/lifecycle_cleanup_task.php index eadeadf1..19455eaf 100644 --- a/classes/task/lifecycle_cleanup_task.php +++ b/classes/task/lifecycle_cleanup_task.php @@ -48,7 +48,7 @@ public function get_name() { public function execute() { global $DB; $twomonthago = time() - 60 * 24 * 60 * 60; - $DB->delete_records_select('tool_lifecycle_delayed', 'delayeduntil <= :time', array('time' => $twomonthago)); - $DB->delete_records_select('tool_lifecycle_delayed_workf', 'delayeduntil <= :time', array('time' => $twomonthago)); + $DB->delete_records_select('tool_lifecycle_delayed', 'delayeduntil <= :time', ['time' => $twomonthago]); + $DB->delete_records_select('tool_lifecycle_delayed_workf', 'delayeduntil <= :time', ['time' => $twomonthago]); } } diff --git a/classes/task/lifecycle_task.php b/classes/task/lifecycle_task.php index 91692d9a..a8ffb669 100644 --- a/classes/task/lifecycle_task.php +++ b/classes/task/lifecycle_task.php @@ -55,7 +55,7 @@ public function execute() { $steps = step_manager::get_step_types(); /* @var \tool_lifecycle\step\libbase[] $steplibs stores the lib classes of all step subplugins.*/ - $steplibs = array(); + $steplibs = []; foreach ($steps as $id => $step) { $steplibs[$id] = lib_manager::get_step_lib($id); $steplibs[$id]->pre_processing_bulk_operation(); diff --git a/classes/view_controller.php b/classes/view_controller.php index ea62ba6e..b0696515 100644 --- a/classes/view_controller.php +++ b/classes/view_controller.php @@ -61,7 +61,7 @@ public function handle_view($renderer, $filterdata) { return; } - $arrayofcourseids = array(); + $arrayofcourseids = []; foreach ($courses as $course) { $arrayofcourseids[$course->id] = $course->id; } @@ -75,7 +75,7 @@ public function handle_view($renderer, $filterdata) { "on p.workflowid = s.workflowid AND p.stepindex = s.sortindex " . "WHERE p.courseid IN (". $listofcourseids . ")"); - $requiresinteraction = array(); + $requiresinteraction = []; $remainingcourses = $arrayofcourseids; foreach ($processes as $process) { diff --git a/db/access.php b/db/access.php index 37c42da5..f6751c5b 100644 --- a/db/access.php +++ b/db/access.php @@ -22,20 +22,20 @@ */ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( +$capabilities = [ - 'tool/lifecycle:managecourses' => array( + 'tool/lifecycle:managecourses' => [ 'contextlevel' => CONTEXT_COURSE, 'captype' => 'write', - 'archetypes' => array( + 'archetypes' => [ 'manager' => CAP_PREVENT, 'editingteacher' => CAP_ALLOW, 'teacher' => CAP_PREVENT, 'students' => CAP_PREVENT, - ), - 'clonepermissionsfrom' => 'moodle/course:update' - ), -); + ], + 'clonepermissionsfrom' => 'moodle/course:update', + ], +]; diff --git a/db/caches.php b/db/caches.php index 0daffb47..6335a0b2 100644 --- a/db/caches.php +++ b/db/caches.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$definitions = array( - 'mformdata' => array( - 'mode' => cache_store::MODE_SESSION - ) -); +$definitions = [ + 'mformdata' => [ + 'mode' => cache_store::MODE_SESSION, + ], +]; diff --git a/db/events.php b/db/events.php index fa9c6449..5642f2ef 100644 --- a/db/events.php +++ b/db/events.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -$observers = array( - array( +$observers = [ + [ 'eventname' => 'core\event\course_deleted', 'callback' => 'tool_lifecycle\local\manager\process_manager::course_deletion_observed', - ) -); + ], +]; diff --git a/db/tasks.php b/db/tasks.php index d061305a..3af80c91 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$tasks = array( - array( +$tasks = [ + [ 'classname' => 'tool_lifecycle\task\lifecycle_task', 'blocking' => 0, 'minute' => '*', @@ -35,8 +35,8 @@ 'month' => '*', 'dayofweek' => '*', 'faildelay' => 1, - ), - array( + ], + [ 'classname' => 'tool_lifecycle\task\lifecycle_cleanup_task', 'blocking' => 0, 'minute' => '0', @@ -44,8 +44,8 @@ 'day' => '*', 'month' => '*', 'dayofweek' => '0', - ), - array( + ], + [ 'classname' => 'tool_lifecycle\task\lifecycle_error_notify_task', 'blocking' => 0, 'minute' => 'R', @@ -53,5 +53,5 @@ 'day' => '*', 'month' => '*', 'dayofweek' => '0', - ), -); + ], +]; diff --git a/db/upgrade.php b/db/upgrade.php index 99accd3e..5cd87a33 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -46,7 +46,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { $table->add_field('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'id'); $table->add_field('active', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'title'); $table->add_field('timeactive', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'active'); - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Conditionally create the table. if (!$dbman->table_exists($table)) { @@ -63,7 +63,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { } $field = new xmldb_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'subpluginname'); - $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_lifecycle_workflow', array('id')); + $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, ['workflowid'], 'tool_lifecycle_workflow', ['id']); // Conditionally create the field. if (!$dbman->field_exists($table, $field)) { @@ -89,7 +89,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { // Add workflowfield to trigger. $field = new xmldb_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'enabled'); - $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_lifecycle_workflow', array('id')); + $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, ['workflowid'], 'tool_lifecycle_workflow', ['id']); // Conditionally create the field. if (!$dbman->field_exists($table, $field)) { @@ -107,7 +107,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { } $field = new xmldb_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'courseid'); - $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_lifecycle_workflow', array('id')); + $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, ['workflowid'], 'tool_lifecycle_workflow', ['id']); // Conditionally create the field. if (!$dbman->field_exists($table, $field)) { @@ -207,7 +207,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { // Define key workflowid_fk (foreign) to be added to tool_lifecycle_trigger. $table = new xmldb_table('tool_lifecycle_trigger'); - $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_lifecycle_workflow', array('id')); + $key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, ['workflowid'], 'tool_lifecycle_workflow', ['id']); // Launch add key workflowid_fk. $dbman->add_key($table, $key); @@ -262,13 +262,13 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { // Define key courseid_fk (foreign) to be dropped form tool_lifecycle_process. $table = new xmldb_table('tool_lifecycle_process'); - $key = new xmldb_key('courseid_fk', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id')); + $key = new xmldb_key('courseid_fk', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); // Launch drop key courseid_fk. $dbman->drop_key($table, $key); // Define key courseid_fk (foreign-unique) to be added to tool_lifecycle_process. - $key = new xmldb_key('courseid_fk', XMLDB_KEY_FOREIGN_UNIQUE, array('courseid'), 'course', array('id')); + $key = new xmldb_key('courseid_fk', XMLDB_KEY_FOREIGN_UNIQUE, ['courseid'], 'course', ['id']); // Launch add key courseid_fk. $dbman->add_key($table, $key); @@ -365,7 +365,7 @@ function xmldb_tool_lifecycle_upgrade($oldversion) { $dbman->add_field($table, $field); } - $params = array($duration, $duration); + $params = [$duration, $duration]; $DB->execute('UPDATE {tool_lifecycle_workflow} SET finishdelay = ?, rollbackdelay = ?', $params); diff --git a/delayedcourses.php b/delayedcourses.php index 923cd36b..634c4e44 100644 --- a/delayedcourses.php +++ b/delayedcourses.php @@ -44,15 +44,15 @@ $workflow = optional_param('workflow', null, PARAM_ALPHANUM); if ($workflow) { if (is_number($workflow)) { - $DB->delete_records('tool_lifecycle_delayed_workf', array('courseid' => $cid, 'workflowid' => $workflow)); + $DB->delete_records('tool_lifecycle_delayed_workf', ['courseid' => $cid, 'workflowid' => $workflow]); } else if ($workflow == 'global') { - $DB->delete_records('tool_lifecycle_delayed', array('courseid' => $cid)); + $DB->delete_records('tool_lifecycle_delayed', ['courseid' => $cid]); } else { throw new \coding_exception('workflow has to be "global" or a int value'); } } else { - $DB->delete_records('tool_lifecycle_delayed', array('courseid' => $cid)); - $DB->delete_records('tool_lifecycle_delayed_workf', array('courseid' => $cid)); + $DB->delete_records('tool_lifecycle_delayed', ['courseid' => $cid]); + $DB->delete_records('tool_lifecycle_delayed_workf', ['courseid' => $cid]); } } else if ($action == 'bulk-delete') { $workflow = optional_param('workflow', null, PARAM_ALPHANUM); diff --git a/downloadbackup.php b/downloadbackup.php index c2877e7f..ddbae288 100644 --- a/downloadbackup.php +++ b/downloadbackup.php @@ -28,7 +28,7 @@ $backupid = required_param('backupid', PARAM_INT); -$backuprecord = $DB->get_record('tool_lifecycle_backups', array('id' => $backupid), 'backupfile', MUST_EXIST); +$backuprecord = $DB->get_record('tool_lifecycle_backups', ['id' => $backupid], 'backupfile', MUST_EXIST); $source = get_config('tool_lifecycle', 'backup_path') . DIRECTORY_SEPARATOR . $backuprecord->backupfile; if (!file_exists($source)) { diff --git a/editelement.php b/editelement.php index de3ac303..9864e63a 100644 --- a/editelement.php +++ b/editelement.php @@ -71,7 +71,7 @@ \tool_lifecycle\permission_and_navigation::setup_workflow($workflow); $params = [ - 'type' => $type + 'type' => $type, ]; if ($elementid) { $params['elementid'] = $element->id; diff --git a/lib.php b/lib.php index fa4532ae..28be8395 100644 --- a/lib.php +++ b/lib.php @@ -46,9 +46,9 @@ function tool_lifecycle_extend_navigation_course($navigation, $course, $context) $url = null; $settingnode = null; - $url = new moodle_url('/admin/tool/lifecycle/view.php', array( - 'contextid' => $context->id - )); + $url = new moodle_url('/admin/tool/lifecycle/view.php', [ + 'contextid' => $context->id, + ]); // Add the course life cycle link. $linktext = get_string('managecourses_link', 'tool_lifecycle'); diff --git a/renderer.php b/renderer.php index f17197d3..f9b7eb9b 100644 --- a/renderer.php +++ b/renderer.php @@ -56,7 +56,7 @@ public function header($title = null) { * @param array $errors * @throws coding_exception */ - public function render_workflow_upload_form($form, $errors = array()) { + public function render_workflow_upload_form($form, $errors = []) { $this->header(get_string('adminsettings_edit_workflow_definition_heading', 'tool_lifecycle')); foreach ($errors as $error) { \core\notification::add($error, \core\notification::ERROR); diff --git a/step/createbackup/db/upgrade.php b/step/createbackup/db/upgrade.php index d1583cd7..56a1a62b 100644 --- a/step/createbackup/db/upgrade.php +++ b/step/createbackup/db/upgrade.php @@ -45,7 +45,7 @@ function xmldb_lifecyclestep_createbackup_upgrade($oldversion) { foreach ($coursedeletesteps as $step) { if (empty(settings_manager::get_settings($step->id, 'step'))) { settings_manager::save_settings($step->id, 'step', 'createbackup', - array($settingsname => $settingsvalue)); + [$settingsname => $settingsvalue]); } } diff --git a/step/createbackup/lib.php b/step/createbackup/lib.php index ae38c21c..18724439 100644 --- a/step/createbackup/lib.php +++ b/step/createbackup/lib.php @@ -100,9 +100,9 @@ public function get_subpluginname() { * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array( + return [ new instance_setting('maximumbackupspercron', PARAM_INT, true), - ); + ]; } /** diff --git a/step/deletecourse/db/upgrade.php b/step/deletecourse/db/upgrade.php index c8467c5e..43560660 100644 --- a/step/deletecourse/db/upgrade.php +++ b/step/deletecourse/db/upgrade.php @@ -49,7 +49,7 @@ function xmldb_lifecyclestep_deletecourse_upgrade($oldversion) { foreach ($coursedeletesteps as $step) { if (empty(settings_manager::get_settings($step->id, 'step'))) { settings_manager::save_settings($step->id, 'step', 'deletecourse', - array($settingsname => $settingsvalue)); + [$settingsname => $settingsvalue]); } } diff --git a/step/deletecourse/lib.php b/step/deletecourse/lib.php index 3503f159..098f512a 100644 --- a/step/deletecourse/lib.php +++ b/step/deletecourse/lib.php @@ -94,9 +94,9 @@ public function get_subpluginname() { * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array( + return [ new instance_setting('maximumdeletionspercron', PARAM_INT, true), - ); + ]; } /** diff --git a/step/duplicate/db/access.php b/step/duplicate/db/access.php index 85169b97..78e62082 100644 --- a/step/duplicate/db/access.php +++ b/step/duplicate/db/access.php @@ -22,17 +22,17 @@ */ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( +$capabilities = [ - 'lifecyclestep/duplicate:enterdata' => array( + 'lifecyclestep/duplicate:enterdata' => [ 'contextlevel' => CONTEXT_COURSE, 'captype' => 'write', - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - ), - 'clonepermissionsfrom' => 'tool/lifecycle:managecourses' - ), -); + ], + 'clonepermissionsfrom' => 'tool/lifecycle:managecourses', + ], +]; diff --git a/step/duplicate/interactionlib.php b/step/duplicate/interactionlib.php index f8d389f8..6cece993 100644 --- a/step/duplicate/interactionlib.php +++ b/step/duplicate/interactionlib.php @@ -70,13 +70,13 @@ public function get_action_tools($process) { $shortname = process_data_manager::get_process_data($process->id, $step->id, duplicate::PROC_DATA_COURSESHORTNAME); $fullname = process_data_manager::get_process_data($process->id, $step->id, duplicate::PROC_DATA_COURSEFULLNAME); if (!empty($fullname) && !empty($shortname)) { - return array(); + return []; } - return array( - array('action' => self::ACTION_DUPLICATE_FORM, + return [ + ['action' => self::ACTION_DUPLICATE_FORM, 'alt' => get_string('duplicate_form', 'lifecyclestep_duplicate'), - ), - ); + ], + ]; } /** @@ -116,7 +116,7 @@ public function handle_interaction($process, $step, $action = 'default') { return step_interactive_response::rollback(); } if ($data = $form->get_submitted_data()) { - if ($foundcourses = $DB->get_records('course', array('shortname' => $data->shortname))) { + if ($foundcourses = $DB->get_records('course', ['shortname' => $data->shortname])) { foreach ($foundcourses as $foundcourse) { $foundcoursenames[] = $foundcourse->fullname; } diff --git a/step/duplicate/lib.php b/step/duplicate/lib.php index 201c997d..d730b8df 100644 --- a/step/duplicate/lib.php +++ b/step/duplicate/lib.php @@ -71,7 +71,7 @@ public function process_course($processid, $instanceid, $course) { $shortname, $course->category, $course->visible, - array()); + []); } catch (\moodle_exception $e) { if ($e->getCode() == 'shortnametaken') { process_data_manager::set_process_data($processid, $instanceid, self::PROC_DATA_COURSESHORTNAME, ''); @@ -130,18 +130,18 @@ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php'); // Parameter validation. - $params = array( + $params = [ 'courseid' => $courseid, 'fullname' => $fullname, 'shortname' => $shortname, 'categoryid' => $categoryid, 'visible' => $visible, - 'options' => $options - ); + 'options' => $options, + ]; // Context validation. - if (! ($course = $DB->get_record('course', array('id' => $params['courseid'])))) { + if (! ($course = $DB->get_record('course', ['id' => $params['courseid']]))) { throw new \moodle_exception('invalidcourseid', 'error'); } @@ -151,7 +151,7 @@ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, // Course to be duplicated. $coursecontext = \context_course::instance($course->id); - $backupdefaults = array( + $backupdefaults = [ 'activities' => 1, 'blocks' => 1, 'filters' => 1, @@ -161,10 +161,10 @@ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, 'comments' => 0, 'userscompletion' => 0, 'logs' => 0, - 'grade_histories' => 0 - ); + 'grade_histories' => 0, + ]; - $backupsettings = array(); + $backupsettings = []; // Check for backup and restore options. if (!empty($params['options'])) { foreach ($params['options'] as $option) { @@ -172,7 +172,7 @@ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, // Strict check for a correct value (allways 1 or 0, true or false). $value = clean_param($option['value'], PARAM_INT); - if ($value !== 0 and $value !== 1) { + if ($value !== 0 && $value !== 1) { throw new \moodle_exception('invalidextparam', 'webservice', '', $option['name']); } @@ -197,7 +197,7 @@ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, } // Check if the shortname is used. - if ($foundcourses = $DB->get_records('course', array('shortname' => $shortname))) { + if ($foundcourses = $DB->get_records('course', ['shortname' => $shortname])) { foreach ($foundcourses as $foundcourse) { $foundcoursenames[] = $foundcourse->fullname; } @@ -272,7 +272,7 @@ public function duplicate_course($courseid, $fullname, $shortname, $categoryid, $rc->execute_plan(); $rc->destroy(); - $course = $DB->get_record('course', array('id' => $newcourseid), '*', MUST_EXIST); + $course = $DB->get_record('course', ['id' => $newcourseid], '*', MUST_EXIST); $course->fullname = $params['fullname']; $course->shortname = $params['shortname']; $course->visible = $params['visible']; diff --git a/step/email/classes/privacy/provider.php b/step/email/classes/privacy/provider.php index afbcb511..a41ad4e4 100644 --- a/step/email/classes/privacy/provider.php +++ b/step/email/classes/privacy/provider.php @@ -52,7 +52,7 @@ public static function get_metadata(collection $collection): collection { [ 'touser' => 'privacy:metadata:lifecyclestep_email:touser', 'courseid' => 'privacy:metadata:lifecyclestep_email:courseid', - 'instanceid' => 'privacy:metadata:lifecyclestep_email:instanceid' + 'instanceid' => 'privacy:metadata:lifecyclestep_email:instanceid', ], 'privacy:metadata:lifecyclestep_email:summary' ); @@ -133,7 +133,7 @@ public static function delete_data_for_users(approved_userlist $userlist): void $DB->delete_records('lifecyclestep_email', ['touser' => $userid]); } else if ($userlist->get_context() instanceof context_course) { $DB->delete_records('lifecyclestep_email', ['touser' => $userid, - 'courseid' => $userlist->get_context()->instanceid]); + 'courseid' => $userlist->get_context()->instanceid, ]); } } } diff --git a/step/email/db/access.php b/step/email/db/access.php index 7c33a548..3ec76d81 100644 --- a/step/email/db/access.php +++ b/step/email/db/access.php @@ -22,20 +22,20 @@ */ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( +$capabilities = [ - 'lifecyclestep/email:preventdeletion' => array( + 'lifecyclestep/email:preventdeletion' => [ 'contextlevel' => CONTEXT_COURSE, 'captype' => 'write', - 'archetypes' => array( + 'archetypes' => [ 'manager' => CAP_PREVENT, 'editingteacher' => CAP_ALLOW, 'teacher' => CAP_PREVENT, 'students' => CAP_PREVENT, - ), - 'clonepermissionsfrom' => 'tool/lifecycle:managecourses' - ), -); + ], + 'clonepermissionsfrom' => 'tool/lifecycle:managecourses', + ], +]; diff --git a/step/email/interactionlib.php b/step/email/interactionlib.php index 1085e128..8d71b69b 100644 --- a/step/email/interactionlib.php +++ b/step/email/interactionlib.php @@ -67,11 +67,11 @@ public function get_relevant_capability() { * @throws \coding_exception */ public function get_action_tools($process) { - return array( - array('action' => self::ACTION_KEEP, + return [ + ['action' => self::ACTION_KEEP, 'alt' => get_string('keep_course', 'lifecyclestep_email'), - ), - ); + ], + ]; } /** diff --git a/step/email/lib.php b/step/email/lib.php index 8ade151c..f25b78bb 100644 --- a/step/email/lib.php +++ b/step/email/lib.php @@ -111,13 +111,13 @@ public function post_processing_bulk_operation() { $settings['contenthtml'] = format_text($settings['contenthtml'], FORMAT_HTML); $userstobeinformed = $DB->get_records('lifecyclestep_email', - array('instanceid' => $step->id), '', 'distinct touser'); + ['instanceid' => $step->id], '', 'distinct touser'); foreach ($userstobeinformed as $userrecord) { $user = \core_user::get_user($userrecord->touser); $transaction = $DB->start_delegated_transaction(); $mailentries = $DB->get_records('lifecyclestep_email', - array('instanceid' => $step->id, - 'touser' => $user->id)); + ['instanceid' => $step->id, + 'touser' => $user->id, ]); $parsedsettings = $this->replace_placeholders($settings, $user, $step->id, $mailentries); @@ -127,8 +127,8 @@ public function post_processing_bulk_operation() { // TODO: use course info to parse content template! email_to_user($user, \core_user::get_noreply_user(), $subject, $content, $contenthtml); $DB->delete_records('lifecyclestep_email', - array('instanceid' => $step->id, - 'touser' => $user->id)); + ['instanceid' => $step->id, + 'touser' => $user->id, ]); $transaction->allow_commit(); } } @@ -148,8 +148,8 @@ public function post_processing_bulk_operation() { private function replace_placeholders($strings, $user, $stepid, $mailentries) { global $CFG; - $patterns = array(); - $replacements = array(); + $patterns = []; + $replacements = []; // Replaces firstname of the user. $patterns[] = '##firstname##'; @@ -182,7 +182,7 @@ private function replace_placeholders($strings, $user, $stepid, $mailentries) { // Replace courses html. $patterns[] = '##courses-html##'; $courses = $mailentries; - $coursestabledata = array(); + $coursestabledata = []; foreach ($courses as $entry) { $coursestabledata[$entry->courseid] = $this->parse_course_row_data($entry->courseid); } @@ -213,7 +213,7 @@ private function parse_course($courseid) { */ private function parse_course_row_data($courseid) { $course = get_course($courseid); - return array($course->fullname); + return [$course->fullname]; } /** @@ -221,12 +221,12 @@ private function parse_course_row_data($courseid) { * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array( + return [ new instance_setting('responsetimeout', PARAM_INT, false), new instance_setting('subject', PARAM_TEXT, true), new instance_setting('content', PARAM_RAW, true), new instance_setting('contenthtml', PARAM_RAW, true), - ); + ]; } /** @@ -271,6 +271,6 @@ public function extend_add_instance_form_definition($mform) { */ public function extend_add_instance_form_definition_after_data($mform, $settings) { $mform->setDefault('contenthtml', - array('text' => isset($settings['contenthtml']) ? $settings['contenthtml'] : '', 'format' => FORMAT_HTML)); + ['text' => isset($settings['contenthtml']) ? $settings['contenthtml'] : '', 'format' => FORMAT_HTML]); } } diff --git a/step/email/tests/privacy/provider_test.php b/step/email/tests/privacy/provider_test.php index 37e3afa7..feb35b6d 100644 --- a/step/email/tests/privacy/provider_test.php +++ b/step/email/tests/privacy/provider_test.php @@ -146,7 +146,7 @@ public function test_export_user_data(): void { $writer = writer::with_context($course1context); $this->assertTrue($writer->has_any_data()); $recordids = $DB->get_records('lifecyclestep_email', ['touser' => $this->user1->id, - 'courseid' => $this->course1->id], '', 'id'); + 'courseid' => $this->course1->id, ], '', 'id'); foreach ($recordids as $id) { $exportedrecord = $writer->get_data(['lifecyclestep_email-' . $id->id]); $this->assertEquals($this->user1->id, $exportedrecord->touser); @@ -156,7 +156,7 @@ public function test_export_user_data(): void { $writer = writer::with_context($course2context); $this->assertTrue($writer->has_any_data()); $recordids = $DB->get_records('lifecyclestep_email', ['touser' => $this->user1->id, - 'courseid' => $this->course2->id], '', 'id'); + 'courseid' => $this->course2->id, ], '', 'id'); foreach ($recordids as $id) { $exportedrecord = $writer->get_data(['lifecyclestep_email-' . $id->id]); $this->assertEquals($this->user1->id, $exportedrecord->touser); diff --git a/step/lib.php b/step/lib.php index 7209d1d3..86c8345c 100644 --- a/step/lib.php +++ b/step/lib.php @@ -104,7 +104,7 @@ abstract public function get_subpluginname(); * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array(); + return []; } /** diff --git a/tests/generator/lib.php b/tests/generator/lib.php index ae963a13..cd0461b4 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -46,27 +46,27 @@ class tool_lifecycle_generator extends testing_module_generator { /** @var array $defaultsteps Default steps configuration. */ private static $defaultsteps = [ "deletecourse" => [ - "maximumdeletionspercron" => 10 + "maximumdeletionspercron" => 10, ], "email" => [ "responsetimeout" => 10, "subject" => "Test Email", "content" => "Content", - "contenthtml" => "Content HTML" + "contenthtml" => "Content HTML", ], "createbackup" => [ - "maximumbackupspercron" => 10 + "maximumbackupspercron" => 10, ], ]; /** @var array $defaulttrigger Default trigger configuration. */ private static $defaulttrigger = [ "startdatedelay" => [ - "delay" => 10000 + "delay" => 10000, ], "categories" => [ "categories" => "1,10", - "exclude" => true + "exclude" => true, ], ]; diff --git a/tests/manually_triggered_process_test.php b/tests/manually_triggered_process_test.php index 52597adc..b231ca24 100644 --- a/tests/manually_triggered_process_test.php +++ b/tests/manually_triggered_process_test.php @@ -82,7 +82,7 @@ public function setUp() : void { $manualworkflow = $generator->create_manual_workflow($triggersettings); $step = $generator->create_step("instance1", "createbackup", $manualworkflow->id); settings_manager::save_settings($step->id, settings_type::STEP, "createbackup", - array("maximumbackupspercron" => 10) + ["maximumbackupspercron" => 10] ); workflow_manager::handle_action(action::WORKFLOW_ACTIVATE, $manualworkflow->id); diff --git a/tests/privacy_test.php b/tests/privacy_test.php index 461a5f37..6e9d76af 100644 --- a/tests/privacy_test.php +++ b/tests/privacy_test.php @@ -150,12 +150,12 @@ public function test_export_user_data() { $writer = writer::with_context(\context_system::instance()); $step = step_manager::get_step_instance_by_workflow_index($this->workflow->id, 1); $subcontext = ['tool_lifecycle', 'action_log', "process_$p1->id", $step->instancename, - "action_" . self::ACTION_KEEP]; + "action_" . self::ACTION_KEEP, ]; $data1 = $writer->get_data($subcontext); $this->assertEquals($u1->id, $data1->userid); $this->assertEquals(self::ACTION_KEEP, $data1->action); $subcontext = ['tool_lifecycle', 'action_log', "process_$p2->id", $step->instancename, - "action_" . self::ACTION_KEEP]; + "action_" . self::ACTION_KEEP, ]; $data2 = $writer->get_data($subcontext); $this->assertEquals($u1->id, $data2->userid); $this->assertEquals(self::ACTION_KEEP, $data2->action); diff --git a/tests/process_error_test.php b/tests/process_error_test.php index 2e601fe1..a4ca2d5c 100644 --- a/tests/process_error_test.php +++ b/tests/process_error_test.php @@ -75,7 +75,7 @@ public function setUp() : void { $manualworkflow = $generator->create_manual_workflow($triggersettings); $step = $generator->create_step("instance1", "deletecourse", $manualworkflow->id); settings_manager::save_settings($step->id, settings_type::STEP, "deletecourse", - array("maximumdeletionspercron" => 10) + ["maximumdeletionspercron" => 10] ); workflow_manager::handle_action(action::WORKFLOW_ACTIVATE, $manualworkflow->id); diff --git a/tests/settings_manager_test.php b/tests/settings_manager_test.php index e91623cb..8fc4f09b 100644 --- a/tests/settings_manager_test.php +++ b/tests/settings_manager_test.php @@ -105,18 +105,18 @@ public function test_remove_workflow() { $data = new \stdClass(); $data->delay = 100; settings_manager::save_settings($this->trigger->id, settings_type::TRIGGER, $this->trigger->subpluginname, $data); - $settingsstep = $DB->get_records('tool_lifecycle_settings', array('instanceid' => $this->step->id, - 'type' => settings_type::STEP)); + $settingsstep = $DB->get_records('tool_lifecycle_settings', ['instanceid' => $this->step->id, + 'type' => settings_type::STEP, ]); $this->assertNotEmpty($settingsstep); - $settingstrigger = $DB->get_records('tool_lifecycle_settings', array('instanceid' => $this->trigger->id, - 'type' => settings_type::TRIGGER)); + $settingstrigger = $DB->get_records('tool_lifecycle_settings', ['instanceid' => $this->trigger->id, + 'type' => settings_type::TRIGGER, ]); $this->assertNotEmpty($settingstrigger); workflow_manager::remove($this->workflow->id); - $settingsstep = $DB->get_records('tool_lifecycle_settings', array('instanceid' => $this->step->id, - 'type' => settings_type::STEP)); + $settingsstep = $DB->get_records('tool_lifecycle_settings', ['instanceid' => $this->step->id, + 'type' => settings_type::STEP, ]); $this->assertEmpty($settingsstep); - $settingstrigger = $DB->get_records('tool_lifecycle_settings', array('instanceid' => $this->trigger->id, - 'type' => settings_type::TRIGGER)); + $settingstrigger = $DB->get_records('tool_lifecycle_settings', ['instanceid' => $this->trigger->id, + 'type' => settings_type::TRIGGER, ]); $this->assertEmpty($settingstrigger); } diff --git a/trigger/categories/lib.php b/trigger/categories/lib.php index b44376f6..0ace8460 100644 --- a/trigger/categories/lib.php +++ b/trigger/categories/lib.php @@ -73,7 +73,7 @@ public function get_course_recordset_where($triggerid) { require_once($CFG->libdir . '/coursecatlib.php'); $categoryobjects = \coursecat::get_many($categories); } - $allcategories = array(); + $allcategories = []; foreach ($categories as $category) { array_push($allcategories , $category); $children = $categoryobjects[$category]->get_all_children_ids(); @@ -87,7 +87,7 @@ public function get_course_recordset_where($triggerid) { $where = "NOT " . $where; } - return array($where, $inparams); + return [$where, $inparams]; } /** @@ -103,10 +103,10 @@ public function get_subpluginname() { * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array( + return [ new instance_setting('categories', PARAM_SEQUENCE, true), new instance_setting('exclude', PARAM_BOOL, true), - ); + ]; } /** @@ -118,10 +118,10 @@ public function instance_settings() { */ public function extend_add_instance_form_definition($mform) { $displaylist = core_course_category::make_categories_list(); - $options = array( + $options = [ 'multiple' => true, 'noselectionstring' => get_string('categories_noselection', 'lifecycletrigger_categories'), - ); + ]; $mform->addElement('autocomplete', 'categories', get_string('categories', 'lifecycletrigger_categories'), $displaylist, $options); diff --git a/trigger/categories/tests/trigger_test.php b/trigger/categories/tests/trigger_test.php index c00bfda6..cda087c1 100644 --- a/trigger/categories/tests/trigger_test.php +++ b/trigger/categories/tests/trigger_test.php @@ -70,11 +70,11 @@ public function setUp() : void { $this->category = $generator->create_category(); $othercategory = $generator->create_category(); - $this->childcategory = $generator->create_category(array('parent' => $this->category->id)); - $data = array( + $this->childcategory = $generator->create_category(['parent' => $this->category->id]); + $data = [ 'categories' => $othercategory->id . ',' . $this->category->id, 'exclude' => true, - ); + ]; $this->excludetrigger = \tool_lifecycle_trigger_categories_generator::create_trigger_with_workflow($data); @@ -88,7 +88,7 @@ public function setUp() : void { */ public function test_course_has_cat() { - $course = $this->getDataGenerator()->create_course(array('category' => $this->category->id)); + $course = $this->getDataGenerator()->create_course(['category' => $this->category->id]); $recordset = $this->processor->get_course_recordset([$this->excludetrigger], []); foreach ($recordset as $element) { @@ -113,7 +113,7 @@ public function test_course_has_cat() { */ public function test_course_within_cat() { - $course = $this->getDataGenerator()->create_course(array('category' => $this->childcategory->id)); + $course = $this->getDataGenerator()->create_course(['category' => $this->childcategory->id]); $recordset = $this->processor->get_course_recordset([$this->excludetrigger], []); foreach ($recordset as $element) { diff --git a/trigger/lib.php b/trigger/lib.php index 3c01ffb7..312c967c 100644 --- a/trigger/lib.php +++ b/trigger/lib.php @@ -50,7 +50,7 @@ abstract public function get_subpluginname(); * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array(); + return []; } /** @@ -152,7 +152,7 @@ public function is_manual_trigger() { * @return array A list containing the constructed sql fragment and an array of parameters. */ public function get_course_recordset_where($triggerid) { - return array('', array()); + return ['', []]; } } diff --git a/trigger/manual/lib.php b/trigger/manual/lib.php index b3bc945e..56a3ff2f 100644 --- a/trigger/manual/lib.php +++ b/trigger/manual/lib.php @@ -76,7 +76,7 @@ public function extend_add_instance_form_definition($mform) { $elementname = 'capability'; $capabilities = get_all_capabilities(); - $capabilitynames = array(); + $capabilitynames = []; foreach ($capabilities as $cap) { $capabilitynames[$cap['name']] = $cap['name']; } diff --git a/trigger/sitecourse/lib.php b/trigger/sitecourse/lib.php index 14809c74..5553ade3 100644 --- a/trigger/sitecourse/lib.php +++ b/trigger/sitecourse/lib.php @@ -59,7 +59,7 @@ public function check_course($course, $triggerid) { public function get_course_recordset_where($triggerid) { global $DB; list($insql, $inparam) = $DB->get_in_or_equal(SITEID, SQL_PARAMS_NAMED); - return array("{course}.id {$insql}", $inparam); + return ["{course}.id {$insql}", $inparam]; } /** diff --git a/trigger/specificdate/lib.php b/trigger/specificdate/lib.php index 9df0bcbd..67922207 100644 --- a/trigger/specificdate/lib.php +++ b/trigger/specificdate/lib.php @@ -80,11 +80,11 @@ public function get_course_recordset_where($triggerid) { $settings['timelastrun'] = $current; $trigger = trigger_manager::get_instance($triggerid); settings_manager::save_settings($triggerid, settings_type::TRIGGER, $trigger->subpluginname, $settings); - return array('true', array()); + return ['true', []]; } } } - return array('false', array()); + return ['false', []]; } /** @@ -95,16 +95,16 @@ public function get_course_recordset_where($triggerid) { */ private function parse_dates($datesraw) { $dates = preg_split('/\r\n|\r|\n/', $datesraw); - $result = array(); + $result = []; foreach ($dates as $date) { $dateparts = explode('.', $date); if (count($dateparts) !== 2) { throw new \moodle_exception("Each date has to consist of two parts devided by point. We got: " . $date); } - $result[] = array( + $result[] = [ 'mon' => $dateparts[1], - 'day' => $dateparts[0] - ); + 'day' => $dateparts[0], + ]; } return $result; } @@ -122,10 +122,10 @@ public function get_subpluginname() { * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array( + return [ new instance_setting('dates', PARAM_TEXT), new instance_setting('timelastrun', PARAM_INT), - ); + ]; } /** diff --git a/trigger/startdatedelay/lib.php b/trigger/startdatedelay/lib.php index 01e3d0ed..7f9f5940 100644 --- a/trigger/startdatedelay/lib.php +++ b/trigger/startdatedelay/lib.php @@ -60,10 +60,10 @@ public function check_course($course, $triggerid) { public function get_course_recordset_where($triggerid) { $delay = settings_manager::get_settings($triggerid, settings_type::TRIGGER)['delay']; $where = "{course}.startdate < :startdatedelay"; - $params = array( + $params = [ "startdatedelay" => time() - $delay, - ); - return array($where, $params); + ]; + return [$where, $params]; } /** @@ -79,9 +79,9 @@ public function get_subpluginname() { * @return instance_setting[] containing settings keys and PARAM_TYPES */ public function instance_settings() { - return array( - new instance_setting('delay', PARAM_INT, true) - ); + return [ + new instance_setting('delay', PARAM_INT, true), + ]; } /** diff --git a/trigger/startdatedelay/tests/trigger_test.php b/trigger/startdatedelay/tests/trigger_test.php index 0175bf4e..cae2a285 100644 --- a/trigger/startdatedelay/tests/trigger_test.php +++ b/trigger/startdatedelay/tests/trigger_test.php @@ -62,7 +62,7 @@ public function setUp() : void { */ public function test_young_course() { - $course = $this->getDataGenerator()->create_course(array('startdate' => time() - 50 * 24 * 60 * 60)); + $course = $this->getDataGenerator()->create_course(['startdate' => time() - 50 * 24 * 60 * 60]); $recordset = $this->processor->get_course_recordset([$this->triggerinstance], []); $found = false; @@ -81,7 +81,7 @@ public function test_young_course() { */ public function test_old_course() { - $course = $this->getDataGenerator()->create_course(array('startdate' => time() - 200 * 24 * 60 * 60)); + $course = $this->getDataGenerator()->create_course(['startdate' => time() - 200 * 24 * 60 * 60]); $recordset = $this->processor->get_course_recordset([$this->triggerinstance], []); $found = false; diff --git a/workflowoverview.php b/workflowoverview.php index f89e0afd..512a24e1 100644 --- a/workflowoverview.php +++ b/workflowoverview.php @@ -84,7 +84,7 @@ 'edit' => get_string('edit'), 'delete' => get_string('delete'), 'move_up' => get_string('move_up', 'tool_lifecycle'), - 'move_down' => get_string('move_down', 'tool_lifecycle') + 'move_down' => get_string('move_down', 'tool_lifecycle'), ]; $showcoursecounts = get_config('tool_lifecycle', 'showcoursecounts'); @@ -97,15 +97,18 @@ $displaytotaltriggered = !empty($triggers); } +$displaytriggers = []; +$displaysteps = []; + foreach ($triggers as $trigger) { // The array from the DB Function uses ids as keys. // Mustache cannot handle arrays which have other keys therefore a new array is build. // FUTURE: Nice to have Icon for each subplugin. - + $trigger = (object)(array) $trigger; // Cast to normal object to be able to set dynamic properties. $actionmenu = new action_menu([ new action_menu_link_secondary( new moodle_url(urls::EDIT_ELEMENT, ['type' => settings_type::TRIGGER, 'elementid' => $trigger->id]), - new pix_icon('i/edit', $str['edit']), $str['edit']) + new pix_icon('i/edit', $str['edit']), $str['edit']), ]); if ($iseditable) { $actionmenu->add(new action_menu_link_secondary( @@ -123,11 +126,13 @@ $trigger->excludedcourses = $amounts[$trigger->sortindex]->excluded; } } + $displaytriggers[] = $trigger; } foreach ($steps as $step) { + $step = (object)(array) $step; // Cast to normal object to be able to set dynamic properties. $ncourses = $DB->count_records('tool_lifecycle_process', - array('stepindex' => $step->sortindex, 'workflowid' => $workflowid)); + ['stepindex' => $step->sortindex, 'workflowid' => $workflowid]); $step->numberofcourses = $ncourses; if ($step->id == $stepid) { $step->selected = true; @@ -135,7 +140,7 @@ $actionmenu = new action_menu([ new action_menu_link_secondary( new moodle_url(urls::EDIT_ELEMENT, ['type' => settings_type::STEP, 'elementid' => $step->id]), - new pix_icon('i/edit', $str['edit']), $str['edit']) + new pix_icon('i/edit', $str['edit']), $str['edit']), ]); if ($iseditable) { $actionmenu->add(new action_menu_link_secondary( @@ -159,11 +164,12 @@ } } $step->actionmenu = $OUTPUT->render($actionmenu); + $displaysteps[] = $step; } -$arrayofcourses = array(); +$arrayofcourses = []; -$url = new moodle_url(urls::WORKFLOW_DETAILS, array('wf' => $workflowid)); +$url = new moodle_url(urls::WORKFLOW_DETAILS, ['wf' => $workflowid]); $out = null; if ($stepid) { @@ -184,12 +190,12 @@ 'rollbackdelay' => format_time($workflow->rollbackdelay), 'finishdelay' => format_time($workflow->finishdelay), 'delayglobally' => $workflow->delayforallworkflows, - 'trigger' => array_values($triggers), + 'trigger' => $displaytriggers, 'showcoursecounts' => $showcoursecounts, - 'steps' => array_values($steps), + 'steps' => $displaysteps, 'listofcourses' => $arrayofcourses, 'nosteplink' => $nosteplink, - 'table' => $out + 'table' => $out, ]; if ($showcoursecounts) { $data['automatic'] = $displaytotaltriggered; @@ -217,15 +223,15 @@ $addinstance .= $OUTPUT->render_from_template('tool_lifecycle/warn_icon', $icondata); $addinstance .= $OUTPUT->single_select(new \moodle_url(urls::EDIT_ELEMENT, - array('type' => settings_type::TRIGGER, 'wf' => $workflow->id)), - 'subplugin', $selectabletriggers, '', array('' => get_string('add_new_trigger_instance', 'tool_lifecycle')), + ['type' => settings_type::TRIGGER, 'wf' => $workflow->id]), + 'subplugin', $selectabletriggers, '', ['' => get_string('add_new_trigger_instance', 'tool_lifecycle')], null, ['id' => 'tool_lifecycle-choose-trigger']); $steps = step_manager::get_step_types(); $addinstance .= ''; $addinstance .= $OUTPUT->single_select(new \moodle_url(urls::EDIT_ELEMENT, - array('type' => settings_type::STEP, 'wf' => $workflow->id)), - 'subplugin', $steps, '', array('' => get_string('add_new_step_instance', 'tool_lifecycle')), + ['type' => settings_type::STEP, 'wf' => $workflow->id]), + 'subplugin', $steps, '', ['' => get_string('add_new_step_instance', 'tool_lifecycle')], null, ['id' => 'tool_lifecycle-choose-step']); $data['addinstance'] = $addinstance; }