Also set the queue types map when rebuilding the ready queue map
[lhc/web/wiklou.git] / includes / Preferences.php
index 4b91386..081315e 100644 (file)
  * over to the tryUISubmit static method of this class.
  */
 class Preferences {
-       static $defaultPreferences = null;
-       static $saveFilters = array(
-                       'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
-                       'cols' => array( 'Preferences', 'filterIntval' ),
-                       'rows' => array( 'Preferences', 'filterIntval' ),
-                       'rclimit' => array( 'Preferences', 'filterIntval' ),
-                       'wllimit' => array( 'Preferences', 'filterIntval' ),
-                       'searchlimit' => array( 'Preferences', 'filterIntval' ),
+       /** @var array */
+       protected static $defaultPreferences = null;
+
+       /** @var array */
+       protected static $saveFilters = array(
+               'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
+               'cols' => array( 'Preferences', 'filterIntval' ),
+               'rows' => array( 'Preferences', 'filterIntval' ),
+               'rclimit' => array( 'Preferences', 'filterIntval' ),
+               'wllimit' => array( 'Preferences', 'filterIntval' ),
+               'searchlimit' => array( 'Preferences', 'filterIntval' ),
        );
 
        // Stuff that shouldn't be saved as a preference.
@@ -71,8 +74,8 @@ class Preferences {
 
        /**
         * @throws MWException
-        * @param $user User
-        * @param $context IContextSource
+        * @param User $user
+        * @param IContextSource $context
         * @return array|null
         */
        static function getPreferences( $user, IContextSource $context ) {
@@ -143,10 +146,10 @@ class Preferences {
        /**
         * Pull option from a user account. Handles stuff like array-type preferences.
         *
-        * @param $name
-        * @param $info
-        * @param $user User
-        * @return array|String
+        * @param string $name
+        * @param array $info
+        * @param User $user
+        * @return array|string
         */
        static function getOptionFromUser( $name, $info, $user ) {
                $val = $user->getOption( $name );
@@ -186,9 +189,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         * @return void
         */
        static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
@@ -210,13 +213,6 @@ class Preferences {
                        'section' => 'personal/info',
                );
 
-               $defaultPreferences['userid'] = array(
-                       'type' => 'info',
-                       'label-message' => array( 'uid', $userName ),
-                       'default' => $user->getId(),
-                       'section' => 'personal/info',
-               );
-
                # Get groups to which the user belongs
                $userEffectiveGroups = $user->getEffectiveGroups();
                $userGroups = $userMembers = array();
@@ -562,9 +558,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         * @return void
         */
        static function skinPreferences( $user, IContextSource $context, &$defaultPreferences ) {
@@ -606,9 +602,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function filesPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                ## Files #####################################
@@ -627,9 +623,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         * @return void
         */
        static function datetimePreferences( $user, IContextSource $context, &$defaultPreferences ) {
@@ -700,9 +696,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function renderingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                ## Diffs ####################################
@@ -760,9 +756,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgAllowUserCssPrefs;
@@ -848,9 +844,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function rcPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgRCMaxAge, $wgRCShowWatchingUsers;
@@ -905,9 +901,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function watchlistPreferences( $user, IContextSource $context, &$defaultPreferences ) {
                global $wgUseRCPatrol, $wgEnableAPI, $wgRCMaxAge;
@@ -1009,34 +1005,16 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $defaultPreferences Array
+        * @param User $user
+        * @param IContextSource $context
+        * @param array $defaultPreferences
         */
        static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
-               global $wgContLang;
-
-               $defaultPreferences['searcheverything'] = array(
-                       'type' => 'toggle',
-                       'label-message' => 'searcheverything-enable',
-                       'section' => 'searchoptions/advancedsearchoptions',
-               );
-
-               $nsOptions = $wgContLang->getFormattedNamespaces();
-               $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
-               foreach ( $nsOptions as $ns => $name ) {
-                       if ( $ns < 0 ) {
-                               unset( $nsOptions[$ns] );
-                       }
+               foreach ( MWNamespace::getValidNamespaces() as $n ) {
+                       $defaultPreferences[ 'searchNs' . $n ] = array(
+                               'type' => 'api',
+                       );
                }
-
-               $defaultPreferences['searchnamespaces'] = array(
-                       'type' => 'multiselect',
-                       'label-message' => 'defaultns',
-                       'options' => array_flip( $nsOptions ),
-                       'section' => 'searchoptions/advancedsearchoptions',
-                       'prefix' => 'searchNs',
-               );
        }
 
        /**
@@ -1046,9 +1024,9 @@ class Preferences {
        }
 
        /**
-        * @param $user User The User object
-        * @param $context IContextSource
-        * @return Array: text/links to display as key; $skinkey as value
+        * @param User $user The User object
+        * @param IContextSource $context
+        * @return array Text/links to display as key; $skinkey as value
         */
        static function generateSkinOptions( $user, IContextSource $context ) {
                global $wgDefaultSkin, $wgAllowUserCss, $wgAllowUserJs;
@@ -1104,7 +1082,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getDateOptions( IContextSource $context ) {
@@ -1139,7 +1117,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getImageSizes( IContextSource $context ) {
@@ -1157,7 +1135,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getThumbSizes( IContextSource $context ) {
@@ -1175,9 +1153,9 @@ class Preferences {
        }
 
        /**
-        * @param $signature string
-        * @param $alldata array
-        * @param $form HTMLForm
+        * @param string $signature
+        * @param array $alldata
+        * @param HTMLForm $form
         * @return bool|string
         */
        static function validateSignature( $signature, $alldata, $form ) {
@@ -1200,9 +1178,9 @@ class Preferences {
        }
 
        /**
-        * @param $signature string
-        * @param $alldata array
-        * @param $form HTMLForm
+        * @param string $signature
+        * @param array $alldata
+        * @param HTMLForm $form
         * @return string
         */
        static function cleanSignature( $signature, $alldata, $form ) {
@@ -1218,10 +1196,10 @@ class Preferences {
        }
 
        /**
-        * @param $user User
-        * @param $context IContextSource
-        * @param $formClass string
-        * @param array $remove array of items to remove
+        * @param User $user
+        * @param IContextSource $context
+        * @param string $formClass
+        * @param array $remove Array of items to remove
         * @return HtmlForm
         */
        static function getFormObject(
@@ -1260,7 +1238,7 @@ class Preferences {
        }
 
        /**
-        * @param $context IContextSource
+        * @param IContextSource $context
         * @return array
         */
        static function getTimezoneOptions( IContextSource $context ) {
@@ -1334,8 +1312,8 @@ class Preferences {
        }
 
        /**
-        * @param $value
-        * @param $alldata
+        * @param string $value
+        * @param array $alldata
         * @return int
         */
        static function filterIntval( $value, $alldata ) {
@@ -1343,8 +1321,8 @@ class Preferences {
        }
 
        /**
-        * @param $tz
-        * @param $alldata
+        * @param string $tz
+        * @param array $alldata
         * @return string
         */
        static function filterTimezoneInput( $tz, $alldata ) {
@@ -1377,8 +1355,8 @@ class Preferences {
        /**
         * Handle the form submission if everything validated properly
         *
-        * @param $formData
-        * @param $form PreferencesForm
+        * @param array $formData
+        * @param PreferencesForm $form
         * @return bool|Status|string
         */
        static function tryFormSubmit( $formData, $form ) {
@@ -1401,7 +1379,10 @@ class Preferences {
 
                // Fortunately, the realname field is MUCH simpler
                // (not really "private", but still shouldn't be edited without permission)
-               if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) ) {
+               if ( !in_array( 'realname', $wgHiddenPrefs )
+                       && $user->isAllowed( 'editmyprivateinfo' )
+                       && array_key_exists( 'realname', $formData )
+               ) {
                        $realName = $formData['realname'];
                        $user->setRealName( $realName );
                }
@@ -1437,8 +1418,8 @@ class Preferences {
        }
 
        /**
-        * @param $formData
-        * @param $form PreferencesForm
+        * @param array $formData
+        * @param PreferencesForm $form
         * @return Status
         */
        public static function tryUISubmit( $formData, $form ) {
@@ -1468,9 +1449,9 @@ class Preferences {
         * right.
         *
         * @deprecated since 1.20; use User::setEmailWithConfirmation() instead.
-        * @param $user User
+        * @param User $user
         * @param string $newaddr New email address
-        * @return Array (true on success or Status on failure, info string)
+        * @return array (true on success or Status on failure, info string)
         */
        public static function trySetUserEmail( User $user, $newaddr ) {
                wfDeprecated( __METHOD__, '1.20' );
@@ -1485,7 +1466,7 @@ class Preferences {
 
        /**
         * @deprecated since 1.19
-        * @param $user User
+        * @param User $user
         * @return array
         */
        public static function loadOldSearchNs( $user ) {
@@ -1513,7 +1494,7 @@ class PreferencesForm extends HTMLForm {
        private $modifiedUser;
 
        /**
-        * @param $user User
+        * @param User $user
         */
        public function setModifiedUser( $user ) {
                $this->modifiedUser = $user;
@@ -1541,8 +1522,8 @@ class PreferencesForm extends HTMLForm {
        }
 
        /**
-        * @param $html string
-        * @return String
+        * @param string $html
+        * @return string
         */
        function wrapForm( $html ) {
                $html = Xml::tags( 'div', array( 'id' => 'preferences' ), $html );
@@ -1551,7 +1532,7 @@ class PreferencesForm extends HTMLForm {
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getButtons() {
                if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
@@ -1574,7 +1555,7 @@ class PreferencesForm extends HTMLForm {
        /**
         * Separate multi-option preferences into multiple preferences, since we
         * have to store them separately
-        * @param $data array
+        * @param array $data
         * @return array
         */
        function filterDataForSubmit( $data ) {
@@ -1603,7 +1584,7 @@ class PreferencesForm extends HTMLForm {
        /**
         * Get the "<legend>" for a given section key. Normally this is the
         * prefs-$key message but we'll allow extensions to override it.
-        * @param $key string
+        * @param string $key
         * @return string
         */
        function getLegend( $key ) {