. /** * Defines workshop_file_info class * * @package mod * @subpackage workshop * @copyright 2009 David Mudrak * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Represents virtual root node for all submissions * * Workshop submission uses two fileareas: workshop_submission_content * for editor's embeded media and workshop_submission_attachment for attachments. * In both, the itemid represents the submission id. */ class workshop_file_info_submissions_container extends file_info { protected $course; protected $cm; protected $areas; protected $filearea; public function __construct($browser, $course, $cm, $context, $areas, $filearea) { parent::__construct($browser, $context); $this->course = $course; $this->cm = $cm; $this->areas = $areas; $this->filearea = $filearea; } /** * Returns list of standard virtual file/directory identification. * The difference from stored_file parameters is that null values * are allowed in all fields * @return array with keys contextid, filearea, itemid, filepath and filename */ public function get_params() { return array('contextid'=>$this->context->id, 'component'=>'mod_workshop', 'filearea' =>$this->filearea, 'itemid' =>null, 'filepath' =>null, 'filename' =>null); } /** * Returns localised visible name. * @return string */ public function get_visible_name() { return $this->areas[$this->filearea]; } /** * Can I add new files or directories? * @return bool */ public function is_writable() { return false; } /** * Is directory? * @return bool */ public function is_directory() { return true; } /** * Returns list of children. * @return array of file_info instances */ public function get_children() { global $DB; $children = array(); $itemids = $DB->get_records('files', array('contextid' => $this->context->id, 'component' => 'mod_workshop', 'filearea' => $this->filearea), 'itemid', "DISTINCT itemid"); foreach ($itemids as $itemid => $unused) { if ($child = $this->browser->get_file_info($this->context, $this->filearea, $itemid)) { $children[] = $child; } } return $children; } /** * Returns parent file_info instance * @return file_info or null for root */ public function get_parent() { return $this->browser->get_file_info($this->context); } }