Skip to content

Commit 273c7c8

Browse files
committed
Fix CI issues
1 parent 2a03757 commit 273c7c8

File tree

73 files changed

+743
-738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+743
-738
lines changed

classes/edit_form.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ public function definition() {
5858
$mform->addHelpButton('workflowname', 'workflowname', 'tool_trigger');
5959

6060
// Workflow description.
61-
$editoroptions = array(
61+
$editoroptions = [
6262
'subdirs' => 0,
6363
'maxbytes' => 0,
6464
'maxfiles' => 0,
6565
'changeformat' => 0,
6666
'context' => \context_system::instance(),
6767
'noclean' => 0,
68-
'trusttext' => 0
69-
);
68+
'trusttext' => 0,
69+
];
7070
$mform->addElement('editor', 'workflowdescription', get_string ('workflowdescription', 'tool_trigger'), $editoroptions);
7171
$mform->setType('workflowdescription', PARAM_RAW_TRIMMED);
7272
$mform->addHelpButton('workflowdescription', 'workflowdescription', 'tool_trigger');
@@ -95,7 +95,7 @@ public function definition() {
9595
$mform->addElement('advcheckbox',
9696
'workflowactive',
9797
get_string ('workflowactive', 'tool_trigger'),
98-
'Enable', array(), array(0, 1));
98+
'Enable', [], [0, 1]);
9999
$mform->setType('workflowactive', PARAM_INT);
100100
$mform->addHelpButton('workflowactive', 'workflowactive', 'tool_trigger');
101101
$mform->setDefault('workflowactive', 1);
@@ -104,7 +104,7 @@ public function definition() {
104104
$mform->addElement('advcheckbox',
105105
'workflowrealtime',
106106
get_string ('workflowrealtime', 'tool_trigger'),
107-
'Enable', array(), array(0, 1));
107+
'Enable', [], [0, 1]);
108108
$mform->setType('workflowrealtime', PARAM_INT);
109109
$mform->addHelpButton('workflowrealtime', 'workflowrealtime', 'tool_trigger');
110110
$mform->setDefault('workflowrealtime', 0);
@@ -113,7 +113,7 @@ public function definition() {
113113
$mform->addElement('advcheckbox',
114114
'workflowdebug',
115115
get_string('workflowdebug', 'tool_trigger'),
116-
'Enable', array(), array(0, 1));
116+
'Enable', [], [0, 1]);
117117
$mform->setType('workflowdebug', PARAM_INT);
118118
$mform->addHelpButton('workflowdebug', 'workflowdebug', 'tool_trigger');
119119
$mform->setDefault('workflowdebug', 0);

classes/event_processor.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function is_event_ignored(\core\event\base $event) {
138138
// If we do not have the triggers in the cache then return them from the DB.
139139
if ($sitesubscriptions === false) {
140140
// Set the array for the cache.
141-
$sitesubscriptions = array();
141+
$sitesubscriptions = [];
142142
if ($subscriptions = $DB->get_records_sql($sql)) {
143143
foreach ($subscriptions as $subscription) {
144144
$sitesubscriptions[$subscription->event] = true;
@@ -292,20 +292,20 @@ public static function record_workflow_trigger(int $workflowid, $event, int $att
292292

293293
// Get new run number.
294294
$sqlfrag = "SELECT MAX(number) FROM {tool_trigger_workflow_hist} WHERE workflowid = :wfid";
295-
$runnumber = $DB->get_field_sql($sqlfrag, array('wfid' => $workflowid)) + 1;
295+
$runnumber = $DB->get_field_sql($sqlfrag, ['wfid' => $workflowid]) + 1;
296296

297297
// Encode event data as JSON.
298298
$eventdata = json_encode($event);
299299

300-
$id = $DB->insert_record('tool_trigger_workflow_hist', array(
300+
$id = $DB->insert_record('tool_trigger_workflow_hist', [
301301
'workflowid' => $workflowid,
302302
'number' => $runnumber,
303303
'timecreated' => time(),
304304
'event' => $eventdata,
305305
'eventid' => $event->id,
306306
'userid' => $event->userid,
307-
'attemptnum' => $attemptnum
308-
), true);
307+
'attemptnum' => $attemptnum,
308+
], true);
309309

310310
// Return the id for use in other tables.
311311
return $id;
@@ -488,7 +488,7 @@ public static function execute_next_step_historic(int $stepid, int $origrun = 0,
488488
'workflow' => $step->workflowid,
489489
'run' => $origrun,
490490
'number' => $step->number + 1,
491-
'previd' => $step->id
491+
'previd' => $step->id,
492492
];
493493
$nextstep = $DB->get_record_sql($nextstepsql, $params);
494494

@@ -529,7 +529,7 @@ public static function execute_next_step_historic(int $stepid, int $origrun = 0,
529529
'workflow' => $nextstep->workflowid,
530530
'run' => $runid,
531531
'stepname' => $nextstep->name,
532-
'previd' => $previd
532+
'previd' => $previd,
533533
]);
534534

535535
// Return the ID just executed for use in moving through the historic chain.
@@ -559,7 +559,7 @@ public static function execute_next_step_current(int $stepid) {
559559
$nextstep = $DB->get_record_sql($nextstepsql, [
560560
'workflow' => $step->workflowid,
561561
'run' => $step->runid,
562-
'number' => $step->number + 1
562+
'number' => $step->number + 1,
563563
]);
564564

565565
// If no nextstep is found, jump out.
@@ -582,7 +582,7 @@ public static function execute_next_step_current(int $stepid) {
582582
$newstepid = $DB->get_field_sql($newstepsql, [
583583
'workflow' => $nextstep->workflowid,
584584
'run' => $nextstep->runid,
585-
'stepname' => $nextstep->name
585+
'stepname' => $nextstep->name,
586586
]);
587587
return $newstepid;
588588
}
@@ -619,7 +619,7 @@ public static function execute_step_and_continue_historic(int $stepid, bool $com
619619
$newstep = $DB->get_record_sql($newstepsql, [
620620
'workflow' => $step->workflowid,
621621
'run' => $newrunid,
622-
'stepname' => $step->name
622+
'stepname' => $step->name,
623623
]);
624624

625625
// Now execute the next step in the historic chain.
@@ -660,7 +660,7 @@ public static function execute_step_and_continue_current(int $stepid, bool $comp
660660
$newstep = $DB->get_record_sql($newstepsql, [
661661
'workflow' => $step->workflowid,
662662
'run' => $step->runid,
663-
'stepname' => $step->name
663+
'stepname' => $step->name,
664664
]);
665665

666666
// Now execute the next step, based on the step we just created.
@@ -809,7 +809,7 @@ public static function record_cancelled_workflow($workflowid, $event, $runid = n
809809

810810
// Get new run number.
811811
$sqlfrag = "SELECT MAX(number) FROM {tool_trigger_workflow_hist} WHERE workflowid = :wfid";
812-
$runnumber = $DB->get_field_sql($sqlfrag, array('wfid' => $workflowid)) + 1;
812+
$runnumber = $DB->get_field_sql($sqlfrag, ['wfid' => $workflowid]) + 1;
813813

814814
// Encode event data as JSON.
815815
$eventdata = json_encode($event);
@@ -822,7 +822,7 @@ public static function record_cancelled_workflow($workflowid, $event, $runid = n
822822
'timecreated' => time(),
823823
'event' => $eventdata,
824824
'eventid' => $event->id,
825-
'failedstep' => $status
825+
'failedstep' => $status,
826826
];
827827

828828
if (empty($runid)) {

classes/helper/processor_helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function restore_event(\stdClass $data) {
3737
if (empty((array)$data)) {
3838
return null;
3939
}
40-
$extra = array('origin' => $data->origin, 'ip' => $data->ip, 'realuserid' => $data->realuserid);
40+
$extra = ['origin' => $data->origin, 'ip' => $data->ip, 'realuserid' => $data->realuserid];
4141
$data = (array)$data;
4242
$data['other'] = unserialize($data['other']);
4343
if ($data['other'] === false) {
44-
$data['other'] = array();
44+
$data['other'] = [];
4545
}
4646

4747
// Insert eventid into other data.

classes/import_form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function definition() {
5858

5959
// Workflow file.
6060
$mform->addElement('filepicker', 'userfile', get_string('workflowfile', 'tool_trigger'), null,
61-
array('maxbytes' => 256000, 'accepted_types' => '.json'));
61+
['maxbytes' => 256000, 'accepted_types' => '.json']);
6262
$mform->addRule('userfile', get_string('required'), 'required');
6363
}
6464

@@ -73,7 +73,7 @@ public function definition() {
7373
public function validation($data, $files) {
7474
global $USER;
7575

76-
$validationerrors = array();
76+
$validationerrors = [];
7777

7878
// Get the file from the filestystem. $files will always be empty.
7979
$fs = get_file_storage();

classes/json/json_export.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private function get_workflow_json($workflowrecord) {
132132
*
133133
* @param string $workflowjson
134134
*/
135-
private function print_json_data ($workflowjson) {
135+
private function print_json_data($workflowjson) {
136136
echo $workflowjson;
137137
}
138138

classes/learn_process.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class learn_process {
3737
*
3838
* @var array
3939
*/
40-
private $typearray = array();
40+
private $typearray = [];
4141

4242
/**
4343
* Get a list of all the distinct events names in the learning table.
@@ -64,7 +64,7 @@ private function get_learnt_events() {
6464
private function get_learnt_records($learntevent) {
6565
global $DB;
6666

67-
$learntrecords = $DB->get_recordset('tool_trigger_learn_events', array('eventname' => $learntevent));
67+
$learntrecords = $DB->get_recordset('tool_trigger_learn_events', ['eventname' => $learntevent]);
6868

6969
return $learntrecords;
7070
}
@@ -161,7 +161,7 @@ public function store_json_fields($learntevent, $jsonfields) {
161161
$transaction = $DB->start_delegated_transaction();
162162

163163
// Check for existing record in DB.
164-
$exists = $DB->get_record('tool_trigger_event_fields', array('eventname' => $learntevent), '*', IGNORE_MISSING);
164+
$exists = $DB->get_record('tool_trigger_event_fields', ['eventname' => $learntevent], '*', IGNORE_MISSING);
165165

166166
if ($exists) { // If record exists update.
167167
$record->id = $exists->id;
@@ -180,24 +180,24 @@ public function store_json_fields($learntevent, $jsonfields) {
180180
/**
181181
* Process the learnt events and extract the field names.
182182
*/
183-
public function process () {
183+
public function process() {
184184
global $DB;
185185

186186
// Get a list of the event types from the learn table.
187187
$learntevents = $this->get_learnt_events();
188188

189189
// For each type of event get all the entries for that event from the learn table.
190190
foreach ($learntevents as $learntevent) {
191-
$processedrecords = array();
191+
$processedrecords = [];
192192
$learntrecords = $this->get_learnt_records($learntevent);
193193

194194
foreach ($learntrecords as $record) {
195-
$this->typearray = array(); // Reset typearray before calling convert_record_type.
195+
$this->typearray = []; // Reset typearray before calling convert_record_type.
196196
// Convert each record into an array where key is field name and value is type.
197197
$processedrecords[] = $this->convert_record_type($record, false);
198198

199199
// Remove learnt event from DB.
200-
$DB->delete_records('tool_trigger_learn_events', array('id' => $record->id));
200+
$DB->delete_records('tool_trigger_learn_events', ['id' => $record->id]);
201201
}
202202

203203
$learntrecords->close(); // Don't forget to close the recordset!
@@ -239,7 +239,7 @@ public function get_event_fields_json($eventname) {
239239
global $DB;
240240
$jsonfields = $DB->get_record(
241241
'tool_trigger_event_fields',
242-
array('eventname' => $eventname), 'jsonfields', IGNORE_MISSING);
242+
['eventname' => $eventname], 'jsonfields', IGNORE_MISSING);
243243

244244
return $jsonfields;
245245
}
@@ -252,30 +252,30 @@ public function get_event_fields_json($eventname) {
252252
*/
253253
public function get_event_fields_with_type($eventname) {
254254
global $DB;
255-
$fieldarray = array();
255+
$fieldarray = [];
256256

257257
$jsonfields = $DB->get_record(
258258
'tool_trigger_event_fields',
259-
array('eventname' => $eventname), 'jsonfields', IGNORE_MISSING);
259+
['eventname' => $eventname], 'jsonfields', IGNORE_MISSING);
260260

261261
if ($jsonfields) {
262262
$fields = json_decode($jsonfields->jsonfields, true);
263263
foreach ($fields as $field => $type) {
264-
$fieldarray[] = array(
264+
$fieldarray[] = [
265265
'field' => $field,
266-
'type' => $type
267-
);
266+
'type' => $type,
267+
];
268268
}
269269
}
270270

271-
$fieldarray[] = array(
271+
$fieldarray[] = [
272272
'field' => 'wwwroot',
273-
'type' => 'string'
274-
);
275-
$fieldarray[] = array(
273+
'type' => 'string',
274+
];
275+
$fieldarray[] = [
276276
'field' => 'wwwroot_domain',
277-
'type' => 'string'
278-
);
277+
'type' => 'string',
278+
];
279279

280280
return $fieldarray;
281281
}

classes/output/manageworkflows/renderable.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct($uniqueid, \moodle_url $url, $perpage = 100) {
5959

6060
$this->set_attribute('id', 'tooltriggerrules_table');
6161
$this->set_attribute('class', 'tooltrigger managerules generaltable generalbox');
62-
$this->define_columns(array(
62+
$this->define_columns([
6363
'name',
6464
'description',
6565
'eventname',
@@ -68,9 +68,9 @@ public function __construct($uniqueid, \moodle_url $url, $perpage = 100) {
6868
'numsteps',
6969
'lasttriggered',
7070
'triggerhistory',
71-
'manage'
72-
));
73-
$this->define_headers(array(
71+
'manage',
72+
]);
73+
$this->define_headers([
7474
get_string('name', 'tool_trigger'),
7575
get_string('description', 'tool_trigger'),
7676
get_string('event', 'tool_trigger'),
@@ -80,7 +80,7 @@ public function __construct($uniqueid, \moodle_url $url, $perpage = 100) {
8080
get_string('lasttriggered', 'tool_trigger'),
8181
get_string('triggerhistory', 'tool_trigger'),
8282
get_string('manage', 'tool_trigger'),
83-
)
83+
]
8484
);
8585
$this->pagesize = $perpage;
8686
$systemcontext = \context_system::instance();
@@ -101,7 +101,7 @@ public function __construct($uniqueid, \moodle_url $url, $perpage = 100) {
101101
public function col_name(\tool_trigger\workflow $workflow) {
102102
global $OUTPUT;
103103

104-
$editurl = new \moodle_url('/admin/tool/trigger/edit.php', array('workflowid' => $workflow->id));
104+
$editurl = new \moodle_url('/admin/tool/trigger/edit.php', ['workflowid' => $workflow->id]);
105105
return \html_writer::link($editurl, $workflow->get_name($this->context));
106106
}
107107

@@ -142,7 +142,7 @@ public function col_eventname(\tool_trigger\workflow $workflow) {
142142
}
143143

144144
public function col_triggerhistory(\tool_trigger\workflow $workflow) {
145-
$url = new \moodle_url('/admin/tool/trigger/history.php', array('workflow' => $workflow->id));
145+
$url = new \moodle_url('/admin/tool/trigger/history.php', ['workflow' => $workflow->id]);
146146
return \html_writer::link($url, get_string('workflowviewhistory', 'tool_trigger'));
147147
}
148148

@@ -157,25 +157,25 @@ public function col_manage(\tool_trigger\workflow $workflow) {
157157

158158
$manage = '';
159159

160-
$editurl = new \moodle_url('/admin/tool/trigger/edit.php', array('workflowid' => $workflow->id));
160+
$editurl = new \moodle_url('/admin/tool/trigger/edit.php', ['workflowid' => $workflow->id]);
161161
$icon = $OUTPUT->render(new \pix_icon('t/edit', get_string('editrule', 'tool_trigger')));
162-
$manage .= \html_writer::link($editurl, $icon, array('class' => 'action-icon'));
162+
$manage .= \html_writer::link($editurl, $icon, ['class' => 'action-icon']);
163163

164164
// The user should always be able to copy the rule if they are able to view the page.
165165
$copyurl = new \moodle_url('/admin/tool/trigger/manageworkflow.php',
166-
array('workflowid' => $workflow->id, 'action' => 'copy', 'sesskey' => sesskey()));
166+
['workflowid' => $workflow->id, 'action' => 'copy', 'sesskey' => sesskey()]);
167167
$icon = $OUTPUT->render(new \pix_icon('t/copy', get_string('duplicaterule', 'tool_trigger')));
168-
$manage .= \html_writer::link($copyurl, $icon, array('class' => 'action-icon'));
168+
$manage .= \html_writer::link($copyurl, $icon, ['class' => 'action-icon']);
169169

170-
$deleteurl = new \moodle_url('/admin/tool/trigger/manageworkflow.php', array('workflowid' => $workflow->id,
171-
'action' => 'delete', 'sesskey' => sesskey()));
170+
$deleteurl = new \moodle_url('/admin/tool/trigger/manageworkflow.php', ['workflowid' => $workflow->id,
171+
'action' => 'delete', 'sesskey' => sesskey()]);
172172
$icon = $OUTPUT->render(new \pix_icon('t/delete', get_string('deleterule', 'tool_trigger')));
173-
$manage .= \html_writer::link($deleteurl, $icon, array('class' => 'action-icon'));
173+
$manage .= \html_writer::link($deleteurl, $icon, ['class' => 'action-icon']);
174174

175-
$downloadurl = new \moodle_url('/admin/tool/trigger/export.php', array('workflowid' => $workflow->id,
176-
'action' => 'download', 'sesskey' => sesskey()));
175+
$downloadurl = new \moodle_url('/admin/tool/trigger/export.php', ['workflowid' => $workflow->id,
176+
'action' => 'download', 'sesskey' => sesskey()]);
177177
$icon = $OUTPUT->render(new \pix_icon('t/download', get_string('downloadrule', 'tool_trigger')));
178-
$manage .= \html_writer::link($downloadurl, $icon, array('class' => 'action-icon'));
178+
$manage .= \html_writer::link($downloadurl, $icon, ['class' => 'action-icon']);
179179

180180
return $manage;
181181
}

0 commit comments

Comments
 (0)