From 4239150a606101318983a31e2dec548b6dee4a6e Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Thu, 31 May 2012 12:06:32 +0800 Subject: [PATCH 1/2] MDL-33322 Filepicker: fix filepicker for recent file with JS turned of --- repository/filepicker.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/repository/filepicker.php b/repository/filepicker.php index 407b3ddd35e..4dab067602d 100644 --- a/repository/filepicker.php +++ b/repository/filepicker.php @@ -67,7 +67,7 @@ $draftpath = optional_param('draftpath', '/', PARAM_PATH); // user context -$user_context = get_context_instance(CONTEXT_USER, $USER->id); +$user_context = context_user::instance($USER->id); $PAGE->set_context($user_context); if (!$course = $DB->get_record('course', array('id'=>$courseid))) { @@ -298,7 +298,14 @@ case 'download': $record->itemid = $itemid; $record->license = ''; $record->author = ''; - $record->source = $thefile['url']; + + $now = time(); + $record->timecreated = $now; + $record->timemodified = $now; + $record->userid = $USER->id; + $record->contextid = $user_context->id; + + $record->source = serialize((object)array('source' => $thefile['url'])); try { $info = repository::move_to_filepool($thefile['path'], $record); redirect($home_url, get_string('downloadsucc', 'repository')); From 3c693ff4d295c5e7a965fe2063129dcb31a05900 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 1 Jun 2012 10:53:10 +0800 Subject: [PATCH 2/2] MDL-33322: fixed strict standards --- repository/draftfiles_manager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repository/draftfiles_manager.php b/repository/draftfiles_manager.php index b3f1ddeb50d..0bbc3a39042 100644 --- a/repository/draftfiles_manager.php +++ b/repository/draftfiles_manager.php @@ -333,7 +333,8 @@ default: $home_url->param('action', 'browse'); $home_url->param('draftpath', $file->filepath); - $foldername = trim(array_pop(explode('/', trim($file->filepath, '/'))), '/'); + $filepathchunks = explode('/', trim($file->filepath, '/')); + $foldername = trim(array_pop($filepathchunks), '/'); echo html_writer::link($home_url, $foldername); $home_url->param('draftpath', $file->filepath);