protected function get_area_course_section($itemid, $filepath, $filename) {
        global $CFG, $DB;

        if (!has_capability('moodle/course:update', $this->context)) {
            return null;
        }

        if (empty($itemid)) {
            // list all sections
            return new file_info_area_course_section($this->browser, $this->context, $this->course, $this);
        }

        if (!$section = $DB->get_record('course_sections', array('course'=>$this->course->id, 'id'=>$itemid))) {
            return null; // does not exist
        }

        $fs = get_file_storage();

        $filepath = is_null($filepath) ? '/' : $filepath;
        $filename = is_null($filename) ? '.' : $filename;
        if (!$storedfile = $fs->get_file($this->context->id, 'course', 'section', $itemid, $filepath, $filename)) {
            if ($filepath === '/' and $filename === '.') {
                $storedfile = new virtual_root_file($this->context->id, 'course', 'section', $itemid);
            } else {
                // not found
                return null;
            }
        }
        $urlbase = $CFG->wwwroot.'/pluginfile.php';
        require_once($CFG->dirroot.'/course/lib.php');
        $sectionname = get_section_name($this->course, $section);
        return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, $sectionname, true, true, true, false);
    }
protected function get_area_course_section($itemid, $filepath, $filename) {
        global $CFG, $DB;

        if (!has_capability('moodle/course:update', $this->context)) {
            return null;
        }

        if (empty($itemid)) {
            // list all sections
            return new file_info_area_course_section($this->browser, $this->context, $this->course, $this);
        }

        if (!$section = $DB->get_record('course_sections', array('course'=>$this->course->id, 'id'=>$itemid))) {
            return null; // does not exist
        }

        $fs = get_file_storage();

        $filepath = is_null($filepath) ? '/' : $filepath;
        $filename = is_null($filename) ? '.' : $filename;
        if (!$storedfile = $fs->get_file($this->context->id, 'course', 'section', $itemid, $filepath, $filename)) {
            if ($filepath === '/' and $filename === '.') {
                $storedfile = new virtual_root_file($this->context->id, 'course', 'section', $itemid);
            } else {
                // not found
                return null;
            }
        }
        $urlbase = $CFG->wwwroot.'/pluginfile.php';
        require_once($CFG->dirroot.'/course/lib.php');
        $sectionname = get_section_name($this->course, $section);
        return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, $sectionname, true, true, true, false);
    }
protected function get_area_course_section ( $ itemid , $ filepath , $ filename ) { global $ CFG , $ DB ; if ( ! has_capability ( 'moodle/course:update' , $ this -> context ) ) { return null ; } if ( empty ( $ itemid ) ) { // list all sections return new file_info_area_course_section ( $ this -> browser , $ this -> context , $ this -> course , $ this ) ; } if ( ! $ section = $ DB -> get_record ( 'course_sections' , array ( 'course' => $ this -> course -> id , 'id' => $ itemid ) ) ) { return null ; // does not exist } $ fs = get_file_storage ( ) ; $ filepath = is_null ( $ filepath ) ? '/' : $ filepath ; $ filename = is_null ( $ filename ) ? '.' : $ filename ; if ( ! $ storedfile = $ fs -> get_file ( $ this -> context -> id , 'course' , 'section' , $ itemid , $ filepath , $ filename ) ) { if ( $ filepath === '/' and $ filename === '.' ) { $ storedfile = new virtual_root_file ( $ this -> context -> id , 'course' , 'section' , $ itemid ) ; } else { // not found return null ; } } $ urlbase = $ CFG -> wwwroot . '/pluginfile.php' ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; $ sectionname = get_section_name ( $ this -> course , $ section ) ; return new file_info_stored ( $ this -> browser , $ this -> context , $ storedfile , $ urlbase , $ sectionname , true , true , true , false ) ; }
Gets a stored file for the course section filearea directory

@param int $itemid item ID
@param string $filepath file path
@param string $filename file name
@return file_info|null file_info instance or null if not found or access not allowed
Gets a stored file for the course section filearea directory