*cough* Er, make it work? :) [dropped the action=submit] part
[lhc/web/wiklou.git] / includes / User.php
index 60a1bbe..f695d1d 100644 (file)
@@ -5,11 +5,6 @@
  * @package MediaWiki
  */
 
-/**
- *
- */
-require_once( 'WatchedItem.php' );
-
 # Number of characters in user_token field
 define( 'USER_TOKEN_LENGTH', 32 );
 
@@ -58,10 +53,11 @@ class User {
        /**
         * Static factory method
         * @param string $name Username, validated by Title:newFromText()
+        * @param bool $validate Validate username
         * @return User
         * @static
         */
-       function newFromName( $name ) {
+       function newFromName( $name, $validate = true ) {
                # Force usernames to capital
                global $wgContLang;
                $name = $wgContLang->ucfirst( $name );
@@ -77,7 +73,7 @@ class User {
                global $wgAuth;
                $canonicalName = $wgAuth->getCanonicalName( $t->getText() );
 
-               if( !User::isValidUserName( $canonicalName ) ) {
+               if( $validate && !User::isValidUserName( $canonicalName ) ) {
                        return null;
                }
 
@@ -187,9 +183,14 @@ class User {
        }
 
        /**
-        * does the string match an anonymous IPv4 address?
+        * Does the string match an anonymous IPv4 address?
         *
-        * Note: We match \d{1,3}\.\d{1,3}\.\d{1,3}\.xxx as an anonymous IP
+        * This function exists for username validation, in order to reject
+        * usernames which are similar in form to IP addresses. Strings such
+        * as 300.300.300.300 will return true because it looks like an IP 
+        * address, despite not being strictly valid.
+        * 
+        * We match \d{1,3}\.\d{1,3}\.\d{1,3}\.xxx as an anonymous IP
         * address because the usemod software would "cloak" anonymous IP
         * addresses like this, if we allowed accounts like this to be created
         * new users could get the old edits of these anonymous users.
@@ -479,12 +480,6 @@ class User {
                        $this->inDnsBlacklist( $ip, 'http.dnsbl.sorbs.net.' );
        }
 
-       function inOpmBlacklist( $ip ) {
-               global $wgEnableOpm;
-               return $wgEnableOpm &&
-                       $this->inDnsBlacklist( $ip, 'opm.blitzed.org.' );
-       }
-
        function inDnsBlacklist( $ip, $base ) {
                $fname = 'User::inDnsBlacklist';
                wfProfileIn( $fname );
@@ -1197,7 +1192,7 @@ class User {
         * @deprecated
         */
        function isSysop() {
-               wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isSysop() method\n" );
+               throw new MWException( "Call to deprecated (v1.7) User::isSysop() method\n" );
                #return $this->isAllowed( 'protect' );
        }
 
@@ -1206,7 +1201,7 @@ class User {
         * @deprecated
         */
        function isDeveloper() {
-               wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isDeveloper() method\n" );
+               throw new MWException( "Call to deprecated (v1.7) User::isDeveloper() method\n" );
                #return $this->isAllowed( 'siteadmin' );
        }
 
@@ -1215,7 +1210,7 @@ class User {
         * @deprecated
         */
        function isBureaucrat() {
-               wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isBureaucrat() method\n" );
+               throw new MWException( "Call to deprecated (v1.7) User::isBureaucrat() method\n" );
                #return $this->isAllowed( 'makesysop' );
        }