Skip to content

Commit

Permalink
MDL-49504 notes: Move note view triggering to API function
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Apr 2, 2015
1 parent 1d3fd63 commit f0c5f84
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 1 addition & 5 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@
$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) {
Expand Down
20 changes: 20 additions & 0 deletions notes/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

/**
Expand Down Expand Up @@ -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();
}

0 comments on commit f0c5f84

Please sign in to comment.