From: Ævar Arnfjörð Bjarmason Date: Wed, 20 Jul 2005 03:30:44 +0000 (+0000) Subject: * Added a validateDate() function, the date preference option is somtimes not X-Git-Tag: 1.5.0beta4~90 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=d9fc810c9e293ac23dae1897a455488591406a18;p=lhc%2Fweb%2Fwiklou.git * Added a validateDate() function, the date preference option is somtimes not an integer and this was causing an error that made the DateFormatter.php not work for ISO 8601 dates. --- diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index 4616fcc025..066db60ae5 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -121,8 +121,7 @@ class PreferencesForm { $this->mainPrefsForm( '' ); } } - - /** + /** * @access private */ function validateInt( &$val, $min=0, $max=0x7fffffff ) { @@ -144,6 +143,16 @@ class PreferencesForm { } } + /** + * @access private + */ + function validateDate( &$val, $min = 0, $max = 0, $max=0x7fffffff ) { + if ( ( sprintf('%d', $val) === $val && $val >= $min && $val <= $max ) || $val == 'ISO 8601' ) + return $val; + else + return 0; + } + /** * Used to validate the user inputed timezone before saving it as * 'timeciorrection', will return '00:00' if fed bogus data. @@ -217,7 +226,7 @@ class PreferencesForm { if( $wgUseTeX ) { $wgUser->setOption( 'math', $this->mMath ); } - $wgUser->setOption( 'date', $this->validateInt( $this->mDate, 0, 10 ) ); + $wgUser->setOption( 'date', $this->validateDate( $this->mDate, 0, 10 ) ); $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) ); $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) ); $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) );