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