From 8e00c17c6b44fe6fb99b18941b89479faf955d3c Mon Sep 17 00:00:00 2001 From: NinaHerrmann Date: Thu, 23 Nov 2023 11:20:38 +0100 Subject: [PATCH 1/2] let phpcbf fix the most obvious things --- classes/chunkupload_form_element.php | 12 ++++++------ classes/local/chunkupload_file.php | 6 ++---- classes/local/tests/testmform.php | 4 ++-- classes/state_type.php | 2 -- classes/task/cleanup_files.php | 10 +++++----- db/tasks.php | 10 +++++----- proceedupload_ajax.php | 2 +- startupload_ajax.php | 2 +- tests/behat/behat_local_chunkupload.php | 2 +- tests/testupload.php | 2 +- 10 files changed, 24 insertions(+), 28 deletions(-) diff --git a/classes/chunkupload_form_element.php b/classes/chunkupload_form_element.php index 37e9227..26a4955 100644 --- a/classes/chunkupload_form_element.php +++ b/classes/chunkupload_form_element.php @@ -56,7 +56,7 @@ class chunkupload_form_element extends \HTML_QuickForm_input implements \templat // We cannot do $_options = array('return_types'=> FILE_INTERNAL | FILE_REFERENCE);. // So I have to set null here, and do it in constructor. /** @var array options provided to initalize filemanager */ - protected $_options = array('maxbytes' => 0, 'accepted_types' => '*'); + protected $_options = ['maxbytes' => 0, 'accepted_types' => '*']; /** * Constructor @@ -152,14 +152,14 @@ public function tohtml() { $html .= $OUTPUT->render_from_template('core_form/filetypes-descriptions', $filetypedescriptions); } - $PAGE->requires->js_call_amd('local_chunkupload/chunkupload', 'init', array( + $PAGE->requires->js_call_amd('local_chunkupload/chunkupload', 'init', [ 'elementid' => $id, 'acceptedTypes' => $acceptedtypes, 'maxBytes' => (int) $this->_options['maxbytes'], 'wwwroot' => $CFG->wwwroot, 'chunksize' => get_config('local_chunkupload', 'chunksize') * 1024 * 1024, 'browsetext' => get_string('choosefile', 'mod_feedback'), - )); + ]); return $html; } @@ -296,9 +296,9 @@ public static function export_to_filearea($chunkuploadid, $newcontextid, $newcom return null; } - $filerecord = array('contextid' => $newcontextid, 'component' => $newcomponent, + $filerecord = ['contextid' => $newcontextid, 'component' => $newcomponent, 'filearea' => $newfilearea, 'itemid' => $chunkuploadid, 'filepath' => $newfilepath, - 'filename' => $record->filename, 'userid' => $record->userid); + 'filename' => $record->filename, 'userid' => $record->userid, ]; \core_php_time_limit::raise(); @@ -316,7 +316,7 @@ public static function export_to_filearea($chunkuploadid, $newcontextid, $newcom */ public static function delete_file($chunkuploadid) { global $DB; - $DB->delete_records('local_chunkupload_files', array('id' => $chunkuploadid)); + $DB->delete_records('local_chunkupload_files', ['id' => $chunkuploadid]); $path = self::get_path_for_id($chunkuploadid); if (file_exists($path)) { unlink($path); diff --git a/classes/local/chunkupload_file.php b/classes/local/chunkupload_file.php index 87a571d..2a12c17 100644 --- a/classes/local/chunkupload_file.php +++ b/classes/local/chunkupload_file.php @@ -26,8 +26,6 @@ use local_chunkupload\chunkupload_form_element; -defined('MOODLE_INTERNAL') || die(); - /** * Entityclass for chunkupload file. * @@ -49,7 +47,7 @@ class chunkupload_file { */ public function __construct($token) { global $DB; - $record = $DB->get_record('local_chunkupload_files', array('id' => $token)); + $record = $DB->get_record('local_chunkupload_files', ['id' => $token]); if (!$record) { throw new \moodle_exception("Chunkupload file does not exist"); } @@ -97,4 +95,4 @@ public function readfile() { return file_get_contents($this->get_fullpath()); } -} \ No newline at end of file +} diff --git a/classes/local/tests/testmform.php b/classes/local/tests/testmform.php index 4acca5d..4491a9d 100644 --- a/classes/local/tests/testmform.php +++ b/classes/local/tests/testmform.php @@ -54,8 +54,8 @@ public function definition() { 'local_chunkupload\chunkupload_form_element'); $mform->addElement('chunkupload', 'test', get_string('file'), null, - array('maxbytes' => 2 * 1024 * 1024, 'accepted_types' => array('.png'))); + ['maxbytes' => 2 * 1024 * 1024, 'accepted_types' => ['.png']]); $this->add_action_buttons(false, get_string('save')); } -} \ No newline at end of file +} diff --git a/classes/state_type.php b/classes/state_type.php index d0b6b2f..e99c607 100644 --- a/classes/state_type.php +++ b/classes/state_type.php @@ -22,8 +22,6 @@ */ namespace local_chunkupload; -defined('MOODLE_INTERNAL') || die(); - /** * Defines available state_types. * @package local_chunkupload diff --git a/classes/task/cleanup_files.php b/classes/task/cleanup_files.php index ac35dfb..dfe5cb2 100644 --- a/classes/task/cleanup_files.php +++ b/classes/task/cleanup_files.php @@ -54,12 +54,12 @@ public function execute() { // State UNUSED_TOKEN_GENERATED 0. $DB->delete_records_select('local_chunkupload_files', 'state = :state AND lastmodified < :time', - array('time' => time() - $config->state0duration, 'state' => state_type::UNUSED_TOKEN_GENERATED)); + ['time' => time() - $config->state0duration, 'state' => state_type::UNUSED_TOKEN_GENERATED]); // State UPLOAD_STARTED 1. $ids = $DB->get_fieldset_select('local_chunkupload_files', 'id', - 'lastmodified < :time AND state = :state', array('time' => time() - $config->state1duration, - 'state' => state_type::UPLOAD_STARTED)); + 'lastmodified < :time AND state = :state', ['time' => time() - $config->state1duration, + 'state' => state_type::UPLOAD_STARTED, ]); $DB->delete_records_list('local_chunkupload_files', 'id', $ids); foreach ($ids as $id) { $path = chunkupload_form_element::get_path_for_id($id); @@ -70,8 +70,8 @@ public function execute() { // State UPLOAD_COMPLETED 2. $ids = $DB->get_fieldset_select('local_chunkupload_files', 'id', - 'lastmodified < :time AND state = :state', array('time' => time() - $config->state2duration, - 'state' => state_type::UPLOAD_COMPLETED)); + 'lastmodified < :time AND state = :state', ['time' => time() - $config->state2duration, + 'state' => state_type::UPLOAD_COMPLETED, ]); $DB->delete_records_list('local_chunkupload_files', 'id', $ids); foreach ($ids as $id) { $path = chunkupload_form_element::get_path_for_id($id); diff --git a/db/tasks.php b/db/tasks.php index d59a459..6b08e57 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -26,14 +26,14 @@ /* List of handlers */ -$tasks = array( - array( +$tasks = [ + [ 'classname' => 'local_chunkupload\task\cleanup_files', 'blocking' => 0, 'minute' => 'R', 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' - ), -); + 'month' => '*', + ], +]; diff --git a/proceedupload_ajax.php b/proceedupload_ajax.php index 4cdb327..12e5965 100644 --- a/proceedupload_ajax.php +++ b/proceedupload_ajax.php @@ -121,4 +121,4 @@ $DB->update_record('local_chunkupload_files', $record); $response = new stdClass(); -die(json_encode($response)); \ No newline at end of file +die(json_encode($response)); diff --git a/startupload_ajax.php b/startupload_ajax.php index 40b8f38..3ce1271 100644 --- a/startupload_ajax.php +++ b/startupload_ajax.php @@ -112,4 +112,4 @@ $DB->update_record('local_chunkupload_files', $filerecord); $response = new stdClass(); -die(json_encode($response)); \ No newline at end of file +die(json_encode($response)); diff --git a/tests/behat/behat_local_chunkupload.php b/tests/behat/behat_local_chunkupload.php index 939e59c..93ad4ef 100644 --- a/tests/behat/behat_local_chunkupload.php +++ b/tests/behat/behat_local_chunkupload.php @@ -52,4 +52,4 @@ public function i_upload_the_file_to_the_chunkupload($file, $chunkupload) { } -} \ No newline at end of file +} diff --git a/tests/testupload.php b/tests/testupload.php index 5e62cbb..6c8cdc5 100644 --- a/tests/testupload.php +++ b/tests/testupload.php @@ -51,4 +51,4 @@ } } $mform->display(); -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); From 0e7f26500d89f7acd56801b0fd90d043f20512d4 Mon Sep 17 00:00:00 2001 From: NinaHerrmann Date: Thu, 23 Nov 2023 14:52:17 +0100 Subject: [PATCH 2/2] updated version number --- version.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/version.php b/version.php index 271d94b..3364acf 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'local_chunkupload'; -$plugin->release = 'development-version'; -$plugin->version = 2023030100; -$plugin->requires = 2020061500; // Requires Moodle 3.9+. -$plugin->maturity = MATURITY_ALPHA; +$plugin->release = 'v4.3-r1'; +$plugin->version = 2023112200; +$plugin->requires = 2020061524; // Requires Moodle 3.9+. +$plugin->maturity = MATURITY_STABLE;