[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * file index.php 19 * index page to view notes. 20 * if a course id is specified then the entries from that course are shown 21 * if a user id is specified only notes related to that user are shown 22 */ 23 require_once('../config.php'); 24 require_once ('lib.php'); 25 26 $courseid = optional_param('course', SITEID, PARAM_INT); 27 $userid = optional_param('user', 0, PARAM_INT); 28 $filtertype = optional_param('filtertype', '', PARAM_ALPHA); 29 $filterselect = optional_param('filterselect', 0, PARAM_INT); 30 31 if (empty($CFG->enablenotes)) { 32 print_error('notesdisabled', 'notes'); 33 } 34 35 $url = new moodle_url('/notes/index.php'); 36 if ($courseid != SITEID) { 37 $url->param('course', $courseid); 38 } 39 if ($userid !== 0) { 40 $url->param('user', $userid); 41 } 42 $PAGE->set_url($url); 43 44 // Tabs compatibility. 45 switch($filtertype) { 46 case 'course': 47 $courseid = $filterselect; 48 break; 49 case 'site': 50 $courseid = SITEID; 51 break; 52 } 53 54 if (empty($courseid)) { 55 $courseid = SITEID; 56 } 57 58 $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 59 60 if ($userid) { 61 $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); 62 $filtertype = 'user'; 63 $filterselect = $user->id; 64 65 if ($user->deleted) { 66 echo $OUTPUT->header(); 67 echo $OUTPUT->heading(get_string('userdeleted')); 68 echo $OUTPUT->footer(); 69 die; 70 } 71 72 } else { 73 $filtertype = 'course'; 74 $filterselect = $course->id; 75 $user = $USER; 76 } 77 78 require_login($course); 79 80 // Output HTML. 81 if ($course->id == SITEID) { 82 $coursecontext = context_system::instance(); 83 } else { 84 $coursecontext = context_course::instance($course->id); 85 } 86 87 require_capability('moodle/notes:view', $coursecontext); 88 $systemcontext = context_system::instance(); 89 90 // Trigger event. 91 note_view($coursecontext, $userid); 92 93 $strnotes = get_string('notes', 'notes'); 94 if ($userid && $course->id == SITEID) { 95 $PAGE->set_context(context_user::instance($user->id)); 96 $PAGE->navigation->extend_for_user($user); 97 // If we are looking at our own notes, then change focus to 'my notes'. 98 if ($userid == $USER->id) { 99 $notenode = $PAGE->navigation->find('notes', null)->make_inactive(); 100 } 101 102 $notesurl = new moodle_url('/notes/index.php', array('user' => $userid)); 103 $PAGE->navbar->add(get_string('notes', 'notes'), $notesurl); 104 } else if ($course->id != SITEID) { 105 $notenode = $PAGE->navigation->find('currentcoursenotes', null)->make_inactive(); 106 $participantsurl = new moodle_url('/user/view.php', array('id' => $userid, 'course' => $course->id)); 107 $currentcoursenode = $PAGE->navigation->find('currentcourse', null); 108 $participantsnode = $currentcoursenode->find('participants', null); 109 $usernode = $participantsnode->add(fullname($user), $participantsurl); 110 $usernode->make_active(); 111 112 $notesurl = new moodle_url('/notes/index.php', array('user' => $userid, 'course' => $courseid)); 113 $PAGE->navbar->add(get_string('notes', 'notes'), $notesurl); 114 115 $PAGE->set_context(context_course::instance($courseid)); 116 } else { 117 $link = null; 118 if (has_capability('moodle/course:viewparticipants', $coursecontext) 119 || has_capability('moodle/site:viewparticipants', $systemcontext)) { 120 121 $link = new moodle_url('/user/index.php', array('id' => $course->id)); 122 } 123 } 124 125 $PAGE->set_pagelayout('incourse'); 126 $PAGE->set_title($course->fullname); 127 if ($course->id == SITEID) { 128 $PAGE->set_heading(fullname($user)); 129 } else { 130 $PAGE->set_heading($course->fullname); 131 } 132 133 echo $OUTPUT->header(); 134 135 if ($course->id != SITEID) { 136 $headerinfo = array('heading' => fullname($user), 'user' => $user); 137 echo $OUTPUT->context_header($headerinfo, 2); 138 } 139 140 echo $OUTPUT->heading($strnotes); 141 142 $strsitenotes = get_string('sitenotes', 'notes'); 143 $strcoursenotes = get_string('coursenotes', 'notes'); 144 $strpersonalnotes = get_string('personalnotes', 'notes'); 145 $straddnewnote = get_string('addnewnote', 'notes'); 146 147 echo $OUTPUT->box_start(); 148 149 if ($courseid != SITEID) { 150 $context = context_course::instance($courseid); 151 $addid = has_capability('moodle/notes:manage', $context) ? $courseid : 0; 152 $view = has_capability('moodle/notes:view', $context); 153 $fullname = format_string($course->fullname, true, array('context' => $context)); 154 note_print_notes( 155 '<a name="sitenotes"></a>' . $strsitenotes, 156 $addid, 157 $view, 158 0, 159 $userid, 160 NOTES_STATE_SITE, 161 0 162 ); 163 note_print_notes( 164 '<a name="coursenotes"></a>' . $strcoursenotes. ' ('.$fullname.')', 165 $addid, 166 $view, 167 $courseid, 168 $userid, 169 NOTES_STATE_PUBLIC, 170 0 171 ); 172 note_print_notes( 173 '<a name="personalnotes"></a>' . $strpersonalnotes, 174 $addid, 175 $view, 176 $courseid, 177 $userid, 178 NOTES_STATE_DRAFT, 179 $USER->id 180 ); 181 182 } else { // Normal course. 183 $view = has_capability('moodle/notes:view', context_system::instance()); 184 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE, 0); 185 echo '<a name="coursenotes"></a>'; 186 187 if (!empty($userid)) { 188 $courses = enrol_get_users_courses($userid); 189 foreach ($courses as $c) { 190 $ccontext = context_course::instance($c->id); 191 $cfullname = format_string($c->fullname, true, array('context' => $ccontext)); 192 $header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $cfullname . '</a>'; 193 if (has_capability('moodle/notes:manage', context_course::instance($c->id))) { 194 $addid = $c->id; 195 } else { 196 $addid = 0; 197 } 198 note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0); 199 } 200 } 201 } 202 203 echo $OUTPUT->box_end(); 204 205 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |