r104281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104280‎ | r104281 | r104282 >
Date:17:21, 26 November 2011
Author:petrb
Status:deferred (Comments)
Tags:
Comment:
new feature now switch user to away if idle for some time, needs language fix
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php
@@ -22,6 +22,8 @@
2323 'onlinestatusbar-used' => 'Display your online status on your user pages',
2424 // Message in config asking what status they want to use
2525 'onlinestatusbar-status' => 'What is the default status you wish to use:',
 26+ // Message in config about away time
 27+ 'onlinestatusbar-away' => 'Treat as away automaticaly after $1 minutes',
2628 // Message in config asking if user wants to purge the user page
2729 'onlinestatusbar-purge' => 'Purge user page everytime when you login or logout',
2830 // Section for config
@@ -51,6 +53,7 @@
5254 'onlinestatusbar-purge' => 'Option to purge user page everytime they login so that magic word is updated',
5355 'prefs-onlinestatus' => 'Section for config, located in preferences - misc',
5456 'onlinestatusbar-hide' => 'Ask user if they want to hide status bar this is useful when they are using custom template but need to check if they are online',
 57+ 'onlinestatusbar-away' => 'Time in minutes how long to wait until user is flagged as away',
5558 'onlinestatusbar-status-online' => 'Status for users who mark themselves as active',
5659 'onlinestatusbar-status-busy' => 'Status for users who mark themselves as busy',
5760 'onlinestatusbar-status-away' => 'Status for users who mark themselves as away',
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php
@@ -98,6 +98,10 @@
9999 if ( $result < wfTimestamp( TS_MW, $w_time ) ) {
100100 $status = 'write';
101101 }
 102+ } else if ( $user->getOption( 'OnlineStatusBar_away', true ) == true ) {
 103+ if ( $result < wfTimestamp( TS_MW, OnlineStatusBar::getTimeoutDate( false, true ) ) ) {
 104+ $status = 'away';
 105+ }
102106 }
103107 } else {
104108 $status = $wgOnlineStatusBarDefaultOnline;
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -131,9 +131,13 @@
132132 /**
133133 * @return timestamp
134134 */
135 - public static function getTimeoutDate( $delayed = false ) {
136 - global $wgOnlineStatusBar_WriteTime, $wgOnlineStatusBar_LogoutTime;
 135+ public static function getTimeoutDate( $delayed = false, $away = false ) {
 136+ global $wgOnlineStatusBar_AwayTime, $wgOnlineStatusBar_WriteTime, $wgOnlineStatusBar_LogoutTime;
137137
 138+ if ($away) {
 139+ return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_AwayTime;
 140+ }
 141+
138142 if ($delayed) {
139143 return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_WriteTime;
140144 }
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.php
@@ -109,6 +109,8 @@
110110 $wgOnlineStatusBarDefaultEnabled = false;
111111 // how long to wait until user is considered as offline
112112 $wgOnlineStatusBar_LogoutTime = 3600;
 113+// time to wait until we consider user away
 114+$wgOnlineStatusBar_AwayTime = 20 * 60; // 20 minutes
113115
114116 $wgHooks['LoadExtensionSchemaUpdates'][] = 'OnlineStatusBarHooks::ckSchema';
115117 $wgHooks['UserLogoutComplete'][] = 'OnlineStatusBarHooks::logout';
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -101,9 +101,10 @@
102102 * @return bool
103103 */
104104 public static function preferencesHook( User $user, array &$preferences ) {
105 - global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBarModes;
 105+ global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBar_AwayTime, $wgOnlineStatusBarModes;
106106 $preferences['OnlineStatusBar_active'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-used', 'section' => 'misc/onlinestatus' );
107107 $preferences['OnlineStatusBar_hide'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-hide', 'section' => 'misc/onlinestatus' );
 108+ $preferences['OnlineStatusBar_away'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-away', 'section' => 'misc/onlinestatus' );
108109 $preferences['OnlineStatusBar_autoupdate'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-purge', 'section' => 'misc/onlinestatus' );
109110 $preferences['OnlineStatusBar_status'] = array( 'type' => 'radio', 'label-message' => 'onlinestatusbar-status', 'section' => 'misc/onlinestatus',
110111 'options' => array(
@@ -125,6 +126,7 @@
126127 // set defaults
127128 $defaultOptions['OnlineStatusBar_autoupdate'] = false;
128129 $defaultOptions['OnlineStatusBar_status'] = $wgOnlineStatusBarDefaultOnline;
 130+ $defaultOptions['OnlineStatusBar_away'] = true;
129131 $defaultOptions['OnlineStatusBar_active'] = $wgOnlineStatusBarDefaultEnabled;
130132 $defaultOptions['OnlineStatusBar_hide'] = false;
131133 // quit

Follow-up revisions

RevisionCommit summaryAuthorDate
r104302since time is in options there is no need to display itpetrb20:50, 26 November 2011
r104305english rewordedpetrb21:01, 26 November 2011

Comments

#Comment by Raymond (talk | contribs)   17:58, 26 November 2011

Needs 'onlinestatusbar-away' PLURAL for $1: {{PLURAL:$1|$1 minute|$1 minutes}} for proper localication.

#Comment by Petrb (talk | contribs)   19:07, 26 November 2011

I got no idea how to do that neither how to replace $1 with number

#Comment by Petrb (talk | contribs)   21:07, 26 November 2011

resolved since I deleted whole thing

Status & tagging log