Index: trunk/extensions/OnlineStatus/OnlineStatus.php |
— | — | @@ -49,13 +49,9 @@ |
50 | 50 | $wgHooks['ParserGetVariableValueSwitch'][] = 'OnlineStatus::ParserGetVariable'; |
51 | 51 | |
52 | 52 | // Hooks for Special:Preferences |
53 | | - $wgHooks['InitPreferencesForm'][] = 'OnlineStatus::InitPreferencesForm'; |
54 | | - $wgHooks['PreferencesUserInformationPanel'][] = 'OnlineStatus::PreferencesUserInformationPanel'; |
55 | | - $wgHooks['ResetPreferences'][] = 'OnlineStatus::ResetPreferences'; |
56 | | - $wgHooks['SavePreferences'][] = 'OnlineStatus::SavePreferences'; |
| 53 | + $wgHooks['GetPreferences'][] = 'OnlineStatus::GetPreferences'; |
57 | 54 | |
58 | 55 | // User hook |
59 | | - $wgHooks['GetPreferences'][] = 'OnlineStatus::onGetPreferences'; |
60 | 56 | $wgHooks['UserLoginComplete'][] = 'OnlineStatus::UserLoginComplete'; |
61 | 57 | $wgHooks['UserLogoutComplete'][] = 'OnlineStatus::UserLogoutComplete'; |
62 | 58 | |
— | — | @@ -215,52 +211,11 @@ |
216 | 212 | } |
217 | 213 | |
218 | 214 | /** |
219 | | - * Hook function for SavePreferences |
| 215 | + * Hook for user preferences |
220 | 216 | */ |
221 | | - static function SavePreferences( $prefs, $user, &$msg, $old = array() ){ |
222 | | - # We need to invalidate caches for these pages, maybe it would be good |
223 | | - # to be done for subpages, but it would too expensive |
224 | | - if( !is_array( $old ) || empty( $old ) ){ |
225 | | - # MediaWiki is < 1.13, at that time, $old param wasn't present |
226 | | - # We can't check if the user changed the online toggle as it is |
227 | | - # already saved :( |
228 | | - $changed = true; |
229 | | - } elseif( !isset( $old['online'] ) || !isset( $old['showonline'] ) ) { |
230 | | - $changed = true; |
231 | | - } else { |
232 | | - $changed = !( $old['online'] == $user->mOptions['online'] |
233 | | - && $old['showonline'] == $user->mOptions['showonline'] ); |
234 | | - } |
235 | | - if( $changed ){ |
236 | | - $user->getUserPage()->invalidateCache(); |
237 | | - $user->getTalkPage()->invalidateCache(); |
238 | | - } |
239 | | - return true; |
240 | | - } |
241 | | - |
242 | | - /** |
243 | | - * Hook function for InitPreferencesForm |
244 | | - */ |
245 | | - static function InitPreferencesForm( $prefs, $request ) { |
246 | | - $prefs->mToggles['online'] = $request->getVal( 'wpOnline' ); |
247 | | - $prefs->mToggles['showonline'] = $request->getCheck( 'wpOpShowOnline' ) ? 1 : 0; |
248 | | - return true; |
249 | | - } |
250 | | - |
251 | | - /** |
252 | | - * Hook function for ResetPreferences |
253 | | - */ |
254 | | - static function ResetPreferences( $prefs, $user ) { |
255 | | - $prefs->mToggles['online'] = $user->getOption( 'online' ); |
256 | | - $prefs->mToggles['showonline'] = $user->getOption( 'showonline' ); |
257 | | - return true; |
258 | | - } |
259 | | - |
260 | | - /** |
261 | | - * Hook function for PreferencesUserInformationPanel |
262 | | - */ |
263 | | - static function PreferencesUserInformationPanel( $prefsForm, &$html ) { |
| 217 | + public static function GetPreferences( $user, &$preferences ) { |
264 | 218 | wfLoadExtensionMessages( 'OnlineStatus' ); |
| 219 | + |
265 | 220 | $msg = wfMsgForContentNoTrans( 'onlinestatus-levels' ); |
266 | 221 | $lines = explode( "\n", $msg ); |
267 | 222 | $radios = array(); |
— | — | @@ -268,30 +223,9 @@ |
269 | 224 | if( substr( $line, 0, 1 ) != '*' ) |
270 | 225 | continue; |
271 | 226 | $lev = trim( $line, '* ' ); |
272 | | - $radios[] = Xml::radioLabel( |
273 | | - wfMsg( 'onlinestatus-toggle-' . $lev ), |
274 | | - 'wpOnline', |
275 | | - $lev, |
276 | | - 'wpOnline-' . $lev, |
277 | | - $lev == $prefsForm->mToggles['online'] |
278 | | - ); |
| 227 | + $radios[wfMsg( 'onlinestatus-toggle-' . $lev )] = $lev; |
279 | 228 | } |
280 | | - $out = "<ul>\n<li>"; |
281 | | - $out .= implode( "</li>\n<li>", $radios ); |
282 | | - $out .= "</li>\n</ul>"; |
283 | | - $html .= $prefsForm->tableRow( |
284 | | - wfMsgExt( 'onlinestatus-toggles-desc', array( 'escapenoentities' ) ), |
285 | | - $out . |
286 | | - Xml::checkLabel( wfMsg( 'onlinestatus-toggles-show' ), 'wpOpShowOnline', 'wpOpShowOnline', (bool)$prefsForm->mToggles['showonline'] ) . |
287 | | - wfMsgExt( 'onlinestatus-toggles-explain', array( 'parse' ) ) |
288 | | - ); |
289 | | - return true; |
290 | | - } |
291 | 229 | |
292 | | - /** |
293 | | - * Hook for user preferences |
294 | | - */ |
295 | | - public static function onGetPreferences( $user, &$preferences ) { |
296 | 230 | $preferences['onlinestatusonlogin'] = |
297 | 231 | array( |
298 | 232 | 'type' => 'toggle', |
— | — | @@ -306,6 +240,22 @@ |
307 | 241 | 'label-message' => 'onlinestatus-pref-offlineonlogout', |
308 | 242 | ); |
309 | 243 | |
| 244 | + $prefs = array( |
| 245 | + 'online' => array( |
| 246 | + 'type' => 'radio', |
| 247 | + 'section' => 'personal', |
| 248 | + 'options' => $radios, |
| 249 | + 'label-message' => 'onlinestatus-toggles-desc', |
| 250 | + ), |
| 251 | + 'showonline' => array( |
| 252 | + 'type' => 'check', |
| 253 | + 'section' => 'personal', |
| 254 | + 'label-message' => 'onlinestatus-toggles-show', |
| 255 | + 'help-message' => 'onlinestatus-toggles-explain', |
| 256 | + ) |
| 257 | + ); |
| 258 | + $preferences = wfArrayInsertAfter( $preferences, $prefs, 'registrationdate' ); |
| 259 | + |
310 | 260 | return true; |
311 | 261 | } |
312 | 262 | |