Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | */ |
17 | 17 | |
18 | 18 | class OnlineStatusBar { |
19 | | - public static $Timeout = 8000; |
20 | | - |
21 | 19 | private static function GetNow() |
22 | 20 | { |
23 | 21 | return gmdate('Ymdhis', time()); |
— | — | @@ -29,8 +27,7 @@ |
30 | 28 | return '<div style="border: 0px solid black; background: transparent; float: right; position: relative; top:-3px; padding: 5px"><p><b>' . $text . ': <span style="color: ' . $color . '; font:bold;"><img alt="Ledorange.svg" src="//upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Ledorange.svg/20px-Ledorange.svg.png" width="20" height="20" />' . $wgOnlineStatusBarModes[$mode] . '</span></b></p></div>'; |
31 | 29 | } |
32 | 30 | |
33 | | - |
34 | | - static function UpdateDb($user, $db) |
| 31 | + static function UpdateDb() |
35 | 32 | { |
36 | 33 | global $wgUser, $wgDBname, $wgOnlineStatusBarTable; |
37 | 34 | if ( OnlineStatusBar::GetStatus($wgUser->getID()) != $OnlineStatusBar->DefaultOnline ) |
— | — | @@ -48,12 +45,29 @@ |
49 | 46 | |
50 | 47 | return false; |
51 | 48 | } |
| 49 | + |
| 50 | + static function UpdateStatus() |
| 51 | + { |
| 52 | + global $wgUser, $wgDBname, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTable; |
| 53 | + $now = OnlineStatusBar::GetNow(); |
| 54 | + if (OnlineStatusBar::GetStatus() != $wgOnlineStatusBarDefaultOffline) |
| 55 | + { |
| 56 | + OnlineStatusBar::UpdateDb(); |
| 57 | + return true; |
| 58 | + } |
| 59 | + $db = wfGetDB ( DB_MASTER ); |
| 60 | + $db->SelectDB( $wgDBname ); |
| 61 | + $db->update($wgOnlineStatusBarTable, array ('timestamp' => $now), array ('username' => $wgUser->getName()), __METHOD__ ); |
| 62 | + |
| 63 | + return false; |
52 | 64 | |
| 65 | + } |
| 66 | + |
53 | 67 | public static function DeleteOld() |
54 | 68 | { |
55 | | - global $wgOnlineStatusBarTable, $wgDBname; |
| 69 | + global $wgOnlineStatusBarTable, $wgOnlineStatusBar_LogoutTime, $wgDBname; |
56 | 70 | $db = wfGetDB ( DB_MASTER ); |
57 | | - $time = OnlineStatusBar::GetNow() - $Timeout; |
| 71 | + $time = OnlineStatusBar::GetNow() - $wgOnlineStatusBar_LogoutTime; |
58 | 72 | $db->SelectDB( $wgDBname ); |
59 | 73 | $db->delete( $wgOnlineStatusBarTable, array( 'timestamp < "' . $time . '"' ) ,__METHOD__ ); |
60 | 74 | return 0; |
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -82,6 +82,7 @@ |
83 | 83 | function wfOnlineStatusBar_RenderBar(&$article, &$outputDone, &$pcache) |
84 | 84 | { |
85 | 85 | global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarModes, $wgOut; |
| 86 | + OnlineStatusBar::UpdateStatus(); |
86 | 87 | $ns=$article->getTitle()->getNamespace(); |
87 | 88 | if(($ns == "3") || ($ns == "2")) |
88 | 89 | { |