Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / mod / resource / view.php
blobaeb9c392c529d820b1f4580511c485607cfba968
1 <?php // $Id$
3 require_once("../../config.php");
4 require_once("lib.php");
6 $id = optional_param('id', 0, PARAM_INT); // Course Module ID
7 $r = optional_param('r', 0, PARAM_INT); // Resource
9 if ($r) { // Two ways to specify the resource
10 if (! $resource = get_record('resource', 'id', $r)) {
11 error('Resource ID was incorrect');
14 if (! $cm = get_coursemodule_from_instance('resource', $resource->id, $resource->course)) {
15 error('Course Module ID was incorrect');
18 } else if ($id) {
19 if (! $cm = get_coursemodule_from_id('resource', $id)) {
20 error('Course Module ID was incorrect');
23 if (! $resource = get_record('resource', 'id', $cm->instance)) {
24 error('Resource ID was incorrect');
26 } else {
27 error('No valid parameters!!');
30 if (! $course = get_record('course', 'id', $cm->course)) {
31 error('Incorrect course id');
34 require_course_login($course, true, $cm);
36 require ($CFG->dirroot.'/mod/resource/type/'.$resource->type.'/resource.class.php');
37 $resourceclass = 'resource_'.$resource->type;
38 $resourceinstance = new $resourceclass($cm->id);
40 $resourceinstance->display();