info.php 2.94 KB
Newer Older
1
<?php
2
3
4
5
6
7

/// Displays external information about a course

    require_once("../config.php");
    require_once("lib.php");

8
9
    $id   = optional_param('id', false, PARAM_INT); // Course id
    $name = optional_param('name', false, PARAM_RAW); // Course short name
10
11

    if (!$id and !$name) {
12
        print_error("unspecifycourseid");
13
14
15
    }

    if ($name) {
16
        if (!$course = $DB->get_record("course", array("shortname"=>$name))) {
17
            print_error("invalidshortname");
18
19
        }
    } else {
skodak's avatar
skodak committed
20
        if (!$course = $DB->get_record("course", array("id"=>$id))) {
21
            print_error("invalidcourseid");
22
23
24
25
26
        }
    }

    $site = get_site();

27
28
29
30
    if ($CFG->forcelogin) {
        require_login();
    }

31
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
32
    if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
33
34
35
        print_error('coursehidden', '', $CFG->wwwroot .'/');
    }

36
37
    $PAGE->set_context($context);
    $PAGE->set_pagelayout('course');
38
    $PAGE->set_url('/course/info.php', array('id' => $course->id));
39
    $PAGE->set_title(get_string("summaryof", "", $course->fullname));
40
41
42
43
    $PAGE->set_heading('Course info');
    $PAGE->set_course($course);
    $PAGE->navbar->add(get_string('summary'));

44
    echo $OUTPUT->header();
45
    echo $OUTPUT->heading('<a href="view.php?id='.$course->id.'">'.format_string($course->fullname) . '</a><br />(' . format_string($course->shortname) . ')');
46

47
48
    // print enrol info
    if ($texts = enrol_get_course_description_texts($course)) {
49
        echo $OUTPUT->box_start('generalbox icons');
50
        echo implode($texts);
51
        echo $OUTPUT->box_end();
52
    }
53

54
    echo $OUTPUT->box_start('generalbox info');
moodler's avatar
moodler committed
55

56
    $course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
57
    echo format_text($course->summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
58

59
60
61
    if (!empty($CFG->coursecontact)) {
        $coursecontactroles = explode(',', $CFG->coursecontact);
        foreach ($coursecontactroles as $roleid) {
skodak's avatar
skodak committed
62
            $role = $DB->get_record('role', array('id'=>$roleid));
63
            $roleid = (int) $roleid;
64
            if ($users = get_role_users($roleid, $context, true)) {
moodler's avatar
moodler committed
65
                foreach ($users as $teacher) {
66
                    $fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
67
                    $namesarray[] = format_string(role_get_name($role, $context)).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
moodler's avatar
moodler committed
68
                                    $teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
69
                }
70
            }
moodler's avatar
moodler committed
71
        }
72

moodler's avatar
moodler committed
73
74
75
76
        if (!empty($namesarray)) {
            echo "<ul class=\"teachers\">\n<li>";
            echo implode('</li><li>', $namesarray);
            echo "</li></ul>";
77
78
79
        }
    }

80
// TODO: print some enrol icons
81

82
    echo $OUTPUT->box_end();
83
84
85

    echo "<br />";

86
    echo $OUTPUT->footer();
87

88