Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / user / User.php
index 2e3314e..0acdb55 100644 (file)
@@ -1862,7 +1862,7 @@ class User implements IDBAccessObject {
         */
        public function isPingLimitable() {
                global $wgRateLimitsExcludedIPs;
-               if ( in_array( $this->getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
+               if ( IP::isInRanges( $this->getRequest()->getIP(), $wgRateLimitsExcludedIPs ) ) {
                        // No other good way currently to disable rate limits
                        // for specific IPs. :P
                        // But this is a crappy hack and should die.
@@ -3770,6 +3770,42 @@ class User implements IDBAccessObject {
                // user_talk page; it's cleared one page view later in WikiPage::doViewUpdates().
        }
 
+       /**
+        * Compute experienced level based on edit count and registration date.
+        *
+        * @return string 'newcomer', 'learner', or 'experienced'
+        */
+       public function getExperienceLevel() {
+               global $wgLearnerEdits,
+                       $wgExperiencedUserEdits,
+                       $wgLearnerMemberSince,
+                       $wgExperiencedUserMemberSince;
+
+               if ( $this->isAnon() ) {
+                       return false;
+               }
+
+               $editCount = $this->getEditCount();
+               $registration = $this->getRegistration();
+               $now = time();
+               $learnerRegistration = wfTimestamp( TS_MW, $now - $wgLearnerMemberSince * 86400 );
+               $experiencedRegistration = wfTimestamp( TS_MW, $now - $wgExperiencedUserMemberSince * 86400 );
+
+               if (
+                       $editCount < $wgLearnerEdits ||
+                       $registration > $learnerRegistration
+               ) {
+                       return 'newcomer';
+               } elseif (
+                       $editCount > $wgExperiencedUserEdits &&
+                       $registration <= $experiencedRegistration
+               ) {
+                       return 'experienced';
+               } else {
+                       return 'learner';
+               }
+       }
+
        /**
         * Set a cookie on the user's client. Wrapper for
         * WebResponse::setCookie