Merge branch 'MDL-30239-master' of git://github.com/jleyva/moodle

This commit is contained in:
Dan Poltawski 2015-02-09 12:32:59 +00:00
commit b9d7f56337
3 changed files with 26 additions and 3 deletions

View File

@ -74,6 +74,7 @@ class core_files_external extends external_api {
* @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 @@ class core_files_external extends external_api {
$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 @@ class core_files_external extends external_api {
'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 @@ class core_files_external extends external_api {
'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 @@ class core_files_external extends external_api {
* 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 @@ class core_files_external extends external_api {
'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),
)
)
)

View File

@ -244,6 +244,8 @@ class core_files_externallib_testcase extends advanced_testcase {
// 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 @@ class core_files_externallib_testcase extends advanced_testcase {
'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);

View File

@ -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
<PLUGIN name="component_name"> tag instead of the version dependent <MOODLE version="x.y"> 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 ===