MDL-40058 mod_wiki: Replaced add_to_log for course_module_viewed with event

This commit is contained in:
Rajesh Taneja
2013-12-11 13:52:58 +11:00
committed by Marina Glancy
parent 8ac1d22436
commit 48f871e09b
2 changed files with 55 additions and 1 deletions
@@ -0,0 +1,47 @@
<?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/>.
/**
* mod_wiki course module viewed event.
*
* @package mod_wiki
* @copyright 2013 Rajesh Taneja <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_wiki\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_wiki course module viewed event class.
*
* @package mod_wiki
* @copyright 2013 Rajesh Taneja <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['level'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'wiki';
}
}
+8 -1
View File
@@ -298,7 +298,14 @@ if($pageid) {
$event->add_record_snapshot('wiki_pages', $page);
$event->trigger();
} else if($id) {
add_to_log($course->id, 'wiki', 'view', "view.php?id=".$id, $id, $cm->id);
$event = \mod_wiki\event\course_module_viewed::create(
array(
'context' => $context,
'objectid' => $wiki->id
)
);
$event->add_record_snapshot('wiki', $wiki);
$event->trigger();
} else if($wid && $title) {
$event = \mod_wiki\event\page_viewed::create(
array(