Make RC patroling an optional feature that can be turned off by setting wgUseRCPatrol...
[mediawiki.git] / includes / SpecialNewpages.php
blobd9f85fe145d8d6744166b804c074f00dce380377
1 <?php
3 require_once( "QueryPage.php" );
5 class NewPagesPage extends QueryPage {
7 function getName() {
8 return "Newpages";
11 function isExpensive() {
12 # Indexed on RC, and will *not* work with querycache yet.
13 return false;
14 #return parent::isExpensive();
17 function getSQL() {
18 global $wgUser, $wgOnlySysopsCanPatrol;
19 $usepatrol = ( $wgUser->getID() != 0 && ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) ) ? 1 : 0;
20 $dbr =& wfGetDB( DB_SLAVE );
21 extract( $dbr->tableNames( 'recentchanges', 'cur' ) );
23 return
24 "SELECT 'Newpages' as type,
25 rc_namespace AS namespace,
26 rc_title AS title,
27 rc_cur_id AS value,
28 rc_user AS user,
29 rc_user_text AS user_text,
30 rc_comment as comment,
31 rc_timestamp AS timestamp,
32 '{$usepatrol}' as usepatrol,
33 rc_patrolled AS patrolled,
34 rc_id AS rcid,
35 length(cur_text) as length,
36 cur_text as text
37 FROM $recentchanges,$cur
38 WHERE rc_cur_id=cur_id AND rc_new=1
39 AND rc_namespace=0 AND cur_is_redirect=0";
42 function formatResult( $skin, $result ) {
43 global $wgLang, $wgUser, $wgOnlySysopsCanPatrol;
44 $u = $result->user;
45 $ut = $result->user_text;
47 $length = wfMsg( "nbytes", $wgLang->formatNum( $result->length ) );
48 $c = $skin->formatComment($result->comment );
50 if ( 0 == $u ) { # not by a logged-in user
51 $ul = $ut;
53 else {
54 $ul = $skin->makeLink( $wgLang->getNsText(NS_USER) . ":{$ut}", $ut );
57 $d = $wgLang->timeanddate( $result->timestamp, true );
59 # Since there is no diff link, we need to give users a way to
60 # mark the article as patrolled if it isn't already
61 if ( $result->usepatrol && $result->patrolled == 0 && $wgUser->getID() != 0 &&
62 ( $wgUser->isSysop() || !$wgOnlySysopsCanPatrol ) )
63 $link = $skin->makeKnownLink( $result->title, '', "rcid={$result->rcid}" );
64 else
65 $link = $skin->makeKnownLink( $result->title, '' );
67 $s = "{$d} {$link} ({$length}) . . {$ul}";
69 if ( "" != $c && "*" != $c ) {
70 $s .= " <em>({$c})</em>";
73 return $s;
77 function wfSpecialNewpages()
79 global $wgRequest;
80 list( $limit, $offset ) = wfCheckLimits();
82 $npp = new NewPagesPage();
84 if( !$npp->doFeed( $wgRequest->getVal( 'feed' ) ) ) {
85 $npp->doQuery( $offset, $limit );