Some cleaning up of the notes interface and conversion from DOS to unix
This commit is contained in:
+78
-78
@@ -1,78 +1,78 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
// retrieve parameters
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$userid = optional_param('user', 0, PARAM_INT);
|
||||
|
||||
// locate course information
|
||||
if (!($course = get_record('course', 'id', $courseid))) {
|
||||
error('Incorrect course id found');
|
||||
}
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
|
||||
// locate context information
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// check capability
|
||||
if (!has_capability('moodle/notes:manage', $context)) {
|
||||
error('You may not create notes');
|
||||
}
|
||||
|
||||
// build-up form
|
||||
require_once('edit_form.php');
|
||||
// get option values for the user select
|
||||
$extradata['userlist'] = array();
|
||||
$usersincourse = "SELECT * FROM {$CFG->prefix}user WHERE id IN (SELECT userid FROM {$CFG->prefix}role_assignments WHERE contextid={$context->id})";
|
||||
$userlist = get_records_sql($usersincourse);
|
||||
// format userdata using fullname
|
||||
if($userlist) {
|
||||
foreach($userlist as $user) {
|
||||
$extradata['userlist'][$user->id] = fullname($user);
|
||||
}
|
||||
}
|
||||
// create form
|
||||
$noteform = new note_edit_form(null, $extradata);
|
||||
|
||||
// if form was cancelled then return to the previous notes list
|
||||
if ($noteform->is_cancelled()) {
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $courseid . '&user=' . $userid);
|
||||
}
|
||||
|
||||
// if data was submitted and validated, then save it to database
|
||||
if ($formdata = $noteform->get_data()) {
|
||||
$note = new object();
|
||||
$note->courseid = $formdata->course;
|
||||
$note->content = $formdata->content;
|
||||
$note->format = FORMAT_PLAIN;
|
||||
$note->userid = $formdata->user;
|
||||
$note->publishstate = $formdata->publishstate;
|
||||
if (note_save($note)) {
|
||||
add_to_log($note->courseid, 'notes', 'add', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id , 'add note');
|
||||
}
|
||||
// redirect to notes list that contains this note
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid);
|
||||
}
|
||||
|
||||
if($noteform->is_submitted()) {
|
||||
// if data was submitted with errors, then use it as default for new form
|
||||
$note = $noteform->get_submitted_data(false);
|
||||
} else {
|
||||
// if data was not submitted yet, then use default values
|
||||
$note = new object();
|
||||
$note->id = 0;
|
||||
$note->course = $courseid;
|
||||
$note->user = $userid;
|
||||
$note->publishstate = optional_param('state', NOTES_STATE_PUBLIC, PARAM_ALPHA);
|
||||
}
|
||||
$noteform->set_data($note);
|
||||
$strnotes = get_string('addnewnote', 'notes');
|
||||
|
||||
// output HTML
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
$noteform->display();
|
||||
print_footer();
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
// retrieve parameters
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$userid = optional_param('user', 0, PARAM_INT);
|
||||
|
||||
// locate course information
|
||||
if (!($course = get_record('course', 'id', $courseid))) {
|
||||
error('Incorrect course id found');
|
||||
}
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
|
||||
// locate context information
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// check capability
|
||||
if (!has_capability('moodle/notes:manage', $context)) {
|
||||
error('You may not create notes');
|
||||
}
|
||||
|
||||
// build-up form
|
||||
require_once('edit_form.php');
|
||||
// get option values for the user select
|
||||
$extradata['userlist'] = array();
|
||||
$usersincourse = "SELECT * FROM {$CFG->prefix}user WHERE id IN (SELECT userid FROM {$CFG->prefix}role_assignments WHERE contextid={$context->id})";
|
||||
$userlist = get_records_sql($usersincourse);
|
||||
// format userdata using fullname
|
||||
if($userlist) {
|
||||
foreach($userlist as $user) {
|
||||
$extradata['userlist'][$user->id] = fullname($user);
|
||||
}
|
||||
}
|
||||
// create form
|
||||
$noteform = new note_edit_form(null, $extradata);
|
||||
|
||||
// if form was cancelled then return to the previous notes list
|
||||
if ($noteform->is_cancelled()) {
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $courseid . '&user=' . $userid);
|
||||
}
|
||||
|
||||
// if data was submitted and validated, then save it to database
|
||||
if ($formdata = $noteform->get_data()) {
|
||||
$note = new object();
|
||||
$note->courseid = $formdata->course;
|
||||
$note->content = $formdata->content;
|
||||
$note->format = FORMAT_PLAIN;
|
||||
$note->userid = $formdata->user;
|
||||
$note->publishstate = $formdata->publishstate;
|
||||
if (note_save($note)) {
|
||||
add_to_log($note->courseid, 'notes', 'add', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id , 'add note');
|
||||
}
|
||||
// redirect to notes list that contains this note
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid);
|
||||
}
|
||||
|
||||
if($noteform->is_submitted()) {
|
||||
// if data was submitted with errors, then use it as default for new form
|
||||
$note = $noteform->get_submitted_data(false);
|
||||
} else {
|
||||
// if data was not submitted yet, then use default values
|
||||
$note = new object();
|
||||
$note->id = 0;
|
||||
$note->course = $courseid;
|
||||
$note->user = $userid;
|
||||
$note->publishstate = optional_param('state', NOTES_STATE_PUBLIC, PARAM_ALPHA);
|
||||
}
|
||||
$noteform->set_data($note);
|
||||
$strnotes = get_string('addnewnote', 'notes');
|
||||
|
||||
// output HTML
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
$noteform->display();
|
||||
print_footer();
|
||||
|
||||
+50
-50
@@ -1,51 +1,51 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
// retrieve parameters
|
||||
$noteid = required_param('note', PARAM_INT);
|
||||
|
||||
// locate note information
|
||||
if (!$note = note_load($noteid)) {
|
||||
error('Incorrect note id specified');
|
||||
}
|
||||
|
||||
// locate course information
|
||||
if (!$course = get_record('course', 'id', $note->courseid)) {
|
||||
error('Incorrect course id found');
|
||||
}
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
|
||||
// locate context information
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// check capability
|
||||
if (!has_capability('moodle/notes:manage', $context)) {
|
||||
error('You may not delete this note');
|
||||
}
|
||||
|
||||
if (data_submitted() && confirm_sesskey()) {
|
||||
//if data was submitted and is valid, then delete note
|
||||
$returnurl = $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user=' . $note->userid;
|
||||
if (note_delete($noteid)) {
|
||||
add_to_log($note->courseid, 'notes', 'delete', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id , 'delete note');
|
||||
} else {
|
||||
error('Error occured while deleting post', $returnurl);
|
||||
}
|
||||
redirect($returnurl);
|
||||
} else {
|
||||
// if data was not submitted yet, then show note data with a delete confirmation form
|
||||
$strnotes = get_string('notes', 'notes');
|
||||
$optionsyes = array('note'=>$noteid, 'sesskey'=>sesskey());
|
||||
$optionsno = array('course'=>$course->id, 'user'=>$note->userid);
|
||||
|
||||
// output HTML
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
notice_yesno(get_string('deleteconfirm', 'notes'), 'delete.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
echo '<br />';
|
||||
note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);
|
||||
print_footer();
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
// retrieve parameters
|
||||
$noteid = required_param('note', PARAM_INT);
|
||||
|
||||
// locate note information
|
||||
if (!$note = note_load($noteid)) {
|
||||
error('Incorrect note id specified');
|
||||
}
|
||||
|
||||
// locate course information
|
||||
if (!$course = get_record('course', 'id', $note->courseid)) {
|
||||
error('Incorrect course id found');
|
||||
}
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
|
||||
// locate context information
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// check capability
|
||||
if (!has_capability('moodle/notes:manage', $context)) {
|
||||
error('You may not delete this note');
|
||||
}
|
||||
|
||||
if (data_submitted() && confirm_sesskey()) {
|
||||
//if data was submitted and is valid, then delete note
|
||||
$returnurl = $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user=' . $note->userid;
|
||||
if (note_delete($noteid)) {
|
||||
add_to_log($note->courseid, 'notes', 'delete', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id , 'delete note');
|
||||
} else {
|
||||
error('Error occured while deleting post', $returnurl);
|
||||
}
|
||||
redirect($returnurl);
|
||||
} else {
|
||||
// if data was not submitted yet, then show note data with a delete confirmation form
|
||||
$strnotes = get_string('notes', 'notes');
|
||||
$optionsyes = array('note'=>$noteid, 'sesskey'=>sesskey());
|
||||
$optionsno = array('course'=>$course->id, 'user'=>$note->userid);
|
||||
|
||||
// output HTML
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
notice_yesno(get_string('deleteconfirm', 'notes'), 'delete.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
echo '<br />';
|
||||
note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);
|
||||
print_footer();
|
||||
}
|
||||
+84
-84
@@ -1,84 +1,84 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
// retrieve parameters
|
||||
$noteid = required_param('note', PARAM_INT);
|
||||
|
||||
// locate note information
|
||||
if (!$note = note_load($noteid)) {
|
||||
error('Incorrect note id specified');
|
||||
}
|
||||
|
||||
// locate course information
|
||||
if (!$course = get_record('course', 'id', $note->courseid)) {
|
||||
error('Incorrect course id found');
|
||||
}
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
|
||||
// locate context information
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// check capability
|
||||
if (!has_capability('moodle/notes:manage', $context)) {
|
||||
error('You may not modify notes');
|
||||
}
|
||||
|
||||
// build-up form
|
||||
require_once('edit_form.php');
|
||||
// get option values for the user select
|
||||
$extradata['userlist'] = array();
|
||||
if ($course->id == SITEID) {
|
||||
$usersincourse = "SELECT * FROM {$CFG->prefix}user WHERE id={$userid}";
|
||||
} else {
|
||||
$usersincourse = "SELECT * FROM {$CFG->prefix}user WHERE id IN (SELECT userid FROM {$CFG->prefix}role_assignments WHERE contextid={$context->id})";
|
||||
}
|
||||
$userlist = get_records_sql($usersincourse);
|
||||
// format userdata using fullname
|
||||
if($userlist) {
|
||||
foreach($userlist as $user) {
|
||||
$extradata['userlist'][$user->id] = fullname($user);
|
||||
}
|
||||
}
|
||||
// create form
|
||||
$noteform = new note_edit_form(null, $extradata);
|
||||
|
||||
// if form was cancelled then return to the notes list of the note
|
||||
if ($noteform->is_cancelled()) {
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid);
|
||||
}
|
||||
|
||||
// if data was submitted and validated, then save it to database
|
||||
if ($formdata = $noteform->get_data()){
|
||||
$note->courseid = $formdata->course;
|
||||
$note->userid = $formdata->user;
|
||||
$note->content = $formdata->content;
|
||||
$note->format = FORMAT_PLAIN;
|
||||
$note->publishstate = $formdata->publishstate;
|
||||
if (note_save($note)) {
|
||||
add_to_log($note->courseid, 'notes', 'update', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id, 'update note');
|
||||
}
|
||||
// redirect to notes list that contains this note
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid);
|
||||
}
|
||||
|
||||
|
||||
if($noteform->is_submitted()) {
|
||||
// if data was submitted with errors, then use it as default for new form
|
||||
$note = $noteform->get_submitted_data(false);
|
||||
}else{
|
||||
// if data was not submitted yet, then used values retrieved from the database
|
||||
$note->user = $note->userid;
|
||||
$note->course = $note->courseid;
|
||||
$note->note = $note->id;
|
||||
}
|
||||
$noteform->set_data($note);
|
||||
$strnotes = get_string('editnote', 'notes');
|
||||
|
||||
// output HTML
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
$noteform->display();
|
||||
print_footer();
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
// retrieve parameters
|
||||
$noteid = required_param('note', PARAM_INT);
|
||||
|
||||
// locate note information
|
||||
if (!$note = note_load($noteid)) {
|
||||
error('Incorrect note id specified');
|
||||
}
|
||||
|
||||
// locate course information
|
||||
if (!$course = get_record('course', 'id', $note->courseid)) {
|
||||
error('Incorrect course id found');
|
||||
}
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
|
||||
// locate context information
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
// check capability
|
||||
if (!has_capability('moodle/notes:manage', $context)) {
|
||||
error('You may not modify notes');
|
||||
}
|
||||
|
||||
// build-up form
|
||||
require_once('edit_form.php');
|
||||
// get option values for the user select
|
||||
$extradata['userlist'] = array();
|
||||
if ($course->id == SITEID) {
|
||||
$usersincourse = "SELECT * FROM {$CFG->prefix}user WHERE id={$userid}";
|
||||
} else {
|
||||
$usersincourse = "SELECT * FROM {$CFG->prefix}user WHERE id IN (SELECT userid FROM {$CFG->prefix}role_assignments WHERE contextid={$context->id})";
|
||||
}
|
||||
$userlist = get_records_sql($usersincourse);
|
||||
// format userdata using fullname
|
||||
if($userlist) {
|
||||
foreach($userlist as $user) {
|
||||
$extradata['userlist'][$user->id] = fullname($user);
|
||||
}
|
||||
}
|
||||
// create form
|
||||
$noteform = new note_edit_form(null, $extradata);
|
||||
|
||||
// if form was cancelled then return to the notes list of the note
|
||||
if ($noteform->is_cancelled()) {
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid);
|
||||
}
|
||||
|
||||
// if data was submitted and validated, then save it to database
|
||||
if ($formdata = $noteform->get_data()){
|
||||
$note->courseid = $formdata->course;
|
||||
$note->userid = $formdata->user;
|
||||
$note->content = $formdata->content;
|
||||
$note->format = FORMAT_PLAIN;
|
||||
$note->publishstate = $formdata->publishstate;
|
||||
if (note_save($note)) {
|
||||
add_to_log($note->courseid, 'notes', 'update', 'index.php?course='.$note->courseid.'&user='.$note->userid . '#note-' . $note->id, 'update note');
|
||||
}
|
||||
// redirect to notes list that contains this note
|
||||
redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid);
|
||||
}
|
||||
|
||||
|
||||
if($noteform->is_submitted()) {
|
||||
// if data was submitted with errors, then use it as default for new form
|
||||
$note = $noteform->get_submitted_data(false);
|
||||
}else{
|
||||
// if data was not submitted yet, then used values retrieved from the database
|
||||
$note->user = $note->userid;
|
||||
$note->course = $note->courseid;
|
||||
$note->note = $note->id;
|
||||
}
|
||||
$noteform->set_data($note);
|
||||
$strnotes = get_string('editnote', 'notes');
|
||||
|
||||
// output HTML
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
$noteform->display();
|
||||
print_footer();
|
||||
|
||||
+34
-34
@@ -1,34 +1,34 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class note_edit_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$strcontent = get_string('content', 'notes');
|
||||
$strpublishstate = get_string('publishstate', 'notes');
|
||||
$mform->addElement('header', 'general', get_string('note', 'notes'));
|
||||
|
||||
$mform->addElement('select', 'user', get_string('user'), $this->_customdata['userlist']);
|
||||
$mform->addRule('user', get_string('nouser', 'notes'), 'required', null, 'client');
|
||||
|
||||
$mform->addElement('textarea', 'content', $strcontent, array('rows'=>15, 'cols'=>40));
|
||||
$mform->setType('content', PARAM_RAW);
|
||||
$mform->addRule('content', get_string('nocontent', 'notes'), 'required', null, 'client');
|
||||
$mform->setHelpButton('content', 'writing');
|
||||
|
||||
$mform->addElement('select', 'publishstate', $strpublishstate, note_get_state_names());
|
||||
$mform->setDefault('publishstate', NOTES_STATE_PUBLIC);
|
||||
$mform->setType('publishstate', PARAM_ALPHA);
|
||||
$mform->setHelpButton('publishstate', array('status', $strpublishstate, 'notes'));
|
||||
|
||||
$this->add_action_buttons();
|
||||
|
||||
$mform->addElement('hidden', 'course');
|
||||
$mform->setType('course', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'note');
|
||||
$mform->setType('note', PARAM_INT);
|
||||
}
|
||||
}
|
||||
<?php // $Id$
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class note_edit_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$strcontent = get_string('content', 'notes');
|
||||
$strpublishstate = get_string('publishstate', 'notes');
|
||||
$mform->addElement('header', 'general', get_string('note', 'notes'));
|
||||
|
||||
$mform->addElement('select', 'user', get_string('user'), $this->_customdata['userlist']);
|
||||
$mform->addRule('user', get_string('nouser', 'notes'), 'required', null, 'client');
|
||||
|
||||
$mform->addElement('textarea', 'content', $strcontent, array('rows'=>15, 'cols'=>40));
|
||||
$mform->setType('content', PARAM_RAW);
|
||||
$mform->addRule('content', get_string('nocontent', 'notes'), 'required', null, 'client');
|
||||
$mform->setHelpButton('content', 'writing');
|
||||
|
||||
$mform->addElement('select', 'publishstate', $strpublishstate, note_get_state_names());
|
||||
$mform->setDefault('publishstate', NOTES_STATE_PUBLIC);
|
||||
$mform->setType('publishstate', PARAM_ALPHA);
|
||||
$mform->setHelpButton('publishstate', array('status', $strpublishstate, 'notes'));
|
||||
|
||||
$this->add_action_buttons();
|
||||
|
||||
$mform->addElement('hidden', 'course');
|
||||
$mform->setType('course', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'note');
|
||||
$mform->setType('note', PARAM_INT);
|
||||
}
|
||||
}
|
||||
|
||||
+99
-88
@@ -1,88 +1,99 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* 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');
|
||||
// retrieve parameters
|
||||
$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);
|
||||
|
||||
// tabs compatibility
|
||||
switch($filtertype) {
|
||||
case 'course':
|
||||
$courseid = $filterselect;
|
||||
break;
|
||||
case 'site':
|
||||
$courseid = SITEID;
|
||||
break;
|
||||
}
|
||||
|
||||
// locate course information
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Incorrect course id specified');
|
||||
}
|
||||
|
||||
// locate user information
|
||||
if ($userid) {
|
||||
if(!$user = get_record('user', 'id', $userid)) {
|
||||
error('Incorrect user id specified');
|
||||
}
|
||||
$filtertype = 'user';
|
||||
$filterselect = $user->id;
|
||||
} else {
|
||||
$filtertype = 'course';
|
||||
$filterselect = $course->id;
|
||||
}
|
||||
|
||||
// require login to access notes
|
||||
require_login($course->id);
|
||||
$strnotes = get_string('notes', 'notes');
|
||||
$crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
$currenttab = 'notes';
|
||||
// output HTML
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
|
||||
|
||||
require_once($CFG->dirroot .'/user/tabs.php');
|
||||
|
||||
$strsitenotes = get_string('sitenotes', 'notes');
|
||||
$strcoursenotes = get_string('coursenotes', 'notes');
|
||||
$strpersonalnotes = get_string('personalnotes', 'notes');
|
||||
$straddnewnote = get_string('addnewnote', 'notes');
|
||||
|
||||
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, $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 {
|
||||
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($userid) {
|
||||
$courses = get_my_courses($userid);
|
||||
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;
|
||||
}
|
||||
note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes');
|
||||
|
||||
print_footer($course);
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* 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');
|
||||
|
||||
/// retrieve parameters
|
||||
$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);
|
||||
|
||||
/// tabs compatibility
|
||||
switch($filtertype) {
|
||||
case 'course':
|
||||
$courseid = $filterselect;
|
||||
break;
|
||||
case 'site':
|
||||
$courseid = SITEID;
|
||||
break;
|
||||
}
|
||||
|
||||
/// locate course information
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Incorrect course id specified');
|
||||
}
|
||||
|
||||
/// locate user information
|
||||
if ($userid) {
|
||||
if (!$user = get_record('user', 'id', $userid)) {
|
||||
error('Incorrect user id specified');
|
||||
}
|
||||
$filtertype = 'user';
|
||||
$filterselect = $user->id;
|
||||
} else {
|
||||
$filtertype = 'course';
|
||||
$filterselect = $course->id;
|
||||
}
|
||||
|
||||
/// require login to access notes
|
||||
require_login($course->id);
|
||||
add_to_log($courseid, 'notes', 'view', 'index.php?course='.$courseid.'&user='.$userid, 'view notes');
|
||||
|
||||
|
||||
/// output HTML
|
||||
|
||||
$strnotes = get_string('notes', 'notes');
|
||||
$nav = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
|
||||
|
||||
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($nav));
|
||||
|
||||
$currenttab = 'notes';
|
||||
require_once($CFG->dirroot .'/user/tabs.php');
|
||||
|
||||
$strsitenotes = get_string('sitenotes', 'notes');
|
||||
$strcoursenotes = get_string('coursenotes', 'notes');
|
||||
$strpersonalnotes = get_string('personalnotes', 'notes');
|
||||
$straddnewnote = get_string('addnewnote', 'notes');
|
||||
|
||||
print_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, $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)) {
|
||||
$courses = get_my_courses($userid);
|
||||
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;
|
||||
}
|
||||
note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_box_end();
|
||||
|
||||
print_footer($course);
|
||||
?>
|
||||
|
||||
+243
-239
@@ -1,239 +1,243 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* Library of functions and constants for notes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constants for states.
|
||||
*/
|
||||
define('NOTES_STATE_DRAFT', 'draft');
|
||||
define('NOTES_STATE_PUBLIC', 'public');
|
||||
define('NOTES_STATE_SITE', 'site');
|
||||
|
||||
/**
|
||||
* Constants for note parts (flags used by note_print and note_print_list).
|
||||
*/
|
||||
define('NOTES_SHOW_FULL', 0x07);
|
||||
define('NOTES_SHOW_HEAD', 0x02);
|
||||
define('NOTES_SHOW_BODY', 0x01);
|
||||
define('NOTES_SHOW_FOOT', 0x04);
|
||||
|
||||
/**
|
||||
* Retrieves a list of note objects with specific atributes.
|
||||
*
|
||||
* @param int $courseid id of the course in which the notes were posted (0 means any)
|
||||
* @param int $userid id of the user to which the notes refer (0 means any)
|
||||
* @param string $state state of the notes (i.e. draft, public, site) ('' means any)
|
||||
* @param int $author id of the user who modified the note last time (0 means any)
|
||||
* @param string $order an order to sort the results in
|
||||
* @param int $limitfrom number of records to skip (offset)
|
||||
* @param int $limitnum number of records to fetch
|
||||
* @return array of note objects
|
||||
*/
|
||||
function note_list($courseid=0, $userid=0, $state = '', $author = 0, $order='lastmodified DESC', $limitfrom=0, $limitnum=0) {
|
||||
// setup filters
|
||||
$select = array();
|
||||
if($courseid) {
|
||||
$selects[] = 'courseid=' . $courseid;
|
||||
}
|
||||
if($userid) {
|
||||
$selects[] = 'userid=' . $userid;
|
||||
}
|
||||
if($author) {
|
||||
$selects[] = 'usermodified=' . $author;
|
||||
}
|
||||
if($state) {
|
||||
$selects[] = 'publishstate="' . $state . '"';
|
||||
}
|
||||
$selects[] = 'module="notes"';
|
||||
$select = implode(' AND ', $selects);
|
||||
$fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
|
||||
// retrieve data
|
||||
$rs =& get_recordset_select('post', $select, $order, $fields, $limitfrom, $limitnum);
|
||||
return recordset_to_array($rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a note object based on its id.
|
||||
*
|
||||
* @param int $note_id id of the note to retrieve
|
||||
* @return note object
|
||||
*/
|
||||
function note_load($note_id) {
|
||||
$fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
|
||||
return get_record_select('post', 'id=' . $note_id . ' AND module="notes"', $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a note object. The note object is passed by reference and its fields (i.e. id)
|
||||
* might change during the save.
|
||||
*
|
||||
* @param note $note object to save
|
||||
* @return boolean true if the object was saved; false otherwise
|
||||
*/
|
||||
function note_save(&$note) {
|
||||
global $USER;
|
||||
// setup & clean fields
|
||||
$note->module = 'notes';
|
||||
$note->lastmodified = time();
|
||||
$note->usermodified = $USER->id;
|
||||
if(empty($note->format)) {
|
||||
$note->format = FORMAT_PLAIN;
|
||||
}
|
||||
if(empty($note->publishstate)) {
|
||||
$note->publishstate = NOTES_STATE_PUBLIC;
|
||||
}
|
||||
// save data
|
||||
if(empty($note->id)) {
|
||||
// insert new note
|
||||
$note->created = $note->lastmodified;
|
||||
if($id = insert_record('post', $note)) {
|
||||
$note->id = $id;
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
} else {
|
||||
// update old note
|
||||
$result = update_record('post', $note);
|
||||
}
|
||||
unset($note->module);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a note object based on its id.
|
||||
*
|
||||
* @param int $note_id id of the note to delete
|
||||
* @return boolean true if the object was deleted; false otherwise
|
||||
*/
|
||||
function note_delete($noteid) {
|
||||
return delete_records_select('post', 'id=' . $noteid . ' AND module="notes"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a state value to its corespondent name
|
||||
*
|
||||
* @param string $state state value to convert
|
||||
* @return string corespondent state name
|
||||
*/
|
||||
function note_get_state_name($state) {
|
||||
// cache state names
|
||||
static $states;
|
||||
if (empty($states)) {
|
||||
$states = note_get_state_names();
|
||||
}
|
||||
return @$states[$state];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of mappings from state values to state names
|
||||
*
|
||||
* @return array of mappings
|
||||
*/
|
||||
function note_get_state_names() {
|
||||
return array(
|
||||
NOTES_STATE_DRAFT => get_string('personal', 'notes'),
|
||||
NOTES_STATE_PUBLIC => get_string('course', 'notes'),
|
||||
NOTES_STATE_SITE => get_string('site', 'notes'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a note object
|
||||
*
|
||||
* @param note $note the note object to print
|
||||
* @param int $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print
|
||||
*/
|
||||
function note_print($note, $detail = NOTES_SHOW_FULL) {
|
||||
|
||||
global $CFG, $USER;
|
||||
$user = get_record('user','id',$note->userid);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $note->courseid);
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$authoring->name = fullname(get_record('user','id',$note->usermodified));
|
||||
$authoring->date = userdate($note->lastmodified);
|
||||
echo '<div class="notepost '. $note->publishstate . 'notepost' .
|
||||
($note->usermodified == $USER->id ? ' ownnotepost' : '') .
|
||||
'" id="note-'. $note->id .'">';
|
||||
|
||||
// print note head (e.g. author, user refering to, etc)
|
||||
if($detail & NOTES_SHOW_HEAD) {
|
||||
echo '<div class="header">';
|
||||
echo '<div class="user">';
|
||||
print_user_picture($user->id, $note->courseid, $user->picture);
|
||||
echo fullname($user) . '</div>';
|
||||
echo '<div class="info">' .
|
||||
get_string('bynameondate', 'notes', $authoring) .
|
||||
' (' . get_string('created', 'notes') . ': ' . userdate($note->created) . ')</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// print note content
|
||||
if($detail & NOTES_SHOW_BODY) {
|
||||
echo '<div class="content">';
|
||||
echo format_text($note->content, $note->format);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// print note options (e.g. delete, edit)
|
||||
if($detail & NOTES_SHOW_FOOT) {
|
||||
if (has_capability('moodle/notes:manage', $sitecontext) && $note->publishstate == NOTES_STATE_SITE ||
|
||||
has_capability('moodle/notes:manage', $context) && ($note->publishstate == NOTES_STATE_PUBLIC || $note->usermodified == $USER->id)) {
|
||||
echo '<div class="footer"><p>';
|
||||
echo '<a href="'.$CFG->wwwroot.'/notes/edit.php?note='.$note->id. '">'. get_string('edit') .'</a> | ';
|
||||
echo '<a href="'.$CFG->wwwroot.'/notes/delete.php?note='.$note->id. '">'. get_string('delete') .'</a>';
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a list of note objects
|
||||
*
|
||||
* @param array $notes array of note objects to print
|
||||
* @param int $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print
|
||||
*/
|
||||
function note_print_list($notes, $detail = NOTES_SHOW_FULL) {
|
||||
|
||||
/// Start printing of the note
|
||||
echo '<div class="notelist">';
|
||||
foreach ($notes as $note) {
|
||||
note_print($note, $detail);
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves and prints a list of note objects with specific atributes.
|
||||
*
|
||||
* @param string $header HTML to print above the list
|
||||
* @param int $addcourseid id of the course for the add notes link (0 hide link)
|
||||
* @param boolean $viewnotes true if the notes should be printed; false otherwise (print notesnotvisible string)
|
||||
* @param int $courseid id of the course in which the notes were posted (0 means any)
|
||||
* @param int $userid id of the user to which the notes refer (0 means any)
|
||||
* @param string $state state of the notes (i.e. draft, public, site) ('' means any)
|
||||
* @param int $author id of the user who modified the note last time (0 means any)
|
||||
*/
|
||||
function note_print_notes($header, $addcourseid = 0, $viewnotes = true, $courseid = 0, $userid = 0, $state = '', $author = 0)
|
||||
{
|
||||
global $CFG;
|
||||
if ($header) {
|
||||
echo '<h3 id="notestitle">' . $header . '</h3>';
|
||||
}
|
||||
if ($addcourseid) {
|
||||
echo '<p><a href="'. $CFG->wwwroot .'/notes/add.php?course=' . $addcourseid . '&user=' . $userid . '&state=' . $state . '">' . get_string('addnewnote', 'notes') . '</a></p>';
|
||||
}
|
||||
if ($viewnotes) {
|
||||
$notes =& note_list($courseid, $userid, $state, $author);
|
||||
if($notes) {
|
||||
note_print_list($notes);
|
||||
} else {
|
||||
echo '<p>' . get_string('nonotes', 'notes') . '</p>';
|
||||
}
|
||||
} else {
|
||||
echo '<p>' . get_string('notesnotvisible', 'notes') . '</p>';
|
||||
}
|
||||
}
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* Library of functions and constants for notes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constants for states.
|
||||
*/
|
||||
define('NOTES_STATE_DRAFT', 'draft');
|
||||
define('NOTES_STATE_PUBLIC', 'public');
|
||||
define('NOTES_STATE_SITE', 'site');
|
||||
|
||||
/**
|
||||
* Constants for note parts (flags used by note_print and note_print_list).
|
||||
*/
|
||||
define('NOTES_SHOW_FULL', 0x07);
|
||||
define('NOTES_SHOW_HEAD', 0x02);
|
||||
define('NOTES_SHOW_BODY', 0x01);
|
||||
define('NOTES_SHOW_FOOT', 0x04);
|
||||
|
||||
/**
|
||||
* Retrieves a list of note objects with specific atributes.
|
||||
*
|
||||
* @param int $courseid id of the course in which the notes were posted (0 means any)
|
||||
* @param int $userid id of the user to which the notes refer (0 means any)
|
||||
* @param string $state state of the notes (i.e. draft, public, site) ('' means any)
|
||||
* @param int $author id of the user who modified the note last time (0 means any)
|
||||
* @param string $order an order to sort the results in
|
||||
* @param int $limitfrom number of records to skip (offset)
|
||||
* @param int $limitnum number of records to fetch
|
||||
* @return array of note objects
|
||||
*/
|
||||
function note_list($courseid=0, $userid=0, $state = '', $author = 0, $order='lastmodified DESC', $limitfrom=0, $limitnum=0) {
|
||||
// setup filters
|
||||
$select = array();
|
||||
if($courseid) {
|
||||
$selects[] = 'courseid=' . $courseid;
|
||||
}
|
||||
if($userid) {
|
||||
$selects[] = 'userid=' . $userid;
|
||||
}
|
||||
if($author) {
|
||||
$selects[] = 'usermodified=' . $author;
|
||||
}
|
||||
if($state) {
|
||||
$selects[] = 'publishstate="' . $state . '"';
|
||||
}
|
||||
$selects[] = 'module="notes"';
|
||||
$select = implode(' AND ', $selects);
|
||||
$fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
|
||||
// retrieve data
|
||||
$rs =& get_recordset_select('post', $select, $order, $fields, $limitfrom, $limitnum);
|
||||
return recordset_to_array($rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a note object based on its id.
|
||||
*
|
||||
* @param int $note_id id of the note to retrieve
|
||||
* @return note object
|
||||
*/
|
||||
function note_load($note_id) {
|
||||
$fields = 'id,courseid,userid,content,format,created,lastmodified,usermodified,publishstate';
|
||||
return get_record_select('post', 'id=' . $note_id . ' AND module="notes"', $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a note object. The note object is passed by reference and its fields (i.e. id)
|
||||
* might change during the save.
|
||||
*
|
||||
* @param note $note object to save
|
||||
* @return boolean true if the object was saved; false otherwise
|
||||
*/
|
||||
function note_save(&$note) {
|
||||
global $USER;
|
||||
// setup & clean fields
|
||||
$note->module = 'notes';
|
||||
$note->lastmodified = time();
|
||||
$note->usermodified = $USER->id;
|
||||
if(empty($note->format)) {
|
||||
$note->format = FORMAT_PLAIN;
|
||||
}
|
||||
if(empty($note->publishstate)) {
|
||||
$note->publishstate = NOTES_STATE_PUBLIC;
|
||||
}
|
||||
// save data
|
||||
if(empty($note->id)) {
|
||||
// insert new note
|
||||
$note->created = $note->lastmodified;
|
||||
if($id = insert_record('post', $note)) {
|
||||
$note->id = $id;
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
} else {
|
||||
// update old note
|
||||
$result = update_record('post', $note);
|
||||
}
|
||||
unset($note->module);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a note object based on its id.
|
||||
*
|
||||
* @param int $note_id id of the note to delete
|
||||
* @return boolean true if the object was deleted; false otherwise
|
||||
*/
|
||||
function note_delete($noteid) {
|
||||
return delete_records_select('post', 'id=' . $noteid . ' AND module="notes"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a state value to its corespondent name
|
||||
*
|
||||
* @param string $state state value to convert
|
||||
* @return string corespondent state name
|
||||
*/
|
||||
function note_get_state_name($state) {
|
||||
// cache state names
|
||||
static $states;
|
||||
if (empty($states)) {
|
||||
$states = note_get_state_names();
|
||||
}
|
||||
return @$states[$state];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of mappings from state values to state names
|
||||
*
|
||||
* @return array of mappings
|
||||
*/
|
||||
function note_get_state_names() {
|
||||
return array(
|
||||
NOTES_STATE_DRAFT => get_string('personal', 'notes'),
|
||||
NOTES_STATE_PUBLIC => get_string('course', 'notes'),
|
||||
NOTES_STATE_SITE => get_string('site', 'notes'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a note object
|
||||
*
|
||||
* @param note $note the note object to print
|
||||
* @param int $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print
|
||||
*/
|
||||
function note_print($note, $detail = NOTES_SHOW_FULL) {
|
||||
|
||||
global $CFG, $USER;
|
||||
$user = get_record('user','id',$note->userid);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $note->courseid);
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$authoring->name = fullname(get_record('user','id',$note->usermodified));
|
||||
$authoring->date = userdate($note->lastmodified);
|
||||
echo '<div class="notepost '. $note->publishstate . 'notepost' .
|
||||
($note->usermodified == $USER->id ? ' ownnotepost' : '') .
|
||||
'" id="note-'. $note->id .'">';
|
||||
|
||||
// print note head (e.g. author, user refering to, etc)
|
||||
if($detail & NOTES_SHOW_HEAD) {
|
||||
echo '<div class="header">';
|
||||
echo '<div class="user">';
|
||||
print_user_picture($user->id, $note->courseid, $user->picture);
|
||||
echo fullname($user) . '</div>';
|
||||
echo '<div class="info">' .
|
||||
get_string('bynameondate', 'notes', $authoring) .
|
||||
' (' . get_string('created', 'notes') . ': ' . userdate($note->created) . ')</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// print note content
|
||||
if($detail & NOTES_SHOW_BODY) {
|
||||
echo '<div class="content">';
|
||||
echo format_text($note->content, $note->format);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// print note options (e.g. delete, edit)
|
||||
if($detail & NOTES_SHOW_FOOT) {
|
||||
if (has_capability('moodle/notes:manage', $sitecontext) && $note->publishstate == NOTES_STATE_SITE ||
|
||||
has_capability('moodle/notes:manage', $context) && ($note->publishstate == NOTES_STATE_PUBLIC || $note->usermodified == $USER->id)) {
|
||||
echo '<div class="footer"><p>';
|
||||
echo '<a href="'.$CFG->wwwroot.'/notes/edit.php?note='.$note->id. '">'. get_string('edit') .'</a> | ';
|
||||
echo '<a href="'.$CFG->wwwroot.'/notes/delete.php?note='.$note->id. '">'. get_string('delete') .'</a>';
|
||||
echo '</p></div>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a list of note objects
|
||||
*
|
||||
* @param array $notes array of note objects to print
|
||||
* @param int $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print
|
||||
*/
|
||||
function note_print_list($notes, $detail = NOTES_SHOW_FULL) {
|
||||
|
||||
/// Start printing of the note
|
||||
echo '<div class="notelist">';
|
||||
foreach ($notes as $note) {
|
||||
note_print($note, $detail);
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves and prints a list of note objects with specific atributes.
|
||||
*
|
||||
* @param string $header HTML to print above the list
|
||||
* @param int $addcourseid id of the course for the add notes link (0 hide link)
|
||||
* @param boolean $viewnotes true if the notes should be printed; false otherwise (print notesnotvisible string)
|
||||
* @param int $courseid id of the course in which the notes were posted (0 means any)
|
||||
* @param int $userid id of the user to which the notes refer (0 means any)
|
||||
* @param string $state state of the notes (i.e. draft, public, site) ('' means any)
|
||||
* @param int $author id of the user who modified the note last time (0 means any)
|
||||
*/
|
||||
function note_print_notes($header, $addcourseid = 0, $viewnotes = true, $courseid = 0, $userid = 0, $state = '', $author = 0)
|
||||
{
|
||||
global $CFG;
|
||||
if ($header) {
|
||||
echo '<h3 class="notestitle">' . $header . '</h3>';
|
||||
echo '<div class="notesgroup">';
|
||||
}
|
||||
if ($addcourseid) {
|
||||
echo '<p><a href="'. $CFG->wwwroot .'/notes/add.php?course=' . $addcourseid . '&user=' . $userid . '&state=' . $state . '">' . get_string('addnewnote', 'notes') . '</a></p>';
|
||||
}
|
||||
if ($viewnotes) {
|
||||
$notes =& note_list($courseid, $userid, $state, $author);
|
||||
if ($notes) {
|
||||
note_print_list($notes);
|
||||
}
|
||||
} else {
|
||||
echo '<p>' . get_string('notesnotvisible', 'notes') . '</p>';
|
||||
}
|
||||
if ($header) {
|
||||
echo '</div>'; // notesgroup
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
+9
-9
@@ -1,9 +1,9 @@
|
||||
<?php // $Id$
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/// Code fragment to define the version of the note module
|
||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$note_version = 2007070700; // The current version of note module (Date: YYYYMMDDXX)
|
||||
$module->cron = 1800; // Period for cron to check this module (secs)
|
||||
<?php // $Id$
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/// Code fragment to define the version of the note module
|
||||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$note_version = 2007070700; // The current version of note module (Date: YYYYMMDDXX)
|
||||
$module->cron = 1800; // Period for cron to check this module (secs)
|
||||
|
||||
@@ -2496,11 +2496,21 @@ body#message-send .notifysuccess {
|
||||
}
|
||||
|
||||
.notepost .content {
|
||||
clear: both;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.notepost .footer {
|
||||
clear: both;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
body.notes .generalbox {
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
width:90%;
|
||||
}
|
||||
|
||||
body.notes .notesgroup {
|
||||
margin-left:20px;
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
Reference in New Issue
Block a user