Index: branches/REL1_17/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * @return string |
34 | 34 | */ |
35 | 35 | public static function GetImageHtml( $mode ) { |
36 | | - global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon, $wgOnlineStatusBarModes; |
| 36 | + global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon; |
37 | 37 | $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}"; |
38 | 38 | return Html::element( 'img', array( 'src' => $icon ) ); |
39 | 39 | } |
— | — | @@ -46,23 +46,26 @@ |
47 | 47 | */ |
48 | 48 | public static function getAnonFromTitle( Title $title ) { |
49 | 49 | global $wgOnlineStatusBarTrackIpUsers; |
| 50 | + // if user is anon and we don't track them stop |
50 | 51 | if ( $wgOnlineStatusBarTrackIpUsers == false ) { |
51 | 52 | return false; |
52 | 53 | } |
53 | 54 | |
| 55 | + // checks ns |
54 | 56 | if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) { |
55 | 57 | return false; |
56 | 58 | } |
57 | 59 | |
| 60 | + // we need to create temporary user object |
58 | 61 | $user = User::newFromId( 0 ); |
59 | 62 | $user->setName( $title->getBaseText() ); |
60 | 63 | |
61 | 64 | // Check if something wrong didn't happen |
62 | | - if ( $user === false ) { |
| 65 | + if ( !($user instanceof User) ) { |
63 | 66 | return false; |
64 | 67 | } |
65 | 68 | |
66 | | - $status = self::getStatus( $user ); |
| 69 | + $status = self::getStatus( $user, true ); |
67 | 70 | |
68 | 71 | return array( $status, $user ); |
69 | 72 | } |
— | — | @@ -81,14 +84,14 @@ |
82 | 85 | |
83 | 86 | $user = User::newFromName( $title->getBaseText() ); |
84 | 87 | // Invalid user |
85 | | - if ( $user === false ) { |
| 88 | + if ( !($user instanceof User) ) { |
86 | 89 | return false; |
87 | 90 | } |
88 | 91 | if ( !self::isValid( $user ) ) { |
89 | 92 | return false; |
90 | 93 | } |
91 | 94 | |
92 | | - $status = self::getStatus( $user ); |
| 95 | + $status = self::getStatus( $user, true ); |
93 | 96 | |
94 | 97 | return array( $status, $user ); |
95 | 98 | } |
— | — | @@ -102,11 +105,14 @@ |
103 | 106 | // remove old entries |
104 | 107 | if ( $update ) |
105 | 108 | { |
106 | | - self::DeleteOld(); |
| 109 | + self::deleteOld(); |
107 | 110 | } |
108 | 111 | |
| 112 | + // instead of delete every time just select the records which are not that old |
| 113 | + $t_time = self::getTimeoutDate(); |
109 | 114 | $dbr = wfGetDB( DB_SLAVE ); |
110 | | - $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName() ), |
| 115 | + $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName(), |
| 116 | + "timestamp > " . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ), |
111 | 117 | __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) ); |
112 | 118 | |
113 | 119 | if ( $result === false ) { |
— | — | @@ -128,13 +134,40 @@ |
129 | 135 | } |
130 | 136 | |
131 | 137 | /** |
| 138 | + * Purge page |
| 139 | + * @return bool |
| 140 | + * |
| 141 | + */ |
| 142 | + public static function purge( $user_type ) { |
| 143 | + if ( $user_type instanceof User ) { |
| 144 | + $user = $user_type; |
| 145 | + } else if ( is_string( $user_type ) ){ |
| 146 | + $user = User::newFromName( $user_type ); |
| 147 | + } else { |
| 148 | + return false; |
| 149 | + } |
| 150 | + |
| 151 | + // check if something weird didn't happen |
| 152 | + if ( $user instanceof User ) { |
| 153 | + // purge both pages now |
| 154 | + if ( $user->getOption('OnlineStatusBar_active', false) ) { |
| 155 | + if ( $user->getOption('OnlineStatusBar_autoupdate', false) == true ) { |
| 156 | + WikiPage::factory( $user->getUserPage() )->doPurge(); |
| 157 | + WikiPage::factory( $user->getTalkPage() )->doPurge(); |
| 158 | + } |
| 159 | + } |
| 160 | + } |
| 161 | + return true; |
| 162 | + } |
| 163 | + |
| 164 | + /** |
132 | 165 | * Insert to the database |
133 | 166 | * @return bool |
134 | 167 | */ |
135 | | - public static function UpdateDb() { |
136 | | - global $wgUser, $wgOnlineStatusBarDefaultOnline; |
| 168 | + public static function updateDb() { |
| 169 | + global $wgUser; |
137 | 170 | // Skip users we don't track |
138 | | - if ( self::IsValid ( $wgUser ) != true ) { |
| 171 | + if ( self::isValid ( $wgUser ) != true ) { |
139 | 172 | return false; |
140 | 173 | } |
141 | 174 | // If we track them, let's insert it to the table |
— | — | @@ -148,12 +181,23 @@ |
149 | 182 | } |
150 | 183 | |
151 | 184 | /** |
| 185 | + * Update status of user |
152 | 186 | * @return bool |
153 | 187 | */ |
154 | | - public static function UpdateStatus() { |
155 | | - global $wgUser, $wgOnlineStatusBarDefaultOffline; |
156 | | - if ( OnlineStatusBar::GetStatus( $wgUser, true ) == $wgOnlineStatusBarDefaultOffline ) { |
157 | | - OnlineStatusBar::UpdateDb(); |
| 188 | + public static function updateStatus() { |
| 189 | + global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled; |
| 190 | + // if anon users are not tracked and user is anon leave it |
| 191 | + if ( !$wgOnlineStatusBarTrackIpUsers ) { |
| 192 | + if ( !$wgUser->isLoggedIn() ) { |
| 193 | + return false; |
| 194 | + } |
| 195 | + } |
| 196 | + // if user doesn't want to be tracked leave it as well for privacy reasons |
| 197 | + if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
| 198 | + return false; |
| 199 | + } |
| 200 | + if ( OnlineStatusBar::getStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) { |
| 201 | + OnlineStatusBar::updateDb(); |
158 | 202 | return true; |
159 | 203 | } |
160 | 204 | |
— | — | @@ -165,17 +209,25 @@ |
166 | 210 | __METHOD__ |
167 | 211 | ); |
168 | 212 | |
169 | | - return false; |
| 213 | + return true; |
170 | 214 | } |
171 | 215 | |
172 | 216 | /** |
| 217 | + * @return timestamp |
| 218 | + */ |
| 219 | + private static function getTimeoutDate() { |
| 220 | + global $wgOnlineStatusBar_LogoutTime; |
| 221 | + return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
| 222 | + } |
| 223 | + |
| 224 | + /** |
| 225 | + * Delete old records from the table, this function is called frequently too keep it as small as possible |
173 | 226 | * @return int |
174 | 227 | */ |
175 | | - public static function DeleteOld() { |
176 | | - global $wgOnlineStatusBar_LogoutTime; |
| 228 | + public static function deleteOld() { |
177 | 229 | $dbw = wfGetDB( DB_MASTER ); |
178 | 230 | // calculate time and convert it back to mediawiki format |
179 | | - $time = wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
| 231 | + $time = self::getTimeoutDate(); |
180 | 232 | $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ ); |
181 | 233 | return 0; |
182 | 234 | } |
— | — | @@ -204,7 +256,7 @@ |
205 | 257 | * @param $userName string |
206 | 258 | * @return bool |
207 | 259 | */ |
208 | | - static function DeleteStatus( $userName ) { |
| 260 | + static function deleteStatus( $userName ) { |
209 | 261 | $dbw = wfGetDB( DB_MASTER ); |
210 | 262 | $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user |
211 | 263 | return true; |
Index: branches/REL1_17/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php |
— | — | @@ -22,6 +22,8 @@ |
23 | 23 | 'onlinestatusbar-used' => 'Do you want to let others see if you are online?', |
24 | 24 | // Message in config asking what status they want to use |
25 | 25 | 'onlinestatusbar-status' => 'What is the default status you wish to use:', |
| 26 | + // Message in config asking if user wants to purge the user page |
| 27 | + 'onlinestatusbar-purge' => 'Purge user page everytime when you login or logout', |
26 | 28 | // Section for config |
27 | 29 | 'prefs-onlinestatus' => 'Online status', |
28 | 30 | // Message in config |
— | — | @@ -46,6 +48,7 @@ |
47 | 49 | * $3 a status, it will appear in title bar of their user space pages', |
48 | 50 | 'onlinestatusbar-used' => 'Message in config asking user if they want to enable it, checkbox', |
49 | 51 | 'onlinestatusbar-status' => 'Message in config asking what status they want to use, option box', |
| 52 | + 'onlinestatusbar-purge' => 'Option to purge user page everytime they login so that magic word is updated', |
50 | 53 | 'prefs-onlinestatus' => 'Section for config, located in preferences - misc', |
51 | 54 | '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', |
52 | 55 | 'onlinestatusbar-status-online' => 'Status for users who mark themselves as active', |
— | — | @@ -83,6 +86,7 @@ |
84 | 87 | |
85 | 88 | /** French (Français) |
86 | 89 | * @author DavidL |
| 90 | + * @author Gomoko |
87 | 91 | */ |
88 | 92 | $messages['fr'] = array( |
89 | 93 | 'onlinestatusbar-desc' => "Barre d'état montrant si un utilisateur est en ligne, basé sur les préférences, sur leur page utilisateur", |
— | — | @@ -91,6 +95,11 @@ |
92 | 96 | 'onlinestatusbar-status' => 'Quel est le statut par défaut que vous souhaitez utiliser :', |
93 | 97 | 'prefs-onlinestatus' => 'État en ligne', |
94 | 98 | 'onlinestatusbar-hide' => "Voulez-vous masquer la barre d'état afin d'utiliser le mot magique seulement ? (Pour les utilisateurs avancés)", |
| 99 | + 'onlinestatusbar-status-online' => 'Présent', |
| 100 | + 'onlinestatusbar-status-busy' => 'Occupé', |
| 101 | + 'onlinestatusbar-status-away' => 'Parti', |
| 102 | + 'onlinestatusbar-status-offline' => 'Absent', |
| 103 | + 'onlinestatusbar-status-hidden' => 'Caché', |
95 | 104 | ); |
96 | 105 | |
97 | 106 | /** Galician (Galego) |
— | — | @@ -123,6 +132,23 @@ |
124 | 133 | 'onlinestatusbar-status-hidden' => 'Schowany', |
125 | 134 | ); |
126 | 135 | |
| 136 | +/** Interlingua (Interlingua) |
| 137 | + * @author McDutchie |
| 138 | + */ |
| 139 | +$messages['ia'] = array( |
| 140 | + 'onlinestatusbar-desc' => 'Barra de stato que monstra si un usator es in linea, dependente de su preferentias, in su pagina de usator', |
| 141 | + 'onlinestatusbar-line' => '$1 es ora $2 $3', |
| 142 | + 'onlinestatusbar-used' => 'Vole tu permitter que alteres vide si tu es in linea?', |
| 143 | + 'onlinestatusbar-status' => 'Qual es le stato predefinite que tu vole usar:', |
| 144 | + 'prefs-onlinestatus' => 'Stato in linea', |
| 145 | + 'onlinestatusbar-hide' => 'Vole tu celar le barra de stato pro usar solmente le parola magic? (Pro usatores avantiate)', |
| 146 | + 'onlinestatusbar-status-online' => 'In linea', |
| 147 | + 'onlinestatusbar-status-busy' => 'Occupate', |
| 148 | + 'onlinestatusbar-status-away' => 'Absente', |
| 149 | + 'onlinestatusbar-status-offline' => 'Foras de linea', |
| 150 | + 'onlinestatusbar-status-hidden' => 'Celate', |
| 151 | +); |
| 152 | + |
127 | 153 | /** Luxembourgish (Lëtzebuergesch) |
128 | 154 | * @author Robby |
129 | 155 | */ |
Index: branches/REL1_17/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array( |
19 | 19 | 'path' => __FILE__, |
20 | 20 | 'name' => 'Online status bar', |
21 | | - 'version' => '1.0.0', |
| 21 | + 'version' => '1.0.1', |
22 | 22 | 'author' => array( 'Petr Bena' ), |
23 | 23 | 'descriptionmsg' => 'onlinestatusbar-desc', |
24 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar', |
Index: branches/REL1_17/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -28,16 +28,19 @@ |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | 31 | public static function logout( &$user, &$inject_html, $old_name ) { |
32 | | - OnlineStatusBar::DeleteStatus( $old_name ); |
| 32 | + OnlineStatusBar::purge( $old_name ); |
| 33 | + OnlineStatusBar::deleteStatus( $old_name ); |
33 | 34 | return true; |
34 | 35 | } |
35 | 36 | |
36 | 37 | /** |
37 | | - * Called everytime when it's needed to update db |
| 38 | + * Called everytime on login |
38 | 39 | * @return bool |
39 | 40 | */ |
40 | 41 | public static function updateStatus() { |
41 | | - OnlineStatusBar::UpdateDb(); |
| 42 | + global $wgUser; |
| 43 | + OnlineStatusBar::purge( $wgUser ); |
| 44 | + OnlineStatusBar::updateStatus(); |
42 | 45 | return true; |
43 | 46 | } |
44 | 47 | |
— | — | @@ -51,7 +54,7 @@ |
52 | 55 | public static function renderBar( &$article, &$outputDone, &$pcache ) { |
53 | 56 | $context = $article->getContext(); |
54 | 57 | |
55 | | - OnlineStatusBar::UpdateStatus(); |
| 58 | + OnlineStatusBar::updateStatus(); |
56 | 59 | $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() ); |
57 | 60 | if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) { |
58 | 61 | $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() ); |
— | — | @@ -88,6 +91,7 @@ |
89 | 92 | global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBarModes; |
90 | 93 | $preferences['OnlineStatusBar_active'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-used', 'section' => 'misc/onlinestatus' ); |
91 | 94 | $preferences['OnlineStatusBar_hide'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-hide', 'section' => 'misc/onlinestatus' ); |
| 95 | + $preferences['OnlineStatusBar_autoupdate'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-purge', 'section' => 'misc/onlinestatus' ); |
92 | 96 | $preferences['OnlineStatusBar_status'] = array( 'type' => 'radio', 'label-message' => 'onlinestatusbar-status', 'section' => 'misc/onlinestatus', |
93 | 97 | 'options' => array( |
94 | 98 | wfMessage( 'onlinestatusbar-status-online' )->escaped() => 'online', |
— | — | @@ -106,6 +110,7 @@ |
107 | 111 | public static function setDefaultOptions( &$defaultOptions ) { |
108 | 112 | global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled; |
109 | 113 | // set defaults |
| 114 | + $defaultOptions['OnlineStatusBar_autoupdate'] = false; |
110 | 115 | $defaultOptions['OnlineStatusBar_status'] = $wgOnlineStatusBarDefaultOnline; |
111 | 116 | $defaultOptions['OnlineStatusBar_active'] = $wgOnlineStatusBarDefaultEnabled; |
112 | 117 | $defaultOptions['OnlineStatusBar_hide'] = false; |
Property changes on: branches/REL1_17/extensions/OnlineStatusBar |
___________________________________________________________________ |
Added: svn:mergeinfo |
113 | 118 | Merged /trunk/extensions/OnlineStatusBar:r83817,90221,90723,91145,101374-101518 |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.body.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | * @return string |
34 | 34 | */ |
35 | 35 | public static function GetImageHtml( $mode ) { |
36 | | - global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon, $wgOnlineStatusBarModes; |
| 36 | + global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon; |
37 | 37 | $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}"; |
38 | 38 | return Html::element( 'img', array( 'src' => $icon ) ); |
39 | 39 | } |
— | — | @@ -46,23 +46,26 @@ |
47 | 47 | */ |
48 | 48 | public static function getAnonFromTitle( Title $title ) { |
49 | 49 | global $wgOnlineStatusBarTrackIpUsers; |
| 50 | + // if user is anon and we don't track them stop |
50 | 51 | if ( $wgOnlineStatusBarTrackIpUsers == false ) { |
51 | 52 | return false; |
52 | 53 | } |
53 | 54 | |
| 55 | + // checks ns |
54 | 56 | if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) { |
55 | 57 | return false; |
56 | 58 | } |
57 | 59 | |
| 60 | + // we need to create temporary user object |
58 | 61 | $user = User::newFromId( 0 ); |
59 | 62 | $user->setName( $title->getBaseText() ); |
60 | 63 | |
61 | 64 | // Check if something wrong didn't happen |
62 | | - if ( $user === false ) { |
| 65 | + if ( !($user instanceof User) ) { |
63 | 66 | return false; |
64 | 67 | } |
65 | 68 | |
66 | | - $status = self::getStatus( $user ); |
| 69 | + $status = self::getStatus( $user, true ); |
67 | 70 | |
68 | 71 | return array( $status, $user ); |
69 | 72 | } |
— | — | @@ -81,14 +84,14 @@ |
82 | 85 | |
83 | 86 | $user = User::newFromName( $title->getBaseText() ); |
84 | 87 | // Invalid user |
85 | | - if ( $user === false ) { |
| 88 | + if ( !($user instanceof User) ) { |
86 | 89 | return false; |
87 | 90 | } |
88 | 91 | if ( !self::isValid( $user ) ) { |
89 | 92 | return false; |
90 | 93 | } |
91 | 94 | |
92 | | - $status = self::getStatus( $user ); |
| 95 | + $status = self::getStatus( $user, true ); |
93 | 96 | |
94 | 97 | return array( $status, $user ); |
95 | 98 | } |
— | — | @@ -102,11 +105,14 @@ |
103 | 106 | // remove old entries |
104 | 107 | if ( $update ) |
105 | 108 | { |
106 | | - self::DeleteOld(); |
| 109 | + self::deleteOld(); |
107 | 110 | } |
108 | 111 | |
| 112 | + // instead of delete every time just select the records which are not that old |
| 113 | + $t_time = self::getTimeoutDate(); |
109 | 114 | $dbr = wfGetDB( DB_SLAVE ); |
110 | | - $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName() ), |
| 115 | + $result = $dbr->selectField( 'online_status', 'username', array( 'username' => $user->getName(), |
| 116 | + "timestamp > " . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ), |
111 | 117 | __METHOD__, array( 'LIMIT 1', 'ORDER BY timestamp DESC' ) ); |
112 | 118 | |
113 | 119 | if ( $result === false ) { |
— | — | @@ -128,13 +134,40 @@ |
129 | 135 | } |
130 | 136 | |
131 | 137 | /** |
| 138 | + * Purge page |
| 139 | + * @return bool |
| 140 | + * |
| 141 | + */ |
| 142 | + public static function purge( $user_type ) { |
| 143 | + if ( $user_type instanceof User ) { |
| 144 | + $user = $user_type; |
| 145 | + } else if ( is_string( $user_type ) ){ |
| 146 | + $user = User::newFromName( $user_type ); |
| 147 | + } else { |
| 148 | + return false; |
| 149 | + } |
| 150 | + |
| 151 | + // check if something weird didn't happen |
| 152 | + if ( $user instanceof User ) { |
| 153 | + // purge both pages now |
| 154 | + if ( $user->getOption('OnlineStatusBar_active', false) ) { |
| 155 | + if ( $user->getOption('OnlineStatusBar_autoupdate', false) == true ) { |
| 156 | + WikiPage::factory( $user->getUserPage() )->doPurge(); |
| 157 | + WikiPage::factory( $user->getTalkPage() )->doPurge(); |
| 158 | + } |
| 159 | + } |
| 160 | + } |
| 161 | + return true; |
| 162 | + } |
| 163 | + |
| 164 | + /** |
132 | 165 | * Insert to the database |
133 | 166 | * @return bool |
134 | 167 | */ |
135 | | - public static function UpdateDb() { |
136 | | - global $wgUser, $wgOnlineStatusBarDefaultOnline; |
| 168 | + public static function updateDb() { |
| 169 | + global $wgUser; |
137 | 170 | // Skip users we don't track |
138 | | - if ( self::IsValid ( $wgUser ) != true ) { |
| 171 | + if ( self::isValid ( $wgUser ) != true ) { |
139 | 172 | return false; |
140 | 173 | } |
141 | 174 | // If we track them, let's insert it to the table |
— | — | @@ -148,12 +181,23 @@ |
149 | 182 | } |
150 | 183 | |
151 | 184 | /** |
| 185 | + * Update status of user |
152 | 186 | * @return bool |
153 | 187 | */ |
154 | | - public static function UpdateStatus() { |
155 | | - global $wgUser, $wgOnlineStatusBarDefaultOffline; |
156 | | - if ( OnlineStatusBar::GetStatus( $wgUser, true ) == $wgOnlineStatusBarDefaultOffline ) { |
157 | | - OnlineStatusBar::UpdateDb(); |
| 188 | + public static function updateStatus() { |
| 189 | + global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled; |
| 190 | + // if anon users are not tracked and user is anon leave it |
| 191 | + if ( !$wgOnlineStatusBarTrackIpUsers ) { |
| 192 | + if ( !$wgUser->isLoggedIn() ) { |
| 193 | + return false; |
| 194 | + } |
| 195 | + } |
| 196 | + // if user doesn't want to be tracked leave it as well for privacy reasons |
| 197 | + if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) { |
| 198 | + return false; |
| 199 | + } |
| 200 | + if ( OnlineStatusBar::getStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) { |
| 201 | + OnlineStatusBar::updateDb(); |
158 | 202 | return true; |
159 | 203 | } |
160 | 204 | |
— | — | @@ -165,17 +209,25 @@ |
166 | 210 | __METHOD__ |
167 | 211 | ); |
168 | 212 | |
169 | | - return false; |
| 213 | + return true; |
170 | 214 | } |
171 | 215 | |
172 | 216 | /** |
| 217 | + * @return timestamp |
| 218 | + */ |
| 219 | + private static function getTimeoutDate() { |
| 220 | + global $wgOnlineStatusBar_LogoutTime; |
| 221 | + return wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
| 222 | + } |
| 223 | + |
| 224 | + /** |
| 225 | + * Delete old records from the table, this function is called frequently too keep it as small as possible |
173 | 226 | * @return int |
174 | 227 | */ |
175 | | - public static function DeleteOld() { |
176 | | - global $wgOnlineStatusBar_LogoutTime; |
| 228 | + public static function deleteOld() { |
177 | 229 | $dbw = wfGetDB( DB_MASTER ); |
178 | 230 | // calculate time and convert it back to mediawiki format |
179 | | - $time = wfTimestamp( TS_UNIX ) - $wgOnlineStatusBar_LogoutTime; |
| 231 | + $time = self::getTimeoutDate(); |
180 | 232 | $dbw->delete( 'online_status', array( "timestamp < " . $dbw->addQuotes( $dbw->timestamp( $time ) ) ), __METHOD__ ); |
181 | 233 | return 0; |
182 | 234 | } |
— | — | @@ -204,7 +256,7 @@ |
205 | 257 | * @param $userName string |
206 | 258 | * @return bool |
207 | 259 | */ |
208 | | - static function DeleteStatus( $userName ) { |
| 260 | + static function deleteStatus( $userName ) { |
209 | 261 | $dbw = wfGetDB( DB_MASTER ); |
210 | 262 | $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user |
211 | 263 | return true; |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.i18n.php |
— | — | @@ -22,6 +22,8 @@ |
23 | 23 | 'onlinestatusbar-used' => 'Do you want to let others see if you are online?', |
24 | 24 | // Message in config asking what status they want to use |
25 | 25 | 'onlinestatusbar-status' => 'What is the default status you wish to use:', |
| 26 | + // Message in config asking if user wants to purge the user page |
| 27 | + 'onlinestatusbar-purge' => 'Purge user page everytime when you login or logout', |
26 | 28 | // Section for config |
27 | 29 | 'prefs-onlinestatus' => 'Online status', |
28 | 30 | // Message in config |
— | — | @@ -46,6 +48,7 @@ |
47 | 49 | * $3 a status, it will appear in title bar of their user space pages', |
48 | 50 | 'onlinestatusbar-used' => 'Message in config asking user if they want to enable it, checkbox', |
49 | 51 | 'onlinestatusbar-status' => 'Message in config asking what status they want to use, option box', |
| 52 | + 'onlinestatusbar-purge' => 'Option to purge user page everytime they login so that magic word is updated', |
50 | 53 | 'prefs-onlinestatus' => 'Section for config, located in preferences - misc', |
51 | 54 | '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', |
52 | 55 | 'onlinestatusbar-status-online' => 'Status for users who mark themselves as active', |
— | — | @@ -83,6 +86,7 @@ |
84 | 87 | |
85 | 88 | /** French (Français) |
86 | 89 | * @author DavidL |
| 90 | + * @author Gomoko |
87 | 91 | */ |
88 | 92 | $messages['fr'] = array( |
89 | 93 | 'onlinestatusbar-desc' => "Barre d'état montrant si un utilisateur est en ligne, basé sur les préférences, sur leur page utilisateur", |
— | — | @@ -91,6 +95,11 @@ |
92 | 96 | 'onlinestatusbar-status' => 'Quel est le statut par défaut que vous souhaitez utiliser :', |
93 | 97 | 'prefs-onlinestatus' => 'État en ligne', |
94 | 98 | 'onlinestatusbar-hide' => "Voulez-vous masquer la barre d'état afin d'utiliser le mot magique seulement ? (Pour les utilisateurs avancés)", |
| 99 | + 'onlinestatusbar-status-online' => 'Présent', |
| 100 | + 'onlinestatusbar-status-busy' => 'Occupé', |
| 101 | + 'onlinestatusbar-status-away' => 'Parti', |
| 102 | + 'onlinestatusbar-status-offline' => 'Absent', |
| 103 | + 'onlinestatusbar-status-hidden' => 'Caché', |
95 | 104 | ); |
96 | 105 | |
97 | 106 | /** Galician (Galego) |
— | — | @@ -123,6 +132,23 @@ |
124 | 133 | 'onlinestatusbar-status-hidden' => 'Schowany', |
125 | 134 | ); |
126 | 135 | |
| 136 | +/** Interlingua (Interlingua) |
| 137 | + * @author McDutchie |
| 138 | + */ |
| 139 | +$messages['ia'] = array( |
| 140 | + 'onlinestatusbar-desc' => 'Barra de stato que monstra si un usator es in linea, dependente de su preferentias, in su pagina de usator', |
| 141 | + 'onlinestatusbar-line' => '$1 es ora $2 $3', |
| 142 | + 'onlinestatusbar-used' => 'Vole tu permitter que alteres vide si tu es in linea?', |
| 143 | + 'onlinestatusbar-status' => 'Qual es le stato predefinite que tu vole usar:', |
| 144 | + 'prefs-onlinestatus' => 'Stato in linea', |
| 145 | + 'onlinestatusbar-hide' => 'Vole tu celar le barra de stato pro usar solmente le parola magic? (Pro usatores avantiate)', |
| 146 | + 'onlinestatusbar-status-online' => 'In linea', |
| 147 | + 'onlinestatusbar-status-busy' => 'Occupate', |
| 148 | + 'onlinestatusbar-status-away' => 'Absente', |
| 149 | + 'onlinestatusbar-status-offline' => 'Foras de linea', |
| 150 | + 'onlinestatusbar-status-hidden' => 'Celate', |
| 151 | +); |
| 152 | + |
127 | 153 | /** Luxembourgish (Lëtzebuergesch) |
128 | 154 | * @author Robby |
129 | 155 | */ |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBar.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $wgExtensionCredits[version_compare( $wgVersion, '1.17', '>=' ) ? 'userpage tools' : 'other'][] = array( |
19 | 19 | 'path' => __FILE__, |
20 | 20 | 'name' => 'Online status bar', |
21 | | - 'version' => '1.0.0', |
| 21 | + 'version' => '1.0.1', |
22 | 22 | 'author' => array( 'Petr Bena' ), |
23 | 23 | 'descriptionmsg' => 'onlinestatusbar-desc', |
24 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:OnlineStatusBar', |
Index: branches/REL1_18/extensions/OnlineStatusBar/OnlineStatusBarHooks.php |
— | — | @@ -28,16 +28,19 @@ |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | 31 | public static function logout( &$user, &$inject_html, $old_name ) { |
32 | | - OnlineStatusBar::DeleteStatus( $old_name ); |
| 32 | + OnlineStatusBar::purge( $old_name ); |
| 33 | + OnlineStatusBar::deleteStatus( $old_name ); |
33 | 34 | return true; |
34 | 35 | } |
35 | 36 | |
36 | 37 | /** |
37 | | - * Called everytime when it's needed to update db |
| 38 | + * Called everytime on login |
38 | 39 | * @return bool |
39 | 40 | */ |
40 | 41 | public static function updateStatus() { |
41 | | - OnlineStatusBar::UpdateDb(); |
| 42 | + global $wgUser; |
| 43 | + OnlineStatusBar::purge( $wgUser ); |
| 44 | + OnlineStatusBar::updateStatus(); |
42 | 45 | return true; |
43 | 46 | } |
44 | 47 | |
— | — | @@ -51,7 +54,7 @@ |
52 | 55 | public static function renderBar( &$article, &$outputDone, &$pcache ) { |
53 | 56 | $context = $article->getContext(); |
54 | 57 | |
55 | | - OnlineStatusBar::UpdateStatus(); |
| 58 | + OnlineStatusBar::updateStatus(); |
56 | 59 | $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() ); |
57 | 60 | if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) { |
58 | 61 | $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() ); |
— | — | @@ -88,6 +91,7 @@ |
89 | 92 | global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled, $wgOnlineStatusBarModes; |
90 | 93 | $preferences['OnlineStatusBar_active'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-used', 'section' => 'misc/onlinestatus' ); |
91 | 94 | $preferences['OnlineStatusBar_hide'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-hide', 'section' => 'misc/onlinestatus' ); |
| 95 | + $preferences['OnlineStatusBar_autoupdate'] = array( 'type' => 'toggle', 'label-message' => 'onlinestatusbar-purge', 'section' => 'misc/onlinestatus' ); |
92 | 96 | $preferences['OnlineStatusBar_status'] = array( 'type' => 'radio', 'label-message' => 'onlinestatusbar-status', 'section' => 'misc/onlinestatus', |
93 | 97 | 'options' => array( |
94 | 98 | wfMessage( 'onlinestatusbar-status-online' )->escaped() => 'online', |
— | — | @@ -106,6 +110,7 @@ |
107 | 111 | public static function setDefaultOptions( &$defaultOptions ) { |
108 | 112 | global $wgOnlineStatusBarDefaultOnline, $wgOnlineStatusBarDefaultEnabled; |
109 | 113 | // set defaults |
| 114 | + $defaultOptions['OnlineStatusBar_autoupdate'] = false; |
110 | 115 | $defaultOptions['OnlineStatusBar_status'] = $wgOnlineStatusBarDefaultOnline; |
111 | 116 | $defaultOptions['OnlineStatusBar_active'] = $wgOnlineStatusBarDefaultEnabled; |
112 | 117 | $defaultOptions['OnlineStatusBar_hide'] = false; |
Property changes on: branches/REL1_18/extensions/OnlineStatusBar |
___________________________________________________________________ |
Added: svn:mergeinfo |
113 | 118 | Merged /trunk/extensions/OnlineStatusBar:r97886-97887,97899,97969,98054,98179,98497,98607,98654,98773,98801,98960,98982,99059,99097,99164,99167,99187,99193,99653,99897,100092,100573,100689,100692,101374-101518 |