diff --git a/files/externallib.php b/files/externallib.php index fdf63c548b190..19cba7ff1104e 100644 --- a/files/externallib.php +++ b/files/externallib.php @@ -74,6 +74,7 @@ public static function get_files_parameters() { * @param string $contextlevel The context level for the file location. * @param int $instanceid The instance id for where the file is located. * @return array + * @since Moodle 2.9 Returns additional fields (timecreated, filesize, author, license) * @since Moodle 2.2 */ public static function get_files($contextid, $component, $filearea, $itemid, $filepath, $filename, $modified = null, @@ -139,6 +140,7 @@ public static function get_files($contextid, $component, $filearea, $itemid, $fi $params = $child->get_params(); $timemodified = $child->get_timemodified(); + $timecreated = $child->get_timecreated(); if ($child->is_directory()) { if ((is_null($modified)) or ($modified < $timemodified)) { @@ -151,7 +153,11 @@ public static function get_files($contextid, $component, $filearea, $itemid, $fi 'filename' => $child->get_visible_name(), 'url' => null, 'isdir' => true, - 'timemodified' => $timemodified + 'timemodified' => $timemodified, + 'timecreated' => $timecreated, + 'filesize' => 0, + 'author' => null, + 'license' => null ); $list[] = $node; } @@ -166,7 +172,11 @@ public static function get_files($contextid, $component, $filearea, $itemid, $fi 'filename' => $child->get_visible_name(), 'url' => $child->get_url(), 'isdir' => false, - 'timemodified' => $timemodified + 'timemodified' => $timemodified, + 'timecreated' => $timecreated, + 'filesize' => $child->get_filesize(), + 'author' => $child->get_author(), + 'license' => $child->get_license() ); $list[] = $node; } @@ -181,6 +191,7 @@ public static function get_files($contextid, $component, $filearea, $itemid, $fi * Returns description of get_files returns * * @return external_single_structure + * @since Moodle 2.9 Returns additional fields for files (timecreated, filesize, author, license) * @since Moodle 2.2 */ public static function get_files_returns() { @@ -210,6 +221,10 @@ public static function get_files_returns() { 'isdir' => new external_value(PARAM_BOOL, ''), 'url' => new external_value(PARAM_TEXT, ''), 'timemodified' => new external_value(PARAM_INT, ''), + 'timecreated' => new external_value(PARAM_INT, 'Time created', VALUE_OPTIONAL), + 'filesize' => new external_value(PARAM_INT, 'File size', VALUE_OPTIONAL), + 'author' => new external_value(PARAM_TEXT, 'File owner', VALUE_OPTIONAL), + 'license' => new external_value(PARAM_TEXT, 'File license', VALUE_OPTIONAL), ) ) ) diff --git a/files/tests/externallib_test.php b/files/tests/externallib_test.php index 3922c6494b6a3..b49ff72f63dd2 100644 --- a/files/tests/externallib_test.php +++ b/files/tests/externallib_test.php @@ -244,6 +244,8 @@ public function test_get_files() { // Create a file from the string that we made earlier. $file = $fs->create_file_from_string($filerecord, $filecontent); $timemodified = $file->get_timemodified(); + $timecreated = $file->get_timemodified(); + $filesize = $file->get_filesize(); // Use the web service function to return the information about the file that we just uploaded. // The first time is with a valid context ID. @@ -293,7 +295,12 @@ public function test_get_files() { 'filename' => 'Simple4.txt', 'url' => 'http://www.example.com/moodle/pluginfile.php/'.$context->id.'/mod_data/content/'.$itemid.'/Simple4.txt', 'isdir' => false, - 'timemodified' => $timemodified); + 'timemodified' => $timemodified, + 'timecreated' => $timecreated, + 'filesize' => $filesize, + 'author' => null, + 'license' => null + ); // Make sure that they are the same. $this->assertEquals($testdata, $testfilelisting); diff --git a/lib/upgrade.txt b/lib/upgrade.txt index e2451da66205a..0d652cf8c94ae 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -15,6 +15,7 @@ information provided here is intended especially for developers. * For 3rd party plugin specific environment.xml files, it's now possible to specify version independent checks by using the tag instead of the version dependent one. If the PLUGIN tag is used any Moodle specific tags will be ignored. +* External function core_files_get_files returns additional fields (timecreated, filesize, author, license) === 2.8 ===