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();
/**
* 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() ) {
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.
*