';
// Print note head (e.g. author, user refering to, etc).
if ($detail & NOTES_SHOW_HEAD) {
echo '';
}
// Print note content.
if ($detail & NOTES_SHOW_BODY) {
echo '
';
echo format_text($note->content, $note->format, array('overflowdiv' => true));
echo '
';
}
// Print note options (e.g. delete, edit).
if ($detail & NOTES_SHOW_FOOT) {
if (has_capability('moodle/notes:manage', $systemcontext) && $note->publishstate == NOTES_STATE_SITE ||
has_capability('moodle/notes:manage', $context) &&
($note->publishstate == NOTES_STATE_PUBLIC || $note->usermodified == $USER->id)) {
echo '';
}
}
echo '
';
}
/**
* 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) {
echo '';
foreach ($notes as $note) {
note_print($note, $detail);
}
echo '
';
}
/**
* 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 ''; // The notesgroup div.
}
}
/**
* Delete all notes about users in course-
* @param int $courseid
* @return bool success
*/
function note_delete_all($courseid) {
global $DB;
return $DB->delete_records('post', array('module' => 'notes', 'courseid' => $courseid));
}
/**
* Return a list of page types
* @param string $pagetype current page type
* @param stdClass $parentcontext Block's parent context
* @param stdClass $currentcontext Current context of block
*/
function note_page_type_list($pagetype, $parentcontext, $currentcontext) {
return array('notes-*' => get_string('page-notes-x', 'notes'));
}
/**
* Trigger notes viewed event
*
* @param stdClass $context context object
* @param int $userid user id (the user we are viewing the notes)
* @since Moodle 2.9
*/
function note_view($context, $userid) {
$event = \core\event\notes_viewed::create(array(
'relateduserid' => $userid,
'context' => $context
));
$event->trigger();
}
/**
* Add nodes to myprofile page.
*
* @param \core_user\output\myprofile\tree $tree Tree object
* @param stdClass $user user object
* @param bool $iscurrentuser
* @param stdClass $course Course object
*
* @return bool
*/
function core_notes_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
global $CFG;
if (empty($CFG->enablenotes)) {
// Notes are disabled, nothing to do.
return false;
}
if (isguestuser($user)) {
// No notes for guest users.
return false;
}
$url = new moodle_url("/notes/index.php", array('user' => $user->id));
$title = get_string('notes', 'core_notes');
if (empty($course)) {
// Site level profile.
if (!has_capability('moodle/notes:view', context_system::instance())) {
// No cap, nothing to do.
return false;
}
} else {
if (!has_capability('moodle/notes:view', context_course::instance($course->id))) {
// No cap, nothing to do.
return false;
}
$url->param('course', $course->id);
}
$notesnode = new core_user\output\myprofile\node('miscellaneous', 'notes', $title, null, $url);
$tree->add_node($notesnode);
}