MDL-49504 notes: Move note view triggering to API function

This commit is contained in:
Juan Leyva 2015-03-31 13:30:30 +02:00
parent 1d3fd63f97
commit f0c5f8406c
2 changed files with 21 additions and 5 deletions

View File

@ -87,11 +87,7 @@ require_capability('moodle/notes:view', $coursecontext);
$systemcontext = context_system::instance();
// Trigger event.
$event = \core\event\notes_viewed::create(array(
'relateduserid' => $userid,
'context' => $coursecontext
));
$event->trigger();
note_view($coursecontext, $userid);
$strnotes = get_string('notes', 'notes');
if ($userid) {

View File

@ -16,6 +16,9 @@
/**
* Library of functions and constants for notes
*
* @package core_notes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
@ -347,3 +350,20 @@ function note_delete_all($courseid) {
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();
}