} else { error('You must specify a course_module ID or an instance ID'); } require_login($course, true, $cm); $context = context_module::instance($cm->id); require_capability('mod/resource:view', $context); add_to_log($course->id, 'pdfparts', 'view', "view.php?id={$cm->id}", $pdfparts->name, $cm->id); // Update 'viewed' state if required by completion system $completion = new completion_info($course); $completion->set_module_viewed($cm); $PAGE->set_url('/mod/pdfparts/view.php', array('id' => $cm->id)); $fs = get_file_storage(); $files = $fs->get_area_files($context->id, 'mod_pdfparts', 'content', 0, 'sortorder DESC, id ASC', false); // TODO: this is not very efficient!! if (count($files) < 1) { resource_print_filenotfound($pdfparts, $cm, $course); die; } else { $file = reset($files); unset($files); } $pdfparts->mainfile = $file->get_filename(); $displaytype = pdfparts_get_final_display_type($pdfparts); // override the property loaded from DB with the values from the GET request if ($pages) { $pdfparts->pages = $pages; // I don't like this ideea, but... } /* if ($displaytype == RESOURCELIB_DISPLAY_OPEN || $displaytype == RESOURCELIB_DISPLAY_DOWNLOAD) { // For 'open' and 'download' links, we always redirect to the content - except
$context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/resource:view', $context); add_to_log($course->id, 'resource', 'view', 'view.php?id=' . $cm->id, $resource->id, $cm->id); // Update 'viewed' state if required by completion system $completion = new completion_info($course); $completion->set_module_viewed($cm); $PAGE->set_url('/mod/resource/view.php', array('id' => $cm->id)); if ($resource->tobemigrated) { resource_print_tobemigrated($resource, $cm, $course); die; } $fs = get_file_storage(); $files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false); // TODO: this is not very efficient!! if (count($files) < 1) { resource_print_filenotfound($resource, $cm, $course); die; } else { $file = reset($files); unset($files); } if ($redirect) { // coming from course page or url index page // this redirect trick solves caching problems when tracking views ;-) $path = '/' . $context->id . '/mod_resource/content/' . $resource->revision . $file->get_filepath() . $file->get_filename(); $fullurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', $path, false); redirect($fullurl); } $resource->mainfile = $file->get_filename(); switch (resource_get_final_display_type($resource)) { case RESOURCELIB_DISPLAY_EMBED: