diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-28 09:50:25 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-01-28 09:50:25 -0500 |
commit | 5744df39e15f85c6cc8a9faf8924d77e76d2b216 (patch) | |
tree | a8c8dd40a94d1fa0d5377566aa5548ae55a163da /includes/Preferences.php | |
parent | 4bb2aeca1d198391ca856aa16c40b8559c68daec (diff) | |
parent | 224b22a051051f6c2e494c3a2fb4adb42898e2d1 (diff) |
Merge branch 'archwiki'
Conflicts:
extensions/FluxBBAuthPlugin.php
extensions/SyntaxHighlight_GeSHi/README
extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php
extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php
extensions/SyntaxHighlight_GeSHi/geshi/docs/CHANGES
extensions/SyntaxHighlight_GeSHi/geshi/docs/THANKS
extensions/SyntaxHighlight_GeSHi/geshi/docs/TODO
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constant.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constructor.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Destructor.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Function.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Global.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/I.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Index.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/L.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lminus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lplus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Method.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateVariable.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticMethod.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticVariable.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/T.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tminus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tplus.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Variable.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/blank.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/class_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/file.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/function_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button_disabled.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button_disabled.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/private_class_logo.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial_folder.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/up_button.png
extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html
extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt
extensions/SyntaxHighlight_GeSHi/geshi/geshi.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/4cs.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502acme.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502kickass.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502tasm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/68000devpac.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/abap.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript3.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ada.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/algol68.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/apache.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/applescript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/apt_sources.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/asm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/asp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoconf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/autohotkey.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoit.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/avisynth.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/awk.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bascomavr.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bash.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/basic4gl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bibtex.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/blitzbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/bnf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/boo.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/c.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_loadrunner.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_mac.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/caddcl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cadlisp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfdg.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/chaiscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cil.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/clojure.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cmake.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cobol.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/coffeescript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp-qt.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/csharp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/css.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/cuesheet.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/d.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/dcs.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/delphi.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/diff.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/div.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/dos.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/dot.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/e.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ecmascript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/eiffel.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/email.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/epc.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/erlang.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/euphoria.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/f1.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/falcon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/fo.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/fortran.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/freebasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/fsharp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gambas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gdb.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/genero.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/genie.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gettext.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/glsl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gnuplot.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/go.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/groovy.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/gwbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/hicest.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/hq9plus.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/html4strict.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/html5.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/icon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/idl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ini.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/inno.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/intercal.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/io.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/j.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/java.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/java5.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/javascript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/jquery.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/kixtart.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonec.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonecpp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/latex.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lb.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lisp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/llvm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/locobasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/logtalk.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lolcode.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusformulas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lsl2.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/lua.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/m68k.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/magiksf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/make.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mapbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/matlab.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mirc.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mmix.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula2.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula3.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mpasm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mxml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/mysql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/newlisp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/nsis.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oberon2.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/objc.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/objeck.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml-brief.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oobas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle11.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle8.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oxygene.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/oz.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pascal.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pcre.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/per.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl6.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pic16.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pike.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pixelbender.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pli.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/plsql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/postgresql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/povray.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/powerbuilder.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/powershell.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/proftpd.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/progress.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/prolog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/properties.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/providex.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/purebasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/pycon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/python.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/q.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/qbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rails.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rebol.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/reg.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/robots.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rpmspec.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/rsplus.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/ruby.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/sas.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/scala.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/scheme.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/scilab.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/sdlbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/smalltalk.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/smarty.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/sql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/systemverilog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/tcl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/teraterm.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/text.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/thinbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/tsql.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/typoscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/unicon.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/uscript.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vala.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vb.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vbnet.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/verilog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vhdl.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/vim.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualfoxpro.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualprolog.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/whitespace.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/whois.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/winbatch.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xbasic.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xorg_conf.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/xpp.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/yaml.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/z80.php
extensions/SyntaxHighlight_GeSHi/geshi/geshi/zxbasic.php
Diffstat (limited to 'includes/Preferences.php')
-rw-r--r-- | includes/Preferences.php | 596 |
1 files changed, 319 insertions, 277 deletions
diff --git a/includes/Preferences.php b/includes/Preferences.php index db231573..c9caf4f7 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1,6 +1,6 @@ <?php /** - * Form to edit user perferences. + * Form to edit user preferences. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,6 +56,12 @@ class Preferences { 'searchlimit' => array( 'Preferences', 'filterIntval' ), ); + // Stuff that shouldn't be saved as a preference. + private static $saveBlacklist = array( + 'realname', + 'emailaddress', + ); + /** * @throws MWException * @param $user User @@ -90,10 +96,19 @@ class Preferences { } } + ## Make sure that form fields have their parent set. See bug 41337. + $dummyForm = new HTMLForm( array(), $context ); + + $disable = !$user->isAllowed( 'editmyoptions' ); + ## Prod in defaults from the user foreach ( $defaultPreferences as $name => &$info ) { $prefFromUser = self::getOptionFromUser( $name, $info, $user ); + if ( $disable && !in_array( $name, self::$saveBlacklist ) ) { + $info['disabled'] = 'disabled'; + } $field = HTMLForm::loadInputFromParameters( $name, $info ); // For validation + $field->mParent = $dummyForm; $defaultOptions = User::getDefaultOptions(); $globalDefault = isset( $defaultOptions[$name] ) ? $defaultOptions[$name] @@ -129,7 +144,7 @@ class Preferences { static function getOptionFromUser( $name, $info, $user ) { $val = $user->getOption( $name ); - // Handling for array-type preferences + // Handling for multiselect preferences if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) || ( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) { $options = HTMLFormField::flattenOptions( $info['options'] ); @@ -143,6 +158,23 @@ class Preferences { } } + // Handling for checkmatrix preferences + if ( ( isset( $info['type'] ) && $info['type'] == 'checkmatrix' ) || + ( isset( $info['class'] ) && $info['class'] == 'HTMLCheckMatrix' ) ) { + $columns = HTMLFormField::flattenOptions( $info['columns'] ); + $rows = HTMLFormField::flattenOptions( $info['rows'] ); + $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name; + $val = array(); + + foreach ( $columns as $column ) { + foreach ( $rows as $row ) { + if ( $user->getOption( "$prefix$column-$row" ) ) { + $val[] = "$column-$row"; + } + } + } + } + return $val; } @@ -156,20 +188,24 @@ class Preferences { global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode, $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars, $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication, - $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress; + $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress, + $wgSecureLogin; + + // retrieving user name for GENDER and misc. + $userName = $user->getName(); ## User info ##################################### // Information panel $defaultPreferences['username'] = array( 'type' => 'info', - 'label-message' => 'username', - 'default' => $user->getName(), + 'label-message' => array( 'username', $userName ), + 'default' => $userName, 'section' => 'personal/info', ); $defaultPreferences['userid'] = array( 'type' => 'info', - 'label-message' => 'uid', + 'label-message' => array( 'uid', $userName ), 'default' => $user->getId(), 'section' => 'personal/info', ); @@ -182,10 +218,10 @@ class Preferences { // Skip the default * group, seems useless here continue; } - $groupName = User::getGroupName( $ueg ); + $groupName = User::getGroupName( $ueg ); $userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName ); - $memberName = User::getGroupMember( $ueg, $user->getName() ); + $memberName = User::getGroupMember( $ueg, $userName ); $userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName ); } asort( $userGroups ); @@ -196,7 +232,7 @@ class Preferences { $defaultPreferences['usergroups'] = array( 'type' => 'info', 'label' => $context->msg( 'prefs-memberingroups' )->numParams( - count( $userGroups ) )->parse(), + count( $userGroups ) )->params( $userName )->parse(), 'default' => $context->msg( 'prefs-memberingroups-type', $lang->commaList( $userGroups ), $lang->commaList( $userMembers ) @@ -205,10 +241,14 @@ class Preferences { 'section' => 'personal/info', ); + $editCount = Linker::link( SpecialPage::getTitleFor( "Contributions", $userName ), + $lang->formatNum( $user->getEditCount() ) ); + $defaultPreferences['editcount'] = array( 'type' => 'info', + 'raw' => true, 'label-message' => 'prefs-edits', - 'default' => $lang->formatNum( $user->getEditCount() ), + 'default' => $editCount, 'section' => 'personal/info', ); @@ -228,31 +268,23 @@ class Preferences { ); } + $canViewPrivateInfo = $user->isAllowed( 'viewmyprivateinfo' ); + $canEditPrivateInfo = $user->isAllowed( 'editmyprivateinfo' ); + // Actually changeable stuff $defaultPreferences['realname'] = array( - 'type' => $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', + // (not really "private", but still shouldn't be edited without permission) + 'type' => $canEditPrivateInfo && $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname', ); - $defaultPreferences['gender'] = array( - 'type' => 'select', - 'section' => 'personal/info', - 'options' => array( - $context->msg( 'gender-male' )->text() => 'male', - $context->msg( 'gender-female' )->text() => 'female', - $context->msg( 'gender-unknown' )->text() => 'unknown', - ), - 'label-message' => 'yourgender', - 'help-message' => 'prefs-help-gender', - ); - - if ( $wgAuth->allowPasswordChange() ) { + if ( $canEditPrivateInfo && $wgAuth->allowPasswordChange() ) { $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ), $context->msg( 'prefs-resetpass' )->escaped(), array(), - array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) ); + array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) ); $defaultPreferences['password'] = array( 'type' => 'info', @@ -270,6 +302,15 @@ class Preferences { 'section' => 'personal/info', ); } + // Only show preferhttps if secure login is turned on + if ( $wgSecureLogin && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) { + $defaultPreferences['prefershttps'] = array( + 'type' => 'toggle', + 'label-message' => 'tog-prefershttps', + 'help-message' => 'prefs-help-prefershttps', + 'section' => 'personal/info' + ); + } // Language $languages = Language::fetchLanguageNames( null, 'mw' ); @@ -290,39 +331,74 @@ class Preferences { 'label-message' => 'yourlanguage', ); - /* see if there are multiple language variants to choose from*/ - $variantArray = array(); + $defaultPreferences['gender'] = array( + 'type' => 'radio', + 'section' => 'personal/i18n', + 'options' => array( + $context->msg( 'parentheses', + $context->msg( 'gender-unknown' )->text() + )->text() => 'unknown', + $context->msg( 'gender-female' )->text() => 'female', + $context->msg( 'gender-male' )->text() => 'male', + ), + 'label-message' => 'yourgender', + 'help-message' => 'prefs-help-gender', + ); + + // see if there are multiple language variants to choose from if ( !$wgDisableLangConversion ) { - $variants = $wgContLang->getVariants(); + foreach ( LanguageConverter::$languagesWithVariants as $langCode ) { + if ( $langCode == $wgContLang->getCode() ) { + $variants = $wgContLang->getVariants(); - foreach ( $variants as $v ) { - $v = str_replace( '_', '-', strtolower( $v ) ); - $variantArray[$v] = $wgContLang->getVariantname( $v, false ); - } + if ( count( $variants ) <= 1 ) { + continue; + } - $options = array(); - foreach ( $variantArray as $code => $name ) { - $display = wfBCP47( $code ) . ' - ' . $name; - $options[$display] = $code; - } + $variantArray = array(); + foreach ( $variants as $v ) { + $v = str_replace( '_', '-', strtolower( $v ) ); + $variantArray[$v] = $lang->getVariantname( $v, false ); + } - if ( count( $variantArray ) > 1 ) { - $defaultPreferences['variant'] = array( - 'label-message' => 'yourvariant', - 'type' => 'select', - 'options' => $options, - 'section' => 'personal/i18n', - 'help-message' => 'prefs-help-variant', - ); + $options = array(); + foreach ( $variantArray as $code => $name ) { + $display = wfBCP47( $code ) . ' - ' . $name; + $options[$display] = $code; + } + + $defaultPreferences['variant'] = array( + 'label-message' => 'yourvariant', + 'type' => 'select', + 'options' => $options, + 'section' => 'personal/i18n', + 'help-message' => 'prefs-help-variant', + ); + + if ( !$wgDisableTitleConversion ) { + $defaultPreferences['noconvertlink'] = array( + 'type' => 'toggle', + 'section' => 'personal/i18n', + 'label-message' => 'tog-noconvertlink', + ); + } + } else { + $defaultPreferences["variant-$langCode"] = array( + 'type' => 'api', + ); + } } } - if ( count( $variantArray ) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion ) { - $defaultPreferences['noconvertlink'] = - array( + // Stuff from Language::getExtraUserToggles() + // FIXME is this dead code? $extraUserToggles doesn't seem to be defined for any language + $toggles = $wgContLang->getExtraUserToggles(); + + foreach ( $toggles as $toggle ) { + $defaultPreferences[$toggle] = array( 'type' => 'toggle', 'section' => 'personal/i18n', - 'label-message' => 'tog-noconvertlink', + 'label-message' => "tog-$toggle", ); } @@ -354,44 +430,45 @@ class Preferences { ## Email stuff if ( $wgEnableEmail ) { - $helpMessages[] = $wgEmailConfirmToEdit - ? 'prefs-help-email-required' - : 'prefs-help-email' ; + if ( $canViewPrivateInfo ) { + $helpMessages[] = $wgEmailConfirmToEdit + ? 'prefs-help-email-required' + : 'prefs-help-email'; + + if ( $wgEnableUserEmail ) { + // additional messages when users can send email to each other + $helpMessages[] = 'prefs-help-email-others'; + } - if( $wgEnableUserEmail ) { - // additional messages when users can send email to each other - $helpMessages[] = 'prefs-help-email-others'; - } + $emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : ''; + if ( $canEditPrivateInfo && $wgAuth->allowPropChange( 'emailaddress' ) ) { + $link = Linker::link( + SpecialPage::getTitleFor( 'ChangeEmail' ), + $context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(), + array(), + array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) ); + + $emailAddress .= $emailAddress == '' ? $link : ( + $context->msg( 'word-separator' )->plain() + . $context->msg( 'parentheses' )->rawParams( $link )->plain() + ); + } - $link = Linker::link( - SpecialPage::getTitleFor( 'ChangeEmail' ), - $context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(), - array(), - array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) ); - - $emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : ''; - if ( $wgAuth->allowPropChange( 'emailaddress' ) ) { - $emailAddress .= $emailAddress == '' ? $link : ( - $context->msg( 'word-separator' )->plain() - . $context->msg( 'parentheses' )->rawParams( $link )->plain() + $defaultPreferences['emailaddress'] = array( + 'type' => 'info', + 'raw' => true, + 'default' => $emailAddress, + 'label-message' => 'youremail', + 'section' => 'personal/email', + 'help-messages' => $helpMessages, + # 'cssclass' chosen below ); } - - $defaultPreferences['emailaddress'] = array( - 'type' => 'info', - 'raw' => true, - 'default' => $emailAddress, - 'label-message' => 'youremail', - 'section' => 'personal/email', - 'help-messages' => $helpMessages, - # 'cssclass' chosen below - ); - $disableEmailPrefs = false; - $emailauthenticationclass = 'mw-email-not-authenticated'; if ( $wgEmailAuthentication ) { + $emailauthenticationclass = 'mw-email-not-authenticated'; if ( $user->getEmail() ) { if ( $user->getEmailAuthenticationTimestamp() ) { // date and time are separate parameters to facilitate localisation. @@ -413,7 +490,7 @@ class Preferences { SpecialPage::getTitleFor( 'Confirmemail' ), $context->msg( 'emailconfirmlink' )->escaped() ) . '<br />'; - $emailauthenticationclass="mw-email-not-authenticated"; + $emailauthenticationclass = "mw-email-not-authenticated"; } } else { $disableEmailPrefs = true; @@ -421,17 +498,19 @@ class Preferences { $emailauthenticationclass = 'mw-email-none'; } - $defaultPreferences['emailauthentication'] = array( - 'type' => 'info', - 'raw' => true, - 'section' => 'personal/email', - 'label-message' => 'prefs-emailconfirm-label', - 'default' => $emailauthenticated, - # Apply the same CSS class used on the input to the message: - 'cssclass' => $emailauthenticationclass, - ); + if ( $canViewPrivateInfo ) { + $defaultPreferences['emailauthentication'] = array( + 'type' => 'info', + 'raw' => true, + 'section' => 'personal/email', + 'label-message' => 'prefs-emailconfirm-label', + 'default' => $emailauthenticated, + # Apply the same CSS class used on the input to the message: + 'cssclass' => $emailauthenticationclass, + ); + $defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass; + } } - $defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass; if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) { $defaultPreferences['disablemail'] = array( @@ -507,14 +586,15 @@ class Preferences { # be nice to somehow merge this back in there to avoid redundancy. if ( $wgAllowUserCss || $wgAllowUserJs ) { $linkTools = array(); + $userName = $user->getName(); if ( $wgAllowUserCss ) { - $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.css' ); + $cssPage = Title::makeTitleSafe( NS_USER, $userName . '/common.css' ); $linkTools[] = Linker::link( $cssPage, $context->msg( 'prefs-custom-css' )->escaped() ); } if ( $wgAllowUserJs ) { - $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/common.js' ); + $jsPage = Title::makeTitleSafe( NS_USER, $userName . '/common.js' ); $linkTools[] = Linker::link( $jsPage, $context->msg( 'prefs-custom-js' )->escaped() ); } @@ -526,18 +606,6 @@ class Preferences { 'section' => 'rendering/skin', ); } - - $selectedSkin = $user->getOption( 'skin' ); - if ( in_array( $selectedSkin, array( 'cologneblue', 'standard' ) ) ) { - $settings = array_flip( $context->getLanguage()->getQuickbarSettings() ); - - $defaultPreferences['quickbar'] = array( - 'type' => 'radio', - 'options' => $settings, - 'section' => 'rendering/skin', - 'label-message' => 'qbsettings', - ); - } } /** @@ -640,6 +708,18 @@ class Preferences { * @param $defaultPreferences Array */ static function renderingPreferences( $user, IContextSource $context, &$defaultPreferences ) { + ## Diffs #################################### + $defaultPreferences['diffonly'] = array( + 'type' => 'toggle', + 'section' => 'rendering/diffs', + 'label-message' => 'tog-diffonly', + ); + $defaultPreferences['norollbackdiff'] = array( + 'type' => 'toggle', + 'section' => 'rendering/diffs', + 'label-message' => 'tog-norollbackdiff', + ); + ## Page Rendering ############################## global $wgAllowUserCssPrefs; if ( $wgAllowUserCssPrefs ) { @@ -666,7 +746,7 @@ class Preferences { 'section' => 'rendering/advancedrendering', 'options' => $stubThresholdOptions, 'size' => 20, - 'label' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay? + 'label-raw' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay? ); if ( $wgAllowUserCssPrefs ) { @@ -686,11 +766,6 @@ class Preferences { 'section' => 'rendering/advancedrendering', 'label-message' => 'tog-showhiddencats' ); - $defaultPreferences['showjumplinks'] = array( - 'type' => 'toggle', - 'section' => 'rendering/advancedrendering', - 'label-message' => 'tog-showjumplinks', - ); if ( $wgAllowUserCssPrefs ) { $defaultPreferences['justify'] = array( @@ -713,28 +788,31 @@ class Preferences { * @param $defaultPreferences Array */ static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) { - global $wgUseExternalEditor, $wgAllowUserCssPrefs; + global $wgAllowUserCssPrefs; ## Editing ##################################### - $defaultPreferences['cols'] = array( - 'type' => 'int', - 'label-message' => 'columns', - 'section' => 'editing/textboxsize', - 'min' => 4, - 'max' => 1000, + if ( $wgAllowUserCssPrefs ) { + $defaultPreferences['editsection'] = array( + 'type' => 'toggle', + 'section' => 'editing/advancedediting', + 'label-message' => 'tog-editsection', + ); + } + $defaultPreferences['editsectiononrightclick'] = array( + 'type' => 'toggle', + 'section' => 'editing/advancedediting', + 'label-message' => 'tog-editsectiononrightclick', ); - $defaultPreferences['rows'] = array( - 'type' => 'int', - 'label-message' => 'rows', - 'section' => 'editing/textboxsize', - 'min' => 4, - 'max' => 1000, + $defaultPreferences['editondblclick'] = array( + 'type' => 'toggle', + 'section' => 'editing/advancedediting', + 'label-message' => 'tog-editondblclick', ); if ( $wgAllowUserCssPrefs ) { $defaultPreferences['editfont'] = array( 'type' => 'select', - 'section' => 'editing/advancedediting', + 'section' => 'editing/editor', 'label-message' => 'editfont-style', 'options' => array( $context->msg( 'editfont-default' )->text() => 'default', @@ -744,73 +822,59 @@ class Preferences { ) ); } - $defaultPreferences['previewontop'] = array( - 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-previewontop', + $defaultPreferences['cols'] = array( + 'type' => 'int', + 'label-message' => 'columns', + 'section' => 'editing/editor', + 'min' => 4, + 'max' => 1000, ); - $defaultPreferences['previewonfirst'] = array( - 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-previewonfirst', + $defaultPreferences['rows'] = array( + 'type' => 'int', + 'label-message' => 'rows', + 'section' => 'editing/editor', + 'min' => 4, + 'max' => 1000, ); - - if ( $wgAllowUserCssPrefs ) { - $defaultPreferences['editsection'] = array( + if ( $user->isAllowed( 'minoredit' ) ) { + $defaultPreferences['minordefault'] = array( 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-editsection', + 'section' => 'editing/editor', + 'label-message' => 'tog-minordefault', ); } - $defaultPreferences['editsectiononrightclick'] = array( + $defaultPreferences['forceeditsummary'] = array( 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-editsectiononrightclick', + 'section' => 'editing/editor', + 'label-message' => 'tog-forceeditsummary', ); - $defaultPreferences['editondblclick'] = array( + $defaultPreferences['useeditwarning'] = array( 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-editondblclick', + 'section' => 'editing/editor', + 'label-message' => 'tog-useeditwarning', ); $defaultPreferences['showtoolbar'] = array( 'type' => 'toggle', - 'section' => 'editing/advancedediting', + 'section' => 'editing/editor', 'label-message' => 'tog-showtoolbar', ); - if ( $user->isAllowed( 'minoredit' ) ) { - $defaultPreferences['minordefault'] = array( - 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-minordefault', - ); - } - - if ( $wgUseExternalEditor ) { - $defaultPreferences['externaleditor'] = array( - 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-externaleditor', - ); - $defaultPreferences['externaldiff'] = array( - 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-externaldiff', - ); - } - - $defaultPreferences['forceeditsummary'] = array( + $defaultPreferences['previewonfirst'] = array( 'type' => 'toggle', - 'section' => 'editing/advancedediting', - 'label-message' => 'tog-forceeditsummary', + 'section' => 'editing/preview', + 'label-message' => 'tog-previewonfirst', + ); + $defaultPreferences['previewontop'] = array( + 'type' => 'toggle', + 'section' => 'editing/preview', + 'label-message' => 'tog-previewontop', ); - - $defaultPreferences['uselivepreview'] = array( 'type' => 'toggle', - 'section' => 'editing/advancedediting', + 'section' => 'editing/preview', 'label-message' => 'tog-uselivepreview', ); + } /** @@ -879,7 +943,7 @@ class Preferences { global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge; $watchlistdaysMax = ceil( $wgRCMaxAge / ( 3600 * 24 ) ); - + ## Watchlist ##################################### $defaultPreferences['watchlistdays'] = array( 'type' => 'float', @@ -887,7 +951,7 @@ class Preferences { 'max' => $watchlistdaysMax, 'section' => 'watchlist/displaywatchlist', 'help' => $context->msg( 'prefs-watchlist-days-max' )->numParams( - $watchlistdaysMax )->text(), + $watchlistdaysMax )->text(), 'label-message' => 'prefs-watchlist-days', ); $defaultPreferences['wllimit'] = array( @@ -937,19 +1001,6 @@ class Preferences { ); } - if ( $wgEnableAPI ) { - # Some random gibberish as a proposed default - // @todo Fixme: this should use CryptRand but we may not want to read urandom on every view - $hash = sha1( mt_rand() . microtime( true ) ); - - $defaultPreferences['watchlisttoken'] = array( - 'type' => 'text', - 'section' => 'watchlist/advancedwatchlist', - 'label-message' => 'prefs-watchlist-token', - 'help' => $context->msg( 'prefs-help-watchlist-token', $hash )->escaped() - ); - } - $watchTypes = array( 'edit' => 'watchdefault', 'move' => 'watchmoves', @@ -963,6 +1014,8 @@ class Preferences { foreach ( $watchTypes as $action => $pref ) { if ( $user->isAllowed( $action ) ) { + // Messages: + // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations $defaultPreferences[$pref] = array( 'type' => 'toggle', 'section' => 'watchlist/advancedwatchlist', @@ -970,6 +1023,19 @@ class Preferences { ); } } + + if ( $wgEnableAPI ) { + $defaultPreferences['watchlisttoken'] = array( + 'type' => 'api', + ); + $defaultPreferences['watchlisttoken-info'] = array( + 'type' => 'info', + 'section' => 'watchlist/tokenwatchlist', + 'label-message' => 'prefs-watchlist-token', + 'default' => $user->getTokenFromOption( 'watchlisttoken' ), + 'help-message' => 'prefs-help-watchlist-token2', + ); + } } /** @@ -988,7 +1054,6 @@ class Preferences { 'min' => 0, ); - if ( $wgVectorUseSimpleSearch ) { $defaultPreferences['vector-simplesearch'] = array( 'type' => 'toggle', @@ -1009,62 +1074,27 @@ class Preferences { 'section' => 'searchoptions/advancedsearchoptions', ); - $nsOptions = array(); - - foreach ( $wgContLang->getNamespaces() as $ns => $name ) { + $nsOptions = $wgContLang->getFormattedNamespaces(); + $nsOptions[0] = $context->msg( 'blanknamespace' )->text(); + foreach ( $nsOptions as $ns => $name ) { if ( $ns < 0 ) { - continue; - } - - $displayNs = str_replace( '_', ' ', $name ); - - if ( !$displayNs ) { - $displayNs = $context->msg( 'blanknamespace' )->text(); + unset( $nsOptions[$ns] ); } - - $displayNs = htmlspecialchars( $displayNs ); - $nsOptions[$displayNs] = $ns; } $defaultPreferences['searchnamespaces'] = array( 'type' => 'multiselect', 'label-message' => 'defaultns', - 'options' => $nsOptions, + 'options' => array_flip( $nsOptions ), 'section' => 'searchoptions/advancedsearchoptions', 'prefix' => 'searchNs', ); } /** - * @param $user User - * @param $context IContextSource - * @param $defaultPreferences Array + * Dummy, kept for backwards-compatibility. */ static function miscPreferences( $user, IContextSource $context, &$defaultPreferences ) { - global $wgContLang; - - ## Misc ##################################### - $defaultPreferences['diffonly'] = array( - 'type' => 'toggle', - 'section' => 'misc/diffs', - 'label-message' => 'tog-diffonly', - ); - $defaultPreferences['norollbackdiff'] = array( - 'type' => 'toggle', - 'section' => 'misc/diffs', - 'label-message' => 'tog-norollbackdiff', - ); - - // Stuff from Language::getExtraUserToggles() - $toggles = $wgContLang->getExtraUserToggles(); - - foreach ( $toggles as $toggle ) { - $defaultPreferences[$toggle] = array( - 'type' => 'toggle', - 'section' => 'personal/i18n', - 'label-message' => "tog-$toggle", - ); - } } /** @@ -1102,7 +1132,7 @@ class Preferences { } # Create preview link - $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) ); + $mplink = htmlspecialchars( $mptitle->getLocalURL( array( 'useskin' => $skinkey ) ) ); $linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>"; # Create links to user CSS/JS pages @@ -1236,7 +1266,7 @@ class Preferences { * @param $user User * @param $context IContextSource * @param $formClass string - * @param $remove Array: array of items to remove + * @param array $remove array of items to remove * @return HtmlForm */ static function getFormObject( $user, IContextSource $context, $formClass = 'PreferencesForm', array $remove = array() ) { @@ -1270,15 +1300,17 @@ class Preferences { } /** + * @param $context IContextSource * @return array */ static function getTimezoneOptions( IContextSource $context ) { $opt = array(); - global $wgLocalTZoffset, $wgLocaltimezone; - // Check that $wgLocalTZoffset is the same as $wgLocaltimezone - if ( $wgLocalTZoffset == date( 'Z' ) / 60 ) { - $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $wgLocaltimezone )->text(); + global $wgLocalTZoffset; + $timestamp = MWTimestamp::getLocalInstance(); + // Check that $wgLocalTZoffset is the same as the local time zone offset + if ( $wgLocalTZoffset == $timestamp->format( 'Z' ) / 60 ) { + $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $timestamp->getTimezone()->getName() )->text(); } else { $tzstring = sprintf( '%+03d:%02d', floor( $wgLocalTZoffset / 60 ), abs( $wgLocalTZoffset ) % 60 ); $server_tz_msg = $context->msg( 'timezoneuseserverdefault', $tzstring )->text(); @@ -1339,7 +1371,7 @@ class Preferences { * @param $alldata * @return int */ - static function filterIntval( $value, $alldata ){ + static function filterIntval( $value, $alldata ) { return intval( $value ); } @@ -1360,7 +1392,9 @@ class Preferences { $data[0] = intval( $data[0] ); $data[1] = intval( $data[1] ); $minDiff = abs( $data[0] ) * 60 + $data[1]; - if ( $data[0] < 0 ) $minDiff = - $minDiff; + if ( $data[0] < 0 ) { + $minDiff = - $minDiff; + } } else { $minDiff = intval( $data[0] ) * 60; } @@ -1374,17 +1408,23 @@ class Preferences { } /** + * Handle the form submission if everything validated properly + * * @param $formData * @param $form PreferencesForm * @param $entryPoint string * @return bool|Status|string */ static function tryFormSubmit( $formData, $form, $entryPoint = 'internal' ) { - global $wgHiddenPrefs; + global $wgHiddenPrefs, $wgAuth; $user = $form->getModifiedUser(); $result = true; + if ( !$user->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) { + return Status::newFatal( 'mypreferencesprotected' ); + } + // Filter input foreach ( array_keys( $formData ) as $name ) { if ( isset( self::$saveFilters[$name] ) ) { @@ -1393,41 +1433,39 @@ class Preferences { } } - // Stuff that shouldn't be saved as a preference. - $saveBlacklist = array( - 'realname', - 'emailaddress', - ); - // Fortunately, the realname field is MUCH simpler - if ( !in_array( 'realname', $wgHiddenPrefs ) ) { + // (not really "private", but still shouldn't be edited without permission) + if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) ) { $realName = $formData['realname']; $user->setRealName( $realName ); } - foreach ( $saveBlacklist as $b ) { - unset( $formData[$b] ); - } + if ( $user->isAllowed( 'editmyoptions' ) ) { + foreach ( self::$saveBlacklist as $b ) { + unset( $formData[$b] ); + } - # If users have saved a value for a preference which has subsequently been disabled - # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference - # is subsequently re-enabled - # TODO: maintenance script to actually delete these - foreach( $wgHiddenPrefs as $pref ){ - # If the user has not set a non-default value here, the default will be returned - # and subsequently discarded - $formData[$pref] = $user->getOption( $pref, null, true ); - } + # If users have saved a value for a preference which has subsequently been disabled + # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference + # is subsequently re-enabled + # TODO: maintenance script to actually delete these + foreach ( $wgHiddenPrefs as $pref ) { + # If the user has not set a non-default value here, the default will be returned + # and subsequently discarded + $formData[$pref] = $user->getOption( $pref, null, true ); + } - // Keeps old preferences from interfering due to back-compat - // code, etc. - $user->resetOptions(); + // Keep old preferences from interfering due to back-compat code, etc. + $user->resetOptions( 'unused', $form->getContext() ); - foreach ( $formData as $key => $value ) { - $user->setOption( $key, $value ); + foreach ( $formData as $key => $value ) { + $user->setOption( $key, $value ); + } + + $user->saveSettings(); } - $user->saveSettings(); + $wgAuth->updateExternalDB( $user ); return $result; } @@ -1460,11 +1498,12 @@ class Preferences { /** * Try to set a user's email address. * This does *not* try to validate the address. - * Caller is responsible for checking $wgAuth. + * Caller is responsible for checking $wgAuth and 'editmyprivateinfo' + * right. * * @deprecated in 1.20; use User::setEmailWithConfirmation() instead. * @param $user User - * @param $newaddr string New email address + * @param string $newaddr New email address * @return Array (true on success or Status on failure, info string) */ public static function trySetUserEmail( User $user, $newaddr ) { @@ -1479,7 +1518,7 @@ class Preferences { } /** - * @deprecated in 1.19; will be removed in 1.20. + * @deprecated in 1.19 * @param $user User * @return array */ @@ -1549,34 +1588,37 @@ class PreferencesForm extends HTMLForm { * @return String */ function getButtons() { + if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) { + return ''; + } + $html = parent::getButtons(); - $t = SpecialPage::getTitleFor( 'Preferences', 'reset' ); + if ( $this->getModifiedUser()->isAllowed( 'editmyoptions' ) ) { + $t = SpecialPage::getTitleFor( 'Preferences', 'reset' ); - $html .= "\n" . Linker::link( $t, $this->msg( 'restoreprefs' )->escaped() ); + $html .= "\n" . Linker::link( $t, $this->msg( 'restoreprefs' )->escaped() ); - $html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html ); + $html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html ); + } return $html; } /** + * Separate multi-option preferences into multiple preferences, since we + * have to store them separately * @param $data array * @return array */ function filterDataForSubmit( $data ) { - // Support for separating MultiSelect preferences into multiple preferences - // Due to lack of array support. foreach ( $this->mFlatFields as $fieldname => $field ) { - $info = $field->mParams; - if ( $field instanceof HTMLMultiSelectField ) { - $options = HTMLFormField::flattenOptions( $info['options'] ); + if ( $field instanceof HTMLNestedFilterable ) { + $info = $field->mParams; $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $fieldname; - - foreach ( $options as $opt ) { - $data["$prefix$opt"] = in_array( $opt, $data[$fieldname] ); + foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) { + $data["$prefix$key"] = $value; } - unset( $data[$fieldname] ); } } |