Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -51,6 +51,9 @@ |
52 | 52 | |
53 | 53 | OnlineStatusBar::UpdateStatus(); |
54 | 54 | $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() ); |
| 55 | + if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) { |
| 56 | + $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() ); |
| 57 | + } |
55 | 58 | |
56 | 59 | if ( $result === false ) { |
57 | 60 | return true; |
— | — | @@ -158,4 +161,4 @@ |
159 | 162 | $ret = $result[0]; |
160 | 163 | return true; |
161 | 164 | } |
162 | | -} |
\ No newline at end of file |
| 165 | +} |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -38,6 +38,36 @@ |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
| 42 | + * Returns the status and User element |
| 43 | + * |
| 44 | + * @param Title $title |
| 45 | + * @return array|bool Array containing the status and User object |
| 46 | + */ |
| 47 | + public static function getAnonFromTitle( Title $title ) { |
| 48 | + global $wgOnlineStatusBarTrackIpUsers; |
| 49 | + if ( $wgOnlineStatusBarTrackIpUsers == false ) { |
| 50 | + return false; |
| 51 | + } |
| 52 | + |
| 53 | + if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) { |
| 54 | + return false; |
| 55 | + } |
| 56 | + |
| 57 | + $user = User::newFromId( 0 ); |
| 58 | + $user->setName( $title->getBaseText() ); |
| 59 | + |
| 60 | + // Check if something wrong didn't happen |
| 61 | + if ( $user === false ) { |
| 62 | + return false; |
| 63 | + } |
| 64 | + |
| 65 | + $status = self::getStatus( $user ); |
| 66 | + |
| 67 | + return array( $status, $user ); |
| 68 | + } |
| 69 | + |
| 70 | + |
| 71 | + /** |
42 | 72 | * Returns the status and User element |
43 | 73 | * |
44 | 74 | * @param Title $title |
— | — | @@ -53,7 +83,6 @@ |
54 | 84 | if ( $user === false ) { |
55 | 85 | return false; |
56 | 86 | } |
57 | | - |
58 | 87 | if ( !self::isValid( $user ) ) { |
59 | 88 | return false; |
60 | 89 | } |
— | — | @@ -79,7 +108,12 @@ |
80 | 109 | if ( $result === false ) { |
81 | 110 | $status = $wgOnlineStatusBarDefaultOffline; |
82 | 111 | } else { |
83 | | - $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline ); |
| 112 | + // let's check if it isn't anon |
| 113 | + if ( $user->isLoggedIn() ) { |
| 114 | + $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline ); |
| 115 | + } else { |
| 116 | + $status = $wgOnlineStatusBarDefaultOnline; |
| 117 | + } |
84 | 118 | } |
85 | 119 | |
86 | 120 | if ( $status == 'hidden' ) { |
— | — | @@ -136,8 +170,6 @@ |
137 | 171 | global $wgOnlineStatusBar_LogoutTime; |
138 | 172 | $dbw = wfGetDB( DB_MASTER ); |
139 | 173 | $time = wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
140 | | - // FIXME: This looks wrong: |
141 | | - $time = $dbw->addQuotes( $dbw->timestamp( $time ) - $wgOnlineStatusBar_LogoutTime ); |
142 | 174 | $dbw->delete( 'online_status', array( "timestamp < $time" ), __METHOD__ ); |
143 | 175 | return 0; |
144 | 176 | } |