From ac930bf8191f860ee6ec085cf3a0c37bfdc204dd Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Wed, 9 Apr 2008 12:44:53 +0000 Subject: [PATCH] Modify UserLoginComplete and UserLogoutComplete hooks to allow HTML injection into the success page by hooks. For CentralAuth 'global logging in' --- docs/hooks.txt | 2 ++ includes/SpecialUserlogin.php | 4 +++- includes/SpecialUserlogout.php | 11 +++++++---- includes/User.php | 1 - 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index db9d542b60..63d89a523b 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1119,6 +1119,7 @@ $user: User to get groups for 'UserLoginComplete': after a user has logged in $user: the user object that was created on login +$inject_html: Any HTML to inject after the "logged in" message. 'UserLoginForm': change to manipulate the login form $template: SimpleTemplate instance for the form @@ -1128,6 +1129,7 @@ $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.) +$inject_html: Any HTML to inject after the "logged out" message. 'UserRights': After a user's group memberships are changed $user : User object that was changed diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 211a9c108c..9a93014f65 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -603,12 +603,14 @@ class LoginForm { # Run any hooks; ignore results - wfRunHooks('UserLoginComplete', array(&$wgUser)); + $injected_html = ''; + wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html)); $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); $wgOut->setArticleRelated( false ); $wgOut->addWikiText( $msg ); + $wgOut->addHtml( $injected_html ); if ( !empty( $this->mReturnTo ) ) { $wgOut->returnToMain( $auto, $this->mReturnTo ); } else { diff --git a/includes/SpecialUserlogout.php b/includes/SpecialUserlogout.php index d9952ea594..7dac24a719 100644 --- a/includes/SpecialUserlogout.php +++ b/includes/SpecialUserlogout.php @@ -12,8 +12,11 @@ function wfSpecialUserlogout() { $wgUser->logout(); $wgOut->setRobotpolicy( 'noindex,nofollow' ); - $wgOut->addHTML( wfMsgExt( 'logouttext', array( 'parse' ) ) ); + + // Hook. + $injected_html = ''; + wfRunHooks( 'UserLogoutComplete', array(&$wgUser, &$injected_html) ); + + $wgOut->addHTML( wfMsgExt( 'logouttext', array( 'parse' ) ) . $injected_html ); $wgOut->returnToMain(); -} - - +} \ No newline at end of file diff --git a/includes/User.php b/includes/User.php index 103130f072..6106733e57 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1976,7 +1976,6 @@ class User { global $wgUser; if( wfRunHooks( 'UserLogout', array(&$this) ) ) { $this->doLogout(); - wfRunHooks( 'UserLogoutComplete', array(&$wgUser) ); } } -- 2.20.1