Clean up e-mail authentication code.
[lhc/web/wiklou.git] / includes / SpecialPreferences.php
1 <?php
2 /**
3 * Hold things related to displaying and saving user preferences.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 if( !defined( 'MEDIAWIKI' ) )
9 die();
10
11 /** to get a list of languages in setting user's language preference */
12 require_once('languages/Names.php');
13
14 /**
15 * Entry point that create the "Preferences" object
16 */
17 function wfSpecialPreferences() {
18 global $wgRequest;
19
20 $form = new PreferencesForm( $wgRequest );
21 $form->execute();
22 }
23
24 /**
25 * Preferences form handling
26 * This object will show the preferences form and can save it as well.
27 * @package MediaWiki
28 * @subpackage SpecialPage
29 */
30 class PreferencesForm {
31 var $mQuickbar, $mOldpass, $mNewpass, $mRetypePass, $mStubs;
32 var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick;
33 var $mUserLanguage, $mUserVariant;
34 var $mSearch, $mRecent, $mHourDiff, $mSearchLines, $mSearchChars, $mAction;
35 var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize;
36
37 /**
38 * Constructor
39 * Load some values
40 */
41 function PreferencesForm( &$request ) {
42 global $wgLang, $wgContLang, $wgUser, $wgAllowRealName;
43
44 $this->mQuickbar = $request->getVal( 'wpQuickbar' );
45 $this->mOldpass = $request->getVal( 'wpOldpass' );
46 $this->mNewpass = $request->getVal( 'wpNewpass' );
47 $this->mRetypePass =$request->getVal( 'wpRetypePass' );
48 $this->mStubs = $request->getVal( 'wpStubs' );
49 $this->mRows = $request->getVal( 'wpRows' );
50 $this->mCols = $request->getVal( 'wpCols' );
51 $this->mSkin = $request->getVal( 'wpSkin' );
52 $this->mMath = $request->getVal( 'wpMath' );
53 $this->mDate = $request->getVal( 'wpDate' );
54 $this->mUserEmail = $request->getVal( 'wpUserEmail' );
55 $this->mRealName = ($wgAllowRealName) ? $request->getVal( 'wpRealName' ) : '';
56 $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 1 : 0;
57 $this->mNick = $request->getVal( 'wpNick' );
58 $this->mUserLanguage = $request->getVal( 'wpUserLanguage' );
59 $this->mUserVariant = $request->getVal( 'wpUserVariant' );
60 $this->mSearch = $request->getVal( 'wpSearch' );
61 $this->mRecent = $request->getVal( 'wpRecent' );
62 $this->mHourDiff = $request->getVal( 'wpHourDiff' );
63 $this->mSearchLines = $request->getVal( 'wpSearchLines' );
64 $this->mSearchChars = $request->getVal( 'wpSearchChars' );
65 $this->mImageSize = $request->getVal( 'wpImageSize' );
66 $this->mThumbSize = $request->getInt( 'wpThumbSize' );
67
68 $this->mAction = $request->getVal( 'action' );
69 $this->mReset = $request->getCheck( 'wpReset' );
70 $this->mPosted = $request->wasPosted();
71 $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
72 $this->mPosted &&
73 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
74
75 # User toggles (the big ugly unsorted list of checkboxes)
76 $this->mToggles = array();
77 if ( $this->mPosted ) {
78 $togs = $wgLang->getUserToggles();
79 foreach ( $togs as $tname ) {
80 $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0;
81 }
82 }
83
84 $this->mUsedToggles = array();
85
86 # Search namespace options
87 # Note: namespaces don't necessarily have consecutive keys
88 $this->mSearchNs = array();
89 if ( $this->mPosted ) {
90 $namespaces = $wgContLang->getNamespaces();
91 foreach ( $namespaces as $i => $namespace ) {
92 if ( $i >= 0 ) {
93 $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0;
94 }
95 }
96 }
97
98 # Validate language
99 if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) {
100 $this->mUserLanguage = 'nolanguage';
101 }
102 }
103
104 function execute() {
105 global $wgUser, $wgOut;
106
107 if ( $wgUser->isAnon() ) {
108 $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' );
109 return;
110 }
111 if ( wfReadOnly() ) {
112 $wgOut->readOnlyPage();
113 return;
114 }
115 if ( $this->mReset ) {
116 $this->resetPrefs();
117 $this->mainPrefsForm( wfMsg( 'prefsreset' ) );
118 } else if ( $this->mSaveprefs ) {
119 $this->savePreferences();
120 } else {
121 $this->resetPrefs();
122 $this->mainPrefsForm( '' );
123 }
124 }
125
126 /**
127 * @access private
128 */
129 function validateInt( &$val, $min=0, $max=0x7fffffff ) {
130 $val = intval($val);
131 $val = min($val, $max);
132 $val = max($val, $min);
133 return $val;
134 }
135
136 /**
137 * @access private
138 */
139 function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) {
140 $val = trim($val);
141 if($val === '') {
142 return $val;
143 } else {
144 return $this->validateInt( $val, $min, $max );
145 }
146 }
147
148 /**
149 * Used to validate the user inputed timezone before saving it as
150 * 'timeciorrection', will return '00:00' if fed bogus data.
151 * Note: It's not a 100% correct implementation timezone-wise, it will
152 * accept stuff like '14:30',
153 * @access private
154 * @param string $s the user input
155 * @return string
156 */
157 function validateTimeZone( $s ) {
158 if ( $s !== '' ) {
159 if ( strpos( $s, ':' ) ) {
160 # HH:MM
161 $array = explode( ':' , $s );
162 $hour = intval( $array[0] );
163 $minute = intval( $array[1] );
164 } else {
165 $minute = intval( $s * 60 );
166 $hour = intval( $minute / 60 );
167 $minute = abs( $minute ) % 60;
168 }
169 # Max is +14:00 and min is -12:00, see:
170 # http://en.wikipedia.org/wiki/Timezone
171 $hour = min( $hour, 14 );
172 $hour = max( $hour, -12 );
173 $minute = min( $minute, 59 );
174 $minute = max( $minute, 0 );
175 $s = sprintf( "%02d:%02d", $hour, $minute );
176 }
177 return $s;
178 }
179
180 /**
181 * @access private
182 */
183 function savePreferences() {
184 global $wgUser, $wgLang, $wgOut;
185 global $wgEnableUserEmail, $wgEnableEmail;
186 global $wgEmailAuthentication, $wgMinimalPasswordLength;
187
188 if ( '' != $this->mNewpass ) {
189 if ( $this->mNewpass != $this->mRetypePass ) {
190 $this->mainPrefsForm( wfMsg( 'badretype' ) );
191 return;
192 }
193
194 if ( strlen( $this->mNewpass ) < $wgMinimalPasswordLength ) {
195 $this->mainPrefsForm( wfMsg( 'passwordtooshort', $wgMinimalPasswordLength ) );
196 return;
197 }
198
199 if (!$wgUser->checkPassword( $this->mOldpass )) {
200 $this->mainPrefsForm( wfMsg( 'wrongpassword' ) );
201 return;
202 }
203 $wgUser->setPassword( $this->mNewpass );
204 }
205 $wgUser->setRealName( $this->mRealName );
206 $wgUser->setOption( 'language', $this->mUserLanguage );
207 $wgUser->setOption( 'variant', $this->mUserVariant );
208 $wgUser->setOption( 'nickname', $this->mNick );
209 $wgUser->setOption( 'quickbar', $this->mQuickbar );
210 $wgUser->setOption( 'skin', $this->mSkin );
211 $wgUser->setOption( 'math', $this->mMath );
212 $wgUser->setOption( 'date', $this->mDate );
213 $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
214 $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
215 $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
216 $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) );
217 $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) );
218 $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) );
219 $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) );
220 $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mHourDiff, -12, 14 ) );
221 $wgUser->setOption( 'imagesize', $this->mImageSize );
222 $wgUser->setOption( 'thumbsize', $this->mThumbSize );
223
224 # Set search namespace options
225 foreach( $this->mSearchNs as $i => $value ) {
226 $wgUser->setOption( "searchNs{$i}", $value );
227 }
228
229 if( $wgEnableEmail && $wgEnableUserEmail ) {
230 $wgUser->setOption( 'disablemail', $this->mEmailFlag );
231 }
232
233 # Set user toggles
234 foreach ( $this->mToggles as $tname => $tvalue ) {
235 $wgUser->setOption( $tname, $tvalue );
236 }
237 $wgUser->setCookies();
238 $wgUser->saveSettings();
239
240 $error = wfMsg( 'savedprefs' );
241 if( $wgEnableEmail ) {
242 $newadr = $this->mUserEmail;
243 $oldadr = $wgUser->getEmail();
244 if( ($newadr != '') && ($newadr != $oldadr) ) {
245 # the user has supplied a new email address on the login page
246 if( $wgUser->isValidEmailAddr( $newadr ) ) {
247 $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
248 $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
249 $wgUser->saveSettings();
250 if ($wgEmailAuthentication) {
251 # Mail a temporary password to the dirty address.
252 # User can come back through the confirmation URL to re-enable email.
253 $result = $wgUser->sendConfirmationMail();
254 if( WikiError::isError( $result ) ) {
255 $error = wfMsg( 'mailerror', $result->getMessage() );
256 } else {
257 $error = wfMsg( 'passwordsentforemailauthentication', $wgUser->getName() );
258 }
259 }
260 } else {
261 $error = wfMsg( 'invalidemailaddress' );
262 }
263 } else {
264 $wgUser->setEmail( $this->mUserEmail );
265 $wgUser->setCookies();
266 $wgUser->saveSettings();
267 }
268 }
269
270 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
271 $po = ParserOptions::newFromUser( $wgUser );
272 $this->mainPrefsForm( $error );
273 }
274
275 /**
276 * @access private
277 */
278 function resetPrefs() {
279 global $wgUser, $wgLang, $wgContLang, $wgAllowRealName;
280
281 $this->mOldpass = $this->mNewpass = $this->mRetypePass = '';
282 $this->mUserEmail = $wgUser->getEmail();
283 $this->mUserEmailAuthenticated = $wgUser->getEmailAuthenticationTimestamp();
284 $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : '';
285 $this->mUserLanguage = $wgUser->getOption( 'language' );
286 if( empty( $this->mUserLanguage ) ) {
287 # Quick hack for conversions, where this value is blank
288 global $wgContLanguageCode;
289 $this->mUserLanguage = $wgContLanguageCode;
290 }
291 $this->mUserVariant = $wgUser->getOption( 'variant');
292 if ( 1 == $wgUser->getOption( 'disablemail' ) ) { $this->mEmailFlag = 1; }
293 else { $this->mEmailFlag = 0; }
294 $this->mNick = $wgUser->getOption( 'nickname' );
295
296 $this->mQuickbar = $wgUser->getOption( 'quickbar' );
297 $this->mSkin = $wgUser->getOption( 'skin' );
298 $this->mMath = $wgUser->getOption( 'math' );
299 $this->mDate = $wgUser->getOption( 'date' );
300 $this->mRows = $wgUser->getOption( 'rows' );
301 $this->mCols = $wgUser->getOption( 'cols' );
302 $this->mStubs = $wgUser->getOption( 'stubthreshold' );
303 $this->mHourDiff = $wgUser->getOption( 'timecorrection' );
304 $this->mSearch = $wgUser->getOption( 'searchlimit' );
305 $this->mSearchLines = $wgUser->getOption( 'contextlines' );
306 $this->mSearchChars = $wgUser->getOption( 'contextchars' );
307 $this->mImageSize = $wgUser->getOption( 'imagesize' );
308 $this->mThumbSize = $wgUser->getOption( 'thumbsize' );
309 $this->mRecent = $wgUser->getOption( 'rclimit' );
310
311 $togs = $wgLang->getUserToggles();
312 foreach ( $togs as $tname ) {
313 $ttext = wfMsg('tog-'.$tname);
314 $this->mToggles[$tname] = $wgUser->getOption( $tname );
315 }
316
317 $namespaces = $wgContLang->getNamespaces();
318 foreach ( $namespaces as $i => $namespace ) {
319 if ( $i >= 0 ) {
320 $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i );
321 }
322 }
323 }
324
325 /**
326 * @access private
327 */
328 function namespacesCheckboxes() {
329 global $wgContLang, $wgUser;
330
331 # Determine namespace checkboxes
332 $namespaces = $wgContLang->getNamespaces();
333 $r1 = '';
334
335 foreach ( $namespaces as $i => $name ) {
336 # Skip special or anything similar
337 if ( $i >= 0 ) {
338 $checked = '';
339 if ( $this->mSearchNs[$i] ) {
340 $checked = ' checked="checked"';
341 }
342 $name = str_replace( '_', ' ', $namespaces[$i] );
343 if ( '' == $name ) {
344 $name = wfMsg( 'blanknamespace' );
345 }
346
347 if ( 0 != $i ) {
348 $r1 .= ' ';
349 }
350 $r1 .= "<label><input type='checkbox' value=\"1\" name=\"" .
351 "wpNs$i\"{$checked} />{$name}</label>\n";
352 }
353 }
354
355 return $r1;
356 }
357
358
359 function getToggle( $tname, $trailer = false) {
360 global $wgUser, $wgLang;
361
362 $this->mUsedToggles[$tname] = true;
363 $ttext = $wgLang->getUserToggle( $tname );
364
365 if ( 1 == $wgUser->getOption( $tname ) ) {
366 $checked = ' checked="checked"';
367 } else {
368 $checked = '';
369 }
370 $trailer =($trailer) ? $trailer : '';
371 return "<div><input type='checkbox' value=\"1\" "
372 . "id=\"$tname\" name=\"wpOp$tname\"$checked /><label for=\"$tname\">$ttext</label>$trailer</div>\n";
373 }
374
375 /**
376 * @access private
377 */
378 function mainPrefsForm( $err ) {
379 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgValidSkinNames;
380 global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
381 global $wgLanguageNames, $wgDisableLangConversion;
382 global $wgEmailNotificationForWatchlistPages, $wgEmailNotificationForUserTalkPages,$wgEmailNotificationForMinorEdits;
383 global $wgRCShowWatchingUsers, $wgEmailNotificationRevealPageEditorAddress;
384 global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
385 global $wgContLanguageCode;
386
387 $wgOut->setPageTitle( wfMsg( 'preferences' ) );
388 $wgOut->setArticleRelated( false );
389 $wgOut->setRobotpolicy( 'noindex,nofollow' );
390
391 if ( '' != $err ) {
392 $wgOut->addHTML( "<p class='error'>" . htmlspecialchars( $err ) . "</p>\n" );
393 }
394 $uname = $wgUser->getName();
395 $uid = $wgUser->getID();
396
397 $wgOut->addWikiText( wfMsg( 'prefslogintext', $uname, $uid ) );
398 $wgOut->addWikiText( wfMsg('clearyourcache'));
399
400 $qbs = $wgLang->getQuickbarSettings();
401 $skinNames = $wgLang->getSkinNames();
402 $mathopts = $wgLang->getMathNames();
403 $dateopts = $wgLang->getDateFormats();
404 $togs = $wgLang->getUserToggles();
405
406 $titleObj = Title::makeTitle( NS_SPECIAL, 'Preferences' );
407 $action = $titleObj->escapeLocalURL();
408
409 $qb = wfMsg( 'qbsettings' );
410 $cp = wfMsg( 'changepassword' );
411 $sk = wfMsg( 'skin' );
412 $math = wfMsg( 'math' );
413 $files = wfMsg( 'files' );
414 $dateFormat = wfMsg('dateformat');
415 $opw = wfMsg( 'oldpassword' );
416 $npw = wfMsg( 'newpassword' );
417 $rpw = wfMsg( 'retypenew' );
418 $svp = wfMsg( 'saveprefs' );
419 $rsp = wfMsg( 'resetprefs' );
420 $tbs = wfMsg( 'textboxsize' );
421 $tbr = wfMsg( 'rows' );
422 $tbc = wfMsg( 'columns' );
423 $ltz = wfMsg( 'localtime' );
424 $timezone = wfMsg( 'timezonelegend' );
425 $tzt = wfMsg( 'timezonetext' );
426 $tzo = wfMsg( 'timezoneoffset' );
427 $tzGuess = wfMsg( 'guesstimezone' );
428 $tzServerTime = wfMsg( 'servertime' );
429 $yem = wfMsg( 'youremail' );
430 $yrn = ($wgAllowRealName) ? wfMsg( 'yourrealname' ) : '';
431 $yl = wfMsg( 'yourlanguage' );
432 $yv = wfMsg( 'yourvariant' );
433 $emf = wfMsg( 'emailflag' );
434 $ynn = wfMsg( 'yournick' );
435 $stt = wfMsg ( 'stubthreshold' ) ;
436 $srh = wfMsg( 'searchresultshead' );
437 $rpp = wfMsg( 'resultsperpage' );
438 $scl = wfMsg( 'contextlines' );
439 $scc = wfMsg( 'contextchars' );
440 $rcc = wfMsg( 'recentchangescount' );
441 $dsn = wfMsg( 'defaultns' );
442
443 $wgOut->addHTML( "<form id=\"preferences\" name=\"preferences\" action=\"$action\"
444 method=\"post\">" );
445
446 # First section: identity
447 # Email, etc.
448 #
449 $this->mUserEmail = htmlspecialchars( $this->mUserEmail );
450 $this->mRealName = htmlspecialchars( $this->mRealName );
451 $this->mNick = htmlspecialchars( $this->mNick );
452 if ( $this->mEmailFlag ) { $emfc = 'checked="checked"'; }
453 else { $emfc = ''; }
454
455 if ($wgEmailAuthentication && ($this->mUserEmail != '') ) {
456 if( $wgUser->getEmailAuthenticationTimestamp() ) {
457 $emailauthenticated = wfMsg('emailauthenticated',$wgLang->timeanddate($wgUser->getEmailAuthenticationTimestamp(), true ) ).'<br />';
458 $disabled = '';
459 } else {
460 $skin = $wgUser->getSkin();
461 $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' .
462 $skin->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Confirmemail' ),
463 wfMsg( 'emailconfirmlink' ) );
464 $disabled = ' '.wfMsg('disableduntilauthent');
465 }
466 } else {
467 $emailauthenticated = '';
468 }
469
470 if ($this->mUserEmail == '') {
471 $disabled = ' '.wfMsg('disablednoemail');
472 }
473
474 $ps = $this->namespacesCheckboxes();
475
476 $enotifwatchlistpages = ($wgEmailNotificationForWatchlistPages) ? $this->getToggle( 'enotifwatchlistpages', $disabled) : '';
477 $enotifusertalkpages = ($wgEmailNotificationForUserTalkPages) ? $this->getToggle( 'enotifusertalkpages', $disabled) : '';
478 $enotifminoredits = ($wgEmailNotificationForMinorEdits) ? $this->getToggle( 'enotifminoredits', $disabled) : '';
479 $enotifrevealaddr = ($wgEmailNotificationRevealPageEditorAddress) ? $this->getToggle( 'enotifrevealaddr', $disabled) : '';
480 $prefs_help_email_enotif = ( $wgEmailNotificationForWatchlistPages || $wgEmailNotificationForUserTalkPages) ? ' ' . wfMsg('prefs-help-email-enotif') : '';
481 $prefs_help_realname = '';
482
483 $wgOut->addHTML( "<fieldset>
484 <legend>".wfMsg('prefs-personal')."</legend>");
485
486 if ($wgAllowRealName) {
487 $wgOut->addHTML("<div><label>$yrn: <input type='text' name=\"wpRealName\" value=\"{$this->mRealName}\" size='20' /></label></div>");
488 $prefs_help_realname = wfMsg('prefs-help-realname').'<br />';
489 }
490
491 if( $wgEnableEmail ) {
492 $wgOut->addHTML("
493 <div><label>$yem: <input type='text' name=\"wpUserEmail\" value=\"{$this->mUserEmail}\" size='20' /></label></div>" );
494 $wgOut->addHTML(
495 $emailauthenticated.
496 $enotifrevealaddr.
497 $enotifwatchlistpages.
498 $enotifusertalkpages.
499 $enotifminoredits );
500 if( $wgEnableUserEmail ) {
501 $wgOut->addHTML(
502 "<div><label><input type='checkbox' $emfc value=\"1\" name=\"wpEmailFlag\" />$emf.$disabled</label></div>" );
503 }
504 }
505
506 $fancysig = $this->getToggle( 'fancysig' );
507 $wgOut->addHTML("
508 <div><label>$ynn: <input type='text' name=\"wpNick\" value=\"{$this->mNick}\" size='25' /></label></div>
509 <div>$fancysig<br /></div>
510 <div><label>$yl: <select name=\"wpUserLanguage\">\n");
511
512 /**
513 * If a bogus value is set, default to the content language.
514 * Otherwise, no default is selected and the user ends up
515 * with an Afrikaans interface since it's first in the list.
516 */
517 if( isset( $wgLanguageNames[$this->mUserLanguage] ) ) {
518 $selectedLang = $this->mUserLanguage;
519 } else {
520 $selectedLang = $wgContLanguageCode;
521 }
522 foreach($wgLanguageNames as $code => $name) {
523 global $IP;
524 /* only add languages that have a file */
525 $langfile="$IP/languages/Language".str_replace('-', '_', ucfirst($code)).".php";
526 if(file_exists($langfile) || $code == $wgContLanguageCode) {
527 $sel = ($code == $selectedLang)? 'selected="selected"' : '';
528 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
529 }
530 }
531 $wgOut->addHtml("</select></label></div>\n" );
532
533 /* see if there are multiple language variants to choose from*/
534 if(!$wgDisableLangConversion) {
535 $variants = $wgContLang->getVariants();
536 $size=sizeof($variants);
537
538 $variantArray=array();
539 foreach($variants as $v) {
540 $v = str_replace( '_', '-', strtolower($v));
541 if($name=$wgLanguageNames[$v]) {
542 $variantArray[$v] = $name;
543 }
544 }
545 $size=sizeof($variantArray);
546
547 if(sizeof($variantArray) > 1) {
548 $wgOut->addHtml("
549 <div><label>$yv: <select name=\"wpUserVariant\">\n");
550 foreach($variantArray as $code => $name) {
551 $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
552 $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
553 }
554 }
555 }
556 # Fields for changing password
557 #
558 $this->mOldpass = htmlspecialchars( $this->mOldpass );
559 $this->mNewpass = htmlspecialchars( $this->mNewpass );
560 $this->mRetypePass = htmlspecialchars( $this->mRetypePass );
561
562 $wgOut->addHTML( "<fieldset>
563 <legend>$cp</legend>
564 <div><label>$opw: <input type='password' name=\"wpOldpass\" value=\"{$this->mOldpass}\" size='20' /></label></div>
565 <div><label>$npw: <input type='password' name=\"wpNewpass\" value=\"{$this->mNewpass}\" size='20' /></label></div>
566 <div><label>$rpw: <input type='password' name=\"wpRetypePass\" value=\"{$this->mRetypePass}\" size='20' /></label></div>
567 " . $this->getToggle( "rememberpassword" ) . "
568 </fieldset>
569 <div class='prefsectiontip'>".$prefs_help_realname.wfMsg('prefs-help-email').$prefs_help_email_enotif."</div>\n</fieldset>\n" );
570
571 # Quickbar setting
572 #
573 if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
574 $wgOut->addHtml( "<fieldset>\n<legend>$qb</legend>\n" );
575 for ( $i = 0; $i < count( $qbs ); ++$i ) {
576 if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; }
577 else { $checked = ""; }
578 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpQuickbar\" value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" );
579 }
580 $wgOut->addHtml( "</fieldset>\n\n" );
581 }
582
583 # Skin setting
584 #
585 $wgOut->addHTML( "<fieldset>\n<legend>$sk</legend>\n" );
586 # Only show members of $wgValidSkinNames rather than
587 # $skinNames (skins is all skin names from Language.php)
588 foreach ($wgValidSkinNames as $skinkey => $skinname ) {
589 if ( $skinkey == $this->mSkin ) {
590 $checked = ' checked="checked"';
591 } else {
592 $checked = '';
593 }
594 if ( isset( $skinNames[$skinkey] ) ) {
595 $sn = $skinNames[$skinkey];
596 } else {
597 $sn = $skinname;
598 }
599 global $wgDefaultSkin;
600 if( $skinkey == $wgDefaultSkin ) {
601 $sn .= ' (' . wfMsg( 'default' ) . ')';
602 }
603 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpSkin\" value=\"$skinkey\"$checked /> {$sn}</label></div>\n" );
604 }
605 $wgOut->addHTML( "</fieldset>\n\n" );
606
607 # Math setting
608 #
609 $wgOut->addHTML( "<fieldset>\n<legend>$math</legend>\n" );
610 for ( $i = 0; $i < count( $mathopts ); ++$i ) {
611 if ( $i == $this->mMath ) { $checked = ' checked="checked"'; }
612 else { $checked = ""; }
613 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpMath\"
614 value=\"$i\"$checked /> ".wfMsg($mathopts[$i])."</label></div>\n" );
615 }
616 $wgOut->addHTML( "</fieldset>\n\n" );
617
618 # Files
619 #
620 $wgOut->addHTML("<fieldset>
621 <legend>$files</legend>
622 <div><label>" . wfMsg('imagemaxsize') . "<select name=\"wpImageSize\">");
623
624 $imageLimitOptions = null;
625 foreach ( $wgImageLimits as $index => $limits ) {
626 $selected = ($index == $this->mImageSize) ? 'selected="selected"' : '';
627 $imageLimitOptions .= "<option value=\"{$index}\" {$selected}>{$limits[0]}x{$limits[1]}</option>\n";
628 }
629
630 $imageThumbOptions = null;
631 $wgOut->addHTML( "{$imageLimitOptions}</select></label></div>
632 <div><label>" . wfMsg('thumbsize') . "<select name=\"wpThumbSize\">");
633 foreach ( $wgThumbLimits as $index => $size ) {
634 $selected = ($index == $this->mThumbSize) ? 'selected="selected"' : '';
635 $imageThumbOptions .= "<option value=\"{$index}\" {$selected}>{$size}px</option>\n";
636 }
637 $wgOut->addHTML( "{$imageThumbOptions}</select></label></div></fieldset>\n\n");
638
639 # Date format
640 #
641 if ($dateopts) {
642 $wgOut->addHTML( "<fieldset>\n<legend>$dateFormat</legend>\n" );
643 foreach($dateopts as $key => $option) {
644 ($key == $this->mDate) ? $checked = ' checked="checked"' : $checked = '';
645 $wgOut->addHTML( "<div><label><input type='radio' name=\"wpDate\" ".
646 "value=\"$key\"$checked />$option</label></div>\n" );
647 }
648 $wgOut->addHTML( "</fieldset>\n\n");
649 }
650
651 # Time zone
652 #
653
654 $nowlocal = $wgLang->time( $now = wfTimestampNow(), true );
655 $nowserver = $wgLang->time( $now, false );
656
657 $wgOut->addHTML( "<fieldset>
658 <legend>$timezone</legend>
659 <div><b>$tzServerTime:</b>" . $nowserver . "</div>
660 <div><b>$ltz:</b> $nowlocal</div>
661 <div><label>$tzo*: <input type='text' name=\"wpHourDiff\" value=\"" . htmlspecialchars( $this->mHourDiff ) . "\" size='6' /></label></div>
662 <div><input type=\"button\" value=\"$tzGuess\" onclick=\"javascript:guessTimezone()\" id=\"guesstimezonebutton\" style=\"display:none\" /></div>
663 <div class='prefsectiontip'>* {$tzt}</div>
664 </fieldset>\n\n" );
665
666 # Editing
667 #
668 $wgOut->addHTML( "<fieldset>
669 <legend>$tbs</legend>\n
670 <div>
671 <label>$tbr: <input type='text' name=\"wpRows\" value=\"{$this->mRows}\" size='6' /></label>
672 <label>$tbc: <input type='text' name=\"wpCols\" value=\"{$this->mCols}\" size='6' /></label>
673 </div> " .
674 $this->getToggle( "editsection" ) .
675 $this->getToggle( "editsectiononrightclick" ) .
676 $this->getToggle( "editondblclick" ) .
677 $this->getToggle( "editwidth" ) .
678 $this->getToggle( "showtoolbar" ) .
679 $this->getToggle( "previewonfirst" ) .
680 $this->getToggle( "previewontop" ) .
681 $this->getToggle( "watchdefault" ) .
682 $this->getToggle( "minordefault" ) .
683 $this->getToggle( "externaleditor" ) .
684 $this->getToggle( "externaldiff" ) .
685 "
686 </fieldset>");
687
688 $shownumberswatching = ($wgRCShowWatchingUsers) ? $this->getToggle('shownumberswatching') : '';
689
690 $wgOut->addHTML( "
691 <fieldset><legend>".wfMsg('prefs-rc')."</legend>
692 <div><label>$rcc: <input type='text' name=\"wpRecent\" value=\"$this->mRecent\" size='6' /></label></div>" .
693 $this->getToggle( "hideminor" ) . $shownumberswatching .
694 $this->getToggle( "usenewrc" ) .
695 $this->getToggle( "rcusemodstyle" ) .
696 $this->getToggle('showupdated', wfMsg('updatedmarker')) .
697 "<div><label>$stt: <input type='text' name=\"wpStubs\" value=\"$this->mStubs\" size='6' /></label></div>
698 </fieldset>
699
700 <fieldset>
701 <legend>$srh</legend>
702 <div><label>$rpp: <input type='text' name=\"wpSearch\" value=\"$this->mSearch\" size='6' /></label></div>
703 <div><label>$scl: <input type='text' name=\"wpSearchLines\" value=\"$this->mSearchLines\" size='6' /></label></div>
704 <div><label>$scc: <input type='text' name=\"wpSearchChars\" value=\"$this->mSearchChars\" size='6' /></label></div>
705
706 <fieldset>
707 <legend>$dsn</legend>
708 $ps
709 </fieldset>
710 </fieldset>
711 " );
712
713 # Various checkbox options
714 #
715 $wgOut->addHTML("<fieldset><legend>".wfMsg('prefs-misc')."</legend>");
716
717 foreach ( $togs as $tname ) {
718 if( !array_key_exists( $tname, $this->mUsedToggles ) ) {
719 $wgOut->addHTML( $this->getToggle( $tname ) );
720 }
721 }
722 $wgOut->addHTML( "</fieldset>\n\n" );
723
724 $token = htmlspecialchars( $wgUser->editToken() );
725 $wgOut->addHTML( "
726 <div id='prefsubmit'>
727 <div>
728 <input type='submit' name=\"wpSaveprefs\" value=\"$svp\" accesskey=\"".
729 wfMsg('accesskey-save')."\" title=\"[alt-".wfMsg('accesskey-save')."]\" />
730 <input type='submit' name=\"wpReset\" value=\"$rsp\" />
731 </div>
732
733 </div>
734
735 <input type='hidden' name='wpEditToken' value=\"{$token}\" />
736 </form>\n" );
737 }
738 }
739 ?>