* Mark non-autoconfirmed users in RC
authorAaron Schulz <aaron@users.mediawiki.org>
Sat, 6 Sep 2008 15:01:59 +0000 (15:01 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Sat, 6 Sep 2008 15:01:59 +0000 (15:01 +0000)
* Avoid overselecting fields in RC and add $fields to SpecialRecentChangesQuery
* Some whitespace tweaks in RecentChange.php. Remove dead code.
* Avoid rc_new check in ChangesList
* Move some "unpatrolled" CSS to shared.css. Add 'newuser' CSS.
* Bump style version

docs/hooks.txt
includes/ChangesList.php
includes/DefaultSettings.php
includes/RecentChange.php
includes/specials/SpecialRecentchanges.php
skins/common/oldshared.css
skins/common/shared.css
skins/modern/main.css
skins/monobook/main.css

index cae3053..d26d514 100644 (file)
@@ -1218,6 +1218,7 @@ $opts: FormOptions for this request
 &$tables: array of tables to be queried
 &$join_conds: join conditions for the tables
 $opts: FormOptions for this request
+&$fields: select fields
 
 'SpecialSearchNogomatch': called when user clicked the "Go" button but the target doesn't exist
 $title: title object generated from the text entred by the user
index 1dfc933..291f297 100644 (file)
@@ -75,17 +75,38 @@ class ChangesList {
         * @param bool $patrolled
         * @param string $nothing, string to use for empty space
         * @param bool $bot
+        * @param bool $newbie
         * @return string
         */
-       protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false ) {
+       protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false, $newbie = false ) {
                $f = $new ? '<span class="newpage">' . $this->message['newpageletter'] . '</span>'
                                : $nothing;
                $f .= $minor ? '<span class="minor">' . $this->message['minoreditletter'] . '</span>'
                                : $nothing;
                $f .= $bot ? '<span class="bot">' . $this->message['boteditletter'] . '</span>' : $nothing;
                $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
+               $f .= $newbie ? '<span class="newuser">*</span>' : $nothing;
                return $f;
        }
+       
+       protected static function userIsNew( Array $attribs ) {
+               global $wgAutoConfirmCount, $wgAutoConfirmAge;
+               if( !array_key_exists('user_editcount',$attribs) || !array_key_exists('user_registration',$attribs) ) {
+                       return false; // missing input!
+               }
+               static $time;
+               $time = time();
+               $edits = $attribs['user_editcount'];
+               $age = $attribs['user_registration'];
+               if( $wgAutoConfirmCount && !$edits || $wgAutoConfirmAge && !$age ) {
+                       return true;
+               } else if( $wgAutoConfirmCount && $edits < $wgAutoConfirmCount ) {
+                       return true;
+               } else if( $wgAutoConfirmAge && ($time - wfTimestampOrNull(TS_UNIX,$age)) < $wgAutoConfirmAge ) {
+                       return true;
+               }
+               return false;
+       }
 
        /**
         * Returns text for the start of the tabular part of RC
@@ -343,9 +364,10 @@ class OldChangesList extends ChangesList {
                        wfProfileIn($fname.'-page');
 
                        $this->insertDiffHist($s, $rc, $unpatrolled);
-
                        # M, N, b and ! (minor, new, bot and unpatrolled)
-                       $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot );
+                       $newbie = self::userIsNew( $rcObj->mAttribs );
+                       $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', 
+                               $rc_bot, $newbie );
                        $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
 
                        wfProfileOut($fname.'-page');
@@ -542,15 +564,14 @@ class EnhancedChangesList extends ChangesList {
                # Collate list of users
                $userlinks = array();
                # Other properties
-               $unpatrolled = false;
-               $isnew = false;
+               $unpatrolled = $isnew = $newbie = false;
                $curId = $currentRevision = 0;
                # Some catalyst variables...
                $namehidden = true;
                $alllogs = true;
                foreach( $block as $rcObj ) {
                        $oldid = $rcObj->mAttribs['rc_last_oldid'];
-                       if( $rcObj->mAttribs['rc_new'] ) {
+                       if( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
                                $isnew = true;
                        }
                        // If all log actions to this page were hidden, then don't
@@ -568,6 +589,9 @@ class EnhancedChangesList extends ChangesList {
                        if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
                                $alllogs = false;
                        }
+                       if( self::userIsNew( $rcObj->mAttribs ) ) {
+                               $newbie = true;
+                       }
                        # Get the latest entry with a page_id and oldid
                        # since logs may not have these.
                        if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
@@ -606,7 +630,7 @@ class EnhancedChangesList extends ChangesList {
                $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.'&nbsp;';
 
                # Main line
-               $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot );
+               $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot, $newbie );
 
                # Timestamp
                $r .= '&nbsp;'.$block[0]->timestamp.'&nbsp;</tt></td><td>';
@@ -689,7 +713,8 @@ class EnhancedChangesList extends ChangesList {
                        #$r .= '<tr><td valign="top">'.$this->spacerArrow();
                        $r .= '<tr><td valign="top">';
                        $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
-                       $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
+                       $newbie = self::userIsNew( $rcObj->mAttribs );
+                       $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot, $newbie );
                        $r .= '&nbsp;</tt></td><td valign="top">';
 
                        $o = '';
@@ -815,14 +840,15 @@ class EnhancedChangesList extends ChangesList {
                $curIdEq = 'curid='.$rc_cur_id;
 
                $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
-
                $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . '&nbsp;';
 
                # Flag and Timestamp
                if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
                        $r .= '&nbsp;&nbsp;&nbsp;&nbsp;'; // 4 flags -> 4 spaces
                } else {
-                       $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
+                       $newbie = self::userIsNew( $rcObj->mAttribs );
+                       $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, 
+                               '&nbsp;', $rc_bot, $newbie );
                }
                $r .= '&nbsp;'.$rcObj->timestamp.'&nbsp;</tt></td><td>';
 
@@ -838,7 +864,7 @@ class EnhancedChangesList extends ChangesList {
                }
 
                # Diff and hist links
-               if ( $rc_type != RC_LOG ) {
+               if( $rc_type != RC_LOG ) {
                   $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
                   $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
                }
index bf092b5..d3bcb70 100644 (file)
@@ -1383,7 +1383,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '172';
+$wgStyleVersion = '173';
 
 
 # Server-side caching:
index c22c9ea..a308c26 100644 (file)
@@ -49,15 +49,13 @@ class RecentChange
 
        # Factory methods
 
-       public static function newFromRow( $row )
-       {
+       public static function newFromRow( $row ) {
                $rc = new RecentChange;
                $rc->loadFromRow( $row );
                return $rc;
        }
 
-       public static function newFromCurRow( $row )
-       {
+       public static function newFromCurRow( $row ) {
                $rc = new RecentChange;
                $rc->loadFromCurRow( $row );
                $rc->notificationtimestamp = false;
@@ -110,26 +108,22 @@ class RecentChange
 
        # Accessors
 
-       function setAttribs( $attribs )
-       {
+       function setAttribs( $attribs ) {
                $this->mAttribs = $attribs;
        }
 
-       function setExtra( $extra )
-       {
+       function setExtra( $extra ) {
                $this->mExtra = $extra;
        }
 
-       function &getTitle()
-       {
+       function &getTitle() {
                if ( $this->mTitle === false ) {
                        $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
                }
                return $this->mTitle;
        }
 
-       function getMovedToTitle()
-       {
+       function getMovedToTitle() {
                if ( $this->mMovedToTitle === false ) {
                        $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
                                $this->mAttribs['rc_moved_to_title'] );
@@ -138,8 +132,7 @@ class RecentChange
        }
 
        # Writes the data in this object to the database
-       function save()
-       {
+       function save() {
                global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, 
                $wgRC2UDPPort, $wgRC2UDPPrefix, $wgRC2UDPOmitBots;
                $fname = 'RecentChange::save';
@@ -178,35 +171,6 @@ class RecentChange
                # Update old rows, if necessary
                if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
                        $lastTime = $this->mExtra['lastTimestamp'];
-                       #$now = $this->mAttribs['rc_timestamp'];
-                       #$curId = $this->mAttribs['rc_cur_id'];
-
-                       # Don't bother looking for entries that have probably
-                       # been purged, it just locks up the indexes needlessly.
-                       global $wgRCMaxAge;
-                       $age = time() - wfTimestamp( TS_UNIX, $lastTime );
-                       if( $age < $wgRCMaxAge ) {
-                               # live hack, will commit once tested - kate
-                               # Update rc_this_oldid for the entries which were current
-                               #
-                               #$oldid = $this->mAttribs['rc_last_oldid'];
-                               #$ns = $this->mAttribs['rc_namespace'];
-                               #$title = $this->mAttribs['rc_title'];
-                               #
-                               #$dbw->update( 'recentchanges',
-                               #       array( /* SET */
-                               #               'rc_this_oldid' => $oldid
-                               #       ), array( /* WHERE */
-                               #               'rc_namespace' => $ns,
-                               #               'rc_title' => $title,
-                               #               'rc_timestamp' => $dbw->timestamp( $lastTime )
-                               #       ), $fname
-                               #);
-                       }
-
-                       # Update rc_cur_time
-                       #$dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
-                       #       array( 'rc_cur_id' => $curId ), $fname );
                }
 
                # Notify external application via UDP
@@ -576,13 +540,43 @@ class RecentChange
        public function getAttribute( $name ) {
                return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
        }
+       
+       /*
+       * Get RC select fields for changes lists
+       */
+       public static function getSelectFields() {
+               return array( 
+                       'rc_timestamp', 
+                       'rc_cur_time', 
+                       'rc_user',
+                       'rc_user_text',
+                       'rc_namespace',
+                       'rc_title',
+                       'rc_comment',
+                       'rc_minor',
+                       'rc_type',
+                       'rc_cur_id',
+                       'rc_this_oldid',
+                       'rc_last_oldid',
+                       'rc_bot',
+                       'rc_moved_to_ns',
+                       'rc_moved_to_title',
+                       'rc_patrolled',
+                       'rc_old_len',
+                       'rc_new_len',
+                       'rc_params',
+                       'rc_log_type',
+                       'rc_log_action',
+                       'rc_log_id',
+                       'rc_deleted' // this one REALLY should be set...
+               );
+       }
 
        /**
         * Gets the end part of the diff URL associated with this object
         * Blank if no diff link should be displayed
         */
-       function diffLinkTrail( $forceCur )
-       {
+       function diffLinkTrail( $forceCur ) {
                if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
                        $trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
                                "&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
index 0fe1345..591f9ce 100644 (file)
@@ -264,8 +264,11 @@ class SpecialRecentChanges extends SpecialPage {
        public function doMainQuery( $conds, $opts ) {
                global $wgUser;
 
-               $tables = array( 'recentchanges' );
-               $join_conds = array();
+               $tables = array( 'recentchanges', 'user' );
+               $join_conds = array( 'user' => array('LEFT JOIN','rc_user != 0 AND user_id = rc_user') );
+               $fields = RecentChange::getSelectFields();
+               $fields[] = 'user_editcount';
+               $fields[] = 'user_registration';
 
                $uid = $wgUser->getId();
                $dbr = wfGetDB( DB_SLAVE );
@@ -276,10 +279,10 @@ class SpecialRecentChanges extends SpecialPage {
                // JOIN on watchlist for users
                if( $uid ) {
                        $tables[] = 'watchlist';
-                       $join_conds = array( 'watchlist' => array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace") );
+                       $join_conds['watchlist'] = array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
                }
 
-               wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) );
+               wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$fields ) );
 
                // Is there either one namespace selected or excluded?
                // Also, if this is "all" or main namespace, just use timestamp index.
@@ -313,7 +316,7 @@ class SpecialRecentChanges extends SpecialPage {
        }
 
        /**
-        * Send output to $wgOut, only called if not used feeds
+        * Send output to $wgOut, only called if not using feeds
         *
         * @param $rows array of database rows
         * @param $opts FormOptions
index 5cffb07..66ea615 100644 (file)
@@ -212,6 +212,10 @@ span.unpatrolled {
        font-weight:bold;
        color:red;
 }
+span.newuser {
+       font-weight:bold;
+       color:orange;
+}
 
 span.updatedmarker {
        color:black;
index 16be614..20d95ad 100644 (file)
@@ -56,7 +56,19 @@ table.filehistory td.filehistory-selected {
 }
 
 /*
- * rev_deleted stuff
+ * Recent changes
+ */
+span.unpatrolled {
+       font-weight: bold;
+       color: red;
+}
+span.newuser {
+       font-weight:bold;
+       color:orange;
+}
+
+/*
+ * RevisionDelete stuff
  */
 li span.deleted, span.history-deleted {
        text-decoration: line-through;
index d86a1f8..f6d95d6 100644 (file)
@@ -650,10 +650,6 @@ div.patrollink {
 span.newpage, span.minor, span.searchmatch, span.bot {
        font-weight: bold;
 }
-span.unpatrolled {
-       font-weight: bold;
-       color: red;
-}
 
 span.searchmatch {
        color: red;
index 8db47d2..4cf1168 100644 (file)
@@ -1154,10 +1154,6 @@ div.patrollink {
 span.newpage, span.minor, span.bot {
        font-weight: bold;
 }
-span.unpatrolled {
-       font-weight: bold;
-       color: red;
-}
 
 .sharedUploadNotice {
        font-style: italic;