Skip to content

Commit 8da25b9

Browse files
committed
Upgrade logging to use Events
add_to_log has been deprecated since Moodle 2.7. This patch adds an event and triggers it instead of calling add_to_log; a version bump is included in order to register the event class.
1 parent 3ac4471 commit 8da25b9

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
namespace mod_echolink\event;
3+
defined('MOODLE_INTERNAL') || die();
4+
class course_module_viewed extends \core\event\course_module_viewed {
5+
protected function init() {
6+
$this->data['crud'] = 'c';
7+
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
8+
$this->data['objecttable'] = 'echolink';
9+
}
10+
}

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
defined('MOODLE_INTERNAL') || die();
2727

28-
$plugin->version = 2016050501; // The current module version (Date: YYYYMMDDXX)
28+
$plugin->version = 2016050502; // The current module version (Date: YYYYMMDDXX)
2929
$plugin->requires = 2011112900; // Requires this Moodle version
3030
$plugin->component = 'mod_echolink'; // Full name of the plugin (used for diagnostics)
3131
$plugin->cron = 0;

view.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@
4747
$context = context_module::instance($cm->id);
4848
require_capability('mod/echolink:view', $context);
4949

50-
add_to_log($course->id, 'echolink', 'view', 'view.php?id='.$cm->id, $echolink->id, $cm->id);
51-
50+
// Log this request.
51+
$params = array(
52+
'objectid' => $course->id,
53+
'context' => $context
54+
);
55+
$event = \mod_echolink\event\course_module_viewed::create($params);
56+
$event->add_record_snapshot('echolink', $echolink);
57+
$event->trigger();
5258

5359
// Update 'viewed' state if required by completion system
5460
$completion = new completion_info($course);

0 commit comments

Comments
 (0)