3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Defines workshop_file_info class
22 * @subpackage workshop
23 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') ||
die();
30 * Represents virtual root node for all submissions
32 * Workshop submission uses two fileareas: workshop_submission_content
33 * for editor's embeded media and workshop_submission_attachment for attachments.
34 * In both, the itemid represents the submission id.
36 class workshop_file_info_submissions_container
extends file_info
{
42 public function __construct($browser, $course, $cm, $context, $areas, $filearea) {
43 parent
::__construct($browser, $context);
44 $this->course
= $course;
46 $this->areas
= $areas;
47 $this->filearea
= $filearea;
51 * Returns list of standard virtual file/directory identification.
52 * The difference from stored_file parameters is that null values
53 * are allowed in all fields
54 * @return array with keys contextid, filearea, itemid, filepath and filename
56 public function get_params() {
57 return array('contextid'=>$this->context
->id
,
58 'component'=>'mod_workshop',
59 'filearea' =>$this->filearea
,
66 * Returns localised visible name.
69 public function get_visible_name() {
70 return $this->areas
[$this->filearea
];
74 * Can I add new files or directories?
77 public function is_writable() {
85 public function is_directory() {
90 * Returns list of children.
91 * @return array of file_info instances
93 public function get_children() {
97 $itemids = $DB->get_records('files', array('contextid' => $this->context
->id
, 'component' => 'mod_workshop', 'filearea' => $this->filearea
),
98 'itemid', "DISTINCT itemid");
99 foreach ($itemids as $itemid => $unused) {
100 if ($child = $this->browser
->get_file_info($this->context
, $this->filearea
, $itemid)) {
101 $children[] = $child;
108 * Returns parent file_info instance
109 * @return file_info or null for root
111 public function get_parent() {
112 return $this->browser
->get_file_info($this->context
);