Skip to content

Commit

Permalink
Merge pull request #25 from Opencast-Moodle/update/4.3
Browse files Browse the repository at this point in the history
let phpcbf fix the most obvious things
  • Loading branch information
NinaHerrmann authored Nov 23, 2023
2 parents b6f3c80 + 0e7f265 commit 181f47a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 32 deletions.
12 changes: 6 additions & 6 deletions classes/chunkupload_form_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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();

Expand All @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions classes/local/chunkupload_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

use local_chunkupload\chunkupload_form_element;

defined('MOODLE_INTERNAL') || die();

/**
* Entityclass for chunkupload file.
*
Expand All @@ -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");
}
Expand Down Expand Up @@ -97,4 +95,4 @@ public function readfile() {
return file_get_contents($this->get_fullpath());
}

}
}
4 changes: 2 additions & 2 deletions classes/local/tests/testmform.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}
}
2 changes: 0 additions & 2 deletions classes/state_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/
namespace local_chunkupload;

defined('MOODLE_INTERNAL') || die();

/**
* Defines available state_types.
* @package local_chunkupload
Expand Down
10 changes: 5 additions & 5 deletions classes/task/cleanup_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions db/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '*',
],
];
2 changes: 1 addition & 1 deletion proceedupload_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@
$DB->update_record('local_chunkupload_files', $record);

$response = new stdClass();
die(json_encode($response));
die(json_encode($response));
2 changes: 1 addition & 1 deletion startupload_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@
$DB->update_record('local_chunkupload_files', $filerecord);

$response = new stdClass();
die(json_encode($response));
die(json_encode($response));
2 changes: 1 addition & 1 deletion tests/behat/behat_local_chunkupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ public function i_upload_the_file_to_the_chunkupload($file, $chunkupload) {
}


}
}
2 changes: 1 addition & 1 deletion tests/testupload.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
}
}
$mform->display();
echo $OUTPUT->footer();
echo $OUTPUT->footer();
8 changes: 4 additions & 4 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 181f47a

Please sign in to comment.