* regression fix: make dumpUploads.php work again
[lhc/web/wiklou.git] / includes / User.php
index 6734c32..10ccd47 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;
                }
                
@@ -1022,7 +1031,7 @@ class User {
                        return $result;
                }
 
-               global $wgRateLimits, $wgRateLimitsExcludedGroups;
+               global $wgRateLimits;
                if( !isset( $wgRateLimits[$action] ) ) {
                        return false;
                }
@@ -1639,8 +1648,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
         */
@@ -2018,11 +2027,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__ );
@@ -2385,10 +2394,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;
@@ -2396,13 +2405,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 );
        }
 
        /**
@@ -2459,7 +2462,9 @@ class User {
         * @return bool
         */
        function canSendEmail() {
-               return $this->isEmailConfirmed();
+               $canSend = $this->isEmailConfirmed();
+               wfRunHooks( 'UserCanSendEmail', array( &$this, &$canSend ) );
+               return $canSend;
        }
 
        /**
@@ -2468,7 +2473,7 @@ class User {
         * @return bool
         */
        function canReceiveEmail() {
-               return $this->canSendEmail() && !$this->getOption( 'disablemail' );
+               return $this->isEmailConfirmed() && !$this->getOption( 'disablemail' );
        }
 
        /**