/** * Returns the view html to display. * * @param array $options An array of display options * @return string HTML fragment */ public function display(array $options = array()) { $this->selection = $this->param4 ? $this->param4 : 0; $this->interval = $this->param5 ? $this->param5 : 0; $this->custom = $this->param6 ? $this->param6 : 0; $this->resetnext = $this->param8 ? $this->param8 : 100; $this->page = $this->filter->page; $this->filter->selection = $this->selection; // Set or clean up cache according to interval. if (!$this->interval and $this->param7) { $this->param7 = null; $this->update($this->data); } // Check if view is caching. if ($this->interval) { $filteroptions = $this->get_cache_filter_options(); foreach ($filteroptions as $option => $value) { $this->filter->{$option} = $value; } if (!($entriesset = $this->get_cache_content())) { $entriesset = $this->entry_manager->fetch_entries(array('filter' => $this->filter)); $this->update_cache_content($entriesset); $this->filter->page = $entriesset->page; } $options['entriesset'] = $entriesset; } return parent::display($options); }
/** * Serves the dataformview_grid template files. * * @param object $course * @param object $cm * @param object $context * @param string $filearea * @param array $args * @param bool $forcedownload * @return bool false if file not found, does not return if found - justsend the file */ function dataformview_grid_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) { if (!in_array($filearea, dataformview_grid_grid::get_file_areas())) { return false; } if ($context->contextlevel == CONTEXT_MODULE) { require_course_login($course, true, $cm); $viewid = (int) array_shift($args); $dataformid = $cm->instance; // Confirm user access. $params = array('dataformid' => $dataformid, 'viewid' => $viewid); if (!mod_dataform\access\view_access::validate($params)) { return false; } $relativepath = implode('/', $args); $fullpath = "/{$context->id}/dataformview_grid/{$filearea}/{$viewid}/{$relativepath}"; $fs = get_file_storage(); if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) { return false; } // Finally send the file. send_stored_file($file, 0, 0, true); // Download MUST be forced - security! } return false; }