Fix "you are blocked" message for users who were blocked by zero-ID user.
[lhc/web/wiklou.git] / includes / Preferences.php
index 9553a40..a701125 100644 (file)
@@ -1,27 +1,30 @@
 <?php
 
 /**
- General information about this file:
-  We're now using the HTMLForm object with some customisation to generate the Preferences
-   form. This object handles generic submission, CSRF protection, layout and other logic
-   in a reusable manner. We subclass it as a PreferencesForm to make some minor
-   customisations.
-  In order to generate the form, the HTMLForm object needs an array structure detailing the
-   form fields available, and that's what this class is for. Each element of the array is
-   a basic property-list, including the type of field, the label it is to be given in the
-   form, callbacks for validation and 'filtering', and other pertinent information. Note that
-   the 'default' field is named for generic forms, and does not represent the preference's
-   default (which is stored in $wgDefaultUserOptions), but the default for the form field,
-   which should be whatever the user has set for that preference. There is no need to
-   override it unless you have some special storage logic (for instance, those not presently
-   stored as options, but which are best set from the user preferences view).
-  Field types are implemented as subclasses of the generic HTMLFormField object, and
-   typically implement at least getInputHTML, which generates the HTML for the input field
-   to be placed in the table. 
-  Once fields have been retrieved and validated, submission logic is handed over to the
-   tryUISubmit static method of this class.
-  */
-
+ * We're now using the HTMLForm object with some customisation to generate the
+ * Preferences form. This object handles generic submission, CSRF protection,
+ * layout and other logic in a reusable manner. We subclass it as a PreferencesForm
+ * to make some minor customisations.
+ *
+ * In order to generate the form, the HTMLForm object needs an array structure
+ * detailing the form fields available, and that's what this class is for. Each
+ * element of the array is a basic property-list, including the type of field,
+ * the label it is to be given in the form, callbacks for validation and
+ * 'filtering', and other pertinent information. Note that the 'default' field
+ * is named for generic forms, and does not represent the preference's default
+ * (which is stored in $wgDefaultUserOptions), but the default for the form
+ * field, which should be whatever the user has set for that preference. There
+ * is no need to override it unless you have some special storage logic (for
+ * instance, those not presently stored as options, but which are best set from
+ * the user preferences view).
+ *
+ * Field types are implemented as subclasses of the generic HTMLFormField
+ * object, and typically implement at least getInputHTML, which generates the
+ * HTML for the input field to be placed in the table.
+ *
+ * Once fields have been retrieved and validated, submission logic is handed
+ * over to the tryUISubmit static method of this class.
+ */
 class Preferences {
        static $defaultPreferences = null;
        static $saveFilters =
@@ -386,7 +389,7 @@ class Preferences {
        
                        }
        
-                       if( $wgEnableUserEmail ) {
+                       if( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
                                $defaultPreferences['disablemail'] =
                                                array(
                                                        'type' => 'toggle',
@@ -556,6 +559,7 @@ class Preferences {
                                        'label-message' => 'timezonelegend',
                                        'options' => self::getTimezoneOptions(),
                                        'default' => $tzSetting,
+                                       'size' => 20,
                                        'section' => 'datetime/timeoffset',
                                );
        }
@@ -585,6 +589,7 @@ class Preferences {
                                        'type' => 'selectorother',
                                        'section' => 'rendering/advancedrendering',
                                        'options' => $stubThresholdOptions,
+                                       'size' => 20,
                                        'label' => wfMsg( 'stub-threshold' ), // Raw HTML message. Yay?
                                );
                $defaultPreferences['highlightbroken'] =
@@ -632,7 +637,7 @@ class Preferences {
        }
 
        static function editingPreferences( $user, &$defaultPreferences ) {
-               global $wgUseExternalEditor, $wgLivePreview;
+               global $wgUseExternalEditor;
 
                ## Editing #####################################
                $defaultPreferences['cols'] =
@@ -734,14 +739,6 @@ class Preferences {
                                        'section' => 'editing/advancedediting',
                                        'label-message' => 'tog-forceeditsummary',
                                );
-               if ( $wgLivePreview ) {
-                       $defaultPreferences['uselivepreview'] =
-                                       array(
-                                               'type' => 'toggle',
-                                               'section' => 'editing/advancedediting',
-                                               'label-message' => 'tog-uselivepreview',
-                                       );
-               }
        }
 
        static function rcPreferences( $user, &$defaultPreferences ) {
@@ -999,8 +996,12 @@ class Preferences {
                }
        }
 
+       /**
+        * @param object $user The user object
+        * @return array Text/links to display as key; $skinkey as value
+        */
        static function generateSkinOptions( $user ) {
-               global $wgDefaultSkin;
+               global $wgDefaultSkin, $wgLang, $wgAllowUserCss, $wgAllowUserJs;
                $ret = array();
 
                $mptitle = Title::newMainPage();
@@ -1021,23 +1022,28 @@ class Preferences {
                $sk = $user->getSkin();
 
                foreach( $validSkinNames as $skinkey => $sn ) {
+                       $linkTools = array();
+
+                       # Mark the default skin
+                       if( $skinkey == $wgDefaultSkin ) {
+                               $linkTools[] = wfMsgHtml( 'default' );
+                       }
+
+                       # Create preview link
                        $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) );
-                       $previewlink = "(<a target='_blank' href=\"$mplink\">$previewtext</a>)";
-                       $extraLinks = '';
-                       global $wgAllowUserCss, $wgAllowUserJs;
+                       $linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
+
+                       # Create links to user CSS/JS pages
                        if( $wgAllowUserCss ) {
                                $cssPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.css' );
-                               $customCSS = $sk->link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) );
-                               $extraLinks .= " ($customCSS)";
+                               $linkTools[] = $sk->link( $cssPage, wfMsgHtml( 'prefs-custom-css' ) );
                        }
                        if( $wgAllowUserJs ) {
                                $jsPage = Title::makeTitleSafe( NS_USER, $user->getName() . '/' . $skinkey . '.js' );
-                               $customJS = $sk->link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) );
-                               $extraLinks .= " ($customJS)";
+                               $linkTools[] = $sk->link( $jsPage, wfMsgHtml( 'prefs-custom-js' ) );
                        }
-                       if( $skinkey == $wgDefaultSkin )
-                               $sn .= ' (' . wfMsgHtml( 'default' ) . ')';
-                       $display = "$sn $previewlink{$extraLinks}";
+
+                       $display = $sn . ' ' . wfMsg( 'parentheses', $wgLang->pipeList( $linkTools ) );
                        $ret[$display] = $skinkey;
                }