Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * @return string |
34 | 34 | */ |
35 | 35 | public static function GetImageHtml( $mode ) { |
36 | | - global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon, $wgOnlineStatusBarModes; |
| 36 | + global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon; |
37 | 37 | $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}"; |
38 | 38 | return Html::element( 'img', array( 'src' => $icon ) ); |
39 | 39 | } |
— | — | @@ -46,19 +46,22 @@ |
47 | 47 | */ |
48 | 48 | public static function getAnonFromTitle( Title $title ) { |
49 | 49 | global $wgOnlineStatusBarTrackIpUsers; |
| 50 | + // if user is anon and we don't track them stop |
50 | 51 | if ( $wgOnlineStatusBarTrackIpUsers == false ) { |
51 | 52 | return false; |
52 | 53 | } |
53 | 54 | |
| 55 | + // checks ns |
54 | 56 | if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) { |
55 | 57 | return false; |
56 | 58 | } |
57 | 59 | |
| 60 | + // we need to create temporary user object |
58 | 61 | $user = User::newFromId( 0 ); |
59 | 62 | $user->setName( $title->getBaseText() ); |
60 | 63 | |
61 | 64 | // Check if something wrong didn't happen |
62 | | - if ( $user === false ) { |
| 65 | + if ( !($user instanceof User) ) { |
63 | 66 | return false; |
64 | 67 | } |
65 | 68 | |
— | — | @@ -102,7 +105,7 @@ |
103 | 106 | // remove old entries |
104 | 107 | if ( $update ) |
105 | 108 | { |
106 | | - self::DeleteOld(); |
| 109 | + self::deleteOld(); |
107 | 110 | } |
108 | 111 | |
109 | 112 | // instead of delete every time just select the records which are not that old |
— | — | @@ -161,10 +164,10 @@ |
162 | 165 | * Insert to the database |
163 | 166 | * @return bool |
164 | 167 | */ |
165 | | - public static function UpdateDb() { |
166 | | - global $wgUser, $wgOnlineStatusBarDefaultOnline; |
| 168 | + public static function updateDb() { |
| 169 | + global $wgUser; |
167 | 170 | // Skip users we don't track |
168 | | - if ( self::IsValid ( $wgUser ) != true ) { |
| 171 | + if ( self::isValid ( $wgUser ) != true ) { |
169 | 172 | return false; |
170 | 173 | } |
171 | 174 | // If we track them, let's insert it to the table |
— | — | @@ -181,7 +184,7 @@ |
182 | 185 | * Update status of user |
183 | 186 | * @return bool |
184 | 187 | */ |
185 | | - public static function UpdateStatus() { |
| 188 | + public static function updateStatus() { |
186 | 189 | global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled; |
187 | 190 | // if anon users are not tracked and user is anon leave it |
188 | 191 | if ( !$wgOnlineStatusBarTrackIpUsers ) { |
— | — | @@ -193,8 +196,8 @@ |
194 | 197 | if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
195 | 198 | return false; |
196 | 199 | } |
197 | | - if ( OnlineStatusBar::GetStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) { |
198 | | - OnlineStatusBar::UpdateDb(); |
| 200 | + if ( OnlineStatusBar::getStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) { |
| 201 | + OnlineStatusBar::updateDb(); |
199 | 202 | return true; |
200 | 203 | } |
201 | 204 | |
— | — | @@ -221,7 +224,7 @@ |
222 | 225 | * Delete old records from the table, this function is called frequently too keep it as small as possible |
223 | 226 | * @return int |
224 | 227 | */ |
225 | | - public static function DeleteOld() { |
| 228 | + public static function deleteOld() { |
226 | 229 | $dbw = wfGetDB( DB_MASTER ); |
227 | 230 | // calculate time and convert it back to mediawiki format |
228 | 231 | $time = self::getTimeoutDate(); |
— | — | @@ -253,7 +256,7 @@ |
254 | 257 | * @param $userName string |
255 | 258 | * @return bool |
256 | 259 | */ |
257 | | - static function DeleteStatus( $userName ) { |
| 260 | + static function deleteStatus( $userName ) { |
258 | 261 | $dbw = wfGetDB( DB_MASTER ); |
259 | 262 | $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user |
260 | 263 | return true; |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | */ |
31 | 31 | public static function logout( &$user, &$inject_html, $old_name ) { |
32 | 32 | OnlineStatusBar::purge( $old_name ); |
33 | | - OnlineStatusBar::DeleteStatus( $old_name ); |
| 33 | + OnlineStatusBar::deleteStatus( $old_name ); |
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | public static function updateStatus() { |
42 | 42 | global $wgUser; |
43 | 43 | OnlineStatusBar::purge( $wgUser ); |
44 | | - OnlineStatusBar::UpdateStatus(); |
| 44 | + OnlineStatusBar::updateStatus(); |
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | public static function renderBar( &$article, &$outputDone, &$pcache ) { |
56 | 56 | $context = $article->getContext(); |
57 | 57 | |
58 | | - OnlineStatusBar::UpdateStatus(); |
| 58 | + OnlineStatusBar::updateStatus(); |
59 | 59 | $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() ); |
60 | 60 | if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) { |
61 | 61 | $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() ); |