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
9 require_once('../config.php');
10 require_once('lib.php');
11 // retrieve parameters
12 $courseid = optional_param('course', SITEID
, PARAM_INT
);
13 $userid = optional_param('user', 0, PARAM_INT
);
14 $filtertype = optional_param('filtertype', '', PARAM_ALPHA
);
15 $filterselect = optional_param('filterselect', 0, PARAM_INT
);
20 $courseid = $filterselect;
27 // locate course information
28 if (!$course = get_record('course', 'id', $courseid)) {
29 error('Incorrect course id specified');
32 // locate user information
34 if(!$user = get_record('user', 'id', $userid)) {
35 error('Incorrect user id specified');
38 $filterselect = $user->id
;
40 $filtertype = 'course';
41 $filterselect = $course->id
;
44 // require login to access notes
45 require_login($course->id
);
46 $strnotes = get_string('notes', 'notes');
47 $crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
48 $currenttab = 'notes';
50 print_header($course->shortname
. ': ' . $strnotes, $course->fullname
, build_navigation($crumbs));
52 require_once($CFG->dirroot
.'/user/tabs.php');
54 if($courseid != SITEID
) {
55 $context = get_context_instance(CONTEXT_COURSE
, $courseid);
56 if (has_capability('moodle/notes:manage', $context)) {
57 $addlink = $CFG->wwwroot
.'/notes/add.php?course=' . $courseid . '&user=' . $userid;
58 echo '<p><a href="'. $addlink . '">' . get_string('addnewnote', 'notes') . '</a></p>';
60 note_print_notes(get_string('sitenotes', 'notes'), $context, 0, $userid, NOTES_STATE_SITE
, 0);
61 note_print_notes(get_string('coursenotes', 'notes'), $context, $courseid, $userid, NOTES_STATE_PUBLIC
, 0);
62 note_print_notes(get_string('personalnotes', 'notes'), $context, $courseid, $userid, NOTES_STATE_DRAFT
, $USER->id
);
64 $context = get_context_instance(CONTEXT_SYSTEM
);
65 note_print_notes(get_string('sitenotes', 'notes'), $context, 0, $userid, NOTES_STATE_SITE
, 0);
67 $courses = get_my_courses($userid);
68 foreach($courses as $c) {
69 $header = '<a href="' . $CFG->wwwroot
. '/course/view.php?id=' . $c->id
. '">' . $c->fullname
. '</a>';
70 note_print_notes($header, $context, $c->id
, $userid, NOTES_STATE_PUBLIC
, 0);
75 add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes');
77 print_footer($course);