MDL-42001 mod_chat: Transforming handlers to observers

This commit is contained in:
Frederic Massart
2013-09-27 13:38:27 +08:00
parent 65a4f26d8a
commit c8135e8b18
3 changed files with 14 additions and 13 deletions
+9 -9
View File
@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User logout event handler definition.
* Event observers definition.
*
* @package mod_chat
* @category event
@@ -23,12 +23,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/* List of handlers */
$handlers = array (
'user_logout' => array (
'handlerfile' => '/mod/chat/lib.php',
'handlerfunction' => 'chat_user_logout',
'schedule' => 'instant',
'internal' => 1,
),
$observers = array(
// User logging out.
array(
'eventname' => '\core\event\user_loggedout',
'callback' => 'chat_user_logout',
'includefile' => '/mod/chat/lib.php'
)
);
+4 -3
View File
@@ -1315,11 +1315,12 @@ function chat_extend_settings_navigation(settings_navigation $settings, navigati
/**
* user logout event handler
*
* @param object $user full $USER object
* @param \core\event\user_loggedout $event The event.
* @return void
*/
function chat_user_logout($user) {
function chat_user_logout(\core\event\user_loggedout $event) {
global $DB;
$DB->delete_records('chat_users', array('userid'=>$user->id));
$DB->delete_records('chat_users', array('userid' => $event->objectid));
}
/**
+1 -1
View File
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$module->version = 2013050100; // The current module version (Date: YYYYMMDDXX)
$module->version = 2013092600; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2013050100; // Requires this Moodle version
$module->component = 'mod_chat'; // Full name of the plugin (used for diagnostics)
$module->cron = 300;