Spacing cleanup
[lhc/web/wiklou.git] / includes / User.php
index c0acf5b..a8bfbe6 100644 (file)
@@ -76,6 +76,7 @@ class User {
                'watchlisthideminor',
                'ccmeonemails',
                'diffonly',
+               'showhiddencats',
        );
 
        /**
@@ -423,16 +424,22 @@ class User {
                || User::isIP( $name )
                || strpos( $name, '/' ) !== false
                || strlen( $name ) > $wgMaxNameChars
-               || $name != $wgContLang->ucfirst( $name ) )
+               || $name != $wgContLang->ucfirst( $name ) ) {
+                       wfDebugLog( 'username', __METHOD__ .
+                               ": '$name' invalid due to empty, IP, slash, length, or lowercase" );
                        return false;
+               }
 
                // Ensure that the name can't be misresolved as a different title,
                // such as with extra namespace keys at the start.
                $parsed = Title::newFromText( $name );
                if( is_null( $parsed )
                        || $parsed->getNamespace()
-                       || strcmp( $name, $parsed->getPrefixedText() ) )
+                       || strcmp( $name, $parsed->getPrefixedText() ) ) {
+                       wfDebugLog( 'username', __METHOD__ .
+                               ": '$name' invalid due to ambiguous prefixes" );
                        return false;
+               }
                
                // Check an additional blacklist of troublemaker characters.
                // Should these be merged into the title char list?
@@ -445,6 +452,8 @@ class User {
                        '\x{e000}-\x{f8ff}' . # private use
                        ']/u';
                if( preg_match( $unicodeBlacklist, $name ) ) {
+                       wfDebugLog( 'username', __METHOD__ .
+                               ": '$name' invalid due to blacklisted characters" );
                        return false;
                }
                
@@ -690,6 +699,7 @@ class User {
         * @deprecated use wfSetupSession()
         */
        function SetupSession() {
+               wfDeprecated( __METHOD__ );
                wfSetupSession();
        }
 
@@ -1022,7 +1032,7 @@ class User {
                        return $result;
                }
 
-               global $wgRateLimits, $wgRateLimitsExcludedGroups;
+               global $wgRateLimits;
                if( !isset( $wgRateLimits[$action] ) ) {
                        return false;
                }
@@ -1154,6 +1164,7 @@ class User {
         * @deprecated use User::newFromId()
         */
        function setID( $v ) {
+               wfDeprecated( __METHOD__ );
                $this->mId = $v;
                $this->clearInstanceCache( 'id' );
        }
@@ -1639,8 +1650,8 @@ class User {
 
        /**
         * Get the list of implicit group memberships this user has.
-        * This includes all explicit groups, plus 'user' if logged in
-        * and '*' for all accounts.
+        * This includes all explicit groups, plus 'user' if logged in,
+        * '*' for all accounts and autopromoted groups
         * @param boolean $recache Don't use the cache
         * @return array of strings
         */
@@ -1749,6 +1760,7 @@ class User {
         * @deprecated
         */
        function isBot() {
+               wfDeprecated( __METHOD__ );
                return $this->isAllowed( 'bot' );
        }
 
@@ -1977,13 +1989,12 @@ class User {
                $this->clearInstanceCache( 'defaults' );
 
                $_SESSION['wsUserID'] = 0;
-               
+
                setcookie( $wgCookiePrefix.'UserID', '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
                setcookie( $wgCookiePrefix.'Token', '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
-               setcookie( $wgCookiePrefix.'UserName', '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
-               setcookie( $wgCookiePrefix.'LoggedOut', '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
-               setcookie( session_name(), '', time() - 3600, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
-               session_destroy();
+
+               # Remember when user logged out, to prevent seeing cached pages
+               setcookie( $wgCookiePrefix.'LoggedOut', wfTimestampNow(), time() + 86400, $wgCookiePath, $wgCookieDomain, $wgCookieSecure );
        }
 
        /**
@@ -2019,11 +2030,11 @@ class User {
 
 
        /**
-        * Checks if a user with the given name exists, returns the ID
+        * Checks if a user with the given name exists, returns the ID.
         */
        function idForName() {
                $s = trim( $this->getName() );
-               if ( 0 == strcmp( '', $s ) ) return 0;
+               if ( $s === '' ) return 0;
 
                $dbr = wfGetDB( DB_SLAVE );
                $id = $dbr->selectField( 'user', 'user_id', array( 'user_name' => $s ), __METHOD__ );
@@ -2200,7 +2211,9 @@ class User {
        /**
         * @deprecated
         */
-       function setLoaded( $loaded ) {}
+       function setLoaded( $loaded ) {
+               wfDeprecated( __METHOD__ );
+       }
 
        /**
         * Get this user's personal page title.
@@ -2386,10 +2399,10 @@ class User {
         *
         * @param string $subject
         * @param string $body
-        * @param strong $from Optional from address; default $wgPasswordSender will be used otherwise.
+        * @param string $from Optional from address; default $wgPasswordSender will be used otherwise.
         * @return mixed True on success, a WikiError object on failure.
         */
-       function sendMail( $subject, $body, $from = null ) {
+       function sendMail( $subject, $body, $from = null, $replyto = null ) {
                if( is_null( $from ) ) {
                        global $wgPasswordSender;
                        $from = $wgPasswordSender;
@@ -2397,13 +2410,7 @@ class User {
 
                $to = new MailAddress( $this );
                $sender = new MailAddress( $from );
-               $error = UserMailer::send( $to, $sender, $subject, $body );
-
-               if( $error == '' ) {
-                       return true;
-               } else {
-                       return new WikiError( $error );
-               }
+               return UserMailer::send( $to, $sender, $subject, $body, $replyto );
        }
 
        /**
@@ -2460,7 +2467,9 @@ class User {
         * @return bool
         */
        function canSendEmail() {
-               return $this->isEmailConfirmed();
+               $canSend = $this->isEmailConfirmed();
+               wfRunHooks( 'UserCanSendEmail', array( &$this, &$canSend ) );
+               return $canSend;
        }
 
        /**
@@ -2469,7 +2478,7 @@ class User {
         * @return bool
         */
        function canReceiveEmail() {
-               return $this->canSendEmail() && !$this->getOption( 'disablemail' );
+               return $this->isEmailConfirmed() && !$this->getOption( 'disablemail' );
        }
 
        /**