* Move useRCPatrol() to User
authorAaron Schulz <aaron@users.mediawiki.org>
Sun, 13 Apr 2008 17:37:41 +0000 (17:37 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sun, 13 Apr 2008 17:37:41 +0000 (17:37 +0000)
* Add useNPPatrol()

includes/ChangesList.php
includes/SpecialRecentchanges.php
includes/User.php

index 1a923c7..6bb93d6 100644 (file)
@@ -241,15 +241,6 @@ class ChangesList {
                }
        }
 
-       /**
-        * Check whether to enable recent changes patrol features
-        * @return bool
-        */
-       public static function usePatrol() {
-               global $wgUseRCPatrol, $wgUser;
-               return( $wgUseRCPatrol && ($wgUser->isAllowed('patrol') || $wgUser->isAllowed('patrolmarks')) );
-       }
-
        /**
         * Returns the string which indicates the number of watching users
         */
@@ -307,7 +298,7 @@ class OldChangesList extends ChangesList {
         * Format a line using the old system (aka without any javascript).
         */
        public function recentChangesLine( &$rc, $watched = false ) {
-               global $wgContLang, $wgRCShowChangedSize;
+               global $wgContLang, $wgRCShowChangedSize, $wgUser;
 
                $fname = 'ChangesList::recentChangesLineOld';
                wfProfileIn( $fname );
@@ -317,7 +308,7 @@ class OldChangesList extends ChangesList {
                extract( $rc->mAttribs );
 
                # Should patrol-related stuff be shown?
-               $unpatrolled = $this->usePatrol() && $rc_patrolled == 0;
+               $unpatrolled = $wgUser->usePatrol() && $rc_patrolled == 0;
 
                $this->insertDateHeader($s,$rc_timestamp);
 
@@ -390,7 +381,7 @@ class EnhancedChangesList extends ChangesList {
         * Format a line for enhanced recentchange (aka with javascript and block of lines).
         */
        public function recentChangesLine( &$baseRC, $watched = false ) {
-               global $wgLang, $wgContLang;
+               global $wgLang, $wgContLang, $wgUser;
 
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC );
@@ -412,7 +403,7 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # Should patrol-related stuff be shown?
-               if( $this->usePatrol() ) {
+               if( $wgUser->usePatrol() ) {
                        $rc->unpatrolled = !$rc_patrolled;
                } else {
                        $rc->unpatrolled = false;
index 22c92c5..b718864 100644 (file)
@@ -147,7 +147,7 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
        $hidem  = $hideminor ? 'AND rc_minor = 0' : '';
        $hidem .= $hidebots ? ' AND rc_bot = 0' : '';
        $hidem .= $hideliu && !$forcebot ? ' AND rc_user = 0' : '';
-       $hidem .= ( ChangesList::usePatrol() && $hidepatrolled ) ? ' AND rc_patrolled = 0' : '';
+       $hidem .= ($wgUser->usePatrol() && $hidepatrolled ) ? ' AND rc_patrolled = 0' : '';
        $hidem .= $hideanons && !$forcebot ? ' AND rc_user != 0' : '';
        $hidem .= $forcebot ? ' AND rc_bot = 1' : '';
 
@@ -521,7 +521,7 @@ function makeOptionsLink( $title, $override, $options ) {
  * @param $nondefaults
  */
 function rcOptionsPanel( $defaults, $nondefaults ) {
-       global $wgLang, $wgUseRCPatrol;
+       global $wgLang, $wgUser;
 
        $options = $nondefaults + $defaults;
 
@@ -571,7 +571,7 @@ function rcOptionsPanel( $defaults, $nondefaults ) {
        $links[] = wfMsgHtml( 'rcshowhidebots', $botLink );
        $links[] = wfMsgHtml( 'rcshowhideanons', $anonsLink );
        $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
-       if( ChangesList::usePatrol() )
+       if( $wgUser->usePatrol() )
                $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
        $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink );
        $hl = implode( ' | ', $links );
index 6106733..e3f190d 100644 (file)
@@ -1776,6 +1776,24 @@ class User {
 
                return in_array( $action, $this->getRights() );
        }
+       
+       /**
+       * Check whether to enable recent changes patrol features for this user
+       * @return bool
+       */
+       public function useRCPatrol() {
+               global $wgUseRCPatrol;
+               return( $wgUseRCPatrol && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
+       }
+       
+       /**
+       * Check whether to enable recent changes patrol features for this user
+       * @return bool
+       */
+       public function useNPPatrol() {
+               global $wgUseRCPatrol, $wgUseNPPatrol;
+               return( ($wgUseRCPatrol || $wgUseNPPatrol) && ($this->isAllowed('patrol') || $this->isAllowed('patrolmarks')) );
+       }
 
        /**
         * Load a skin if it doesn't exist or return it