Fixed PreferencesForm::validateDate().
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 10 Aug 2006 08:00:53 +0000 (08:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 10 Aug 2006 08:00:53 +0000 (08:00 +0000)
includes/SpecialPreferences.php
languages/Language.php

index c0177f3..ba93e87 100644 (file)
@@ -156,11 +156,16 @@ class PreferencesForm {
        /**
         * @access private
         */
-       function validateDate( &$val, $min = 0, $max=0x7fffffff ) {
-               if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) || $val == 'ISO 8601' )
+       function validateDate( $val ) {
+               global $wgLang, $wgContLang;
+               if ( $val !== false && (
+                       in_array( $val, (array)$wgLang->getDatePreferences() ) ||
+                       in_array( $val, (array)$wgContLang->getDatePreferences() ) ) ) 
+               {
                        return $val;
-               else
-                       return 0;
+               } else {
+                       return $wgLang->getDefaultDateFormat();
+               }
        }
 
        /**
@@ -257,7 +262,7 @@ class PreferencesForm {
                if( $wgUseTeX ) {
                        $wgUser->setOption( 'math', $this->mMath );
                }
-               $wgUser->setOption( 'date', $this->validateDate( $this->mDate, 0, 20 ) );
+               $wgUser->setOption( 'date', $this->validateDate( $this->mDate ) );
                $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) );
                $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) );
                $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );
index 49a3bff..2644e58 100644 (file)
@@ -276,6 +276,11 @@ class Language {
                return $this->dateFormats;
        }
 
+       function getDefaultDateFormat() {
+               $this->load();
+               return $this->defaultDateFormat;
+       }
+
        function getDatePreferenceMigrationMap() {
                $this->load();
                return $this->datePreferenceMigrationMap;