コード例 #1
0
ファイル: lib.php プロジェクト: parksandwildlife/learning
/**
 * Serves the dataformview_aligned 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_aligned_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload)
{
    if (!in_array($filearea, dataformview_aligned_aligned::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_aligned/{$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;
}
コード例 #2
0
ファイル: csv.php プロジェクト: vaenda/moodle-mod_dataform
 /**
  * Overridden to show import form without entries
  */
 public function display(array $params = array())
 {
     global $OUTPUT;
     if ($this->_showimportform and $this->param5) {
         // Print import form.
         $mform = $this->get_import_form();
         $mform->set_data($this->data);
         $dataformviewtype = "dataformview-{$this->type}";
         $viewname = str_replace(' ', '_', $this->name);
         $report = $this->print_report();
         return html_writer::tag('div', $mform->render() . $report, array('class' => "{$dataformviewtype} {$viewname}"));
     } else {
         // Print the view.
         return parent::display($params);
     }
 }