Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -126,18 +126,21 @@ |
127 | 127 | * @return string |
128 | 128 | */ |
129 | 129 | static function GetStatus( $userName ) { |
130 | | - global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname; |
| 130 | + global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultIpUsers, $wgOnlineStatusBarDefaultOnline, $wgDBname; |
131 | 131 | $dbw = wfGetDB( DB_MASTER ); |
132 | 132 | OnlineStatusBar::DeleteOld(); |
133 | 133 | $user = User::newFromName( $userName ); |
134 | | - if ( $user == null ) { |
| 134 | + if ( $user == null && User::isIP ( $userName ) != true ) { |
135 | 135 | // something is wrong |
136 | 136 | return $wgOnlineStatusBarDefaultOffline; |
137 | 137 | } |
138 | 138 | $result = $dbw->selectField( 'online_status', 'username', array( 'username' => $userName ), |
139 | 139 | __METHOD__, array( 'limit 1', 'order by timestamp desc' ) ); |
140 | | - if ( $result ) { |
| 140 | + if ( $result && $user != null ) { |
141 | 141 | return $user->getOption( "OnlineStatusBar_status", $wgOnlineStatusDefaultOnline ); |
| 142 | + } else if ( $result && User::isIP ( $userName ) && $wgOnlineStatusBarDefaultIpUsers ) { |
| 143 | + // user is anon |
| 144 | + return $wgOnlineStatusBarDefaultOnline; |
142 | 145 | } |
143 | 146 | return $wgOnlineStatusBarDefaultOffline; |
144 | 147 | } |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -47,23 +47,36 @@ |
48 | 48 | * @return bool
|
49 | 49 | */
|
50 | 50 | public static function renderBar( &$article, &$outputDone, &$pcache ) {
|
51 | | - global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarModes, $wgOut;
|
| 51 | + global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarDefaultIpUsers, $wgOnlineStatusBarModes, $wgOut;
|
52 | 52 | OnlineStatusBar::UpdateStatus();
|
| 53 | + $anon = false;
|
53 | 54 | $ns = $article->getTitle()->getNamespace();
|
54 | 55 | if ( ( $ns == NS_USER_TALK ) || ( $ns == NS_USER ) ) {
|
55 | 56 | $user = OnlineStatusBar::GetOwnerFromTitle ( $article->getTitle() );
|
56 | | - if ( $user == null ) {
|
| 57 | + $userName = $article->getTitle()->getBaseText();
|
| 58 | + if ( User::isIP ( $userName ) != true && $user == null ) {
|
57 | 59 | return true;
|
58 | 60 | }
|
59 | | - $username = $user->getName();
|
60 | | - if ( $user->getOption ( "OnlineStatusBar_hide" ) == true ) {
|
61 | | - return true;
|
| 61 | + if ( User::isIP ( $userName ) && $user == null && $wgOnlineStatusBarDefaultIpUsers ) {
|
| 62 | + // it's anon user and we want to track them
|
| 63 | + $sanitizedusername = $userName;
|
| 64 | + $anon = true;
|
| 65 | + } else {
|
| 66 | + // Fix capitalisation issues
|
| 67 | + $sanitizedusername = $user->getName();
|
62 | 68 | }
|
63 | | - if ( OnlineStatusBar::IsValid( $username ) ) {
|
64 | | - $mode = OnlineStatusBar::GetStatus( $username );
|
| 69 | + if ( $anon == false )
|
| 70 | + {
|
| 71 | + //we don't want to check this
|
| 72 | + if ( $user->getOption ( "OnlineStatusBar_hide" ) == true ) {
|
| 73 | + return true;
|
| 74 | + }
|
| 75 | + }
|
| 76 | + if ( OnlineStatusBar::IsValid( $userName ) ) {
|
| 77 | + $mode = OnlineStatusBar::GetStatus( $userName );
|
65 | 78 | $modetext = $wgOnlineStatusBarModes[$mode];
|
66 | 79 | $image = OnlineStatusBar::getImageHtml( $mode );
|
67 | | - $text = wfMessage( 'onlinestatusbar-line', $username )->rawParams( $image )->params( $modetext )->escaped();
|
| 80 | + $text = wfMessage( 'onlinestatusbar-line', $userName )->rawParams( $image )->params( $modetext )->escaped();
|
68 | 81 | $wgOut->addHtml( OnlineStatusBar::Get_Html( $text, $mode ) );
|
69 | 82 | }
|
70 | 83 | }
|
— | — | @@ -143,6 +156,11 @@ |
144 | 157 | public static function parserGetVariable ( &$parser, &$varCache, &$index, &$ret ){
|
145 | 158 | global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline;
|
146 | 159 | if( $index == 'isonline' ){
|
| 160 | + $ns = $parser->getTitle()->getNamespace();
|
| 161 | + if ( ( $ns != NS_USER_TALK ) && ( $ns != NS_USER ) ) {
|
| 162 | + $ret = "unknown";
|
| 163 | + return true;
|
| 164 | + }
|
147 | 165 | $name = OnlineStatusBar::GetOwnerFromTitle ( $parser->getTitle() )->getName();
|
148 | 166 |
|
149 | 167 | if ( OnlineStatusBar::IsValid($name) != true ) {
|