action already). Checking the return value matters more for "before"
hooks than for "complete" hooks.
-==Existing hooks==
-
-The following list of hooks exist in the code right now:
-
-TBD
+==Events and parameters==
+
+This is a list of known events and parameters; please add to it if
+you're going to add events to the MediaWiki code.
+
+'UserLoginComplete': after a user has logged in
+$user: the user object that was created on login
+
+'UserLogout': before a user logs out
+$user: the user object that is about to be logged out
+
+'UserLogoutComplete': after a user has logged out
+$user: the user object _after_ logout (won't have name, ID, etc.)
+
+
--- /dev/null
+<?
+/* Syslog.php -- an extension to log events to the system logger
+ * Copyright 2004 Evan Prodromou <evan@wikitravel.org>
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @author Evan Prodromou <evan@wikitravel.org>
+ * @package MediaWiki
+ * @subpackage Extensions
+ */
+
+if (defined('MEDIAWIKI')) {
+
+ # Setup globals
+
+ if (!isset($wgSyslogIdentity)) {
+ $wgSyslogIdentity = $wgDBname;
+ }
+ if (!isset($wgSyslogFacility)) {
+ $wgSyslogFacility = LOG_USER;
+ }
+
+ # Hook for login
+
+ function syslogUserLogin(&$user) {
+ syslog(LOG_INFO, "User '" . $user->getName() . "' logged in.");
+ return true;
+ }
+
+ # Hook for logout
+
+ function syslogUserLogout(&$user) {
+ syslog(LOG_INFO, "User '" . $user->getName() . "' logged out.");
+ return true;
+ }
+
+ # Setup -- called once environment is configured
+
+ function setupSyslog() {
+
+ global $wgSyslogIdentity, $wgSyslogFacility, $_syslogId;
+ global $wgHooks;
+
+ openlog($wgSyslogIdentity, LOG_ODELAY | LOG_PID, $wgSyslogFacility);
+
+ $wgHooks['UserLoginComplete'][] = syslogUserLogin;
+ $wgHooks['UserLogout'][] = syslogUserLogout;
+
+ return true;
+ }
+
+ # Add to global list of extensions
+
+ $wgExtensionFunctions[] = setupSyslog;
+}
+
+?>
\ No newline at end of file
function wfSpecialUserlogout() {
global $wgUser, $wgOut, $returnto;
- $wgUser->logout();
- $wgOut->mCookies = array();
- $wgOut->setRobotpolicy( 'noindex,nofollow' );
- $wgOut->addHTML( wfMsg( 'logouttext' ) );
- $wgOut->returnToMain();
+ if (wfRunHooks('UserLogout', $wgUser)) {
+
+ $wgUser->logout();
+
+ $wgOut->mCookies = array();
+ $wgOut->setRobotpolicy( 'noindex,nofollow' );
+ $wgOut->addHTML( wfMsg( 'logouttext' ) );
+ $wgOut->returnToMain();
+
+ wfRunHooks('UserLogoutComplete', $wgUser);
+ }
}
?>