Merge branch 'MDL-52805-42' of https://github.com/Chocolate-lightning/moodle
This commit is contained in:
@@ -296,7 +296,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->header();
|
||||
$output .= $this->output->heading(get_string('notifications', 'admin'));
|
||||
$output .= $this->maturity_info($maturity);
|
||||
$output .= $this->legacy_log_store_writing_error();
|
||||
$output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
|
||||
$output .= $this->insecure_dataroot_warning($insecuredataroot);
|
||||
$output .= $this->development_libs_directories_warning($devlibdir);
|
||||
@@ -2192,21 +2191,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if writing to the deprecated legacy log store is enabled.
|
||||
*
|
||||
* @return string An error message if writing to the legacy log store is enabled.
|
||||
*/
|
||||
protected function legacy_log_store_writing_error() {
|
||||
$enabled = get_config('logstore_legacy', 'loglegacy');
|
||||
$plugins = explode(',', get_config('tool_log', 'enabled_stores'));
|
||||
$enabled = $enabled && in_array('logstore_legacy', $plugins);
|
||||
|
||||
if ($enabled) {
|
||||
return $this->warning(get_string('legacylogginginuse'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display message about the benefits of registering on Moodle.org
|
||||
*
|
||||
|
||||
@@ -36,10 +36,6 @@ class preset_deleted extends base {
|
||||
return "User {$this->userid} has deleted the preset with id {$this->objectid}.";
|
||||
}
|
||||
|
||||
public function get_legacy_logdata(): array {
|
||||
return [$this->courseid, 'tool_admin_presets', 'delete', '', $this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
protected function init(): void {
|
||||
$this->data['crud'] = 'd';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
|
||||
@@ -41,10 +41,6 @@ class preset_exported extends base {
|
||||
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
|
||||
}
|
||||
|
||||
public function get_legacy_logdata(): array {
|
||||
return [$this->courseid, 'tool_admin_presets', 'export', '', $this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
protected function init(): void {
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
|
||||
@@ -41,10 +41,6 @@ class preset_imported extends base {
|
||||
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
|
||||
}
|
||||
|
||||
public function get_legacy_logdata(): array {
|
||||
return [$this->courseid, 'tool_admin_presets', 'import', '', $this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
protected function init(): void {
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
|
||||
@@ -41,10 +41,6 @@ class preset_loaded extends base {
|
||||
['action' => 'load', 'mode' => 'preview', 'id' => $this->objectid]);
|
||||
}
|
||||
|
||||
public function get_legacy_logdata(): array {
|
||||
return [$this->courseid, 'tool_admin_presets', 'load', '', $this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
protected function init(): void {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
|
||||
@@ -36,10 +36,6 @@ class preset_reverted extends base {
|
||||
return "User {$this->userid} has reverted the preset with id {$this->objectid}.";
|
||||
}
|
||||
|
||||
public function get_legacy_logdata(): array {
|
||||
return [$this->courseid, 'tool_admin_presets', 'rollback', '', $this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
protected function init(): void {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
|
||||
@@ -40,10 +40,6 @@ class presets_listed extends base {
|
||||
return new \moodle_url('/admin/tool/admin_presets/index.php');
|
||||
}
|
||||
|
||||
public function get_legacy_logdata(): array {
|
||||
return [$this->courseid, 'tool_admin_presets', 'base', '', $this->objectid, $this->contextinstanceid];
|
||||
}
|
||||
|
||||
protected function init(): void {
|
||||
$this->data['crud'] = 'r';
|
||||
$this->data['edulevel'] = self::LEVEL_OTHER;
|
||||
|
||||
@@ -55,7 +55,5 @@ class preset_deleted_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\tool_admin_presets\event\preset_deleted', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($presetid, $event->objectid);
|
||||
$expected = [0, 'tool_admin_presets', 'delete', '', $presetid, 0];
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,5 @@ class preset_exported_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\tool_admin_presets\event\preset_exported', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($presetid, $event->objectid);
|
||||
$expected = [0, 'tool_admin_presets', 'export', '', $presetid, 0];
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,5 @@ class preset_imported_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\tool_admin_presets\event\preset_imported', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($presetid, $event->objectid);
|
||||
$expected = [0, 'tool_admin_presets', 'import', '', $presetid, 0];
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,5 @@ class preset_loaded_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\tool_admin_presets\event\preset_loaded', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($presetid, $event->objectid);
|
||||
$expected = [0, 'tool_admin_presets', 'load', '', $presetid, 0];
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,5 @@ class preset_reverted_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\tool_admin_presets\event\preset_reverted', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($presetid, $event->objectid);
|
||||
$expected = [0, 'tool_admin_presets', 'rollback', '', $presetid, 0];
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,5 @@ class presets_listed_test extends \advanced_testcase {
|
||||
$this->assertInstanceOf('\tool_admin_presets\event\presets_listed', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($presetid, $event->objectid);
|
||||
$expected = [0, 'tool_admin_presets', 'base', '', $presetid, 0];
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,15 +62,6 @@ class report_viewed extends \core\event\base {
|
||||
return "The user with id '$this->userid' viewed the capability overview report.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'admin', 'tool capability', 'tool/capability/index.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
|
||||
@@ -55,8 +55,6 @@ class events_test extends \advanced_testcase {
|
||||
|
||||
$this->assertInstanceOf('\tool_capability\event\report_viewed', $event);
|
||||
$this->assertEquals(\context_system::instance(), $event->get_context());
|
||||
$expected = array(SITEID, "admin", "tool capability", "tool/capability/index.php");
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
$url = new \moodle_url('/admin/tool/capability/index.php');
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
|
||||
@@ -199,29 +199,4 @@ class manager implements \core\log\manager {
|
||||
$this->readers = null;
|
||||
$this->writers = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy add_to_log() redirection.
|
||||
*
|
||||
* To be used only from deprecated add_to_log() function and event trigger() method.
|
||||
*
|
||||
* NOTE: this is hardcoded to legacy log store plugin, hopefully we can get rid of it soon.
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param string $module The module name e.g. forum, journal, resource, course, user etc
|
||||
* @param string $action 'view', 'update', 'add' or 'delete', possibly followed by another word to clarify
|
||||
* @param string $url The file and parameters used to see the results of the action
|
||||
* @param string $info Additional description information
|
||||
* @param int $cm The course_module->id if there is one
|
||||
* @param int|\stdClass $user If log regards $user other than $USER
|
||||
* @param string $ip Override the IP, should only be used for restore.
|
||||
* @param int $time Override the log time, should only be used for restore.
|
||||
*/
|
||||
public function legacy_add_to_log($courseid, $module, $action, $url = '', $info = '',
|
||||
$cm = 0, $user = 0, $ip = null, $time = null) {
|
||||
$this->init();
|
||||
if (isset($this->stores['logstore_legacy'])) {
|
||||
$this->stores['logstore_legacy']->legacy_add_to_log($courseid, $module, $action, $url, $info, $cm, $user, $ip, $time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,5 @@ function xmldb_tool_log_install() {
|
||||
$enabled[] = 'logstore_standard';
|
||||
}
|
||||
|
||||
// Enable legacy log reading, but only if there are existing data.
|
||||
if (file_exists("$CFG->dirroot/$CFG->admin/tool/log/store/legacy")) {
|
||||
unset_config('loglegacy', 'logstore_legacy');
|
||||
// Do not enabled legacy logging if somebody installed a new
|
||||
// site and in less than one day upgraded to 2.7.
|
||||
$params = array('yesterday' => time() - 60*60*24);
|
||||
if ($DB->record_exists_select('log', "time < :yesterday", $params)) {
|
||||
$enabled[] = 'logstore_legacy';
|
||||
}
|
||||
}
|
||||
|
||||
set_config('enabled_stores', implode(',', $enabled), 'tool_log');
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace logstore_legacy\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Legacy log emulation event class.
|
||||
*
|
||||
* @package core
|
||||
* @since Moodle 2.7
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class legacy_logged extends \core\event\base {
|
||||
|
||||
public function init() {
|
||||
throw new \coding_exception('legacy events cannot be triggered');
|
||||
}
|
||||
|
||||
public static function get_name() {
|
||||
return get_string('eventlegacylogged', 'logstore_legacy');
|
||||
}
|
||||
|
||||
public function get_description() {
|
||||
return $this->other['module'] . ' ' . $this->other['action'] . ' ' . $this->other['info'];
|
||||
}
|
||||
|
||||
public function get_url() {
|
||||
global $CFG;
|
||||
require_once("$CFG->dirroot/course/lib.php");
|
||||
|
||||
$url = \make_log_url($this->other['module'], $this->other['url']);
|
||||
if (!$url) {
|
||||
return null;
|
||||
}
|
||||
return new \moodle_url($url);
|
||||
}
|
||||
}
|
||||
@@ -1,424 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Legacy log reader.
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This is to be removed in Moodle 3.10
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace logstore_legacy\log;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class store implements \tool_log\log\store, \core\log\sql_reader {
|
||||
use \tool_log\helper\store,
|
||||
\tool_log\helper\reader;
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This is to be removed in Moodle 3.10
|
||||
*
|
||||
* @param \tool_log\log\manager $manager
|
||||
*/
|
||||
public function __construct(\tool_log\log\manager $manager) {
|
||||
$this->helper_setup($manager);
|
||||
}
|
||||
|
||||
/** @var array list of db fields which needs to be replaced for legacy log query */
|
||||
protected static $standardtolegacyfields = array(
|
||||
'timecreated' => 'time',
|
||||
'courseid' => 'course',
|
||||
'contextinstanceid' => 'cmid',
|
||||
'origin' => 'ip',
|
||||
'anonymous' => 0,
|
||||
);
|
||||
|
||||
/** @var string Regex to replace the crud params */
|
||||
const CRUD_REGEX = "/(crud).*?(<>|=|!=).*?'(.*?)'/s";
|
||||
|
||||
/**
|
||||
* This method contains mapping required for Moodle core to make legacy store compatible with other sql_reader based
|
||||
* queries.
|
||||
*
|
||||
* @param string $selectwhere Select statment
|
||||
* @param array $params params for the sql
|
||||
* @param string $sort sort fields
|
||||
*
|
||||
* @return array returns an array containing the sql predicate, an array of params and sorting parameter.
|
||||
*/
|
||||
protected static function replace_sql_legacy($selectwhere, array $params, $sort = '') {
|
||||
// Following mapping is done to make can_delete_course() compatible with legacy store.
|
||||
if ($selectwhere == "userid = :userid AND courseid = :courseid AND eventname = :eventname AND timecreated > :since" and
|
||||
empty($sort)) {
|
||||
$replace = "module = 'course' AND action = 'new' AND userid = :userid AND url = :url AND time > :since";
|
||||
$params += array('url' => "view.php?id={$params['courseid']}");
|
||||
return array($replace, $params, $sort);
|
||||
}
|
||||
|
||||
// Replace db field names to make it compatible with legacy log.
|
||||
foreach (self::$standardtolegacyfields as $from => $to) {
|
||||
$selectwhere = str_replace($from, $to, $selectwhere);
|
||||
if (!empty($sort)) {
|
||||
$sort = str_replace($from, $to, $sort);
|
||||
}
|
||||
if (isset($params[$from])) {
|
||||
$params[$to] = $params[$from];
|
||||
unset($params[$from]);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace crud fields.
|
||||
$selectwhere = preg_replace_callback("/(crud).*?(<>|=|!=).*?'(.*?)'/s", self::class .'::replace_crud', $selectwhere);
|
||||
|
||||
return array($selectwhere, $params, $sort);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.10
|
||||
*
|
||||
* @param string $selectwhere
|
||||
* @param array $params
|
||||
* @param string $sort
|
||||
* @param int $limitfrom
|
||||
* @param int $limitnum
|
||||
* @return array
|
||||
*/
|
||||
public function get_events_select($selectwhere, array $params, $sort, $limitfrom, $limitnum) {
|
||||
global $DB;
|
||||
|
||||
$sort = self::tweak_sort_by_id($sort);
|
||||
|
||||
// Replace the query with hardcoded mappings required for core.
|
||||
list($selectwhere, $params, $sort) = self::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
|
||||
$records = array();
|
||||
|
||||
try {
|
||||
// A custom report + on the fly SQL rewriting = a possible exception.
|
||||
$records = $DB->get_recordset_select('log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
|
||||
} catch (\moodle_exception $ex) {
|
||||
debugging("error converting legacy event data " . $ex->getMessage() . $ex->debuginfo, DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
$events = array();
|
||||
|
||||
foreach ($records as $data) {
|
||||
$events[$data->id] = $this->get_log_event($data);
|
||||
}
|
||||
|
||||
$records->close();
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether events are present for the given select clause.
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
*
|
||||
* @param string $selectwhere select conditions.
|
||||
* @param array $params params.
|
||||
*
|
||||
* @return bool Whether events available for the given conditions
|
||||
*/
|
||||
public function get_events_select_exists(string $selectwhere, array $params): bool {
|
||||
global $DB;
|
||||
|
||||
// Replace the query with hardcoded mappings required for core.
|
||||
list($selectwhere, $params) = self::replace_sql_legacy($selectwhere, $params);
|
||||
|
||||
try {
|
||||
return $DB->record_exists_select('log', $selectwhere, $params);
|
||||
} catch (\moodle_exception $ex) {
|
||||
debugging("error converting legacy event data " . $ex->getMessage() . $ex->debuginfo, DEBUG_DEVELOPER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch records using given criteria returning a Traversable object.
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.10
|
||||
*
|
||||
* Note that the traversable object contains a moodle_recordset, so
|
||||
* remember that is important that you call close() once you finish
|
||||
* using it.
|
||||
*
|
||||
* @param string $selectwhere
|
||||
* @param array $params
|
||||
* @param string $sort
|
||||
* @param int $limitfrom
|
||||
* @param int $limitnum
|
||||
* @return \Traversable|\core\event\base[]
|
||||
*/
|
||||
public function get_events_select_iterator($selectwhere, array $params, $sort, $limitfrom, $limitnum) {
|
||||
global $DB;
|
||||
|
||||
$sort = self::tweak_sort_by_id($sort);
|
||||
|
||||
// Replace the query with hardcoded mappings required for core.
|
||||
list($selectwhere, $params, $sort) = self::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
|
||||
try {
|
||||
$recordset = $DB->get_recordset_select('log', $selectwhere, $params, $sort, '*', $limitfrom, $limitnum);
|
||||
} catch (\moodle_exception $ex) {
|
||||
debugging("error converting legacy event data " . $ex->getMessage() . $ex->debuginfo, DEBUG_DEVELOPER);
|
||||
return new \EmptyIterator;
|
||||
}
|
||||
|
||||
return new \core\dml\recordset_walk($recordset, array($this, 'get_log_event'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an event from the log data.
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.10
|
||||
*
|
||||
* @param stdClass $data Log data
|
||||
* @return \core\event\base
|
||||
*/
|
||||
public function get_log_event($data) {
|
||||
return \logstore_legacy\event\legacy_logged::restore_legacy($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.10
|
||||
*
|
||||
* @param string $selectwhere
|
||||
* @param array $params
|
||||
* @return int
|
||||
*/
|
||||
public function get_events_select_count($selectwhere, array $params) {
|
||||
global $DB;
|
||||
|
||||
// Replace the query with hardcoded mappings required for core.
|
||||
list($selectwhere, $params) = self::replace_sql_legacy($selectwhere, $params);
|
||||
|
||||
try {
|
||||
return $DB->count_records_select('log', $selectwhere, $params);
|
||||
} catch (\moodle_exception $ex) {
|
||||
debugging("error converting legacy event data " . $ex->getMessage() . $ex->debuginfo, DEBUG_DEVELOPER);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are the new events appearing in the reader?
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.10
|
||||
*
|
||||
* @return bool true means new log events are being added, false means no new data will be added
|
||||
*/
|
||||
public function is_logging() {
|
||||
return (bool)$this->get_config('loglegacy', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Moodle 3.6 MDL-52953 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.10
|
||||
*/
|
||||
public function dispose() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy add_to_log() code.
|
||||
* @deprecated since Moodle 3.1 MDL-45104 - Please use supported log stores such as "standard" or "external" instead.
|
||||
* @todo MDL-52805 This will be removed in Moodle 3.3
|
||||
*
|
||||
* @param int $courseid The course id
|
||||
* @param string $module The module name e.g. forum, journal, resource, course, user etc
|
||||
* @param string $action 'view', 'update', 'add' or 'delete', possibly followed by another word to clarify.
|
||||
* @param string $url The file and parameters used to see the results of the action
|
||||
* @param string $info Additional description information
|
||||
* @param int $cm The course_module->id if there is one
|
||||
* @param int|\stdClass $user If log regards $user other than $USER
|
||||
* @param string $ip Override the IP, should only be used for restore.
|
||||
* @param int $time Override the log time, should only be used for restore.
|
||||
*/
|
||||
public function legacy_add_to_log($courseid, $module, $action, $url, $info, $cm, $user, $ip = null, $time = null) {
|
||||
// Note that this function intentionally does not follow the normal Moodle DB access idioms.
|
||||
// This is for a good reason: it is the most frequently used DB update function,
|
||||
// so it has been optimised for speed.
|
||||
global $DB, $CFG, $USER;
|
||||
if (!$this->is_logging()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($cm === '' || is_null($cm)) { // Postgres won't translate empty string to its default.
|
||||
$cm = 0;
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$userid = $user;
|
||||
} else {
|
||||
if (\core\session\manager::is_loggedinas()) { // Don't log.
|
||||
return;
|
||||
}
|
||||
$userid = empty($USER->id) ? '0' : $USER->id;
|
||||
}
|
||||
|
||||
if (isset($CFG->logguests) and !$CFG->logguests) {
|
||||
if (!$userid or isguestuser($userid)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$remoteaddr = (is_null($ip)) ? getremoteaddr() : $ip;
|
||||
|
||||
$timenow = (is_null($time)) ? time() : $time;
|
||||
if (!empty($url)) { // Could break doing html_entity_decode on an empty var.
|
||||
$url = html_entity_decode($url, ENT_QUOTES, 'UTF-8');
|
||||
} else {
|
||||
$url = '';
|
||||
}
|
||||
|
||||
// Restrict length of log lines to the space actually available in the
|
||||
// database so that it doesn't cause a DB error. Log a warning so that
|
||||
// developers can avoid doing things which are likely to cause this on a
|
||||
// routine basis.
|
||||
if (\core_text::strlen($action) > 40) {
|
||||
$action = \core_text::substr($action, 0, 37) . '...';
|
||||
debugging('Warning: logged very long action', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
if (!empty($info) && \core_text::strlen($info) > 255) {
|
||||
$info = \core_text::substr($info, 0, 252) . '...';
|
||||
debugging('Warning: logged very long info', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
// If the 100 field size is changed, also need to alter print_log in course/lib.php.
|
||||
if (!empty($url) && \core_text::strlen($url) > 100) {
|
||||
$url = \core_text::substr($url, 0, 97) . '...';
|
||||
debugging('Warning: logged very long URL', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
if (defined('MDL_PERFDB')) {
|
||||
global $PERF;
|
||||
$PERF->logwrites++;
|
||||
};
|
||||
|
||||
$log = array('time' => $timenow, 'userid' => $userid, 'course' => $courseid, 'ip' => $remoteaddr,
|
||||
'module' => $module, 'cmid' => $cm, 'action' => $action, 'url' => $url, 'info' => $info);
|
||||
|
||||
try {
|
||||
$DB->insert_record_raw('log', $log, false);
|
||||
} catch (\dml_exception $e) {
|
||||
debugging('Error: Could not insert a new entry to the Moodle log. ' . $e->errorcode, DEBUG_ALL);
|
||||
|
||||
// MDL-11893, alert $CFG->supportemail if insert into log failed.
|
||||
if ($CFG->supportemail and empty($CFG->noemailever)) {
|
||||
// Function email_to_user is not usable because email_to_user tries to write to the logs table,
|
||||
// and this will get caught in an infinite loop, if disk is full.
|
||||
$site = get_site();
|
||||
$subject = 'Insert into log failed at your moodle site ' . $site->fullname;
|
||||
$message = "Insert into log table failed at " . date('l dS \of F Y h:i:s A') .
|
||||
".\n It is possible that your disk is full.\n\n";
|
||||
$message .= "The failed query parameters are:\n\n" . var_export($log, true);
|
||||
|
||||
$lasttime = get_config('admin', 'lastloginserterrormail');
|
||||
if (empty($lasttime) || time() - $lasttime > 60 * 60 * 24) { // Limit to 1 email per day.
|
||||
// Using email directly rather than messaging as they may not be able to log in to access a message.
|
||||
mail($CFG->supportemail, $subject, $message);
|
||||
set_config('lastloginserterrormail', time(), 'admin');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a replace string for crud related sql conditions. This function is called as callback to preg_replace_callback()
|
||||
* on the actual sql.
|
||||
*
|
||||
* @param array $match matched string for the passed pattern
|
||||
*
|
||||
* @return string The sql string to use instead of original
|
||||
*/
|
||||
protected static function replace_crud($match) {
|
||||
$return = '';
|
||||
unset($match[0]); // The first entry is the whole string.
|
||||
foreach ($match as $m) {
|
||||
// We hard code LIKE here because we are not worried about case sensitivity and want this to be fast.
|
||||
switch ($m) {
|
||||
case 'crud' :
|
||||
$replace = 'action';
|
||||
break;
|
||||
case 'c' :
|
||||
switch ($match[2]) {
|
||||
case '=' :
|
||||
$replace = " LIKE '%add%'";
|
||||
break;
|
||||
case '!=' :
|
||||
case '<>' :
|
||||
$replace = " NOT LIKE '%add%'";
|
||||
break;
|
||||
default:
|
||||
$replace = '';
|
||||
}
|
||||
break;
|
||||
case 'r' :
|
||||
switch ($match[2]) {
|
||||
case '=' :
|
||||
$replace = " LIKE '%view%' OR action LIKE '%report%'";
|
||||
break;
|
||||
case '!=' :
|
||||
case '<>' :
|
||||
$replace = " NOT LIKE '%view%' AND action NOT LIKE '%report%'";
|
||||
break;
|
||||
default:
|
||||
$replace = '';
|
||||
}
|
||||
break;
|
||||
case 'u' :
|
||||
switch ($match[2]) {
|
||||
case '=' :
|
||||
$replace = " LIKE '%update%'";
|
||||
break;
|
||||
case '!=' :
|
||||
case '<>' :
|
||||
$replace = " NOT LIKE '%update%'";
|
||||
break;
|
||||
default:
|
||||
$replace = '';
|
||||
}
|
||||
break;
|
||||
case 'd' :
|
||||
switch ($match[2]) {
|
||||
case '=' :
|
||||
$replace = " LIKE '%delete%'";
|
||||
break;
|
||||
case '!=' :
|
||||
case '<>' :
|
||||
$replace = " NOT LIKE '%delete%'";
|
||||
break;
|
||||
default:
|
||||
$replace = '';
|
||||
}
|
||||
break;
|
||||
default :
|
||||
$replace = '';
|
||||
}
|
||||
$return .= $replace;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Data provider.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2018 Frédéric Massart
|
||||
* @author Frédéric Massart <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace logstore_legacy\privacy;
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use context;
|
||||
use core_privacy\local\metadata\collection;
|
||||
use core_privacy\local\request\approved_contextlist;
|
||||
use core_privacy\local\request\contextlist;
|
||||
use core_privacy\local\request\transform;
|
||||
use core_privacy\local\request\writer;
|
||||
use tool_log\local\privacy\helper;
|
||||
|
||||
/**
|
||||
* Data provider class.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2018 Frédéric Massart
|
||||
* @author Frédéric Massart <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements
|
||||
\core_privacy\local\metadata\provider,
|
||||
\tool_log\local\privacy\logstore_provider,
|
||||
\tool_log\local\privacy\logstore_userlist_provider {
|
||||
|
||||
/**
|
||||
* Returns metadata.
|
||||
*
|
||||
* @param collection $collection The initialised collection to add items to.
|
||||
* @return collection A listing of user data stored through this system.
|
||||
*/
|
||||
public static function get_metadata(collection $collection) : collection {
|
||||
$collection->add_external_location_link('log', [
|
||||
'time' => 'privacy:metadata:log:time',
|
||||
'userid' => 'privacy:metadata:log:userid',
|
||||
'ip' => 'privacy:metadata:log:ip',
|
||||
'action' => 'privacy:metadata:log:action',
|
||||
'url' => 'privacy:metadata:log:url',
|
||||
'info' => 'privacy:metadata:log:info',
|
||||
], 'privacy:metadata:log');
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add contexts that contain user information for the specified user.
|
||||
*
|
||||
* @param contextlist $contextlist The contextlist to add the contexts to.
|
||||
* @param int $userid The user to find the contexts for.
|
||||
* @return void
|
||||
*/
|
||||
public static function add_contexts_for_userid(contextlist $contextlist, $userid) {
|
||||
$sql = "
|
||||
SELECT ctx.id
|
||||
FROM {context} ctx
|
||||
JOIN {log} l
|
||||
ON (l.cmid = 0 AND l.course = ctx.instanceid AND ctx.contextlevel = :courselevel)
|
||||
OR (l.cmid > 0 AND l.cmid = ctx.instanceid AND ctx.contextlevel = :modulelevel)
|
||||
OR (l.course <= 0 AND ctx.id = :syscontextid)
|
||||
WHERE l.userid = :userid";
|
||||
$params = [
|
||||
'courselevel' => CONTEXT_COURSE,
|
||||
'modulelevel' => CONTEXT_MODULE,
|
||||
'syscontextid' => SYSCONTEXTID,
|
||||
'userid' => $userid,
|
||||
];
|
||||
$contextlist->add_from_sql($sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add user IDs that contain user information for the specified context.
|
||||
*
|
||||
* @param \core_privacy\local\request\userlist $userlist The userlist to add the users to.
|
||||
* @return void
|
||||
*/
|
||||
public static function add_userids_for_context(\core_privacy\local\request\userlist $userlist) {
|
||||
$context = $userlist->get_context();
|
||||
list($insql, $params) = static::get_sql_where_from_contexts([$context]);
|
||||
|
||||
$sql = "SELECT l.userid
|
||||
FROM {log} l
|
||||
WHERE $insql";
|
||||
$userlist->add_from_sql('userid', $sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The approved contexts to export information for.
|
||||
*/
|
||||
public static function export_user_data(approved_contextlist $contextlist) {
|
||||
global $DB;
|
||||
|
||||
$userid = $contextlist->get_user()->id;
|
||||
list($insql, $inparams) = static::get_sql_where_from_contexts($contextlist->get_contexts());
|
||||
if (empty($insql)) {
|
||||
return;
|
||||
}
|
||||
$sql = "userid = :userid AND $insql";
|
||||
$params = array_merge($inparams, ['userid' => $userid]);
|
||||
|
||||
$path = [get_string('privacy:path:logs', 'tool_log'), get_string('pluginname', 'logstore_legacy')];
|
||||
$flush = function($lastcontextid, $data) use ($path) {
|
||||
$context = context::instance_by_id($lastcontextid);
|
||||
writer::with_context($context)->export_data($path, (object) ['logs' => $data]);
|
||||
};
|
||||
|
||||
$lastcontextid = null;
|
||||
$data = [];
|
||||
$recordset = $DB->get_recordset_select('log', $sql, $params, 'course, cmid, time, id');
|
||||
foreach ($recordset as $record) {
|
||||
$event = \logstore_legacy\event\legacy_logged::restore_legacy($record);
|
||||
$context = $event->get_context();
|
||||
if ($lastcontextid && $lastcontextid != $context->id) {
|
||||
$flush($lastcontextid, $data);
|
||||
$data = [];
|
||||
}
|
||||
|
||||
$extra = $event->get_logextra();
|
||||
$data[] = [
|
||||
'name' => $event->get_name(),
|
||||
'description' => $event->get_description(),
|
||||
'timecreated' => transform::datetime($event->timecreated),
|
||||
'ip' => $extra['ip'],
|
||||
'origin' => helper::transform_origin($extra['origin']),
|
||||
];
|
||||
|
||||
$lastcontextid = $context->id;
|
||||
}
|
||||
if ($lastcontextid) {
|
||||
$flush($lastcontextid, $data);
|
||||
}
|
||||
$recordset->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all data for all users in the specified context.
|
||||
*
|
||||
* @param context $context The specific context to delete data for.
|
||||
*/
|
||||
public static function delete_data_for_all_users_in_context(context $context) {
|
||||
global $DB;
|
||||
list($sql, $params) = static::get_sql_where_from_contexts([$context]);
|
||||
if (empty($sql)) {
|
||||
return;
|
||||
}
|
||||
$DB->delete_records_select('log', $sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all user data for the specified user, in the specified contexts.
|
||||
*
|
||||
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
|
||||
*/
|
||||
public static function delete_data_for_user(approved_contextlist $contextlist) {
|
||||
global $DB;
|
||||
list($sql, $params) = static::get_sql_where_from_contexts($contextlist->get_contexts());
|
||||
if (empty($sql)) {
|
||||
return;
|
||||
}
|
||||
$userid = $contextlist->get_user()->id;
|
||||
$DB->delete_records_select('log', "$sql AND userid = :userid", array_merge($params, ['userid' => $userid]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all data for a list of users in the specified context.
|
||||
*
|
||||
* @param \core_privacy\local\request\approved_userlist $userlist The specific context and users to delete data for.
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_data_for_userlist(\core_privacy\local\request\approved_userlist $userlist) {
|
||||
global $DB;
|
||||
list($sql, $params) = static::get_sql_where_from_contexts([$userlist->get_context()]);
|
||||
if (empty($sql)) {
|
||||
return;
|
||||
}
|
||||
list($usersql, $userparams) = $DB->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED);
|
||||
$params = array_merge($params, $userparams);
|
||||
$DB->delete_records_select('log', "$sql AND userid $usersql", $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an SQL where statement from a list of contexts.
|
||||
*
|
||||
* @param array $contexts The contexts.
|
||||
* @return array [$sql, $params]
|
||||
*/
|
||||
protected static function get_sql_where_from_contexts(array $contexts) {
|
||||
global $DB;
|
||||
|
||||
$sorted = array_reduce($contexts, function ($carry, $context) {
|
||||
$level = $context->contextlevel;
|
||||
if ($level == CONTEXT_MODULE || $level == CONTEXT_COURSE) {
|
||||
$carry[$level][] = $context->instanceid;
|
||||
} else if ($level == CONTEXT_SYSTEM) {
|
||||
$carry[$level] = $context->id;
|
||||
}
|
||||
return $carry;
|
||||
}, [
|
||||
CONTEXT_COURSE => [],
|
||||
CONTEXT_MODULE => [],
|
||||
CONTEXT_SYSTEM => null,
|
||||
]);
|
||||
|
||||
$sqls = [];
|
||||
$params = [];
|
||||
|
||||
if (!empty($sorted[CONTEXT_MODULE])) {
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($sorted[CONTEXT_MODULE], SQL_PARAMS_NAMED);
|
||||
$sqls[] = "cmid $insql";
|
||||
$params = array_merge($params, $inparams);
|
||||
}
|
||||
|
||||
if (!empty($sorted[CONTEXT_COURSE])) {
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($sorted[CONTEXT_COURSE], SQL_PARAMS_NAMED);
|
||||
|
||||
$sqls[] = "cmid = 0 AND course $insql";
|
||||
$params = array_merge($params, $inparams);
|
||||
}
|
||||
|
||||
if (!empty($sorted[CONTEXT_SYSTEM])) {
|
||||
$sqls[] = "course <= 0";
|
||||
}
|
||||
|
||||
if (empty($sqls)) {
|
||||
return [null, null];
|
||||
}
|
||||
|
||||
return ['((' . implode(') OR (', $sqls) . '))', $params];
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Legacy log reader.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2014 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace logstore_legacy\task;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class cleanup_task extends \core\task\scheduled_task {
|
||||
|
||||
/**
|
||||
* Get a descriptive name for this task (shown to admins).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('taskcleanup', 'logstore_legacy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the job.
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
*/
|
||||
public function execute() {
|
||||
global $CFG, $DB;
|
||||
|
||||
if (empty($CFG->loglifetime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$loglifetime = time() - ($CFG->loglifetime * 3600 * 24); // Value in days.
|
||||
$lifetimep = array($loglifetime);
|
||||
$start = time();
|
||||
|
||||
while ($min = $DB->get_field_select("log", "MIN(time)", "time < ?", $lifetimep)) {
|
||||
// Break this down into chunks to avoid transaction for too long and generally thrashing database.
|
||||
// Experiments suggest deleting one day takes up to a few seconds; probably a reasonable chunk size usually.
|
||||
// If the cleanup has just been enabled, it might take e.g a month to clean the years of logs.
|
||||
$params = array(min($min + 3600 * 24, $loglifetime));
|
||||
$DB->delete_records_select("log", "time < ?", $params);
|
||||
if (time() > $start + 300) {
|
||||
// Do not churn on log deletion for too long each run.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mtrace(" Deleted old legacy log records");
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Legacy log reader cron task.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2014 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => '\logstore_legacy\task\cleanup_task',
|
||||
'blocking' => 0,
|
||||
'minute' => 'R',
|
||||
'hour' => '5',
|
||||
'day' => '*',
|
||||
'dayofweek' => '*',
|
||||
'month' => '*'
|
||||
),
|
||||
);
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Legacy log reader lang strings.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['eventlegacylogged'] = 'Legacy event logged';
|
||||
$string['loglegacy'] = 'Log legacy data';
|
||||
$string['loglegacy_help'] = 'This plugin records log data to the legacy log table (mdl_log). This functionality has been replaced by newer, richer and more efficient logging plugins, so you should only run this plugin if you have old custom reports that directly query the old log table. Writing to the legacy logs will increase load, so it is recommended that you disable this plugin for performance reasons when it is not needed.';
|
||||
$string['pluginname'] = 'Legacy log';
|
||||
$string['pluginname_desc'] = 'A log plugin that stores log entries in the legacy log table.';
|
||||
$string['privacy:metadata:log'] = 'A collection of past events';
|
||||
$string['privacy:metadata:log:action'] = 'A description of the action';
|
||||
$string['privacy:metadata:log:info'] = 'Additional information';
|
||||
$string['privacy:metadata:log:ip'] = 'The IP address used at the time of the event';
|
||||
$string['privacy:metadata:log:time'] = 'The time when the action took place';
|
||||
$string['privacy:metadata:log:url'] = 'The URL related to the event';
|
||||
$string['privacy:metadata:log:userid'] = 'The ID of the user who performed the action';
|
||||
$string['taskcleanup'] = 'Legacy log table cleanup';
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Legacy logging settings.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2014 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($hassiteconfig) {
|
||||
$settings->add(new admin_setting_configcheckbox('logstore_legacy/loglegacy',
|
||||
new lang_string('loglegacy', 'logstore_legacy'),
|
||||
new lang_string('loglegacy_help', 'logstore_legacy'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('logguests',
|
||||
new lang_string('logguests', 'admin'),
|
||||
new lang_string('logguests_help', 'admin'), 1));
|
||||
|
||||
$options = array(0 => new lang_string('neverdeletelogs'),
|
||||
1000 => new lang_string('numdays', '', 1000),
|
||||
365 => new lang_string('numdays', '', 365),
|
||||
180 => new lang_string('numdays', '', 180),
|
||||
150 => new lang_string('numdays', '', 150),
|
||||
120 => new lang_string('numdays', '', 120),
|
||||
90 => new lang_string('numdays', '', 90),
|
||||
60 => new lang_string('numdays', '', 60),
|
||||
35 => new lang_string('numdays', '', 35),
|
||||
10 => new lang_string('numdays', '', 10),
|
||||
5 => new lang_string('numdays', '', 5),
|
||||
2 => new lang_string('numdays', '', 2));
|
||||
|
||||
$settings->add(new admin_setting_configselect('loglifetime',
|
||||
new lang_string('loglifetime', 'admin'),
|
||||
new lang_string('configloglifetime', 'admin'), 0, $options));
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Fixtures for legacy logging testing.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2014 Petr Skoda
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace logstore_legacy\event;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
class unittest_executed extends \core\event\base {
|
||||
public static function get_name() {
|
||||
return 'xxx';
|
||||
}
|
||||
|
||||
public function get_description() {
|
||||
return 'yyy';
|
||||
}
|
||||
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
}
|
||||
|
||||
public function get_url() {
|
||||
return new \moodle_url('/somepath/somefile.php', array('id' => $this->data['other']['sample']));
|
||||
}
|
||||
|
||||
public static function get_legacy_eventname() {
|
||||
return 'test_legacy';
|
||||
}
|
||||
|
||||
protected function get_legacy_eventdata() {
|
||||
return array($this->data['courseid'], $this->data['other']['sample']);
|
||||
}
|
||||
|
||||
protected function get_legacy_logdata() {
|
||||
$cmid = 0;
|
||||
if ($this->contextlevel == CONTEXT_MODULE) {
|
||||
$cmid = $this->contextinstanceid;
|
||||
}
|
||||
return array($this->data['courseid'], 'core_unittest', 'view',
|
||||
'unittest.php?id=' . $this->data['other']['sample'], 'bbb', $cmid);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Fixtures for legacy logging testing.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2014 onwards Ankit Agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace logstore_legacy\test;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
class unittest_logstore_legacy extends \logstore_legacy\log\store {
|
||||
|
||||
/**
|
||||
* Wrapper to make protected method accessible during testing.
|
||||
*
|
||||
* @param string $select sql predicate.
|
||||
* @param array $params sql params.
|
||||
* @param string $sort sort options.
|
||||
*
|
||||
* @return array returns array of sql predicate, params and sorting criteria.
|
||||
*/
|
||||
public static function replace_sql_legacy($select, array $params, $sort = '') {
|
||||
return parent::replace_sql_legacy($select, $params, $sort);
|
||||
}
|
||||
}
|
||||
@@ -1,472 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Data provider tests.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @category test
|
||||
* @copyright 2018 Frédéric Massart
|
||||
* @author Frédéric Massart <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace logstore_legacy\privacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
global $CFG;
|
||||
|
||||
use core_privacy\tests\provider_testcase;
|
||||
use core_privacy\local\request\contextlist;
|
||||
use core_privacy\local\request\approved_contextlist;
|
||||
use core_privacy\local\request\transform;
|
||||
use core_privacy\local\request\writer;
|
||||
use logstore_legacy\privacy\provider;
|
||||
use logstore_legacy\event\unittest_executed;
|
||||
|
||||
require_once(__DIR__ . '/../fixtures/event.php');
|
||||
|
||||
/**
|
||||
* Data provider testcase class.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @category test
|
||||
* @copyright 2018 Frédéric Massart
|
||||
* @author Frédéric Massart <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider_test extends provider_testcase {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest();
|
||||
}
|
||||
|
||||
public function test_get_contexts_for_userid() {
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$u2 = $this->getDataGenerator()->create_user();
|
||||
$u3 = $this->getDataGenerator()->create_user();
|
||||
$c1 = $this->getDataGenerator()->create_course();
|
||||
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
|
||||
$sysctx = \context_system::instance();
|
||||
$c1ctx = \context_course::instance($c1->id);
|
||||
$cm1ctx = \context_module::instance($cm1->cmid);
|
||||
|
||||
$this->enable_logging();
|
||||
$manager = get_log_manager(true);
|
||||
|
||||
// User 1 is the author.
|
||||
$this->setUser($u1);
|
||||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u1), []);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 1]]);
|
||||
$e->trigger();
|
||||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u1), [$cm1ctx]);
|
||||
|
||||
// User 2 is the author.
|
||||
$this->setUser($u2);
|
||||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u2), []);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 2]]);
|
||||
$e->trigger();
|
||||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u2), [$cm1ctx]);
|
||||
|
||||
// User 3 is the author.
|
||||
$this->setUser($u3);
|
||||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u3), []);
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 3]]);
|
||||
$e->trigger();
|
||||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u3), [$sysctx]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test returning user IDs for a given context.
|
||||
*/
|
||||
public function test_add_userids_for_context() {
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$u2 = $this->getDataGenerator()->create_user();
|
||||
$u3 = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$module = $this->getDataGenerator()->create_module('url', ['course' => $course]);
|
||||
$sysctx = \context_system::instance();
|
||||
$c1ctx = \context_course::instance($course->id);
|
||||
$cm1ctx = \context_module::instance($module->cmid);
|
||||
|
||||
$userctx = \context_user::instance($u1->id);
|
||||
|
||||
$this->enable_logging();
|
||||
$manager = get_log_manager(true);
|
||||
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 1]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 2]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 3]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u3);
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 4]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 5]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 6]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 7]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u3);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 8]]);
|
||||
$e->trigger();
|
||||
|
||||
// Start with system and check that each of the contexts returns what we expected.
|
||||
$userlist = new \core_privacy\local\request\userlist($sysctx, 'logstore_legacy');
|
||||
provider::add_userids_for_context($userlist);
|
||||
$systemuserids = $userlist->get_userids();
|
||||
$this->assertCount(2, $systemuserids);
|
||||
$this->assertNotFalse(array_search($u1->id, $systemuserids));
|
||||
$this->assertNotFalse(array_search($u2->id, $systemuserids));
|
||||
// Check the course context.
|
||||
$userlist = new \core_privacy\local\request\userlist($c1ctx, 'logstore_legacy');
|
||||
provider::add_userids_for_context($userlist);
|
||||
$courseuserids = $userlist->get_userids();
|
||||
$this->assertCount(2, $courseuserids);
|
||||
$this->assertNotFalse(array_search($u1->id, $courseuserids));
|
||||
$this->assertNotFalse(array_search($u3->id, $courseuserids));
|
||||
// Check the module context.
|
||||
$userlist = new \core_privacy\local\request\userlist($cm1ctx, 'logstore_legacy');
|
||||
provider::add_userids_for_context($userlist);
|
||||
$moduleuserids = $userlist->get_userids();
|
||||
$this->assertCount(3, $moduleuserids);
|
||||
$this->assertNotFalse(array_search($u1->id, $moduleuserids));
|
||||
$this->assertNotFalse(array_search($u2->id, $moduleuserids));
|
||||
$this->assertNotFalse(array_search($u3->id, $moduleuserids));
|
||||
}
|
||||
|
||||
public function test_delete_data_for_user() {
|
||||
global $DB;
|
||||
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$u2 = $this->getDataGenerator()->create_user();
|
||||
$u3 = $this->getDataGenerator()->create_user();
|
||||
$c1 = $this->getDataGenerator()->create_course();
|
||||
$c2 = $this->getDataGenerator()->create_course();
|
||||
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
|
||||
$sysctx = \context_system::instance();
|
||||
$c1ctx = \context_course::instance($c1->id);
|
||||
$c2ctx = \context_course::instance($c2->id);
|
||||
$cm1ctx = \context_module::instance($cm1->cmid);
|
||||
|
||||
$this->enable_logging();
|
||||
$manager = get_log_manager(true);
|
||||
|
||||
// User 1 is the author.
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 1]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 2]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 3]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 4]]);
|
||||
$e->trigger();
|
||||
|
||||
// User 2 is the author.
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 5]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 6]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 7]]);
|
||||
$e->trigger();
|
||||
|
||||
// Assert what we have.
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(4, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete other context.
|
||||
provider::delete_data_for_user(new approved_contextlist($u1, 'logstore_legacy', [$c2ctx->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(4, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete system.
|
||||
provider::delete_data_for_user(new approved_contextlist($u1, 'logstore_legacy', [$sysctx->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete course.
|
||||
provider::delete_data_for_user(new approved_contextlist($u1, 'logstore_legacy', [$c1ctx->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(2, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete course.
|
||||
provider::delete_data_for_user(new approved_contextlist($u1, 'logstore_legacy', [$cm1ctx->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['userid' => $u1->id, 'cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(0, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
}
|
||||
|
||||
public function test_delete_data_for_all_users_in_context() {
|
||||
global $DB;
|
||||
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$u2 = $this->getDataGenerator()->create_user();
|
||||
$u3 = $this->getDataGenerator()->create_user();
|
||||
$c1 = $this->getDataGenerator()->create_course();
|
||||
$c2 = $this->getDataGenerator()->create_course();
|
||||
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
|
||||
$sysctx = \context_system::instance();
|
||||
$c1ctx = \context_course::instance($c1->id);
|
||||
$c2ctx = \context_course::instance($c2->id);
|
||||
$cm1ctx = \context_module::instance($cm1->cmid);
|
||||
|
||||
$this->enable_logging();
|
||||
$manager = get_log_manager(true);
|
||||
|
||||
// User 1 is the author.
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 1]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 2]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 3]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 4]]);
|
||||
$e->trigger();
|
||||
|
||||
// User 2 is the author.
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 5]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 6]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 7]]);
|
||||
$e->trigger();
|
||||
|
||||
// Assert what we have.
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(4, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete other context.
|
||||
provider::delete_data_for_all_users_in_context($c2ctx);
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(4, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete system.
|
||||
provider::delete_data_for_all_users_in_context($sysctx);
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(3, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(2, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete course.
|
||||
provider::delete_data_for_all_users_in_context($c1ctx);
|
||||
$this->assertTrue($DB->record_exists('log', ['cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(2, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(1, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
|
||||
// Delete course.
|
||||
provider::delete_data_for_all_users_in_context($cm1ctx);
|
||||
$this->assertFalse($DB->record_exists('log', ['cmid' => $cm1->cmid, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['cmid' => 0, 'course' => $c1->id]));
|
||||
$this->assertFalse($DB->record_exists('log', ['cmid' => 0, 'course' => 0]));
|
||||
$this->assertEquals(0, $DB->count_records('log', ['userid' => $u1->id]));
|
||||
$this->assertEquals(0, $DB->count_records('log', ['userid' => $u2->id]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the deletion of data for a list of users in a context.
|
||||
*/
|
||||
public function test_delete_data_for_userlist() {
|
||||
global $DB;
|
||||
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$u2 = $this->getDataGenerator()->create_user();
|
||||
$u3 = $this->getDataGenerator()->create_user();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$module = $this->getDataGenerator()->create_module('url', ['course' => $course]);
|
||||
$sysctx = \context_system::instance();
|
||||
$c1ctx = \context_course::instance($course->id);
|
||||
$cm1ctx = \context_module::instance($module->cmid);
|
||||
|
||||
$userctx = \context_user::instance($u1->id);
|
||||
|
||||
$this->enable_logging();
|
||||
$manager = get_log_manager(true);
|
||||
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 1]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 2]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 3]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u3);
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 4]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 5]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 6]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 7]]);
|
||||
$e->trigger();
|
||||
$this->setUser($u3);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 8]]);
|
||||
$e->trigger();
|
||||
|
||||
// System context deleting one user.
|
||||
$this->assertEquals(3, $DB->count_records('log', ['cmid' => 0, 'course' => 0]));
|
||||
$userlist = new \core_privacy\local\request\approved_userlist($sysctx, 'logstore_legacy', [$u2->id]);
|
||||
provider::delete_data_for_userlist($userlist);
|
||||
$this->assertEquals(1, $DB->count_records('log', ['cmid' => 0, 'course' => 0]));
|
||||
|
||||
// Course context deleting one user.
|
||||
$this->assertEquals(2, $DB->count_records('log', ['cmid' => 0, 'course' => $course->id]));
|
||||
$userlist = new \core_privacy\local\request\approved_userlist($c1ctx, 'logstore_legacy', [$u1->id]);
|
||||
provider::delete_data_for_userlist($userlist);
|
||||
$this->assertEquals(1, $DB->count_records('log', ['cmid' => 0, 'course' => $course->id]));
|
||||
|
||||
// Module context deleting two users.
|
||||
$this->assertEquals(3, $DB->count_records('log', ['cmid' => $module->cmid, 'course' => $course->id]));
|
||||
$userlist = new \core_privacy\local\request\approved_userlist($cm1ctx, 'logstore_legacy', [$u1->id, $u3->id]);
|
||||
provider::delete_data_for_userlist($userlist);
|
||||
$this->assertEquals(1, $DB->count_records('log', ['cmid' => $module->cmid, 'course' => $course->id]));
|
||||
}
|
||||
|
||||
public function test_export_data_for_user() {
|
||||
global $DB;
|
||||
|
||||
$u1 = $this->getDataGenerator()->create_user();
|
||||
$u2 = $this->getDataGenerator()->create_user();
|
||||
$u3 = $this->getDataGenerator()->create_user();
|
||||
$c1 = $this->getDataGenerator()->create_course();
|
||||
$c2 = $this->getDataGenerator()->create_course();
|
||||
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
|
||||
$sysctx = \context_system::instance();
|
||||
$c1ctx = \context_course::instance($c1->id);
|
||||
$c2ctx = \context_course::instance($c2->id);
|
||||
$cm1ctx = \context_module::instance($cm1->cmid);
|
||||
|
||||
$this->enable_logging();
|
||||
$manager = get_log_manager(true);
|
||||
$path = [get_string('privacy:path:logs', 'tool_log'), get_string('pluginname', 'logstore_legacy')];
|
||||
|
||||
// User 1 is the author.
|
||||
$this->setUser($u1);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 1]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 2]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 3]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 4]]);
|
||||
$e->trigger();
|
||||
|
||||
// User 2 is the author.
|
||||
$this->setUser($u2);
|
||||
$e = unittest_executed::create(['context' => $cm1ctx, 'other' => ['sample' => 5]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $c1ctx, 'other' => ['sample' => 6]]);
|
||||
$e->trigger();
|
||||
$e = unittest_executed::create(['context' => $sysctx, 'other' => ['sample' => 7]]);
|
||||
$e->trigger();
|
||||
|
||||
// Test export.
|
||||
provider::export_user_data(new approved_contextlist($u1, 'logstore_legacy', [$cm1ctx->id]));
|
||||
$data = writer::with_context($c1ctx)->get_data($path);
|
||||
$this->assertEmpty($data);
|
||||
$data = writer::with_context($cm1ctx)->get_data($path);
|
||||
$this->assertCount(2, $data->logs);
|
||||
|
||||
writer::reset();
|
||||
provider::export_user_data(new approved_contextlist($u1, 'logstore_legacy', [$c1ctx->id]));
|
||||
$data = writer::with_context($cm1ctx)->get_data($path);
|
||||
$this->assertEmpty($data);
|
||||
$data = writer::with_context($c1ctx)->get_data($path);
|
||||
$this->assertCount(1, $data->logs);
|
||||
|
||||
writer::reset();
|
||||
provider::export_user_data(new approved_contextlist($u1, 'logstore_legacy', [$sysctx->id]));
|
||||
$data = writer::with_context($sysctx)->get_data($path);
|
||||
$this->assertCount(1, $data->logs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the content of a context list.
|
||||
*
|
||||
* @param contextlist $contextlist The collection.
|
||||
* @param array $expected List of expected contexts or IDs.
|
||||
* @return void
|
||||
*/
|
||||
protected function assert_contextlist_equals($contextlist, array $expected) {
|
||||
$expectedids = array_map(function($context) {
|
||||
if (is_object($context)) {
|
||||
return $context->id;
|
||||
}
|
||||
return $context;
|
||||
}, $expected);
|
||||
$contextids = array_map('intval', $contextlist->get_contextids());
|
||||
sort($contextids);
|
||||
sort($expectedids);
|
||||
$this->assertEquals($expectedids, $contextids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable logging.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function enable_logging() {
|
||||
set_config('enabled_stores', 'logstore_legacy', 'tool_log');
|
||||
set_config('loglegacy', 1, 'logstore_legacy');
|
||||
get_log_manager(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the contextlist for a user.
|
||||
*
|
||||
* @param object $user The user.
|
||||
* @return contextlist
|
||||
*/
|
||||
protected function get_contextlist_for_user($user) {
|
||||
$contextlist = new contextlist();
|
||||
provider::add_contexts_for_userid($contextlist, $user->id);
|
||||
return $contextlist;
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace logstore_legacy;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(__DIR__ . '/fixtures/event.php');
|
||||
require_once(__DIR__ . '/fixtures/store.php');
|
||||
|
||||
/**
|
||||
* Legacy log store tests.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2014 Petr Skoda {@link http://skodak.org/}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class store_test extends \advanced_testcase {
|
||||
public function test_log_writing() {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
$user1 = $this->getDataGenerator()->create_user();
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$module1 = $this->getDataGenerator()->create_module('resource', array('course' => $course1));
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
|
||||
// Enable legacy logging plugin.
|
||||
set_config('enabled_stores', 'logstore_legacy', 'tool_log');
|
||||
set_config('loglegacy', 1, 'logstore_legacy');
|
||||
$manager = get_log_manager(true);
|
||||
|
||||
$stores = $manager->get_readers();
|
||||
$this->assertCount(1, $stores);
|
||||
$this->assertEquals(array('logstore_legacy'), array_keys($stores));
|
||||
$store = $stores['logstore_legacy'];
|
||||
$this->assertInstanceOf('logstore_legacy\log\store', $store);
|
||||
$this->assertInstanceOf('core\log\sql_reader', $store);
|
||||
$this->assertTrue($store->is_logging());
|
||||
|
||||
$logs = $DB->get_records('log', array(), 'id ASC');
|
||||
$this->assertCount(0, $logs);
|
||||
|
||||
$this->setCurrentTimeStart();
|
||||
|
||||
$this->setUser(0);
|
||||
$event1 = \logstore_legacy\event\unittest_executed::create(
|
||||
array('context' => \context_module::instance($module1->cmid), 'other' => array('sample' => 5, 'xx' => 10)));
|
||||
$event1->trigger();
|
||||
|
||||
$this->setUser($user1);
|
||||
$event2 = \logstore_legacy\event\unittest_executed::create(
|
||||
array('context' => \context_course::instance($course2->id), 'other' => array('sample' => 6, 'xx' => 11)));
|
||||
$event2->trigger();
|
||||
|
||||
$logs = $DB->get_records('log', array(), 'id ASC');
|
||||
$this->assertCount(2, $logs);
|
||||
|
||||
$log = array_shift($logs);
|
||||
$this->assertNotEmpty($log->id);
|
||||
$this->assertTimeCurrent($log->time);
|
||||
$this->assertEquals(0, $log->userid);
|
||||
$this->assertSame('0.0.0.0', $log->ip);
|
||||
$this->assertEquals($course1->id, $log->course);
|
||||
$this->assertSame('core_unittest', $log->module);
|
||||
$this->assertEquals($module1->cmid, $log->cmid);
|
||||
$this->assertSame('view', $log->action);
|
||||
$this->assertSame('unittest.php?id=5', $log->url);
|
||||
$this->assertSame('bbb', $log->info);
|
||||
|
||||
$oldlogid = $log->id;
|
||||
$log = array_shift($logs);
|
||||
$this->assertGreaterThan($oldlogid, $log->id);
|
||||
$this->assertNotEmpty($log->id);
|
||||
$this->assertTimeCurrent($log->time);
|
||||
$this->assertEquals($user1->id, $log->userid);
|
||||
$this->assertSame('0.0.0.0', $log->ip);
|
||||
$this->assertEquals($course2->id, $log->course);
|
||||
$this->assertSame('core_unittest', $log->module);
|
||||
$this->assertEquals(0, $log->cmid);
|
||||
$this->assertSame('view', $log->action);
|
||||
$this->assertSame('unittest.php?id=6', $log->url);
|
||||
$this->assertSame('bbb', $log->info);
|
||||
|
||||
// Test if disabling works.
|
||||
set_config('enabled_stores', 'logstore_legacy', 'tool_log');
|
||||
set_config('loglegacy', 0, 'logstore_legacy');
|
||||
$manager = get_log_manager(true);
|
||||
$stores = $manager->get_readers();
|
||||
$store = $stores['logstore_legacy'];
|
||||
$this->assertFalse($store->is_logging());
|
||||
|
||||
\logstore_legacy\event\unittest_executed::create(
|
||||
array('context' => \context_system::instance(), 'other' => array('sample' => 5, 'xx' => 10)))->trigger();
|
||||
$this->assertEquals(2, $DB->count_records('log'));
|
||||
|
||||
// Another way to disable legacy completely.
|
||||
set_config('enabled_stores', 'logstore_standard', 'tool_log');
|
||||
set_config('loglegacy', 1, 'logstore_legacy');
|
||||
get_log_manager(true);
|
||||
|
||||
\logstore_legacy\event\unittest_executed::create(
|
||||
array('context' => \context_system::instance(), 'other' => array('sample' => 5, 'xx' => 10)))->trigger();
|
||||
$this->assertEquals(2, $DB->count_records('log'));
|
||||
// Set everything back.
|
||||
set_config('enabled_stores', '', 'tool_log');
|
||||
set_config('loglegacy', 0, 'logstore_legacy');
|
||||
get_log_manager(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test replace_sql_legacy()
|
||||
*/
|
||||
public function test_replace_sql_legacy() {
|
||||
$selectwhere = "userid = :userid AND courseid = :courseid AND eventname = :eventname AND timecreated > :since";
|
||||
$params = array('userid' => 2, 'since' => 3, 'courseid' => 4, 'eventname' => '\core\event\course_created');
|
||||
$expectedselect = "module = 'course' AND action = 'new' AND userid = :userid AND url = :url AND time > :since";
|
||||
$expectedparams = $params + array('url' => "view.php?id=4");
|
||||
|
||||
list($replaceselect, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals($replaceselect, $expectedselect);
|
||||
$this->assertEquals($replaceparams, $expectedparams);
|
||||
|
||||
// Test CRUD related changes.
|
||||
$selectwhere = "edulevel = 0";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals($selectwhere, $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud = 'u'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action LIKE '%update%'", $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud != 'u'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action NOT LIKE '%update%'", $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud <> 'u'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action NOT LIKE '%update%'", $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud = 'r'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action LIKE '%view%' OR action LIKE '%report%'", $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud != 'r'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action NOT LIKE '%view%' AND action NOT LIKE '%report%'", $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud <> 'r'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action NOT LIKE '%view%' AND action NOT LIKE '%report%'", $updatewhere);
|
||||
|
||||
// The slq is incorrect, since quotes must not be present. Make sure this is not parsed.
|
||||
$selectwhere = "edulevel = 0 and 'crud' != 'u'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertNotEquals("edulevel = 0 and action NOT LIKE '%update%'", $updatewhere);
|
||||
|
||||
$selectwhere = "edulevel = 0 and crud = 'u' OR crud != 'r' or crud <> 'd'";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("edulevel = 0 and action LIKE '%update%' OR action NOT LIKE '%view%' AND action NOT LIKE '%report%' or action NOT LIKE '%delete%'", $updatewhere);
|
||||
|
||||
// The anonymous select returns all data.
|
||||
$selectwhere = "anonymous = 0";
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertSame("0 = 0", $updatewhere);
|
||||
|
||||
// Test legacy field names are mapped.
|
||||
$selectwhere = "timecreated = :timecreated and courseid = :courseid and contextinstanceid = :contextinstanceid and origin = :origin";
|
||||
$params = array('timecreated' => 2, 'courseid' => 3, 'contextinstanceid' => 4, 'origin' => 5 );
|
||||
$expectedparams = array('time' => 2, 'course' => 3, 'cmid' => 4, 'ip' => 5);
|
||||
list($updatewhere, $replaceparams) = \logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params);
|
||||
$this->assertEquals("time = :time and course = :course and cmid = :cmid and ip = :ip", $updatewhere);
|
||||
$this->assertSame($expectedparams, $replaceparams);
|
||||
|
||||
// Test sorting parameters.
|
||||
$selectwhere = "courseid = 3";
|
||||
$params = array();
|
||||
$sort = 'timecreated DESC';
|
||||
list($updatewhere, $replaceparams, $sort) =
|
||||
\logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
$this->assertSame('time DESC', $sort);
|
||||
|
||||
$sort = 'courseid DESC';
|
||||
list($updatewhere, $replaceparams, $sort) =
|
||||
\logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
$this->assertSame('course DESC', $sort);
|
||||
|
||||
$sort = 'contextinstanceid DESC';
|
||||
list($updatewhere, $replaceparams, $sort) =
|
||||
\logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
$this->assertSame('cmid DESC', $sort);
|
||||
|
||||
$sort = 'origin DESC';
|
||||
list($updatewhere, $replaceparams, $sort) =
|
||||
\logstore_legacy\test\unittest_logstore_legacy::replace_sql_legacy($selectwhere, $params, $sort);
|
||||
$this->assertSame('ip DESC', $sort);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test logmanager::get_supported_reports returns all reports that require this store.
|
||||
*/
|
||||
public function test_get_supported_reports() {
|
||||
$logmanager = get_log_manager();
|
||||
$allreports = \core_component::get_plugin_list('report');
|
||||
|
||||
// Make sure all supported reports are installed.
|
||||
$expectedreports = array_intersect_key([
|
||||
'log' => 'report_log',
|
||||
'loglive' => 'report_loglive',
|
||||
'outline' => 'report_outline',
|
||||
'participation' => 'report_participation',
|
||||
'stats' => 'report_stats'
|
||||
], $allreports);
|
||||
|
||||
$supportedreports = $logmanager->get_supported_reports('logstore_legacy');
|
||||
|
||||
foreach ($expectedreports as $expectedreport) {
|
||||
$this->assertArrayHasKey($expectedreport, $supportedreports);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the legacy log cleanup works correctly.
|
||||
*/
|
||||
public function test_cleanup_task() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Create some records spread over various days; test multiple iterations in cleanup.
|
||||
$record = (object) array('time' => time());
|
||||
$DB->insert_record('log', $record);
|
||||
$record->time -= 3600 * 24 * 30;
|
||||
$DB->insert_record('log', $record);
|
||||
$record->time -= 3600 * 24 * 30;
|
||||
$DB->insert_record('log', $record);
|
||||
$record->time -= 3600 * 24 * 30;
|
||||
$DB->insert_record('log', $record);
|
||||
$this->assertEquals(4, $DB->count_records('log'));
|
||||
|
||||
// Remove all logs before "today".
|
||||
set_config('loglifetime', 1);
|
||||
|
||||
$this->expectOutputString(" Deleted old legacy log records\n");
|
||||
$clean = new \logstore_legacy\task\cleanup_task();
|
||||
$clean->execute();
|
||||
|
||||
$this->assertEquals(1, $DB->count_records('log'));
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Legacy log reader.
|
||||
*
|
||||
* @package logstore_legacy
|
||||
* @copyright 2013 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2022112800; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2022111800; // Requires this Moodle version.
|
||||
$plugin->component = 'logstore_legacy'; // Full name of the plugin (used for diagnostics).
|
||||
@@ -36,15 +36,14 @@ class manager_test extends \advanced_testcase {
|
||||
$this->assertCount(0, $stores);
|
||||
|
||||
$this->assertFileExists("$CFG->dirroot/$CFG->admin/tool/log/store/standard/version.php");
|
||||
$this->assertFileExists("$CFG->dirroot/$CFG->admin/tool/log/store/legacy/version.php");
|
||||
|
||||
set_config('enabled_stores', 'logstore_standard,logstore_legacy', 'tool_log');
|
||||
set_config('enabled_stores', 'logstore_standard', 'tool_log');
|
||||
$manager = get_log_manager(true);
|
||||
$this->assertInstanceOf('core\log\manager', $manager);
|
||||
|
||||
$stores = $manager->get_readers();
|
||||
$this->assertIsArray($stores);
|
||||
$this->assertCount(2, $stores);
|
||||
$this->assertCount(1, $stores);
|
||||
foreach ($stores as $key => $store) {
|
||||
$this->assertIsString($key);
|
||||
$this->assertInstanceOf('core\log\sql_reader', $store);
|
||||
@@ -61,7 +60,7 @@ class manager_test extends \advanced_testcase {
|
||||
|
||||
$stores = $manager->get_readers('core\log\sql_reader');
|
||||
$this->assertIsArray($stores);
|
||||
$this->assertCount(2, $stores);
|
||||
$this->assertCount(1, $stores);
|
||||
foreach ($stores as $key => $store) {
|
||||
$this->assertIsString($key);
|
||||
$this->assertInstanceOf('core\log\sql_reader', $store);
|
||||
|
||||
@@ -379,9 +379,6 @@ class plugin_test extends \advanced_testcase {
|
||||
$this->assertEquals('user', $event->objecttable);
|
||||
$this->assertEquals('2', $event->objectid);
|
||||
$this->assertEquals(\context_system::instance()->id, $event->contextid);
|
||||
$expectedlog = array(SITEID, 'user', 'login', 'view.php?id=' . $USER->id . '&course=' . SITEID, $user->id,
|
||||
0, $user->id);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,10 +505,7 @@ class plugin_test extends \advanced_testcase {
|
||||
$event = array_pop($events);
|
||||
$this->assertInstanceOf('\core\event\user_created', $event);
|
||||
$this->assertEquals($user['id'], $event->objectid);
|
||||
$this->assertEquals('user_created', $event->get_legacy_eventname());
|
||||
$this->assertEquals(\context_user::instance($user['id']), $event->get_context());
|
||||
$expectedlogdata = array(SITEID, 'user', 'add', '/view.php?id='.$event->objectid, fullname($dbuser));
|
||||
$this->assertEventLegacyLogData($expectedlogdata, $event);
|
||||
|
||||
// First event is user_password_updated.
|
||||
$event = array_pop($events);
|
||||
|
||||
@@ -137,10 +137,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals($USER->id, $event->userid);
|
||||
$this->assertEquals($this->userid, $event->relateduserid);
|
||||
$this->assertEquals("post", $event->objecttable);
|
||||
$arr = array(SITEID, 'blog', 'add', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id, $blog->subject);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEquals("blog_entry_added", $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($blog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -172,10 +168,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals($USER->id, $event->userid);
|
||||
$this->assertEquals($this->userid, $event->relateduserid);
|
||||
$this->assertEquals("post", $event->objecttable);
|
||||
$this->assertEquals("blog_entry_edited", $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($blog, $event);
|
||||
$arr = array (SITEID, 'blog', 'update', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id, $blog->subject);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -207,11 +199,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals($this->userid, $event->relateduserid);
|
||||
$this->assertEquals("post", $event->objecttable);
|
||||
$this->assertEquals($record, $event->get_record_snapshot("post", $blog->id));
|
||||
$this->assertSame('blog_entry_deleted', $event->get_legacy_eventname());
|
||||
$arr = array(SITEID, 'blog', 'delete', 'index.php?userid=' . $blog->userid, 'deleted blog entry with entry id# ' .
|
||||
$blog->id);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEventLegacyData($blog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -292,9 +279,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals($USER->id, $event->userid);
|
||||
$this->assertEquals($this->userid, $event->relateduserid);
|
||||
$this->assertEquals('blog_association', $event->objecttable);
|
||||
$arr = array(SITEID, 'blog', 'add association', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id,
|
||||
$blog->subject, 0, $this->userid);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
|
||||
// Add blog associations with a module.
|
||||
$blog = new \blog_entry($this->postid);
|
||||
@@ -308,9 +292,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals($blog->id, $event->other['blogid']);
|
||||
$this->assertEquals($this->cmid, $event->other['associateid']);
|
||||
$this->assertEquals('coursemodule', $event->other['associatetype']);
|
||||
$arr = array(SITEID, 'blog', 'add association', 'index.php?userid=' . $this->userid . '&entryid=' . $blog->id,
|
||||
$blog->subject, $this->cmid, $this->userid);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -393,10 +374,7 @@ class events_test extends \advanced_testcase {
|
||||
|
||||
// Validate event data.
|
||||
$url = new \moodle_url('/blog/index.php', $other);
|
||||
$url2 = new \moodle_url('index.php', $other);
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$arr = array(SITEID, 'blog', 'view', $url2->out(), 'view blog entry');
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,10 +87,8 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals('event', $event->objecttable);
|
||||
$this->assertEquals(0, $event->courseid);
|
||||
$this->assertEquals($calevent->context, $event->get_context());
|
||||
$expectedlog = array(0, 'calendar', 'add', 'event.php?action=edit&id=' . $calevent->id , $calevent->name);
|
||||
$other = array('repeatid' => 0, 'timestart' => $time, 'name' => 'event');
|
||||
$this->assertEquals($other, $event->other);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
// Now we create a repeated course event.
|
||||
@@ -194,8 +192,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals('event', $event->objecttable);
|
||||
$this->assertEquals(0, $event->courseid);
|
||||
$this->assertEquals($calevent->context, $event->get_context());
|
||||
$expectedlog = array(0, 'calendar', 'edit', 'event.php?action=edit&id=' . $calevent->id , $calevent->name);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
$other = array('repeatid' => 0, 'timestart' => $time, 'name' => 'new event');
|
||||
$this->assertEquals($other, $event->other);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
@@ -249,8 +245,6 @@ class events_test extends \advanced_testcase {
|
||||
$this->assertEquals('event', $event->objecttable);
|
||||
$this->assertEquals($siteid, $event->courseid);
|
||||
$this->assertEquals($calevent->context, $event->get_context());
|
||||
$expectedlog = [$siteid, 'calendar', 'edit', 'event.php?action=edit&id=' . $calevent->id , $calevent->name];
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
$other = array('repeatid' => 0, 'timestart' => $time, 'name' => 'Some wickedly awesome event yo!');
|
||||
$this->assertEquals($other, $event->other);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
@@ -102,7 +102,6 @@ class lib_test extends \advanced_testcase {
|
||||
$url = new \moodle_url('/cohort/index.php', array('contextid' => $event->contextid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEquals($cohort, $event->get_record_snapshot('cohort', $id));
|
||||
$this->assertEventLegacyData($cohort, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -179,7 +178,6 @@ class lib_test extends \advanced_testcase {
|
||||
$url = new \moodle_url('/cohort/edit.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEquals($cohort, $event->get_record_snapshot('cohort', $id));
|
||||
$this->assertEventLegacyData($cohort, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -219,7 +217,6 @@ class lib_test extends \advanced_testcase {
|
||||
$url = new \moodle_url('/cohort/index.php', array('contextid' => $event->contextid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEquals($cohort, $event->get_record_snapshot('cohort', $cohort->id));
|
||||
$this->assertEventLegacyData($cohort, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -279,7 +276,6 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertEquals($USER->id, $event->userid);
|
||||
$url = new \moodle_url('/cohort/assign.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEventLegacyData((object) array('cohortid' => $cohort->id, 'userid' => $user->id), $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -325,7 +321,6 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertEquals($USER->id, $event->userid);
|
||||
$url = new \moodle_url('/cohort/assign.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEventLegacyData((object) array('cohortid' => $cohort->id, 'userid' => $user->id), $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
|
||||
@@ -2179,8 +2179,6 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
'objectid' => $childcat->id,
|
||||
'context' => $childcat->get_context()
|
||||
));
|
||||
$event->set_legacy_logdata(array(SITEID, 'category', 'move', 'editcategory.php?id=' . $childcat->id,
|
||||
$childcat->id));
|
||||
$event->trigger();
|
||||
}
|
||||
fix_course_sortorder();
|
||||
@@ -2371,7 +2369,6 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
'objectid' => $this->id,
|
||||
'context' => $this->get_context()
|
||||
));
|
||||
$event->set_legacy_logdata(array(SITEID, 'category', 'move', 'editcategory.php?id=' . $this->id, $this->id));
|
||||
$event->trigger();
|
||||
}
|
||||
}
|
||||
@@ -2443,7 +2440,6 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
'objectid' => $this->id,
|
||||
'context' => $this->get_context()
|
||||
));
|
||||
$event->set_legacy_logdata(array(SITEID, 'category', 'hide', 'editcategory.php?id=' . $this->id, $this->id));
|
||||
$event->trigger();
|
||||
}
|
||||
}
|
||||
@@ -2502,7 +2498,6 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
'objectid' => $this->id,
|
||||
'context' => $this->get_context()
|
||||
));
|
||||
$event->set_legacy_logdata(array(SITEID, 'category', 'show', 'editcategory.php?id=' . $this->id, $this->id));
|
||||
$event->trigger();
|
||||
}
|
||||
}
|
||||
@@ -3066,8 +3061,6 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
'objectid' => $this->id,
|
||||
'context' => $this->get_context()
|
||||
));
|
||||
$event->set_legacy_logdata(array(SITEID, 'category', 'move', 'management.php?categoryid=' . $this->id,
|
||||
$this->id));
|
||||
$event->trigger();
|
||||
|
||||
// Finally reorder courses.
|
||||
|
||||
@@ -2024,7 +2024,6 @@ function move_courses($courseids, $categoryid) {
|
||||
'fullname' => $dbcourse->fullname,
|
||||
'updatedfields' => array('category' => $category->id))
|
||||
));
|
||||
$event->set_legacy_logdata(array($course->id, 'course', 'move', 'edit.php?id=' . $course->id, $course->id));
|
||||
$event->trigger();
|
||||
}
|
||||
fix_course_sortorder();
|
||||
@@ -2490,7 +2489,6 @@ function update_course($data, $editoroptions = NULL) {
|
||||
'updatedfields' => $updatedfields)
|
||||
));
|
||||
|
||||
$event->set_legacy_logdata(array($course->id, 'course', 'update', 'edit.php?id=' . $course->id, $course->id));
|
||||
$event->trigger();
|
||||
|
||||
if ($oldcourse->format !== $course->format) {
|
||||
|
||||
@@ -51,7 +51,6 @@ foreach ($allmodules as $key=>$module) {
|
||||
|
||||
// Triger view event.
|
||||
$event = \core\event\course_resources_list_viewed::create(array('context' => context_course::instance($course->id)));
|
||||
$event->set_legacy_logdata($availableresources);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->trigger();
|
||||
|
||||
|
||||
@@ -1867,10 +1867,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($course->id, $event->objectid);
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($course, $event->get_record_snapshot('course', $course->id));
|
||||
$this->assertEquals('course_created', $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($course, $event);
|
||||
$expectedlog = array(SITEID, 'course', 'new', 'view.php?id=' . $course->id, $course->fullname . ' (ID ' . $course->id . ')');
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
|
||||
// Now we want to trigger creating a course via the imsenterprise.
|
||||
// Delete the course we created earlier, as we want the imsenterprise plugin to create this.
|
||||
@@ -1941,10 +1937,6 @@ class courselib_test extends advanced_testcase {
|
||||
$url = new moodle_url('/course/edit.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEquals($updatedcourse, $event->get_record_snapshot('course', $event->objectid));
|
||||
$this->assertEquals('course_updated', $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($updatedcourse, $event);
|
||||
$expectedlog = array($updatedcourse->id, 'course', 'update', 'edit.php?id=' . $course->id, $course->id);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
|
||||
// Move course and catch course_updated event.
|
||||
$sink = $this->redirectEvents();
|
||||
@@ -1961,10 +1953,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($movedcourse->id, $event->objectid);
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($movedcourse, $event->get_record_snapshot('course', $movedcourse->id));
|
||||
$this->assertEquals('course_updated', $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($movedcourse, $event);
|
||||
$expectedlog = array($movedcourse->id, 'course', 'move', 'edit.php?id=' . $movedcourse->id, $movedcourse->id);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
|
||||
// Move course to hidden category and catch course_updated event.
|
||||
$sink = $this->redirectEvents();
|
||||
@@ -1981,10 +1969,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($movedcoursehidden->id, $event->objectid);
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($movedcoursehidden, $event->get_record_snapshot('course', $movedcoursehidden->id));
|
||||
$this->assertEquals('course_updated', $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($movedcoursehidden, $event);
|
||||
$expectedlog = array($movedcoursehidden->id, 'course', 'move', 'edit.php?id=' . $movedcoursehidden->id, $movedcoursehidden->id);
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -2054,21 +2038,11 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($course->id, $event->objectid);
|
||||
$this->assertEquals($coursecontext->id, $event->contextid);
|
||||
$this->assertEquals($course, $event->get_record_snapshot('course', $course->id));
|
||||
$this->assertEquals('course_deleted', $event->get_legacy_eventname());
|
||||
$eventdata = $event->get_data();
|
||||
$this->assertSame($course->idnumber, $eventdata['other']['idnumber']);
|
||||
$this->assertSame($course->fullname, $eventdata['other']['fullname']);
|
||||
$this->assertSame($course->shortname, $eventdata['other']['shortname']);
|
||||
|
||||
// The legacy data also passed the context in the course object and substitutes timemodified with the current date.
|
||||
$expectedlegacy = clone($course);
|
||||
$expectedlegacy->context = $coursecontext;
|
||||
$expectedlegacy->timemodified = $event->timecreated;
|
||||
$this->assertEventLegacyData($expectedlegacy, $event);
|
||||
|
||||
// Validate legacy log data.
|
||||
$expectedlog = array(SITEID, 'course', 'delete', 'view.php?id=' . $course->id, $course->fullname . '(ID ' . $course->id . ')');
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -2106,11 +2080,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($course->id, $event->objectid);
|
||||
$this->assertEquals($coursecontext->id, $event->contextid);
|
||||
$this->assertEquals($course, $event->get_record_snapshot('course', $course->id));
|
||||
$this->assertEquals('course_content_removed', $event->get_legacy_eventname());
|
||||
// The legacy data also passed the context and options in the course object.
|
||||
$course->context = $coursecontext;
|
||||
$course->options = array();
|
||||
$this->assertEventLegacyData($course, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -2147,11 +2116,7 @@ class courselib_test extends advanced_testcase {
|
||||
'name' => $category->name,
|
||||
], $event->other);
|
||||
$this->assertEquals($categoryrecord, $event->get_record_snapshot($event->objecttable, $event->objectid));
|
||||
$this->assertEquals('course_category_deleted', $event->get_legacy_eventname());
|
||||
$this->assertEquals(null, $event->get_url());
|
||||
$this->assertEventLegacyData($category, $event);
|
||||
$expectedlog = array(SITEID, 'category', 'delete', 'index.php', $category->name . '(ID ' . $category->id . ')');
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
|
||||
// Create two categories.
|
||||
$category = $this->getDataGenerator()->create_category();
|
||||
@@ -2182,10 +2147,6 @@ class courselib_test extends advanced_testcase {
|
||||
'contentmovedcategoryid' => $category->id,
|
||||
], $event->other);
|
||||
$this->assertEquals($category2record, $event->get_record_snapshot($event->objecttable, $event->objectid));
|
||||
$this->assertEquals('course_category_deleted', $event->get_legacy_eventname());
|
||||
$this->assertEventLegacyData($category2, $event);
|
||||
$expectedlog = array(SITEID, 'category', 'delete', 'index.php', $category2->name . '(ID ' . $category2->id . ')');
|
||||
$this->assertEventLegacyLogData($expectedlog, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -2286,19 +2247,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals('course', $event->objecttable);
|
||||
$this->assertEquals($rc->get_courseid(), $event->objectid);
|
||||
$this->assertEquals(context_course::instance($rc->get_courseid())->id, $event->contextid);
|
||||
$this->assertEquals('course_restored', $event->get_legacy_eventname());
|
||||
$legacydata = (object) array(
|
||||
'courseid' => $rc->get_courseid(),
|
||||
'userid' => $rc->get_userid(),
|
||||
'type' => $rc->get_type(),
|
||||
'target' => $rc->get_target(),
|
||||
'mode' => $rc->get_mode(),
|
||||
'operation' => $rc->get_operation(),
|
||||
'samesite' => $rc->is_samesite()
|
||||
);
|
||||
$url = new moodle_url('/course/view.php', array('id' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEventLegacyData($legacydata, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
|
||||
// Destroy the resource controller since we are done using it.
|
||||
@@ -2357,8 +2305,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($section, $event->get_record_snapshot('course_sections', $event->objectid));
|
||||
$id = $section->id;
|
||||
$sectionnum = $section->section;
|
||||
$expectedlegacydata = array($course->id, "course", "editsection", 'editsection.php?id=' . $id, $sectionnum);
|
||||
$this->assertEventLegacyLogData($expectedlegacydata, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -2392,11 +2338,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($expecteddesc, $event->get_description());
|
||||
$this->assertEquals($section, $event->get_record_snapshot('course_sections', $event->objectid));
|
||||
$this->assertNull($event->get_url());
|
||||
|
||||
// Test legacy data.
|
||||
$sectionnum = $section->section;
|
||||
$expectedlegacydata = array($course->id, "course", "delete section", 'view.php?id=' . $course->id, $sectionnum);
|
||||
$this->assertEventLegacyLogData($expectedlegacydata, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -2546,22 +2487,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals('course_modules', $event->objecttable);
|
||||
$url = new moodle_url('/mod/assign/view.php', array('id' => $module->cmid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
|
||||
// Test legacy data.
|
||||
$this->assertSame('mod_created', $event->get_legacy_eventname());
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'assign';
|
||||
$eventdata->name = $module->name;
|
||||
$eventdata->cmid = $module->cmid;
|
||||
$eventdata->courseid = $module->course;
|
||||
$eventdata->userid = $USER->id;
|
||||
$this->assertEventLegacyData($eventdata, $event);
|
||||
|
||||
$arr = array(
|
||||
array($module->course, "course", "add mod", "../mod/assign/view.php?id=$module->cmid", "assign $module->id"),
|
||||
array($module->course, "assign", "add", "view.php?id=$module->cmid", $module->id, $module->cmid)
|
||||
);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
}
|
||||
@@ -2686,22 +2611,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals('course_modules', $event->objecttable);
|
||||
$url = new moodle_url('/mod/forum/view.php', array('id' => $cm->id));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
|
||||
// Test legacy data.
|
||||
$this->assertSame('mod_updated', $event->get_legacy_eventname());
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'forum';
|
||||
$eventdata->name = $mod->name;
|
||||
$eventdata->cmid = $cm->id;
|
||||
$eventdata->courseid = $cm->course;
|
||||
$eventdata->userid = $USER->id;
|
||||
$this->assertEventLegacyData($eventdata, $event);
|
||||
|
||||
$arr = array(
|
||||
array($cm->course, "course", "update mod", "../mod/forum/view.php?id=$cm->id", "forum $cm->instance"),
|
||||
array($cm->course, "forum", "update", "view.php?id=$cm->id", $cm->instance, $cm->id)
|
||||
);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
}
|
||||
@@ -2746,12 +2655,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals($cm->instance, $event2->other['instanceid']);
|
||||
$this->assertEquals($cm->name, $event2->other['name']);
|
||||
$this->assertEventContextNotUsed($event2);
|
||||
$this->assertSame('mod_updated', $event2->get_legacy_eventname());
|
||||
$arr = array(
|
||||
array($cm->course, "course", "update mod", "../mod/assign/view.php?id=$cm->id", "assign $cm->instance"),
|
||||
array($cm->course, "assign", "update", "view.php?id=$cm->id", $cm->instance, $cm->id)
|
||||
);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2842,19 +2745,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals('course_modules', $event->objecttable);
|
||||
$this->assertEquals(null, $event->get_url());
|
||||
$this->assertEquals($cm, $event->get_record_snapshot('course_modules', $cm->id));
|
||||
|
||||
// Test legacy data.
|
||||
$this->assertSame('mod_deleted', $event->get_legacy_eventname());
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->modulename = 'forum';
|
||||
$eventdata->cmid = $cm->id;
|
||||
$eventdata->courseid = $cm->course;
|
||||
$eventdata->userid = $USER->id;
|
||||
$this->assertEventLegacyData($eventdata, $event);
|
||||
|
||||
$arr = array($cm->course, 'course', "delete mod", "view.php?id=$cm->course", "forum $cm->instance", $cm->id);
|
||||
$this->assertEventLegacyLogData($arr, $event);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3068,7 +2958,6 @@ class courselib_test extends advanced_testcase {
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
$event = \core\event\course_resources_list_viewed::create(array('context' => context_course::instance($course->id)));
|
||||
$event->set_legacy_logdata(array('book', 'page', 'resource'));
|
||||
$sink = $this->redirectEvents();
|
||||
$event->trigger();
|
||||
$events = $sink->get_events();
|
||||
@@ -3081,12 +2970,6 @@ class courselib_test extends advanced_testcase {
|
||||
$this->assertEquals(null, $event->objectid);
|
||||
$this->assertEquals($course->id, $event->courseid);
|
||||
$this->assertEquals($coursecontext->id, $event->contextid);
|
||||
$expectedlegacydata = array(
|
||||
array($course->id, "book", "view all", 'index.php?id=' . $course->id, ''),
|
||||
array($course->id, "page", "view all", 'index.php?id=' . $course->id, ''),
|
||||
array($course->id, "resource", "view all", 'index.php?id=' . $course->id, ''),
|
||||
);
|
||||
$this->assertEventLegacyLogData($expectedlegacydata, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
|
||||
@@ -623,11 +623,6 @@ class plugin_test extends \advanced_testcase {
|
||||
$dbuserenrolled = $DB->get_record('user_enrolments', array('userid' => $user1->id));
|
||||
$this->assertInstanceOf('\core\event\user_enrolment_created', $event);
|
||||
$this->assertEquals($dbuserenrolled->id, $event->objectid);
|
||||
$this->assertEquals('user_enrolled', $event->get_legacy_eventname());
|
||||
$expectedlegacyeventdata = $dbuserenrolled;
|
||||
$expectedlegacyeventdata->enrol = 'meta';
|
||||
$expectedlegacyeventdata->courseid = $course2->id;
|
||||
$this->assertEventLegacyData($expectedlegacyeventdata, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -661,7 +656,6 @@ class plugin_test extends \advanced_testcase {
|
||||
|
||||
$this->assertEquals(0, $DB->count_records('user_enrolments'));
|
||||
$this->assertInstanceOf('\core\event\user_enrolment_deleted', $event);
|
||||
$this->assertEquals('user_unenrolled', $event->get_legacy_eventname());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -697,13 +691,6 @@ class plugin_test extends \advanced_testcase {
|
||||
$dbuserenrolled = $DB->get_record('user_enrolments', array('userid' => $user1->id));
|
||||
$this->assertInstanceOf('\core\event\user_enrolment_updated', $event);
|
||||
$this->assertEquals($dbuserenrolled->id, $event->objectid);
|
||||
$this->assertEquals('user_enrol_modified', $event->get_legacy_eventname());
|
||||
$expectedlegacyeventdata = $dbuserenrolled;
|
||||
$expectedlegacyeventdata->enrol = 'meta';
|
||||
$expectedlegacyeventdata->courseid = $course2->id;
|
||||
$url = new \moodle_url('/enrol/editenrolment.php', array('ue' => $event->objectid));
|
||||
$this->assertEquals($url, $event->get_url());
|
||||
$this->assertEventLegacyData($expectedlegacyeventdata, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
|
||||
@@ -656,13 +656,6 @@ class enrollib_test extends advanced_testcase {
|
||||
$this->assertInstanceOf('\core\event\user_enrolment_created', $event);
|
||||
$this->assertEquals($dbuserenrolled->id, $event->objectid);
|
||||
$this->assertEquals(context_course::instance($course1->id), $event->get_context());
|
||||
$this->assertEquals('user_enrolled', $event->get_legacy_eventname());
|
||||
$expectedlegacyeventdata = $dbuserenrolled;
|
||||
$expectedlegacyeventdata->enrol = $manual->get_name();
|
||||
$expectedlegacyeventdata->courseid = $course1->id;
|
||||
$this->assertEventLegacyData($expectedlegacyeventdata, $event);
|
||||
$expected = array($course1->id, 'course', 'enrol', '../enrol/users.php?id=' . $course1->id, $course1->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
@@ -697,14 +690,6 @@ class enrollib_test extends advanced_testcase {
|
||||
// Validate the event.
|
||||
$this->assertInstanceOf('\core\event\user_enrolment_deleted', $event);
|
||||
$this->assertEquals(context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals('user_unenrolled', $event->get_legacy_eventname());
|
||||
$expectedlegacyeventdata = $dbuserenrolled;
|
||||
$expectedlegacyeventdata->enrol = $manualplugin->get_name();
|
||||
$expectedlegacyeventdata->courseid = $course->id;
|
||||
$expectedlegacyeventdata->lastenrol = true;
|
||||
$this->assertEventLegacyData($expectedlegacyeventdata, $event);
|
||||
$expected = array($course->id, 'course', 'unenrol', '../enrol/users.php?id=' . $course->id, $course->id);
|
||||
$this->assertEventLegacyLogData($expected, $event);
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,6 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
$expected = new \stdClass();
|
||||
$expected->groupid = $group->id;
|
||||
$expected->userid = $user->id;
|
||||
$expected->component = 'mod_workshop';
|
||||
$expected->itemid = '123';
|
||||
$this->assertEventLegacyData($expected, $event);
|
||||
$this->assertSame('groups_member_added', $event->get_legacy_eventname());
|
||||
$this->assertInstanceOf('\core\event\group_member_added', $event);
|
||||
$this->assertEquals($user->id, $event->relateduserid);
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
@@ -83,11 +76,6 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
$expected = new \stdClass();
|
||||
$expected->groupid = $group->id;
|
||||
$expected->userid = $user->id;
|
||||
$this->assertEventLegacyData($expected, $event);
|
||||
$this->assertSame('groups_member_removed', $event->get_legacy_eventname());
|
||||
$this->assertInstanceOf('\core\event\group_member_removed', $event);
|
||||
$this->assertEquals($user->id, $event->relateduserid);
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
@@ -109,8 +97,6 @@ class lib_test extends \advanced_testcase {
|
||||
$event = reset($events);
|
||||
|
||||
$this->assertInstanceOf('\core\event\group_created', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_created', $event->get_legacy_eventname());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
|
||||
@@ -131,9 +117,6 @@ class lib_test extends \advanced_testcase {
|
||||
|
||||
$this->assertInstanceOf('\core\event\grouping_created', $event);
|
||||
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_grouping_created', $event->get_legacy_eventname());
|
||||
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
|
||||
@@ -163,8 +146,6 @@ class lib_test extends \advanced_testcase {
|
||||
|
||||
$this->assertInstanceOf('\core\event\group_updated', $event);
|
||||
$group->name = $data->name;
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_updated', $event->get_legacy_eventname());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
|
||||
@@ -192,8 +173,6 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertTimeCurrent($group->timemodified);
|
||||
|
||||
$this->assertInstanceOf('\core\event\group_updated', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_updated', $event->get_legacy_eventname());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new \moodle_url('/group/group.php', array('id' => $event->objectid));
|
||||
@@ -224,15 +203,6 @@ class lib_test extends \advanced_testcase {
|
||||
// Get the timemodified from DB for comparison with snapshot.
|
||||
$data->timemodified = $DB->get_field('groupings', 'timemodified', array('id'=>$grouping->id));
|
||||
$this->assertTimeCurrent($data->timemodified);
|
||||
// Following fields were not updated so the snapshot should have them the same as in original group.
|
||||
$data->description = $grouping->description;
|
||||
$data->descriptionformat = $grouping->descriptionformat;
|
||||
$data->configdata = $grouping->configdata;
|
||||
$data->idnumber = $grouping->idnumber;
|
||||
$data->timecreated = $grouping->timecreated;
|
||||
// Assert legacy event data.
|
||||
$this->assertEventLegacyData($data, $event);
|
||||
$this->assertSame('groups_grouping_updated', $event->get_legacy_eventname());
|
||||
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($grouping->id, $event->objectid);
|
||||
@@ -270,9 +240,6 @@ class lib_test extends \advanced_testcase {
|
||||
$data->idnumber = $grouping->idnumber;
|
||||
$data->name = $grouping->name;
|
||||
$data->timecreated = $grouping->timecreated;
|
||||
// Assert legacy event data.
|
||||
$this->assertEventLegacyData($data, $event);
|
||||
$this->assertSame('groups_grouping_updated', $event->get_legacy_eventname());
|
||||
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($grouping->id, $event->objectid);
|
||||
@@ -292,9 +259,6 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertCount(1, $events);
|
||||
$event = reset($events);
|
||||
|
||||
$this->assertInstanceOf('\core\event\group_deleted', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_group_deleted', $event->get_legacy_eventname());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new \moodle_url('/group/index.php', array('id' => $event->courseid));
|
||||
@@ -314,8 +278,6 @@ class lib_test extends \advanced_testcase {
|
||||
$event = reset($events);
|
||||
|
||||
$this->assertInstanceOf('\core\event\grouping_deleted', $event);
|
||||
$this->assertEventLegacyData($group, $event);
|
||||
$this->assertSame('groups_grouping_deleted', $event->get_legacy_eventname());
|
||||
$this->assertEquals(\context_course::instance($course->id), $event->get_context());
|
||||
$this->assertEquals($group->id, $event->objectid);
|
||||
$url = new \moodle_url('/group/groupings.php', array('id' => $event->courseid));
|
||||
|
||||
@@ -85,13 +85,4 @@ class h5p_deleted extends \core\event\base {
|
||||
// There is no url since the previous event already has the url where the h5p content has been displayed.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'core_h5p_deleted';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +85,4 @@ class h5p_viewed extends \core\event\base {
|
||||
// There is no url since the previous event already has the url where the h5p content has been displayed.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'core_h5p_viewed';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,6 +266,15 @@ abstract class base implements \IteratorAggregate {
|
||||
if ($expectedcourseid != $event->data['courseid']) {
|
||||
debugging("Inconsistent courseid - context combination detected.", DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
if (method_exists($event, 'get_legacy_logdata') ||
|
||||
method_exists($event, 'set_legacy_logdata') ||
|
||||
method_exists($event, 'get_legacy_eventname') ||
|
||||
method_exists($event, 'get_legacy_eventdata')
|
||||
) {
|
||||
debugging("Invalid event functions defined in " . $event->data['eventname'], DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Let developers validate their custom data (such as $this->data['other'], contextlevel, etc.).
|
||||
@@ -696,39 +705,6 @@ abstract class base implements \IteratorAggregate {
|
||||
return $this->logextra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this event replace legacy event?
|
||||
*
|
||||
* Note: do not use directly!
|
||||
*
|
||||
* @return null|string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* Note: do not use directly!
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doest this event replace add_to_log() statement?
|
||||
*
|
||||
* Note: do not use directly!
|
||||
*
|
||||
* @return null|array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all properties right before triggering the event.
|
||||
*
|
||||
@@ -809,22 +785,6 @@ abstract class base implements \IteratorAggregate {
|
||||
|
||||
$this->triggered = true;
|
||||
|
||||
if (isset($CFG->loglifetime) and $CFG->loglifetime != -1) {
|
||||
if ($data = $this->get_legacy_logdata()) {
|
||||
$manager = get_log_manager();
|
||||
if (method_exists($manager, 'legacy_add_to_log')) {
|
||||
if (is_array($data[0])) {
|
||||
// Some events require several entries in 'log' table.
|
||||
foreach ($data as $d) {
|
||||
call_user_func_array(array($manager, 'legacy_add_to_log'), $d);
|
||||
}
|
||||
} else {
|
||||
call_user_func_array(array($manager, 'legacy_add_to_log'), $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUNIT_TEST and \phpunit_util::is_redirecting_events()) {
|
||||
$this->dispatched = true;
|
||||
\phpunit_util::event_triggered($this);
|
||||
|
||||
@@ -80,21 +80,6 @@ class blog_association_created extends base {
|
||||
return new \moodle_url('/blog/index.php', array('entryid' => $this->other['blogid']));
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
if ($this->other['associatetype'] === 'course') {
|
||||
return array (SITEID, 'blog', 'add association', 'index.php?userid=' . $this->relateduserid. '&entryid=' .
|
||||
$this->other['blogid'], $this->other['subject'], 0, $this->relateduserid);
|
||||
}
|
||||
|
||||
return array (SITEID, 'blog', 'add association', 'index.php?userid=' . $this->relateduserid. '&entryid=' .
|
||||
$this->other['blogid'], $this->other['subject'], $this->other['associateid'], $this->relateduserid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validations.
|
||||
*
|
||||
|
||||
@@ -91,22 +91,6 @@ class blog_entries_viewed extends base {
|
||||
return new \moodle_url('/blog/index.php', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$params = array();
|
||||
foreach ($this->validparams as $param) {
|
||||
if (!empty($this->other[$param])) {
|
||||
$params[$param] = $this->other[$param];
|
||||
}
|
||||
}
|
||||
$url = new \moodle_url('index.php', $params);
|
||||
return array (SITEID, 'blog', 'view', $url->out(), 'view blog entry');
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['entryid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
|
||||
|
||||
@@ -99,34 +99,6 @@ class blog_entry_created extends base {
|
||||
return new \moodle_url('/blog/index.php', array('entryid' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this event replace legacy event?
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'blog_entry_added';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \blog_entry
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array (SITEID, 'blog', 'add', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
|
||||
$this->blogentry->subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validations.
|
||||
*
|
||||
|
||||
@@ -90,34 +90,6 @@ class blog_entry_deleted extends base {
|
||||
return "The user with id '$this->userid' deleted the blog entry with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this event replace legacy event?
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'blog_entry_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \blog_entry
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array (SITEID, 'blog', 'delete', 'index.php?userid=' . $this->relateduserid, 'deleted blog entry with entry id# '.
|
||||
$this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validations.
|
||||
*
|
||||
|
||||
@@ -97,34 +97,6 @@ class blog_entry_updated extends base {
|
||||
return new \moodle_url('/blog/index.php', array('entryid' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \blog_entry
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->blogentry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event name.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'blog_entry_edited';
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace legacy add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'blog', 'update', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
|
||||
$this->blogentry->subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validations.
|
||||
*
|
||||
|
||||
@@ -84,15 +84,6 @@ class calendar_event_created extends base {
|
||||
'event_' . $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace legacy add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'calendar', 'add', 'event.php?action=edit&id=' . $this->objectid , $this->other['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -83,15 +83,6 @@ class calendar_event_updated extends base {
|
||||
return new \moodle_url('/calendar/event.php', array('action' => 'edit', 'id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace legacy add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'calendar', 'edit', 'event.php?action=edit&id=' . $this->objectid, $this->other['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -73,24 +73,6 @@ class cohort_created extends base {
|
||||
return new \moodle_url('/cohort/index.php', array('contextid' => $this->contextid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event name.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'cohort_added';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('cohort', $this->objectid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
// Cohorts are not included in backups, so no mapping is needed for restore.
|
||||
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
|
||||
|
||||
@@ -73,24 +73,6 @@ class cohort_deleted extends base {
|
||||
return new \moodle_url('/cohort/index.php', array('contextid' => $this->contextid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event name.
|
||||
*
|
||||
* @return null|string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'cohort_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('cohort', $this->objectid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
// Cohorts are not included in backups, so no mapping is needed for restore.
|
||||
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
|
||||
|
||||
@@ -74,27 +74,6 @@ class cohort_member_added extends base {
|
||||
return new \moodle_url('/cohort/assign.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event name.
|
||||
*
|
||||
* @return string legacy event name.
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'cohort_member_added';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$data = new \stdClass();
|
||||
$data->cohortid = $this->objectid;
|
||||
$data->userid = $this->relateduserid;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validations.
|
||||
*
|
||||
|
||||
@@ -75,27 +75,6 @@ class cohort_member_removed extends base {
|
||||
return new \moodle_url('/cohort/assign.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event name.
|
||||
*
|
||||
* @return string legacy event name.
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'cohort_member_removed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$data = new \stdClass();
|
||||
$data->cohortid = $this->objectid;
|
||||
$data->userid = $this->relateduserid;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validations.
|
||||
*
|
||||
|
||||
@@ -73,24 +73,6 @@ class cohort_updated extends base {
|
||||
return new \moodle_url('/cohort/edit.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event name.
|
||||
*
|
||||
* @return string legacy event name.
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'cohort_updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('cohort', $this->objectid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
// Cohorts are not included in backups, so no mapping is needed for restore.
|
||||
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
|
||||
|
||||
@@ -95,24 +95,6 @@ abstract class content_viewed extends base {
|
||||
return "The user with id '$this->userid' viewed content.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set legacy logdata.
|
||||
*
|
||||
* @param array $legacydata legacy logdata.
|
||||
*/
|
||||
public function set_legacy_logdata(array $legacydata) {
|
||||
$this->legacylogdata = $legacydata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get legacy logdata.
|
||||
*
|
||||
* @return null|array legacy log data.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return $this->legacylogdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -72,15 +72,6 @@ class course_category_created extends base {
|
||||
return "The user with id '$this->userid' created the course category with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'category', 'add', 'editcategory.php?id=' . $this->objectid, $this->objectid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
// Categories are not backed up, so no need to map them on restore.
|
||||
return array('db' => 'course_categories', 'restore' => base::NOT_MAPPED);
|
||||
|
||||
@@ -79,24 +79,6 @@ class course_category_deleted extends base {
|
||||
return $descr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the legacy event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_category_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy event data.
|
||||
*
|
||||
* @return \core_course_category the category that was deleted
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->coursecat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom data of the event - deleted coursecat.
|
||||
*
|
||||
@@ -119,15 +101,6 @@ class course_category_deleted extends base {
|
||||
return $this->coursecat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'category', 'delete', 'index.php', $this->other['name'] . '(ID ' . $this->objectid . ')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -75,28 +75,6 @@ class course_category_updated extends base {
|
||||
return "The user with id '$this->userid' updated the course category with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the legacy data used for add_to_log().
|
||||
*
|
||||
* @param array $logdata
|
||||
*/
|
||||
public function set_legacy_logdata($logdata) {
|
||||
$this->legacylogdata = $logdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
if (!empty($this->legacylogdata)) {
|
||||
return $this->legacylogdata;
|
||||
}
|
||||
|
||||
return array(SITEID, 'category', 'update', 'editcategory.php?id=' . $this->objectid, $this->objectid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
// Categories are not backed up, so no need to map them on restore.
|
||||
return array('db' => 'course_categories', 'restore' => base::NOT_MAPPED);
|
||||
|
||||
@@ -97,24 +97,6 @@ class course_completed extends base {
|
||||
return new \moodle_url('/report/completion/index.php', array('course' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_completed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return course_completed legacy event data.
|
||||
*
|
||||
* @return \stdClass completion data.
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('course_completions', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -70,13 +70,4 @@ class course_completion_updated extends base {
|
||||
public function get_url() {
|
||||
return new \moodle_url('/course/completion.php', array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy add_to_log() data.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'course', 'completion updated', 'completion.php?id=' . $this->courseid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,28 +69,6 @@ class course_content_deleted extends base {
|
||||
return "The user with id '$this->userid' deleted content from course with id '$this->courseid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the legacy event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_content_removed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy event data.
|
||||
*
|
||||
* @return \stdClass the course the content was deleted from
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$course = $this->get_record_snapshot('course', $this->objectid);
|
||||
$course->context = $this->context;
|
||||
$course->options = $this->other['options'];
|
||||
|
||||
return $course;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -79,33 +79,6 @@ class course_created extends base {
|
||||
return new \moodle_url('/course/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the legacy event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_created';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy event data.
|
||||
*
|
||||
* @return \stdClass the course that was created
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('course', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'course', 'new', 'view.php?id=' . $this->objectid, $this->other['fullname'] . ' (ID ' . $this->objectid . ')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -71,36 +71,6 @@ class course_deleted extends base {
|
||||
return "The user with id '$this->userid' deleted the course with id '$this->courseid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the legacy event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy event data.
|
||||
*
|
||||
* @return \stdClass the course that was deleted
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$course = $this->get_record_snapshot('course', $this->objectid);
|
||||
$course->context = $this->context;
|
||||
$course->timemodified = $this->data['timecreated'];
|
||||
return $course;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'course', 'delete', 'view.php?id=' . $this->objectid, $this->other['fullname'] . '(ID ' . $this->objectid . ')');
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -84,24 +84,6 @@ class course_module_completion_updated extends base {
|
||||
return new \moodle_url('/report/progress/index.php', array('course' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name of the legacy event, which is replaced by this event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'activity_completion_changed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return course module completion legacy event data.
|
||||
*
|
||||
* @return \stdClass completion data.
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('course_modules_completion', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -110,44 +110,6 @@ class course_module_created extends base {
|
||||
return new \moodle_url('/mod/' . $this->other['modulename'] . '/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event name.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'mod_created';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$eventdata = new \stdClass();
|
||||
$eventdata->modulename = $this->other['modulename'];
|
||||
$eventdata->name = $this->other['name'];
|
||||
$eventdata->cmid = $this->objectid;
|
||||
$eventdata->courseid = $this->courseid;
|
||||
$eventdata->userid = $this->userid;
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$log1 = array($this->courseid, "course", "add mod", "../mod/" . $this->other['modulename'] . "/view.php?id=" .
|
||||
$this->objectid, $this->other['modulename'] . " " . $this->other['instanceid']);
|
||||
$log2 = array($this->courseid, $this->other['modulename'], "add",
|
||||
"view.php?id={$this->objectid}",
|
||||
"{$this->other['instanceid']}", $this->objectid);
|
||||
return array($log1, $log2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -72,39 +72,6 @@ class course_module_deleted extends base {
|
||||
"course module id '$this->contextinstanceid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event name.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'mod_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$eventdata = new \stdClass();
|
||||
$eventdata->modulename = $this->other['modulename'];
|
||||
$eventdata->cmid = $this->objectid;
|
||||
$eventdata->courseid = $this->courseid;
|
||||
$eventdata->userid = $this->userid;
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array ($this->courseid, "course", "delete mod", "view.php?id=$this->courseid",
|
||||
$this->other['modulename'] . " " . $this->other['instanceid'], $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* custom validations
|
||||
*
|
||||
|
||||
@@ -90,16 +90,6 @@ abstract class course_module_instance_list_viewed extends base{
|
||||
return new \moodle_url("/mod/$this->modname/index.php", array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, $this->modname, 'view all', 'index.php?id=' . $this->courseid, '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -81,44 +81,6 @@ class course_module_updated extends base {
|
||||
return new \moodle_url('/mod/' . $this->other['modulename'] . '/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event name.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'mod_updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$eventdata = new \stdClass();
|
||||
$eventdata->modulename = $this->other['modulename'];
|
||||
$eventdata->name = $this->other['name'];
|
||||
$eventdata->cmid = $this->objectid;
|
||||
$eventdata->courseid = $this->courseid;
|
||||
$eventdata->userid = $this->userid;
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$log1 = array($this->courseid, "course", "update mod", "../mod/" . $this->other['modulename'] . "/view.php?id=" .
|
||||
$this->objectid, $this->other['modulename'] . " " . $this->other['instanceid']);
|
||||
$log2 = array($this->courseid, $this->other['modulename'], "update",
|
||||
"view.php?id={$this->objectid}",
|
||||
"{$this->other['instanceid']}", $this->objectid);
|
||||
return array($log1, $log2);
|
||||
}
|
||||
|
||||
/**
|
||||
* custom validations
|
||||
*
|
||||
|
||||
@@ -77,16 +77,6 @@ abstract class course_module_viewed extends base {
|
||||
return new \moodle_url("/mod/$this->objecttable/view.php", array('id' => $this->contextinstanceid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, $this->objecttable, 'view', 'view.php?id=' . $this->contextinstanceid, $this->objectid,
|
||||
$this->contextinstanceid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -75,35 +75,6 @@ class course_resources_list_viewed extends base {
|
||||
return new \moodle_url("/course/resources.php", array('id' => $this->courseid));
|
||||
}
|
||||
|
||||
/**
|
||||
* List of resource types enabled in the system. This is used for legacy logging to log one record for each resource type.
|
||||
*
|
||||
* There is no public getter for this data because it does not depend on the
|
||||
* course. It always includes the list of all resource types in the system
|
||||
* even when some of them are not present in the course.
|
||||
*
|
||||
* @param array $data
|
||||
*/
|
||||
public function set_legacy_logdata($data) {
|
||||
$this->resourceslist = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
if (empty($this->resourceslist)) {
|
||||
return null;
|
||||
}
|
||||
$logs = array();
|
||||
foreach ($this->resourceslist as $resourcename) {
|
||||
$logs[] = array($this->courseid, $resourcename, 'view all', 'index.php?id=' . $this->courseid, '');
|
||||
}
|
||||
return $logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -91,32 +91,6 @@ class course_restored extends base {
|
||||
return new \moodle_url('/course/view.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the legacy event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_restored';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy event data.
|
||||
*
|
||||
* @return \stdClass the legacy event data
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return (object) array(
|
||||
'courseid' => $this->objectid,
|
||||
'userid' => $this->userid,
|
||||
'type' => $this->other['type'],
|
||||
'target' => $this->other['target'],
|
||||
'mode' => $this->other['mode'],
|
||||
'operation' => $this->other['operation'],
|
||||
'samesite' => $this->other['samesite'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -73,15 +73,6 @@ class course_section_deleted extends base {
|
||||
"(section name '{$this->other['sectionname']}') for the course with id '$this->courseid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'course', 'delete section', 'view.php?id=' . $this->courseid, $this->other['sectionnum']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -81,16 +81,6 @@ class course_section_updated extends base {
|
||||
return new \moodle_url('/course/editsection.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$sectiondata = $this->get_record_snapshot('course_sections', $this->objectid);
|
||||
return array($this->courseid, 'course', 'editsection', 'editsection.php?id=' . $this->objectid, $sectiondata->section);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -83,42 +83,6 @@ class course_updated extends base {
|
||||
return new \moodle_url('/course/edit.php', array('id' => $this->objectid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the legacy event.
|
||||
*
|
||||
* @return string legacy event name
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'course_updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the legacy event data.
|
||||
*
|
||||
* @return \stdClass the course that was updated
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('course', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the legacy data used for add_to_log().
|
||||
*
|
||||
* @param array $logdata
|
||||
*/
|
||||
public function set_legacy_logdata($logdata) {
|
||||
$this->legacylogdata = $logdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return $this->legacylogdata;
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'course', 'restore' => 'course');
|
||||
}
|
||||
|
||||
@@ -82,16 +82,6 @@ class course_user_report_viewed extends base {
|
||||
'mode' => $this->other['mode']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'course', 'user report', 'user.php?id=' . $this->courseid . '&user='
|
||||
. $this->relateduserid . '&mode=' . $this->other['mode'], $this->relateduserid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -104,30 +104,6 @@ class course_viewed extends base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
if ($this->courseid == SITEID and !isloggedin()) {
|
||||
// We did not log frontpage access in older Moodle versions.
|
||||
return null;
|
||||
}
|
||||
|
||||
// We keep compatibility with 2.7 and 2.8 other['coursesectionid'].
|
||||
if (isset($this->other['coursesectionnumber']) || isset($this->other['coursesectionid'])) {
|
||||
if (isset($this->other['coursesectionnumber'])) {
|
||||
$sectionnumber = $this->other['coursesectionnumber'];
|
||||
} else {
|
||||
$sectionnumber = $this->other['coursesectionid'];
|
||||
}
|
||||
return array($this->courseid, 'course', 'view section', 'view.php?id=' . $this->courseid . '&section='
|
||||
. $sectionnumber, $sectionnumber);
|
||||
}
|
||||
return array($this->courseid, 'course', 'view', 'view.php?id=' . $this->courseid, $this->courseid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -72,15 +72,6 @@ class email_failed extends base {
|
||||
due to the following error: \"{$this->other['errorinfo']}\".";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'library', 'mailer', qualified_me(), 'ERROR: ' . $this->other['errorinfo']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -44,24 +44,6 @@ class group_created extends base {
|
||||
return "The user with id '$this->userid' created the group with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('groups', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_group_created';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -44,24 +44,6 @@ class group_deleted extends base {
|
||||
return "The user with id '$this->userid' deleted the group with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('groups', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_group_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -52,29 +52,6 @@ class group_member_added extends base {
|
||||
"id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$eventdata = new \stdClass();
|
||||
$eventdata->groupid = $this->objectid;
|
||||
$eventdata->userid = $this->relateduserid;
|
||||
$eventdata->component = $this->other['component'];
|
||||
$eventdata->itemid = $this->other['itemid'];
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_member_added';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -45,27 +45,6 @@ class group_member_removed extends base {
|
||||
"id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
$eventdata = new \stdClass();
|
||||
$eventdata->groupid = $this->objectid;
|
||||
$eventdata->userid = $this->relateduserid;
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_member_removed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -44,24 +44,6 @@ class group_updated extends base {
|
||||
return "The user with id '$this->userid' updated the group with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('groups', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_group_updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -44,24 +44,6 @@ class grouping_created extends base {
|
||||
return "The user with id '$this->userid' created the grouping with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('groupings', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_grouping_created';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -51,24 +51,6 @@ class grouping_deleted extends base {
|
||||
return "The user with id '$this->userid' deleted the grouping with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('groupings', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_grouping_deleted';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -44,24 +44,6 @@ class grouping_updated extends base {
|
||||
return "The user with id '$this->userid' updated the grouping with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy event data if get_legacy_eventname() is not empty.
|
||||
*
|
||||
* @return \stdClass
|
||||
*/
|
||||
protected function get_legacy_eventdata() {
|
||||
return $this->get_record_snapshot('groupings', $this->objectid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_legacy_eventname() {
|
||||
return 'groups_grouping_updated';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return localised event name.
|
||||
*
|
||||
|
||||
@@ -72,16 +72,6 @@ class message_contact_added extends base {
|
||||
return "The user with id '$this->userid' added the user with id '$this->relateduserid' to their contact list.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'message', 'add contact', 'index.php?user1=' . $this->relateduserid .
|
||||
'&user2=' . $this->userid, $this->relateduserid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -72,16 +72,6 @@ class message_contact_removed extends base {
|
||||
return "The user with id '$this->userid' removed the user with id '$this->relateduserid' from their contact list.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'message', 'remove contact', 'index.php?user1=' . $this->relateduserid . '&user2=' .
|
||||
$this->userid, $this->relateduserid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -111,23 +111,6 @@ class message_sent extends base {
|
||||
return "A message was sent by the system to the user with id '$this->relateduserid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
// The add_to_log function was only ever called when we sent a message from one user to another. We do not want
|
||||
// to return the legacy log data if we are sending a system message, so check that the userid is valid.
|
||||
if (\core_user::is_real_user($this->userid)) {
|
||||
$messageid = $this->other['messageid'] ?? $this->objectid; // For BC we may have 'messageid' in other.
|
||||
return array(SITEID, 'message', 'write', 'index.php?user=' . $this->userid . '&id=' . $this->relateduserid .
|
||||
'&history=1#m' . $messageid, $this->userid);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -82,16 +82,6 @@ class mnet_access_control_created extends base {
|
||||
"belonging to mnet host '{$this->other['hostname']}'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'admin/mnet', 'add', 'admin/mnet/access_control.php', 'SSO ACL: ' . $this->other['accessctrl'] .
|
||||
' user \'' . $this->other['username'] . '\' from ' . $this->other['hostname']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -82,16 +82,6 @@ class mnet_access_control_updated extends base {
|
||||
"belonging to mnet host '{$this->other['hostname']}'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return legacy data for add_to_log().
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php', 'SSO ACL: ' . $this->other['accessctrl'] .
|
||||
' user \'' . $this->other['username'] . '\' from ' . $this->other['hostname']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -82,17 +82,6 @@ class note_created extends base {
|
||||
return $logurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$logurl = new \moodle_url('index.php', array('course' => $this->courseid, 'user' => $this->relateduserid));
|
||||
$logurl->set_anchor('note-' . $this->objectid);
|
||||
return array($this->courseid, 'notes', 'add', $logurl, 'add note');
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -72,17 +72,6 @@ class note_deleted extends base {
|
||||
"'$this->relateduserid'";
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$logurl = new \moodle_url('index.php', array('course' => $this->courseid, 'user' => $this->relateduserid));
|
||||
$logurl->set_anchor('note-' . $this->objectid);
|
||||
return array($this->courseid, 'notes', 'delete', $logurl, 'delete note');
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -82,17 +82,6 @@ class note_updated extends base {
|
||||
return $logurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
$logurl = new \moodle_url('index.php', array('course' => $this->courseid, 'user' => $this->relateduserid));
|
||||
$logurl->set_anchor('note-' . $this->objectid);
|
||||
return array($this->courseid, 'notes', 'update', $logurl, 'update note');
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
|
||||
@@ -76,14 +76,4 @@ class notes_viewed extends base {
|
||||
public function get_url() {
|
||||
return new \moodle_url('/notes/index.php', array('course' => $this->courseid, 'user' => $this->relateduserid));
|
||||
}
|
||||
|
||||
/**
|
||||
* replace add_to_log() statement.
|
||||
*
|
||||
* @return array of parameters to be passed to legacy add_to_log() function.
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, 'notes', 'view', 'index.php?course=' . $this->courseid.'&user=' . $this->relateduserid,
|
||||
'view notes');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,19 +61,4 @@ class question_category_created extends question_category_base {
|
||||
public function get_description() {
|
||||
return "The user with id '$this->userid' created the question category with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
if ($this->contextlevel == CONTEXT_MODULE) {
|
||||
return array($this->courseid, 'quiz', 'addcategory', 'view.php?id=' . $this->contextinstanceid,
|
||||
$this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
// This is not related to individual quiz at all.
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,15 +64,6 @@ class recent_activity_viewed extends base {
|
||||
return "The user with id '$this->userid' viewed the recent activity report in the course with id '$this->courseid'.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the legacy event log data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array($this->courseid, "course", "recent", "recent.php?id=$this->courseid", $this->courseid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns relevant URL.
|
||||
*
|
||||
|
||||
@@ -73,13 +73,4 @@ class role_allow_assign_updated extends base {
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/roles/allow.php', array('mode' => 'assign'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of parameters to be passed to legacy add_to_log() function.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'role', 'edit allow assign', 'admin/roles/allow.php?mode=assign');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,13 +73,4 @@ class role_allow_override_updated extends base {
|
||||
public function get_url() {
|
||||
return new \moodle_url('/admin/roles/allow.php', array('mode' => 'override'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of parameters to be passed to legacy add_to_log() function.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_legacy_logdata() {
|
||||
return array(SITEID, 'role', 'edit allow override', 'admin/roles/allow.php?mode=override');
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user