2009-09-29 03:52:43 +00:00
|
|
|
<?php
|
2007-08-31 04:05:11 +00:00
|
|
|
|
2009-09-29 03:52:43 +00:00
|
|
|
/**
|
|
|
|
* file index.php
|
|
|
|
* index page to view notes.
|
|
|
|
* if a course id is specified then the entries from that course are shown
|
|
|
|
* if a user id is specified only notes related to that user are shown
|
|
|
|
*/
|
|
|
|
require_once('../config.php');
|
|
|
|
require_once('lib.php');
|
2007-08-31 04:05:11 +00:00
|
|
|
|
|
|
|
/// retrieve parameters
|
2009-09-29 03:52:43 +00:00
|
|
|
$courseid = optional_param('course', SITEID, PARAM_INT);
|
|
|
|
$userid = optional_param('user', 0, PARAM_INT);
|
|
|
|
$filtertype = optional_param('filtertype', '', PARAM_ALPHA);
|
|
|
|
$filterselect = optional_param('filterselect', 0, PARAM_INT);
|
|
|
|
|
2010-01-16 15:39:56 +00:00
|
|
|
$url = new moodle_url('/notes/index.php');
|
2010-08-18 22:18:53 +00:00
|
|
|
if ($courseid != SITEID) {
|
2009-09-29 03:52:43 +00:00
|
|
|
$url->param('course', $courseid);
|
|
|
|
}
|
|
|
|
if ($userid !== 0) {
|
|
|
|
$url->param('user', $userid);
|
|
|
|
}
|
|
|
|
$PAGE->set_url($url);
|
2007-08-31 04:05:11 +00:00
|
|
|
|
|
|
|
/// tabs compatibility
|
2009-09-29 03:52:43 +00:00
|
|
|
switch($filtertype) {
|
|
|
|
case 'course':
|
|
|
|
$courseid = $filterselect;
|
|
|
|
break;
|
|
|
|
case 'site':
|
|
|
|
$courseid = SITEID;
|
|
|
|
break;
|
|
|
|
}
|
2007-08-31 04:05:11 +00:00
|
|
|
|
|
|
|
/// locate course information
|
2010-04-19 06:30:30 +00:00
|
|
|
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
2007-08-31 04:05:11 +00:00
|
|
|
|
|
|
|
/// locate user information
|
2009-09-29 03:52:43 +00:00
|
|
|
if ($userid) {
|
2010-04-19 06:30:30 +00:00
|
|
|
$user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
|
2009-09-29 03:52:43 +00:00
|
|
|
$filtertype = 'user';
|
|
|
|
$filterselect = $user->id;
|
|
|
|
|
|
|
|
if ($user->deleted) {
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->heading(get_string('userdeleted'));
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
die;
|
2007-08-31 04:05:11 +00:00
|
|
|
}
|
|
|
|
|
2009-09-29 03:52:43 +00:00
|
|
|
} else {
|
|
|
|
$filtertype = 'course';
|
|
|
|
$filterselect = $course->id;
|
|
|
|
}
|
|
|
|
|
2007-08-31 04:05:11 +00:00
|
|
|
/// require login to access notes
|
2009-09-29 03:52:43 +00:00
|
|
|
require_login($course);
|
|
|
|
add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes');
|
2007-08-31 04:05:11 +00:00
|
|
|
|
2009-09-29 03:52:43 +00:00
|
|
|
if (empty($CFG->enablenotes)) {
|
|
|
|
print_error('notesdisabled', 'notes');
|
|
|
|
}
|
2007-08-31 04:05:11 +00:00
|
|
|
|
|
|
|
/// output HTML
|
2009-09-29 03:52:43 +00:00
|
|
|
if ($course->id == SITEID) {
|
|
|
|
$coursecontext = get_context_instance(CONTEXT_SYSTEM); // SYSTEM context
|
|
|
|
} else {
|
|
|
|
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); // Course context
|
|
|
|
}
|
|
|
|
$systemcontext = get_context_instance(CONTEXT_SYSTEM); // SYSTEM context
|
|
|
|
|
|
|
|
$strnotes = get_string('notes', 'notes');
|
|
|
|
if ($userid) {
|
2010-04-19 06:30:30 +00:00
|
|
|
$PAGE->set_context(get_context_instance(CONTEXT_USER, $user->id));
|
2009-12-23 01:22:48 +00:00
|
|
|
$PAGE->navigation->extend_for_user($user);
|
|
|
|
} else {
|
2010-04-19 06:30:30 +00:00
|
|
|
$link = null;
|
|
|
|
if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
|
|
|
|
$link = new moodle_url('/user/index.php',array('id'=>$course->id));
|
|
|
|
}
|
2009-12-23 01:22:48 +00:00
|
|
|
$PAGE->navbar->add(get_string('participants'), $link);
|
|
|
|
$PAGE->navbar->add($strnotes);
|
2009-09-29 03:52:43 +00:00
|
|
|
}
|
2010-04-19 06:30:30 +00:00
|
|
|
|
|
|
|
$PAGE->set_pagelayout('course');
|
2009-09-29 03:52:43 +00:00
|
|
|
$PAGE->set_title($course->shortname . ': ' . $strnotes);
|
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2010-05-04 13:04:35 +00:00
|
|
|
if ($userid) {
|
|
|
|
echo $OUTPUT->heading(fullname($user).': '.$strnotes);
|
|
|
|
} else {
|
|
|
|
echo $OUTPUT->heading($course->shortname.': '.$strnotes);
|
|
|
|
}
|
2009-09-29 03:52:43 +00:00
|
|
|
|
|
|
|
$strsitenotes = get_string('sitenotes', 'notes');
|
|
|
|
$strcoursenotes = get_string('coursenotes', 'notes');
|
|
|
|
$strpersonalnotes = get_string('personalnotes', 'notes');
|
|
|
|
$straddnewnote = get_string('addnewnote', 'notes');
|
|
|
|
|
|
|
|
echo $OUTPUT->box_start();
|
|
|
|
|
|
|
|
if ($courseid != SITEID) {
|
|
|
|
//echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a> | <a href="#personalnotes">' . $strpersonalnotes . '</a>';
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
|
|
|
$addid = has_capability('moodle/notes:manage', $context) ? $courseid : 0;
|
|
|
|
$view = has_capability('moodle/notes:view', $context);
|
|
|
|
note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, $addid, $view, 0, $userid, NOTES_STATE_SITE, 0);
|
|
|
|
note_print_notes('<a name="coursenotes"></a>' . $strcoursenotes. ' ('.$course->fullname.')', $addid, $view, $courseid, $userid, NOTES_STATE_PUBLIC, 0);
|
|
|
|
note_print_notes('<a name="personalnotes"></a>' . $strpersonalnotes, $addid, $view, $courseid, $userid, NOTES_STATE_DRAFT, $USER->id);
|
|
|
|
|
|
|
|
} else { // Normal course
|
|
|
|
//echo '<a href="#sitenotes">' . $strsitenotes . '</a> | <a href="#coursenotes">' . $strcoursenotes . '</a>';
|
|
|
|
$view = has_capability('moodle/notes:view', get_context_instance(CONTEXT_SYSTEM));
|
|
|
|
note_print_notes('<a name="sitenotes"></a>' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE, 0);
|
|
|
|
echo '<a name="coursenotes"></a>';
|
|
|
|
|
|
|
|
if (!empty($userid)) {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
$courses = enrol_get_users_courses($userid);
|
2009-09-29 03:52:43 +00:00
|
|
|
foreach($courses as $c) {
|
|
|
|
$header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $c->fullname . '</a>';
|
|
|
|
if (has_capability('moodle/notes:manage', get_context_instance(CONTEXT_COURSE, $c->id))) {
|
|
|
|
$addid = $c->id;
|
|
|
|
} else {
|
|
|
|
$addid = 0;
|
2007-08-31 04:05:11 +00:00
|
|
|
}
|
2009-09-29 03:52:43 +00:00
|
|
|
note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
|
2007-08-31 04:05:11 +00:00
|
|
|
}
|
2007-09-21 07:52:52 +00:00
|
|
|
}
|
2009-09-29 03:52:43 +00:00
|
|
|
}
|
2007-08-31 04:05:11 +00:00
|
|
|
|
2009-09-29 03:52:43 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2007-08-31 04:05:11 +00:00
|
|
|
|
2009-11-01 12:22:45 +00:00
|
|
|
echo $OUTPUT->footer();
|