r100507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100506‎ | r100507 | r100508 >
Date:17:50, 22 October 2011
Author:petrb
Status:deferred
Tags:
Comment:
fixed timeout value
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -15,8 +15,6 @@
1616 */
1717
1818 class OnlineStatusBar {
19 - public static $Timeout = 8000;
20 -
2119 private static function GetNow()
2220 {
2321 return gmdate('Ymdhis', time());
@@ -29,8 +27,7 @@
3028 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>';
3129 }
3230
33 -
34 - static function UpdateDb($user, $db)
 31+ static function UpdateDb()
3532 {
3633 global $wgUser, $wgDBname, $wgOnlineStatusBarTable;
3734 if ( OnlineStatusBar::GetStatus($wgUser->getID()) != $OnlineStatusBar->DefaultOnline )
@@ -48,12 +45,29 @@
4946
5047 return false;
5148 }
 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;
5264
 65+ }
 66+
5367 public static function DeleteOld()
5468 {
55 - global $wgOnlineStatusBarTable, $wgDBname;
 69+ global $wgOnlineStatusBarTable, $wgOnlineStatusBar_LogoutTime, $wgDBname;
5670 $db = wfGetDB ( DB_MASTER );
57 - $time = OnlineStatusBar::GetNow() - $Timeout;
 71+ $time = OnlineStatusBar::GetNow() - $wgOnlineStatusBar_LogoutTime;
5872 $db->SelectDB( $wgDBname );
5973 $db->delete( $wgOnlineStatusBarTable, array( 'timestamp < "' . $time . '"' ) ,__METHOD__ );
6074 return 0;
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -82,6 +82,7 @@
8383 function wfOnlineStatusBar_RenderBar(&$article, &$outputDone, &$pcache)
8484 {
8585 global $wgOnlineStatusBar_Template, $messages, $wgOnlineStatusBarModes, $wgOut;
 86+ OnlineStatusBar::UpdateStatus();
8687 $ns=$article->getTitle()->getNamespace();
8788 if(($ns == "3") || ($ns == "2"))
8889 {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100501Work in progress, extension which adds a status if user is online, there is s...petrb16:47, 22 October 2011

Status & tagging log