Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
require_once('../../config.php');
4
require_once('lib.php');
5
 
6
$concept  = optional_param('concept', '', PARAM_CLEAN);
7
$courseid = optional_param('courseid', 0, PARAM_INT);
8
$eid      = optional_param('eid', 0, PARAM_INT); // glossary entry id
9
$displayformat = optional_param('displayformat',-1, PARAM_SAFEDIR);
10
 
11
$url = new moodle_url('/mod/glossary/showentry.php');
12
$url->param('concept', $concept);
13
$url->param('courseid', $courseid);
14
$url->param('eid', $eid);
15
$url->param('displayformat', $displayformat);
16
$PAGE->set_url($url);
17
 
18
if ($CFG->forcelogin) {
19
    require_login();
20
}
21
 
22
if ($eid) {
23
    $entry = $DB->get_record('glossary_entries', array('id'=>$eid), '*', MUST_EXIST);
24
    $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid), '*', MUST_EXIST);
25
    $cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST);
26
    $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
27
    require_course_login($course, true, $cm);
28
    $entry->glossaryname = $glossary->name;
29
    $entry->cmid = $cm->id;
30
    $entry->courseid = $cm->course;
1441 ariadna 31
    $entry->concept = format_string($entry->concept, true, ["escape" => false]);
1 efrain 32
    $entries = array($entry);
33
 
34
} else if ($concept) {
35
    $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
36
    require_course_login($course);
37
    $entries = glossary_get_entries_search($concept, $courseid);
38
 
39
} else {
40
    throw new \moodle_exception('invalidelementid');
41
}
42
 
43
$PAGE->set_pagelayout('incourse');
44
$PAGE->activityheader->disable();
45
 
46
if ($entries) {
47
    foreach ($entries as $key => $entry) {
48
        // Need to get the course where the entry is,
49
        // in order to check for visibility/approve permissions there
50
        $entrycourse = $DB->get_record('course', array('id' => $entry->courseid), '*', MUST_EXIST);
51
        $modinfo = get_fast_modinfo($entrycourse);
52
        // make sure the entry is visible
53
        if (empty($modinfo->cms[$entry->cmid]->uservisible)) {
54
            unset($entries[$key]);
55
            continue;
56
        }
57
        // make sure the entry is approved (or approvable by current user)
58
        if (!$entry->approved and ($USER->id != $entry->userid)) {
59
            $context = context_module::instance($entry->cmid);
60
            if (!has_capability('mod/glossary:approve', $context)) {
61
                unset($entries[$key]);
62
                continue;
63
            }
64
        }
65
        $entries[$key]->footer = "<p style=\"text-align:right\">&raquo;&nbsp;<a href=\"$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid\">".format_string($entry->glossaryname,true)."</a></p>";
66
        glossary_entry_view($entry, $modinfo->cms[$entry->cmid]->context);
67
    }
68
}
69
 
70
if (!empty($courseid)) {
71
    $strglossaries = get_string('modulenameplural', 'glossary');
72
    $strsearch = get_string('search');
73
 
74
    $PAGE->navbar->add($strglossaries);
75
    $PAGE->navbar->add($strsearch);
1441 ariadna 76
 
77
    $PAGE->set_title(implode(\moodle_page::TITLE_SEPARATOR, [
78
        $strsearch,
79
        $strglossaries,
80
        $course->shortname,
81
    ]));
1 efrain 82
    $PAGE->set_heading($course->fullname);
83
    echo $OUTPUT->header();
84
} else {
85
    echo $OUTPUT->header();    // Needs to be something here to allow linking back to the whole glossary
86
}
87
 
1441 ariadna 88
if (isset($glossary)) {
1 efrain 89
    $url = new moodle_url('view.php', ['id' => $cm->id]);
90
    $backlink = html_writer::link($url, get_string('back'), ['class' => 'btn btn-secondary']);
91
    echo html_writer::tag('div', $backlink, ['class' => 'tertiary-navigation']);
92
}
93
 
94
if ($entries) {
95
    glossary_print_dynaentry($courseid, $entries, $displayformat);
96
}
97
 
98
/// Show one reduced footer
99
echo $OUTPUT->footer();