Change new wgUserRegistration format, put in User:
authorMatthew Flaschen <mflaschen@wikimedia.org>
Wed, 27 Feb 2013 02:32:19 +0000 (21:32 -0500)
committerMattflaschen <mflaschen@wikimedia.org>
Wed, 27 Feb 2013 05:55:55 +0000 (05:55 +0000)
* This is much more useful if it can be passed to new Date.  As a side
effect, this means straight arithmetic comparisons can be done.
* Add a method for this to mediawiki.user (getRegistrationDate).
* Improve docs on server User::getRegistration method by documenting possibility that data is null.

Change-Id: Id7ae0faa930433876939b73d47fc294975e14fb1

includes/OutputPage.php
includes/User.php
resources/mediawiki/mediawiki.user.js

index 525fc24..8a95f04 100644 (file)
@@ -3029,7 +3029,8 @@ $templates
                if ( $user->isLoggedIn() ) {
                        $vars['wgUserId'] = $user->getId();
                        $vars['wgUserEditCount'] = $user->getEditCount();
-                       $vars['wgUserRegistration'] = $user->getRegistration();
+                       $userReg = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
+                       $vars['wgUserRegistration'] = $userReg !== null ? ( $userReg * 1000 ) : null;
                }
                if ( $wgContLang->hasVariants() ) {
                        $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
index de34bfc..7a60d9e 100644 (file)
@@ -3748,8 +3748,9 @@ class User {
        /**
         * Get the timestamp of account creation.
         *
-        * @return String|Bool Timestamp of account creation, or false for
-        *     non-existent/anonymous user accounts.
+        * @return String|Bool|Null Timestamp of account creation, false for
+        *     non-existent/anonymous user accounts, or null if existing account
+        *     but information is not in database.
         */
        public function getRegistration() {
                if ( $this->isAnon() ) {
index 3b2a59c..308e4ad 100644 (file)
                        return this.getName();
                };
 
+               /**
+                * Get date user registered, if available.
+                *
+                * @return {Date|false|null} date user registered, or false for anonymous users, or
+                *  null when data is not available
+                */
+               this.getRegistration = function () {
+                       var registration = mw.config.get( 'wgUserRegistration' );
+                       if ( this.isAnon() ) {
+                               return false;
+                       } else if ( registration === null ) {
+                               // Information may not be available if they signed up before
+                               // MW began storing this.
+                               return null;
+                       } else {
+                               return new Date( registration );
+                       }
+               };
+
                /**
                 * Checks if the current user is anonymous.
                 *