Skip to content

Commit 181f47a

Browse files
authored
Merge pull request #25 from Opencast-Moodle/update/4.3
let phpcbf fix the most obvious things
2 parents b6f3c80 + 0e7f265 commit 181f47a

File tree

11 files changed

+28
-32
lines changed

11 files changed

+28
-32
lines changed

classes/chunkupload_form_element.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class chunkupload_form_element extends \HTML_QuickForm_input implements \templat
5656
// We cannot do $_options = array('return_types'=> FILE_INTERNAL | FILE_REFERENCE);.
5757
// So I have to set null here, and do it in constructor.
5858
/** @var array options provided to initalize filemanager */
59-
protected $_options = array('maxbytes' => 0, 'accepted_types' => '*');
59+
protected $_options = ['maxbytes' => 0, 'accepted_types' => '*'];
6060

6161
/**
6262
* Constructor
@@ -152,14 +152,14 @@ public function tohtml() {
152152
$html .= $OUTPUT->render_from_template('core_form/filetypes-descriptions', $filetypedescriptions);
153153
}
154154

155-
$PAGE->requires->js_call_amd('local_chunkupload/chunkupload', 'init', array(
155+
$PAGE->requires->js_call_amd('local_chunkupload/chunkupload', 'init', [
156156
'elementid' => $id,
157157
'acceptedTypes' => $acceptedtypes,
158158
'maxBytes' => (int) $this->_options['maxbytes'],
159159
'wwwroot' => $CFG->wwwroot,
160160
'chunksize' => get_config('local_chunkupload', 'chunksize') * 1024 * 1024,
161161
'browsetext' => get_string('choosefile', 'mod_feedback'),
162-
));
162+
]);
163163
return $html;
164164
}
165165

@@ -296,9 +296,9 @@ public static function export_to_filearea($chunkuploadid, $newcontextid, $newcom
296296
return null;
297297
}
298298

299-
$filerecord = array('contextid' => $newcontextid, 'component' => $newcomponent,
299+
$filerecord = ['contextid' => $newcontextid, 'component' => $newcomponent,
300300
'filearea' => $newfilearea, 'itemid' => $chunkuploadid, 'filepath' => $newfilepath,
301-
'filename' => $record->filename, 'userid' => $record->userid);
301+
'filename' => $record->filename, 'userid' => $record->userid, ];
302302

303303
\core_php_time_limit::raise();
304304

@@ -316,7 +316,7 @@ public static function export_to_filearea($chunkuploadid, $newcontextid, $newcom
316316
*/
317317
public static function delete_file($chunkuploadid) {
318318
global $DB;
319-
$DB->delete_records('local_chunkupload_files', array('id' => $chunkuploadid));
319+
$DB->delete_records('local_chunkupload_files', ['id' => $chunkuploadid]);
320320
$path = self::get_path_for_id($chunkuploadid);
321321
if (file_exists($path)) {
322322
unlink($path);

classes/local/chunkupload_file.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
use local_chunkupload\chunkupload_form_element;
2828

29-
defined('MOODLE_INTERNAL') || die();
30-
3129
/**
3230
* Entityclass for chunkupload file.
3331
*
@@ -49,7 +47,7 @@ class chunkupload_file {
4947
*/
5048
public function __construct($token) {
5149
global $DB;
52-
$record = $DB->get_record('local_chunkupload_files', array('id' => $token));
50+
$record = $DB->get_record('local_chunkupload_files', ['id' => $token]);
5351
if (!$record) {
5452
throw new \moodle_exception("Chunkupload file does not exist");
5553
}
@@ -97,4 +95,4 @@ public function readfile() {
9795
return file_get_contents($this->get_fullpath());
9896
}
9997

100-
}
98+
}

classes/local/tests/testmform.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function definition() {
5454
'local_chunkupload\chunkupload_form_element');
5555

5656
$mform->addElement('chunkupload', 'test', get_string('file'), null,
57-
array('maxbytes' => 2 * 1024 * 1024, 'accepted_types' => array('.png')));
57+
['maxbytes' => 2 * 1024 * 1024, 'accepted_types' => ['.png']]);
5858

5959
$this->add_action_buttons(false, get_string('save'));
6060
}
61-
}
61+
}

classes/state_type.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*/
2323
namespace local_chunkupload;
2424

25-
defined('MOODLE_INTERNAL') || die();
26-
2725
/**
2826
* Defines available state_types.
2927
* @package local_chunkupload

classes/task/cleanup_files.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ public function execute() {
5454

5555
// State UNUSED_TOKEN_GENERATED 0.
5656
$DB->delete_records_select('local_chunkupload_files', 'state = :state AND lastmodified < :time',
57-
array('time' => time() - $config->state0duration, 'state' => state_type::UNUSED_TOKEN_GENERATED));
57+
['time' => time() - $config->state0duration, 'state' => state_type::UNUSED_TOKEN_GENERATED]);
5858

5959
// State UPLOAD_STARTED 1.
6060
$ids = $DB->get_fieldset_select('local_chunkupload_files', 'id',
61-
'lastmodified < :time AND state = :state', array('time' => time() - $config->state1duration,
62-
'state' => state_type::UPLOAD_STARTED));
61+
'lastmodified < :time AND state = :state', ['time' => time() - $config->state1duration,
62+
'state' => state_type::UPLOAD_STARTED, ]);
6363
$DB->delete_records_list('local_chunkupload_files', 'id', $ids);
6464
foreach ($ids as $id) {
6565
$path = chunkupload_form_element::get_path_for_id($id);
@@ -70,8 +70,8 @@ public function execute() {
7070

7171
// State UPLOAD_COMPLETED 2.
7272
$ids = $DB->get_fieldset_select('local_chunkupload_files', 'id',
73-
'lastmodified < :time AND state = :state', array('time' => time() - $config->state2duration,
74-
'state' => state_type::UPLOAD_COMPLETED));
73+
'lastmodified < :time AND state = :state', ['time' => time() - $config->state2duration,
74+
'state' => state_type::UPLOAD_COMPLETED, ]);
7575
$DB->delete_records_list('local_chunkupload_files', 'id', $ids);
7676
foreach ($ids as $id) {
7777
$path = chunkupload_form_element::get_path_for_id($id);

db/tasks.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626

2727
/* List of handlers */
2828

29-
$tasks = array(
30-
array(
29+
$tasks = [
30+
[
3131
'classname' => 'local_chunkupload\task\cleanup_files',
3232
'blocking' => 0,
3333
'minute' => 'R',
3434
'hour' => '*',
3535
'day' => '*',
3636
'dayofweek' => '*',
37-
'month' => '*'
38-
),
39-
);
37+
'month' => '*',
38+
],
39+
];

proceedupload_ajax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@
121121
$DB->update_record('local_chunkupload_files', $record);
122122

123123
$response = new stdClass();
124-
die(json_encode($response));
124+
die(json_encode($response));

startupload_ajax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@
112112
$DB->update_record('local_chunkupload_files', $filerecord);
113113

114114
$response = new stdClass();
115-
die(json_encode($response));
115+
die(json_encode($response));

tests/behat/behat_local_chunkupload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ public function i_upload_the_file_to_the_chunkupload($file, $chunkupload) {
5252
}
5353

5454

55-
}
55+
}

tests/testupload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
}
5252
}
5353
$mform->display();
54-
echo $OUTPUT->footer();
54+
echo $OUTPUT->footer();

0 commit comments

Comments
 (0)