1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Event observer. 19 * 20 * @package block_recent_activity 21 * @copyright 2014 Marina Glancy 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Event observer. 29 * Stores all actions about modules create/update/delete in plugin own's table. 30 * This allows the block to avoid expensive queries to the log table. 31 * 32 * @package block_recent_activity 33 * @copyright 2014 Marina Glancy 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class block_recent_activity_observer { 37 38 /** @var int indicates that course module was created */ 39 const CM_CREATED = 0; 40 /** @var int indicates that course module was udpated */ 41 const CM_UPDATED = 1; 42 /** @var int indicates that course module was deleted */ 43 const CM_DELETED = 2; 44 45 /** 46 * Store all actions about modules create/update/delete in own table. 47 * 48 * @param \core\event\base $event 49 */ 50 public static function store(\core\event\base $event) { 51 global $DB; 52 $eventdata = new \stdClass(); 53 switch ($event->eventname) { 54 case '\core\event\course_module_created': 55 $eventdata->action = self::CM_CREATED; 56 break; 57 case '\core\event\course_module_updated': 58 $eventdata->action = self::CM_UPDATED; 59 break; 60 case '\core\event\course_module_deleted': 61 $eventdata->action = self::CM_DELETED; 62 $eventdata->modname = $event->other['modulename']; 63 break; 64 default: 65 return; 66 } 67 $eventdata->timecreated = $event->timecreated; 68 $eventdata->courseid = $event->courseid; 69 $eventdata->cmid = $event->objectid; 70 $eventdata->userid = $event->userid; 71 $DB->insert_record('block_recent_activity', $eventdata); 72 } 73 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body