From 4e0effd60cdb6f0962e9abd4c79c21a9e24c8cdd Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 28 Apr 2010 02:16:09 +0000 Subject: [PATCH] Assignment MDL-7206 implement file browsing api in Assignment mod --- mod/assignment/lib.php | 33 +++++++++++---------------------- mod/assignment/locallib.php | 19 +------------------ 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index dd6441b9692..2e9dc8a90bc 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -3459,30 +3459,19 @@ function assignment_get_file_areas($course, $cm, $context) { * @return object file_info instance or null if not found */ function assignment_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) { - global $CFG; + global $CFG, $DB; - $canwrite = has_capability('moodle/course:managefiles', $context); - - $fs = get_file_storage(); - - if ($filearea === 'assignment_submission') { - $filepath = is_null($filepath) ? '/' : $filepath; - $filename = is_null($filename) ? '.' : $filename; - - $urlbase = $CFG->wwwroot.'/pluginfile.php'; - if (!$storedfile = $fs->get_file($context->id, $filearea, 0, $filepath, $filename)) { - if ($filepath === '/' and $filename === '.') { - $storedfile = new virtual_root_file($context->id, $filearea, 0); - } else { - // not found - return null; - } - } - require_once("$CFG->dirroot/mod/assignment/locallib.php"); - return new assignment_content_file_info($browser, $context, $storedfile, $urlbase, $areas[$filearea], true, true, $canwrite, false); + if (!has_capability('moodle/course:managefiles', $context)) { + // no peaking here, sorry + return null; } - // note: folder_intro handled in file_browser automatically + if ($filearea !== 'assignment_submission') { + return null; + } + //TODO: handle itemid as group id here. - return null; + $fs = get_file_storage(); + $files = $fs->get_area_files($context->id, $filearea); + return $files; } \ No newline at end of file diff --git a/mod/assignment/locallib.php b/mod/assignment/locallib.php index 04f619ecfea..9d234a5a0a2 100644 --- a/mod/assignment/locallib.php +++ b/mod/assignment/locallib.php @@ -151,21 +151,4 @@ class assignment_portfolio_caller extends portfolio_module_caller_base { public static function base_supported_formats() { return array(PORTFOLIO_FORMAT_FILE, PORTFOLIO_FORMAT_LEAP2A); } -} -/** - * File browsing support class - */ -class assignment_content_file_info extends file_info_stored { - public function get_parent() { - if ($this->lf->get_filepath() === '/' and $this->lf->get_filename() === '.') { - return $this->browser->get_file_info($this->context); - } - return parent::get_parent(); - } - public function get_visible_name() { - if ($this->lf->get_filepath() === '/' and $this->lf->get_filename() === '.') { - return $this->topvisiblename; - } - return parent::get_visible_name(); - } -} +} \ No newline at end of file