From 9b20471b66f9092a432a7a5274af18596bf7a51b Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 6 Sep 2008 15:01:59 +0000 Subject: [PATCH] * Mark non-autoconfirmed users in RC * 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 | 1 + includes/ChangesList.php | 48 ++++++++++--- includes/DefaultSettings.php | 2 +- includes/RecentChange.php | 84 ++++++++++------------ includes/specials/SpecialRecentchanges.php | 13 ++-- skins/common/oldshared.css | 4 ++ skins/common/shared.css | 14 +++- skins/modern/main.css | 4 -- skins/monobook/main.css | 4 -- 9 files changed, 103 insertions(+), 71 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index cae305341f..d26d514b14 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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 diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 1dfc933d4c..291f297bf6 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -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 = ' ', $bot = false ) { + protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false, $newbie = false ) { $f = $new ? '' . $this->message['newpageletter'] . '' : $nothing; $f .= $minor ? '' . $this->message['minoreditletter'] . '' : $nothing; $f .= $bot ? '' . $this->message['boteditletter'] . '' : $nothing; $f .= $patrolled ? '!' : $nothing; + $f .= $newbie ? '*' : $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 .= ''.$tl.' '; # Main line - $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot ); + $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, ' ', $bot, $newbie ); # Timestamp $r .= ' '.$block[0]->timestamp.' '; @@ -689,7 +713,8 @@ class EnhancedChangesList extends ChangesList { #$r .= ''.$this->spacerArrow(); $r .= ''; $r .= ''.$this->spacerIndent() . $this->spacerIndent(); - $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot ); + $newbie = self::userIsNew( $rcObj->mAttribs ); + $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot, $newbie ); $r .= ' '; $o = ''; @@ -815,14 +840,15 @@ class EnhancedChangesList extends ChangesList { $curIdEq = 'curid='.$rc_cur_id; $r = ''; - $r .= '
' . $this->spacerArrow() . ' '; # Flag and Timestamp if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $r .= '    '; // 4 flags -> 4 spaces } else { - $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot ); + $newbie = self::userIsNew( $rcObj->mAttribs ); + $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, + ' ', $rc_bot, $newbie ); } $r .= ' '.$rcObj->timestamp.' '; @@ -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' ) . ')'; } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index bf092b52f3..d3bcb7021c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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: diff --git a/includes/RecentChange.php b/includes/RecentChange.php index c22c9ea5a5..a308c26f63 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -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']); diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 0fe134580f..591f9ce48e 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -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 diff --git a/skins/common/oldshared.css b/skins/common/oldshared.css index 5cffb07389..66ea6156a8 100644 --- a/skins/common/oldshared.css +++ b/skins/common/oldshared.css @@ -212,6 +212,10 @@ span.unpatrolled { font-weight:bold; color:red; } +span.newuser { + font-weight:bold; + color:orange; +} span.updatedmarker { color:black; diff --git a/skins/common/shared.css b/skins/common/shared.css index 16be6146be..20d95adc08 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -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; diff --git a/skins/modern/main.css b/skins/modern/main.css index d86a1f875d..f6d95d6d48 100644 --- a/skins/modern/main.css +++ b/skins/modern/main.css @@ -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; diff --git a/skins/monobook/main.css b/skins/monobook/main.css index 8db47d2b9f..4cf1168da7 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -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; -- 2.20.1