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 $strsitenotes = get_string('sitenotes', 'notes');
55 $strcoursenotes = get_string('coursenotes', 'notes');
56 $strpersonalnotes = get_string('personalnotes', 'notes');
57 $straddnewnote = get_string('addnewnote', 'notes');
59 if($courseid != SITEID
) {
60 echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a> | <a href="#personalnotes">' . $strpersonalnotes . '</a>';
61 $context = get_context_instance(CONTEXT_COURSE
, $courseid);
62 $addid = has_capability('moodle/notes:manage', $context) ?
$courseid : 0;
63 $view = has_capability('moodle/notes:view', $context);
64 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, $addid, $view, 0, $userid, NOTES_STATE_SITE
, 0);
65 note_print_notes('<a name="coursenotes"></a>' . $strcoursenotes, $addid, $view, $courseid, $userid, NOTES_STATE_PUBLIC
, 0);
66 note_print_notes('<a name="personalnotes"></a>' . $strpersonalnotes, $addid, $view, $courseid, $userid, NOTES_STATE_DRAFT
, $USER->id
);
68 echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a>';
69 $view = has_capability('moodle/notes:view', get_context_instance(CONTEXT_SYSTEM
));
70 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE
, 0);
71 echo '<a name="coursenotes"></a>';
73 $courses = get_my_courses($userid);
74 foreach($courses as $c) {
75 $header = '<a href="' . $CFG->wwwroot
. '/course/view.php?id=' . $c->id
. '">' . $c->fullname
. '</a>';
76 if (has_capability('moodle/notes:manage', get_context_instance(CONTEXT_COURSE
, $c->id
))) {
81 note_print_notes($header, $addid, $view, $c->id
, $userid, NOTES_STATE_PUBLIC
, 0);
86 add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes');
88 print_footer($course);