2009-09-29 03:52:43 +00:00
|
|
|
<?php
|
2014-07-10 16:16:26 +08:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
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
|
|
|
|
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);
|
|
|
|
|
2014-06-30 16:36:49 +08:00
|
|
|
if (empty($CFG->enablenotes)) {
|
|
|
|
print_error('notesdisabled', 'notes');
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-07-10 16:16:26 +08: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
|
|
|
|
2010-10-03 12:14:54 +00:00
|
|
|
if (empty($courseid)) {
|
|
|
|
$courseid = SITEID;
|
|
|
|
}
|
|
|
|
|
2014-07-10 16:16:26 +08:00
|
|
|
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
2007-08-31 04:05:11 +00:00
|
|
|
|
2009-09-29 03:52:43 +00:00
|
|
|
if ($userid) {
|
2014-07-10 16:16:26 +08: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;
|
2015-03-24 15:10:51 +08:00
|
|
|
$user = $USER;
|
2009-09-29 03:52:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course);
|
2014-07-10 16:16:26 +08:00
|
|
|
|
|
|
|
// Output HTML.
|
2009-09-29 03:52:43 +00:00
|
|
|
if ($course->id == SITEID) {
|
2014-07-10 16:16:26 +08:00
|
|
|
$coursecontext = context_system::instance();
|
2009-09-29 03:52:43 +00:00
|
|
|
} else {
|
2014-07-10 16:16:26 +08:00
|
|
|
$coursecontext = context_course::instance($course->id);
|
2009-09-29 03:52:43 +00:00
|
|
|
}
|
2014-07-10 16:16:26 +08:00
|
|
|
|
2014-06-30 16:36:49 +08:00
|
|
|
require_capability('moodle/notes:view', $coursecontext);
|
2014-07-10 16:16:26 +08:00
|
|
|
$systemcontext = context_system::instance();
|
2009-09-29 03:52:43 +00:00
|
|
|
|
2013-10-02 15:45:55 +08:00
|
|
|
// Trigger event.
|
2015-03-31 13:30:30 +02:00
|
|
|
note_view($coursecontext, $userid);
|
2013-10-02 15:45:55 +08:00
|
|
|
|
2009-09-29 03:52:43 +00:00
|
|
|
$strnotes = get_string('notes', 'notes');
|
2015-04-29 12:11:56 +08:00
|
|
|
if ($userid && $course->id == SITEID) {
|
2012-08-02 11:20:48 +08:00
|
|
|
$PAGE->set_context(context_user::instance($user->id));
|
2009-12-23 01:22:48 +00:00
|
|
|
$PAGE->navigation->extend_for_user($user);
|
2015-03-19 10:59:27 +08:00
|
|
|
// If we are looking at our own notes, then change focus to 'my notes'.
|
|
|
|
if ($userid == $USER->id) {
|
|
|
|
$notenode = $PAGE->navigation->find('notes', null)->make_inactive();
|
|
|
|
}
|
2015-04-29 12:11:56 +08:00
|
|
|
|
|
|
|
$notesurl = new moodle_url('/notes/index.php', array('user' => $userid));
|
|
|
|
$PAGE->navbar->add(get_string('notes', 'notes'), $notesurl);
|
|
|
|
} else if ($course->id != SITEID) {
|
|
|
|
$notenode = $PAGE->navigation->find('currentcoursenotes', null)->make_inactive();
|
|
|
|
|
|
|
|
$notesurl = new moodle_url('/notes/index.php', array('user' => $userid, 'course' => $courseid));
|
|
|
|
$PAGE->navbar->add(get_string('notes', 'notes'), $notesurl);
|
|
|
|
|
|
|
|
$PAGE->set_context(context_course::instance($courseid));
|
2009-12-23 01:22:48 +00:00
|
|
|
} else {
|
2010-04-19 06:30:30 +00:00
|
|
|
$link = null;
|
2014-07-10 16:16:26 +08:00
|
|
|
if (has_capability('moodle/course:viewparticipants', $coursecontext)
|
|
|
|
|| has_capability('moodle/site:viewparticipants', $systemcontext)) {
|
|
|
|
|
|
|
|
$link = new moodle_url('/user/index.php', array('id' => $course->id));
|
2010-04-19 06:30:30 +00:00
|
|
|
}
|
2009-09-29 03:52:43 +00:00
|
|
|
}
|
2010-04-19 06:30:30 +00:00
|
|
|
|
2014-09-02 14:44:24 +12:00
|
|
|
$PAGE->set_pagelayout('incourse');
|
2015-03-24 15:10:51 +08:00
|
|
|
$PAGE->set_title($course->fullname);
|
2015-04-29 12:11:56 +08:00
|
|
|
if ($course->id == SITEID) {
|
|
|
|
$PAGE->set_heading(fullname($user));
|
|
|
|
} else {
|
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
|
}
|
2009-09-29 03:52:43 +00:00
|
|
|
|
|
|
|
echo $OUTPUT->header();
|
2015-04-29 12:11:56 +08:00
|
|
|
|
|
|
|
if ($course->id != SITEID) {
|
|
|
|
$headerinfo = array('heading' => fullname($user), 'user' => $user);
|
|
|
|
echo $OUTPUT->context_header($headerinfo, 2);
|
|
|
|
}
|
|
|
|
|
2015-03-24 15:10:51 +08:00
|
|
|
echo $OUTPUT->heading($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) {
|
2012-08-02 11:20:48 +08:00
|
|
|
$context = context_course::instance($courseid);
|
2009-09-29 03:52:43 +00:00
|
|
|
$addid = has_capability('moodle/notes:manage', $context) ? $courseid : 0;
|
|
|
|
$view = has_capability('moodle/notes:view', $context);
|
2011-09-06 13:40:44 +12:00
|
|
|
$fullname = format_string($course->fullname, true, array('context' => $context));
|
2014-07-10 16:16:26 +08:00
|
|
|
note_print_notes(
|
|
|
|
'<a name="sitenotes"></a>' . $strsitenotes,
|
|
|
|
$addid,
|
|
|
|
$view,
|
|
|
|
0,
|
|
|
|
$userid,
|
|
|
|
NOTES_STATE_SITE,
|
|
|
|
0
|
|
|
|
);
|
|
|
|
note_print_notes(
|
|
|
|
'<a name="coursenotes"></a>' . $strcoursenotes. ' ('.$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.
|
2012-08-02 11:20:48 +08:00
|
|
|
$view = has_capability('moodle/notes:view', context_system::instance());
|
2009-09-29 03:52:43 +00:00
|
|
|
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);
|
2014-07-10 16:16:26 +08:00
|
|
|
foreach ($courses as $c) {
|
2012-08-02 11:20:48 +08:00
|
|
|
$ccontext = context_course::instance($c->id);
|
2011-09-06 13:40:44 +12:00
|
|
|
$cfullname = format_string($c->fullname, true, array('context' => $ccontext));
|
|
|
|
$header = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $c->id . '">' . $cfullname . '</a>';
|
2016-10-17 16:07:16 +08:00
|
|
|
$viewcoursenotes = has_capability('moodle/notes:view', $ccontext);
|
|
|
|
if (has_capability('moodle/notes:manage', $ccontext)) {
|
2009-09-29 03:52:43 +00:00
|
|
|
$addid = $c->id;
|
|
|
|
} else {
|
|
|
|
$addid = 0;
|
2007-08-31 04:05:11 +00:00
|
|
|
}
|
2016-10-17 16:07:16 +08:00
|
|
|
note_print_notes($header, $addid, $viewcoursenotes, $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();
|