| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: index.php,v 1.6.2.2 2008/07/05 14:53:32 skodak Exp $ 2 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'); 11 12 /// retrieve parameters 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 18 /// tabs compatibility 19 switch($filtertype) { 20 case 'course': 21 $courseid = $filterselect; 22 break; 23 case 'site': 24 $courseid = SITEID; 25 break; 26 } 27 28 /// locate course information 29 if (!$course = get_record('course', 'id', $courseid)) { 30 error('Incorrect course id specified'); 31 } 32 33 /// locate user information 34 if ($userid) { 35 if (!$user = get_record('user', 'id', $userid)) { 36 error('Incorrect user id specified'); 37 } 38 $filtertype = 'user'; 39 $filterselect = $user->id; 40 41 if ($user->deleted) { 42 print_header(); 43 print_heading(get_string('userdeleted')); 44 print_footer(); 45 die; 46 } 47 48 } else { 49 $filtertype = 'course'; 50 $filterselect = $course->id; 51 } 52 53 /// require login to access notes 54 require_login($course->id); 55 add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes'); 56 57 58 /// output HTML 59 if ($course->id == SITEID) { 60 $coursecontext = get_context_instance(CONTEXT_SYSTEM); // SYSTEM context 61 } else { 62 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Course context 63 } 64 $systemcontext = get_context_instance(CONTEXT_SYSTEM); // SYSTEM context 65 66 $strnotes = get_string('notes', 'notes'); 67 $nav = array(); 68 if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) { 69 $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc'); 70 } 71 if ($userid) { 72 $nav[] = array('name' => fullname($user), 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id. '&course=' . $course->id, 'type' => 'misc'); 73 } 74 $nav[] = array('name' => $strnotes, 'link' => '', 'type' => 'misc'); 75 76 print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($nav)); 77 78 $showroles = 1; 79 $currenttab = 'notes'; 80 require_once($CFG->dirroot .'/user/tabs.php'); 81 82 $strsitenotes = get_string('sitenotes', 'notes'); 83 $strcoursenotes = get_string('coursenotes', 'notes'); 84 $strpersonalnotes = get_string('personalnotes', 'notes'); 85 $straddnewnote = get_string('addnewnote', 'notes'); 86 87 print_box_start(); 88 89 if ($courseid != SITEID) { 90 //echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a> | <a href="#personalnotes">' . $strpersonalnotes . '</a>'; 91 $context = get_context_instance(CONTEXT_COURSE, $courseid); 92 $addid = has_capability('moodle/notes:manage', $context) ? $courseid : 0; 93 $view = has_capability('moodle/notes:view', $context); 94 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, $addid, $view, 0, $userid, NOTES_STATE_SITE, 0); 95 note_print_notes('<a name="coursenotes"></a>' . $strcoursenotes. ' ('.$course->fullname.')', $addid, $view, $courseid, $userid, NOTES_STATE_PUBLIC, 0); 96 note_print_notes('<a name="personalnotes"></a>' . $strpersonalnotes, $addid, $view, $courseid, $userid, NOTES_STATE_DRAFT, $USER->id); 97 98 } else { // Normal course 99 //echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a>'; 100 $view = has_capability('moodle/notes:view', get_context_instance(CONTEXT_SYSTEM)); 101 note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE, 0); 102 echo '<a name="coursenotes"></a>'; 103 104 if (!empty($userid)) { 105 $courses = get_my_courses($userid); 106 foreach($courses as $c) { 107 $header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $c->fullname . '</a>'; 108 if (has_capability('moodle/notes:manage', get_context_instance(CONTEXT_COURSE, $c->id))) { 109 $addid = $c->id; 110 } else { 111 $addid = 0; 112 } 113 note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0); 114 } 115 } 116 } 117 118 print_box_end(); 119 120 print_footer($course); 121 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |