Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -128,6 +128,33 @@ |
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
| 132 | + * Purge page |
| 133 | + * @return bool |
| 134 | + * |
| 135 | + */ |
| 136 | + public static function purge( $userName, $user ) { |
| 137 | + if ( $user === null && $userName != null ) { |
| 138 | + $old_user = User::newFromName( $userName ); |
| 139 | + } |
| 140 | + else { |
| 141 | + $old_user = $user; |
| 142 | + } |
| 143 | + // check if something weird didn't happen |
| 144 | + if ( $old_user === false || $old_user == null ) { |
| 145 | + return true; |
| 146 | + } |
| 147 | + if ( $old_user->getOption('OnlineStatusBar_active') ) { |
| 148 | + if ( $old_user->getOption('OnlineStatusBar_autoupdate') == true ) { |
| 149 | + $update = SquidUpdate::newSimplePurge( $user->getTalkPage() ); |
| 150 | + $update->doUpdate(); |
| 151 | + $update = SquidUpdate::newSimplePurge( $user->getUserPage() ); |
| 152 | + $update->doUpdate(); |
| 153 | + } |
| 154 | + } |
| 155 | + return true; |
| 156 | + } |
| 157 | + |
| 158 | + /** |
132 | 159 | * Insert to the database |
133 | 160 | * @return bool |
134 | 161 | */ |
— | — | @@ -160,7 +187,7 @@ |
161 | 188 | } |
162 | 189 | } |
163 | 190 | // if user doesn't want to be tracked leave him aswel for privacy reasons |
164 | | - if ( !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
| 191 | + if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
165 | 192 | return false; |
166 | 193 | } |
167 | 194 | if ( OnlineStatusBar::GetStatus( $wgUser, true ) == $wgOnlineStatusBarDefaultOffline ) { |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -28,16 +28,20 @@ |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | 31 | public static function logout( &$user, &$inject_html, $old_name ) { |
| 32 | + // this doesn't work yet |
| 33 | + //OnlineStatusBar::purge( $old_name, null ); |
32 | 34 | OnlineStatusBar::DeleteStatus( $old_name ); |
33 | 35 | return true; |
34 | 36 | } |
35 | 37 | |
36 | 38 | /** |
37 | | - * Called everytime when it's needed to update db |
| 39 | + * Called everytime on login |
38 | 40 | * @return bool |
39 | 41 | */ |
40 | 42 | public static function updateStatus() { |
41 | | - OnlineStatusBar::UpdateDb(); |
| 43 | + global $wgUser; |
| 44 | + OnlineStatusBar::purge( "", $wgUser ); |
| 45 | + OnlineStatusBar::UpdateStatus(); |
42 | 46 | return true; |
43 | 47 | } |
44 | 48 | |