Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -40,17 +40,16 @@ |
41 | 41 | |
42 | 42 | static function UpdateDb() |
43 | 43 | { |
44 | | - global $wgUser, $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarTable; |
45 | | - if ( OnlineStatusBar::GetStatus( $wgUser->getID() ) != $wgOnlineStatusBarDefaultOnline ) |
| 44 | + global $wgUser, $wgOnlineStatusBarDefaultOnlinee; |
| 45 | + if ( OnlineStatusBar::GetStatus( $wgUser->getName() ) != $wgOnlineStatusBarDefaultOnline ) |
46 | 46 | { |
47 | 47 | $dbw = wfGetDB( DB_MASTER ); |
48 | | - $now = OnlineStatusBar::GetNow(); |
49 | 48 | $row = array( |
50 | 49 | 'userid' => $wgUser->getID(), |
51 | 50 | 'username' => $wgUser->getName(), |
52 | 51 | 'timestamp' => $dbw->timestamp( wfTimestamp() ), |
53 | 52 | ); |
54 | | - $dbw->insert( $wgOnlineStatusBarTable, $row, __METHOD__, 'DELAYED' ); |
| 53 | + $dbw->insert( 'online_status', $row, __METHOD__, 'DELAYED' ); |
55 | 54 | } |
56 | 55 | |
57 | 56 | return false; |
— | — | @@ -58,16 +57,15 @@ |
59 | 58 | |
60 | 59 | static function UpdateStatus() |
61 | 60 | { |
62 | | - global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTable; |
63 | | - $now = OnlineStatusBar::GetNow(); |
64 | | - if ( OnlineStatusBar::GetStatus( $wgUser->getId() ) == $wgOnlineStatusBarDefaultOffline ) |
| 61 | + global $wgUser, $wgOnlineStatusBarDefaultOffline; |
| 62 | + if ( OnlineStatusBar::GetStatus( $wgUser->getName() ) == $wgOnlineStatusBarDefaultOffline ) |
65 | 63 | { |
66 | 64 | OnlineStatusBar::UpdateDb(); |
67 | 65 | return true; |
68 | 66 | } |
69 | 67 | $dbw = wfGetDB( DB_MASTER ); |
70 | 68 | $dbw->update( |
71 | | - $wgOnlineStatusBarTable, |
| 69 | + 'online_status', |
72 | 70 | array( 'timestamp' => $dbw->timestamp( wfTimestamp() ) ), |
73 | 71 | array( 'username' => $wgUser->getID() ), |
74 | 72 | __METHOD__ |
— | — | @@ -79,20 +77,20 @@ |
80 | 78 | |
81 | 79 | public static function DeleteOld() |
82 | 80 | { |
83 | | - global $wgOnlineStatusBar_LogoutTime, $wgDBname, $wgOnlineStatusBarTable; |
| 81 | + global $wgOnlineStatusBar_LogoutTime, $wgDBname; |
84 | 82 | $dbw = wfGetDB( DB_MASTER ); |
85 | 83 | $time = wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
86 | | - $time = $dbw->addQuotes( $dbw->timestamp( $time ) ); |
87 | | - $dbw->delete( $wgOnlineStatusBarTable, array( "timestamp < $time" ) , __METHOD__ ); |
| 84 | + $time = $dbw->addQuotes( $dbw->timestamp( $time ) - $wgOnlineStatusBar_LogoutTime ); |
| 85 | + $dbw->delete( 'online_status', array( "timestamp < $time" ) , __METHOD__ ); |
88 | 86 | return 0; |
89 | 87 | } |
90 | 88 | |
91 | 89 | static function GetStatus( $userID ) { |
92 | | - global $wgOnlineStatusBarModes, $wgOnlineStatusBarTable, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname; |
| 90 | + global $wgOnlineStatusBarModes, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline, $wgDBname; |
93 | 91 | $dbw = wfGetDB( DB_MASTER ); |
94 | 92 | OnlineStatusBar::DeleteOld(); |
95 | | - $result = $dbw->selectField( 'online_status', 'userid', array( 'userid' => $userID ), __METHOD__, array( 'limit 1', 'order by timestamp desc' ) ); |
96 | | - if ( $result ) |
| 93 | + $result = $dbw->selectField( 'online_status', 'username', array( 'username' => $userID ), __METHOD__, array( 'limit 1', 'order by timestamp desc' ) ); |
| 94 | + if ( $result ); |
97 | 95 | { |
98 | 96 | return $wgOnlineStatusBarDefaultOnline; |
99 | 97 | } |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -30,7 +30,6 @@ |
31 | 31 | |
32 | 32 | // Configuration |
33 | 33 | // Those values can be overriden in LocalSettings, do not change it here |
34 | | -$wgOnlineStatusBarTable = "online_status"; |
35 | 34 | $wgOnlineStatusBarModes = array ( |
36 | 35 | 'online' => "On-line", |
37 | 36 | 'busy' => "Busy", |