// Precache various messages
if( !isset( $this->message ) ) {
$messages = array( 'revertmerge', 'protect_change', 'unblocklink', 'change-blocklink',
- 'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'pipe-separator' );
+ 'revertmove', 'undeletelink', 'revdel-restore', 'rev-delundel', 'hist', 'diff',
+ 'pipe-separator' );
foreach( $messages as $msg ) {
$this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
}
* @param $pattern String
* @param $year Integer: year
* @param $month Integer: month
- * @param $filter Boolean
+ * @param $filter: array
+ * @param $tagFilter: array?
*/
public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '',
- $month = '', $filter = null, $tagFilter='' )
+ $month = '', $filter = null, $tagFilter='' )
{
global $wgScript, $wgMiserMode;
$action = htmlspecialchars( $wgScript );
$this->getUserInput( $user ) . "\n" .
$this->getTitleInput( $page ) . "\n" .
( !$wgMiserMode ? ($this->getTitlePattern( $pattern )."\n") : "" ) .
- "<p>" . $this->getDateMenu( $year, $month ) . "\n" .
+ "<p>" . Xml::dateMenu( $year, $month ) . "\n" .
( $tagSelector ? Xml::tags( 'p', null, implode( ' ', $tagSelector ) ) :'' ). "\n" .
( $filter ? "</p><p>".$this->getFilterLinks( $type, $filter )."\n" : "" ) . "\n" .
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "</p>\n" .
}
private function getFilterLinks( $logType, $filter ) {
- global $wgTitle;
+ global $wgTitle, $wgLang;
// show/hide links
$messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
// Option value -> message mapping
$links = array();
+ $hiddens = ''; // keep track for "go" button
foreach( $filter as $type => $val ) {
$hideVal = 1 - intval($val);
$link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
);
$links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
+ $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
}
// Build links
- return implode( ' | ', $links );
+ return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
}
private function getDefaultQuery() {
* @return String: Formatted HTML
*/
private function getUserInput( $user ) {
- return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 15, $user );
+ return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'mw-log-user', 15, $user );
}
/**
* @return String: Formatted HTML
*/
private function getTitleInput( $title ) {
- return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
- }
-
- /**
- * @param $year Integer
- * @param $month Integer
- * @return string Formatted HTML
- */
- private function getDateMenu( $year, $month ) {
- # Offset overrides year/month selection
- if( $month && $month !== -1 ) {
- $encMonth = intval( $month );
- } else {
- $encMonth = '';
- }
- if ( $year ) {
- $encYear = intval( $year );
- } else if( $encMonth ) {
- $thisMonth = intval( gmdate( 'n' ) );
- $thisYear = intval( gmdate( 'Y' ) );
- if( intval($encMonth) > $thisMonth ) {
- $thisYear--;
- }
- $encYear = $thisYear;
- } else {
- $encYear = '';
- }
- return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
- Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) .
- ' '.
- Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
- Xml::monthSelector( $encMonth, -1 );
+ return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'mw-log-page', 20, $title );
}
/**
$paramArray = LogPage::extractParams( $row->log_params );
$revert = $del = '';
// Some user can hide log items and have review links
- if( $wgUser->isAllowed( 'deleterevision' ) ) {
+ if( !($this->flags & self::NO_ACTION_LINK) && $wgUser->isAllowed( 'deleterevision' ) ) {
$del = $this->getShowHideLinks( $row ) . ' ';
}
// Add review links and such...
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// Different revision types use different URL params...
$key = $paramArray[0];
- // Link to each hidden object ID, $paramArray[1] is the url param
+ // $paramArray[1] is a CVS of the IDs
$Ids = explode( ',', $paramArray[1] );
- $revParams = '';
- foreach( $Ids as $n => $id ) {
- $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id);
+ $query = urlencode($paramArray[1]);
+ $revert = array();
+ // Diff link for single rev deletions
+ if( $key === 'oldid' && count($Ids) == 1 ) {
+ $token = urlencode( $wgUser->editToken( intval($Ids[0]) ) );
+ $revert[] = $this->skin->makeKnownLinkObj( $title, $this->message['diff'],
+ 'diff='.intval($Ids[0])."&unhide=1&token=$token" );
}
- $revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
- 'target=' . $title->getPrefixedUrl() . $revParams ) . ')';
+ // View/modify link...
+ $revert[] = $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
+ 'target='.$title->getPrefixedUrl()."&$key=$query" );
+ // Pipe links
+ $revert = '(' . implode(' | ',$revert) . ')';
}
// Hidden log items, give review link
} else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
if( count($paramArray) == 1 ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
+ // $paramArray[1] is a CVS of the IDs
$Ids = explode( ',', $paramArray[0] );
+ $query = urlencode($paramArray[0]);
// Link to each hidden object ID, $paramArray[1] is the url param
- $logParams = '';
- foreach( $Ids as $n => $id ) {
- $logParams .= '&logid[]=' . intval($id);
- }
$revert = '(' . $this->skin->makeKnownLinkObj( $revdel, $this->message['revdel-restore'],
- 'target=' . $title->getPrefixedUrl() . $logParams ) . ')';
+ 'target='.$title->getPrefixedUrl()."&logid=$query" ) . ')';
}
// Self-created users
} else if( self::typeAction($row,'newusers','create2') ) {
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
// If event was hidden from sysops
if( !self::userCan( $row, LogPage::DELETED_RESTRICTED ) ) {
- $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message['rev-delundel'].')' );
+ $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
+ '('.$this->message['rev-delundel'].')' );
} else if( $row->log_type == 'suppress' ) {
- // No one should be hiding from the oversight log
- $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.$this->message['rev-delundel'].')' );
+ $del = ''; // No one should be hiding from the oversight log
} else {
$target = SpecialPage::getTitleFor( 'Log', $row->log_type );
+ $page = Title::makeTitle( $row->log_namespace, $row->log_title );
$query = array( 'target' => $target->getPrefixedDBkey(),
- 'logid' => $row->log_id
- );
- $del = $this->skin->revDeleteLink( $query, self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
+ 'logid' => $row->log_id, 'page' => $page->getPrefixedDBkey() );
+ $del = $this->skin->revDeleteLink( $query,
+ self::isDeleted( $row, LogPage::DELETED_RESTRICTED ) );
}
return $del;
}
* @return bool
*/
public static function typeAction( $row, $type, $action, $right='' ) {
- $match = is_array($type) ? in_array($row->log_type,$type) : $row->log_type == $type;
+ $match = is_array($type) ?
+ in_array($row->log_type,$type) : $row->log_type == $type;
if( $match ) {
$match = is_array($action) ?
in_array($row->log_action,$action) : $row->log_action == $action;
/**
* SQL clause to skip forbidden log types for this user
* @param $db Database
+ * @param $audience string, public/user
* @return mixed (string or false)
*/
- public static function getExcludeClause( $db ) {
+ public static function getExcludeClause( $db, $audience = 'public' ) {
global $wgLogRestrictions, $wgUser;
// Reset the array, clears extra "where" clauses when $par is used
$hiddenLogs = array();
// Don't show private logs to unprivileged users
foreach( $wgLogRestrictions as $logType => $right ) {
- if( !$wgUser->isAllowed($right) ) {
+ if( $audience == 'public' || !$wgUser->isAllowed($right) ) {
$safeType = $db->strencode( $logType );
$hiddenLogs[] = $safeType;
}
$this->mLogEventsList = $list;
- $this->limitType( $type );
+ $this->limitType( $type ); // also excludes hidden types
$this->limitUser( $user );
$this->limitTitle( $title, $pattern );
$this->getDateCond( $year, $month );
if( isset($wgLogRestrictions[$type]) && !$wgUser->isAllowed($wgLogRestrictions[$type]) ) {
$type = '';
}
- // Don't show private logs to unpriviledged users
- $hideLogs = LogEventsList::getExcludeClause( $this->mDb );
+ // Don't show private logs to unpriviledged users.
+ // Also, only show them upon specific request to avoid suprises.
+ $audience = $type ? 'user' : 'public';
+ $hideLogs = LogEventsList::getExcludeClause( $this->mDb, $audience );
if( $hideLogs !== false ) {
$this->mConds[] = $hideLogs;
}
- if( !$type ) {
- return false;
+ if( $type ) {
+ $this->type = $type;
+ $this->mConds['log_type'] = $type;
}
- $this->type = $type;
- $this->mConds['log_type'] = $type;
}
/**
but for now it won't pass anywhere behind the optimizer */
$this->mConds[] = "NULL";
} else {
+ global $wgUser;
$this->mConds['log_user'] = $userid;
// Paranoia: avoid brute force searches (bug 17342)
- $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0';
+ if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_USER . ' = 0';
+ }
$this->user = $usertitle->getText();
}
}
* @param $pattern String
*/
private function limitTitle( $page, $pattern ) {
- global $wgMiserMode;
+ global $wgMiserMode, $wgUser;
$title = Title::newFromText( $page );
if( strlen($page) == 0 || !$title instanceof Title )
$this->mConds['log_title'] = $title->getDBkey();
}
// Paranoia: avoid brute force searches (bug 17342)
- $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0';
+ if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
+ $this->mConds[] = 'log_deleted & ' . LogPage::DELETED_ACTION . ' = 0';
+ }
}
public function getQueryInfo() {
'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ) ),
);
- ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $this->mTagFilter );
+ ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'],
+ $info['join_conds'], $info['options'], $this->mTagFilter );
return $info;
}