Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -32,15 +32,14 @@ |
33 | 33 | global $wgUser, $wgDBname, $wgOnlineStatusBarTable; |
34 | 34 | if ( OnlineStatusBar::GetStatus($wgUser->getID()) != $OnlineStatusBar->DefaultOnline ) |
35 | 35 | { |
36 | | - $db = wfGetDB( DB_MASTER ); |
37 | | - $db->SelectDB( $wgDBname ); |
| 36 | + $dbw = wfGetDB( DB_MASTER ); |
38 | 37 | $now = OnlineStatusBar::GetNow(); |
39 | 38 | $row = array( |
40 | 39 | 'userid' => $wgUser->getID(), |
41 | 40 | 'username' => $wgUser->getName(), |
42 | 41 | 'timestamp' => $now, |
43 | 42 | ); |
44 | | - $db->insert( $wgOnlineStatusBarTable, $row, __METHOD__, 'DELAYED' ); |
| 43 | + $dbw->insert( $wgOnlineStatusBarTable, $row, __METHOD__, 'DELAYED' ); |
45 | 44 | } |
46 | 45 | |
47 | 46 | return false; |
— | — | @@ -55,9 +54,8 @@ |
56 | 55 | OnlineStatusBar::UpdateDb(); |
57 | 56 | return true; |
58 | 57 | } |
59 | | - $db = wfGetDB ( DB_MASTER ); |
60 | | - $db->SelectDB( $wgDBname ); |
61 | | - $db->update($wgOnlineStatusBarTable, array ('timestamp' => $now), array ('username' => $wgUser->getName()), __METHOD__ ); |
| 58 | + $dbw = wfGetDB ( DB_MASTER ); |
| 59 | + $dbw->update($wgOnlineStatusBarTable, array ('timestamp' => $now), array ('username' => $wgUser->getName()), __METHOD__ ); |
62 | 60 | |
63 | 61 | return false; |
64 | 62 | |
— | — | @@ -66,10 +64,9 @@ |
67 | 65 | public static function DeleteOld() |
68 | 66 | { |
69 | 67 | global $wgOnlineStatusBarTable, $wgOnlineStatusBar_LogoutTime, $wgDBname; |
70 | | - $db = wfGetDB ( DB_MASTER ); |
| 68 | + $dbw= wfGetDB ( DB_MASTER ); |
71 | 69 | $time = OnlineStatusBar::GetNow() - $wgOnlineStatusBar_LogoutTime; |
72 | | - $db->SelectDB( $wgDBname ); |
73 | | - $db->delete( $wgOnlineStatusBarTable, array( 'timestamp < "' . $time . '"' ) ,__METHOD__ ); |
| 70 | + $dbw->delete( $wgOnlineStatusBarTable, array( 'timestamp < "' . $time . '"' ) ,__METHOD__ ); |
74 | 71 | return 0; |
75 | 72 | } |
76 | 73 | |
— | — | @@ -83,11 +80,10 @@ |
84 | 81 | |
85 | 82 | static function GetStatus( $userID ) { |
86 | 83 | global $wgOnlineStatusBarTable, $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname; |
87 | | - $db = wfGetDB ( DB_MASTER ); |
| 84 | + $dbw= wfGetDB ( DB_MASTER ); |
88 | 85 | OnlineStatusBar::DeleteOld(); |
89 | | - $db->SelectDB( $wgDBname ); |
90 | | - $result = $db->select( $wgOnlineStatusBarTable, array ('userid', 'username', 'timestamp'), array('username' => $userID), __METHOD__, array('limit 1', 'order by timestamp desc')); |
91 | | - $values = new ResultWrapper ($db, $result); |
| 86 | + $result = $dbw->select( $wgOnlineStatusBarTable, array ('userid', 'username', 'timestamp'), array('username' => $userID), __METHOD__, array('limit 1', 'order by timestamp desc')); |
| 87 | + $values = new ResultWrapper ($dbw, $result); |
92 | 88 | |
93 | 89 | if ($values->numRows() > 0) |
94 | 90 | { |
— | — | @@ -100,11 +96,8 @@ |
101 | 97 | static function DeleteStatus( $user ) |
102 | 98 | { |
103 | 99 | global $wgOnlineStatusBarTable, $wgDBname; |
104 | | - $db = wfGetDB ( DB_MASTER ); |
105 | | - $db->SelectDB( $wgDBname ); |
106 | | - $db->delete( $wgOnlineStatusBarTable, array ('username' => $user), __METHOD__ ); // delete user |
| 100 | + $dbw= wfGetDB ( DB_MASTER ); |
| 101 | + $dbw->delete( $wgOnlineStatusBarTable, array ('username' => $user), __METHOD__ ); // delete user |
107 | 102 | return true; |
108 | 103 | } |
109 | 104 | } |
110 | | - |
111 | | -?> |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarModes, $wgOut; |
100 | 100 | OnlineStatusBar::UpdateStatus(); |
101 | 101 | $ns=$article->getTitle()->getNamespace(); |
102 | | - if(($ns == "3") || ($ns == "2")) |
| 102 | + if(($ns == NS_USER_TALK) || ($ns == NS_USER)) |
103 | 103 | { |
104 | 104 | // better way to get a username would be great :) |
105 | 105 | $user = preg_replace('/\/.*/', '', preg_replace('/^.*\:/', "", $article->getTitle())); |
— | — | @@ -114,13 +114,11 @@ |
115 | 115 | function wfOnlineStatusBar_UpdateStatus() |
116 | 116 | { |
117 | 117 | OnlineStatusBar::UpdateDb(); |
118 | | - return 0; |
| 118 | + return true; |
119 | 119 | } |
120 | 120 | |
121 | 121 | |
122 | 122 | $commonModuleInfo = array( |
123 | 123 | 'localBasePath' => dirname( __FILE__ ) . '/modules', |
124 | 124 | 'remoteExtPath' => 'OnlineStatusBar/modules', |
125 | | -); |
126 | | - |
127 | | -?> |
| 125 | + ); |