Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 142 lines (119 sloc) 4.977 kB
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
1 <?php
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
2
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
3 /**
4 * file index.php
5 * index page to view notes.
6 * if a course id is specified then the entries from that course are shown
7 * if a user id is specified only notes related to that user are shown
8 */
9 require_once('../config.php');
10 require_once('lib.php');
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
11
12 /// retrieve parameters
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
13 $courseid = optional_param('course', SITEID, PARAM_INT);
14 $userid = optional_param('user', 0, PARAM_INT);
15 $filtertype = optional_param('filtertype', '', PARAM_ALPHA);
16 $filterselect = optional_param('filterselect', 0, PARAM_INT);
17
a685593 @skodak MDL-21233 moodle_url improvemewnts, code simplification, more diagnos…
skodak authored
18 $url = new moodle_url('/notes/index.php');
7b2e259 @skodak MDL-23856 fixed incorrect integer comparison, we should not use === o…
skodak authored
19 if ($courseid != SITEID) {
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
20 $url->param('course', $courseid);
21 }
22 if ($userid !== 0) {
23 $url->param('user', $userid);
24 }
25 $PAGE->set_url($url);
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
26
27 /// tabs compatibility
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
28 switch($filtertype) {
29 case 'course':
30 $courseid = $filterselect;
31 break;
32 case 'site':
33 $courseid = SITEID;
34 break;
35 }
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
36
7b5f1cd @samhemelryk notes MDL-24495 Set default course id for notes
samhemelryk authored
37 if (empty($courseid)) {
38 $courseid = SITEID;
39 }
40
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
41 /// locate course information
3406acd @samhemelryk navigation MDL-22044 Major navigation structure changes.
samhemelryk authored
42 $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
43
44 /// locate user information
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
45 if ($userid) {
3406acd @samhemelryk navigation MDL-22044 Major navigation structure changes.
samhemelryk authored
46 $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
47 $filtertype = 'user';
48 $filterselect = $user->id;
49
50 if ($user->deleted) {
51 echo $OUTPUT->header();
52 echo $OUTPUT->heading(get_string('userdeleted'));
53 echo $OUTPUT->footer();
54 die;
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
55 }
56
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
57 } else {
58 $filtertype = 'course';
59 $filterselect = $course->id;
60 }
61
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
62 /// require login to access notes
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
63 require_login($course);
64 add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&amp;user='.$userid, 'view notes');
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
65
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
66 if (empty($CFG->enablenotes)) {
67 print_error('notesdisabled', 'notes');
68 }
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
69
70 /// output HTML
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
71 if ($course->id == SITEID) {
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
72 $coursecontext = context_system::instance(); // SYSTEM context
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
73 } else {
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
74 $coursecontext = context_course::instance($course->id); // Course context
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
75 }
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
76 $systemcontext = context_system::instance(); // SYSTEM context
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
77
78 $strnotes = get_string('notes', 'notes');
79 if ($userid) {
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
80 $PAGE->set_context(context_user::instance($user->id));
7a7e209 @samhemelryk navigation MDL-20649 Revised the way in which navigation works for users
samhemelryk authored
81 $PAGE->navigation->extend_for_user($user);
82 } else {
3406acd @samhemelryk navigation MDL-22044 Major navigation structure changes.
samhemelryk authored
83 $link = null;
84 if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
85 $link = new moodle_url('/user/index.php',array('id'=>$course->id));
86 }
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
87 }
3406acd @samhemelryk navigation MDL-22044 Major navigation structure changes.
samhemelryk authored
88
89 $PAGE->set_pagelayout('course');
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
90 $PAGE->set_title($course->shortname . ': ' . $strnotes);
91 $PAGE->set_heading($course->fullname);
92
93 echo $OUTPUT->header();
03d9401 @moodler My Moodle MDL-19124 New version of My Moodle, User profiles and Cours…
moodler authored
94 if ($userid) {
95 echo $OUTPUT->heading(fullname($user).': '.$strnotes);
96 } else {
8ebbb06 @samhemelryk MDL-29189 mutlilang Reviewed the uses of course shortname and ensured…
samhemelryk authored
97 echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $coursecontext)).': '.$strnotes);
03d9401 @moodler My Moodle MDL-19124 New version of My Moodle, User profiles and Cours…
moodler authored
98 }
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
99
100 $strsitenotes = get_string('sitenotes', 'notes');
101 $strcoursenotes = get_string('coursenotes', 'notes');
102 $strpersonalnotes = get_string('personalnotes', 'notes');
103 $straddnewnote = get_string('addnewnote', 'notes');
104
105 echo $OUTPUT->box_start();
106
107 if ($courseid != SITEID) {
108 //echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a> | <a href="#personalnotes">' . $strpersonalnotes . '</a>';
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
109 $context = context_course::instance($courseid);
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
110 $addid = has_capability('moodle/notes:manage', $context) ? $courseid : 0;
111 $view = has_capability('moodle/notes:view', $context);
91d284c @samhemelryk MDL-29186 multilang Reviewed the uses of course fullname and ensured …
samhemelryk authored
112 $fullname = format_string($course->fullname, true, array('context' => $context));
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
113 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, $addid, $view, 0, $userid, NOTES_STATE_SITE, 0);
91d284c @samhemelryk MDL-29186 multilang Reviewed the uses of course fullname and ensured …
samhemelryk authored
114 note_print_notes('<a name="coursenotes"></a>' . $strcoursenotes. ' ('.$fullname.')', $addid, $view, $courseid, $userid, NOTES_STATE_PUBLIC, 0);
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
115 note_print_notes('<a name="personalnotes"></a>' . $strpersonalnotes, $addid, $view, $courseid, $userid, NOTES_STATE_DRAFT, $USER->id);
116
117 } else { // Normal course
118 //echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a>';
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
119 $view = has_capability('moodle/notes:view', context_system::instance());
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
120 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE, 0);
121 echo '<a name="coursenotes"></a>';
122
123 if (!empty($userid)) {
df997f8 @skodak MDL-21782 reworked enrolment framework, the core infrastructure is in…
skodak authored
124 $courses = enrol_get_users_courses($userid);
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
125 foreach($courses as $c) {
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
126 $ccontext = context_course::instance($c->id);
91d284c @samhemelryk MDL-29186 multilang Reviewed the uses of course fullname and ensured …
samhemelryk authored
127 $cfullname = format_string($c->fullname, true, array('context' => $ccontext));
128 $header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $cfullname . '</a>';
bf0f06b @ankitagarwal MDL-34471 libraries: Replace all uses of get_context_instance() with …
ankitagarwal authored
129 if (has_capability('moodle/notes:manage', context_course::instance($c->id))) {
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
130 $addid = $c->id;
131 } else {
132 $addid = 0;
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
133 }
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
134 note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
135 }
2f6c662 MDL-11379 and MDL-11380 fixed
nicolasconnault authored
136 }
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
137 }
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
138
2f4a2f2 notes MDL-19818 Upgrade deprecated calls and added set_url calls
samhemelryk authored
139 echo $OUTPUT->box_end();
83e70cc Some cleaning up of the notes interface and conversion from DOS to unix
moodler authored
140
1d42298 @skodak MDL-20700 coding style cleanup - cvs keywords removed, closign php ta…
skodak authored
141 echo $OUTPUT->footer();
Something went wrong with that request. Please try again.