return $this->out->getTitle();
}
+ public function getContext() {
+ return $this->out->getContext();
+ }
+
/**
* @param $queryTypes Array
* @return String: Formatted HTML
* @return String: Formatted HTML list item
*/
public function logLine( $row ) {
- $row->user_name = $this->fixUserName($row->user_name, $row->log_user);
$entry = DatabaseLogEntry::newFromRow( $row );
$formatter = LogFormatter::newFromEntry( $entry );
$formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
public static function showLogExtract(
&$out, $types=array(), $page='', $user='', $param = array()
) {
- global $wgUser, $wgOut;
$defaultParameters = array(
'lim' => 25,
'conds' => array(),
if ( !is_array( $msgKey ) ) {
$msgKey = array( $msgKey );
}
+
+ if ( $out instanceof OutputPage ) {
+ $context = $out->getContext();
+ } else {
+ $context = RequestContext::getMain();
+ }
+
# Insert list of top 50 (or top $lim) items
- $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut, $flags );
+ $loglist = new LogEventsList( $context->getSkin(), $context->getOutput(), $flags );
$pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
if ( isset( $param['offset'] ) ) { # Tell pager to ignore $wgRequest offset
$pager->setOffset( $param['offset'] );
}
/* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
- if (!wfRunHooks('LogEventsListShowLogExtract', array(&$s, $types, $page, $user, $param))) {
+ if ( !wfRunHooks( 'LogEventsListShowLogExtract', array( &$s, $types, $page, $user, $param ) ) ) {
return $pager->getNumRows();
}
}
return false;
}
-
- /**
- * if user_name is empty - use User class to get his name
- * @param $user_name string
- * @param $user_id integer
- * @return string
- */
- public function fixUserName($user_name, $user_id) {
- if ( empty($user_name) ) {
- $oUser = User::newFromID($user_id);
- if ( $oUser instanceof User ) {
- $user_name = $oUser->getName();
- }
- }
-
- return $user_name;
- }
-}
+ }
/**
* @ingroup Pager
*/
class LogPager extends ReverseChronologicalPager {
- private $types = array(), $user = '', $title = '', $pattern = '';
+ private $types = array(), $performer = '', $title = '', $pattern = '';
private $typeCGI = '';
public $mLogEventsList;
*
* @param $list LogEventsList
* @param $types String or Array: log types to show
- * @param $user String: the user who made the log entries
- * @param $title String: the page title the log entries are for
+ * @param $performer String: the user who made the log entries
+ * @param $title String or Title: the page title the log entries are for
* @param $pattern String: do a prefix search rather than an exact title match
* @param $conds Array: extra conditions for the query
* @param $year Integer: the year to start from
* @param $month Integer: the month to start from
* @param $tagFilter String: tag
*/
- public function __construct( $list, $types = array(), $user = '', $title = '', $pattern = '',
+ public function __construct( $list, $types = array(), $performer = '', $title = '', $pattern = '',
$conds = array(), $year = false, $month = false, $tagFilter = '' ) {
- parent::__construct();
+ parent::__construct( $list->getContext() );
$this->mConds = $conds;
$this->mLogEventsList = $list;
$this->limitType( $types ); // also excludes hidden types
- $this->limitUser( $user );
+ $this->limitPerformer( $performer );
$this->limitTitle( $title, $pattern );
$this->getDateCond( $year, $month );
$this->mTagFilter = $tagFilter;
public function getDefaultQuery() {
$query = parent::getDefaultQuery();
$query['type'] = $this->typeCGI; // arrays won't work here
- $query['user'] = $this->user;
+ $query['user'] = $this->performer;
$query['month'] = $this->mMonth;
$query['year'] = $this->mYear;
return $query;
}
- /**
- * @return Title
- */
- function getTitle() {
- return $this->mLogEventsList->getDisplayTitle();
- }
-
// Call ONLY after calling $this->limitType() already!
public function getFilterParams() {
- global $wgFilterLogTypes, $wgUser, $wgRequest;
+ global $wgFilterLogTypes;
$filters = array();
if( count($this->types) ) {
return $filters;
}
foreach( $wgFilterLogTypes as $type => $default ) {
// Avoid silly filtering
- if( $type !== 'patrol' || $wgUser->useNPPatrol() ) {
- $hide = $wgRequest->getInt( "hide_{$type}_log", $default );
+ if( $type !== 'patrol' || $this->getUser()->useNPPatrol() ) {
+ $hide = $this->getRequest()->getInt( "hide_{$type}_log", $default );
$filters[$type] = $hide;
if( $hide )
$this->mConds[] = 'log_type != ' . $this->mDb->addQuotes( $type );
* empty string means no restriction
*/
private function limitType( $types ) {
- global $wgLogRestrictions, $wgUser;
+ global $wgLogRestrictions;
// If $types is not an array, make it an array
$types = ($types === '') ? array() : (array)$types;
// Don't even show header for private logs; don't recognize it...
foreach ( $types as $type ) {
if( isset( $wgLogRestrictions[$type] )
- && !$wgUser->isAllowed($wgLogRestrictions[$type])
+ && !$this->getUser()->isAllowed($wgLogRestrictions[$type])
) {
$types = array_diff( $types, array( $type ) );
}
*
* @param $name String: (In)valid user name
*/
- private function limitUser( $name ) {
+ private function limitPerformer( $name ) {
if( $name == '' ) {
return false;
}
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)
- if( !$wgUser->isAllowed( 'deletedhistory' ) || $wgUser->isBlocked() ) {
+ $user = $this->getUser();
+ if( !$user->isAllowed( 'deletedhistory' ) || $user->isBlocked() ) {
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0';
- } elseif( !$wgUser->isAllowed( 'suppressrevision' ) || $wgUser->isBlocked() ) {
+ } elseif( !$user->isAllowed( 'suppressrevision' ) || $user->isBlocked() ) {
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) .
' != ' . LogPage::SUPPRESSED_USER;
}
- $this->user = $usertitle->getText();
+ $this->performer = $usertitle->getText();
}
}
* Set the log reader to return only entries affecting the given page.
* (For the block and rights logs, this is a user page.)
*
- * @param $page String: Title name as text
+ * @param $page String or Title object: Title name
* @param $pattern String
*/
private function limitTitle( $page, $pattern ) {
- global $wgMiserMode, $wgUser;
+ global $wgMiserMode;
- $title = Title::newFromText( $page );
- if( strlen( $page ) == 0 || !$title instanceof Title ) {
- return false;
+ if ( $page instanceof Title ) {
+ $title = $page;
+ } else {
+ $title = Title::newFromText( $page );
+ if( strlen( $page ) == 0 || !$title instanceof Title ) {
+ return false;
+ }
}
$this->title = $title->getPrefixedText();
$this->mConds['log_title'] = $title->getDBkey();
}
// Paranoia: avoid brute force searches (bug 17342)
- if( !$wgUser->isAllowed( 'deletedhistory' ) || $wgUser->isBlocked() ) {
+ $user = $this->getUser();
+ if( !$user->isAllowed( 'deletedhistory' ) || $user->isBlocked() ) {
$this->mConds[] = $db->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0';
- } elseif( !$wgUser->isAllowed( 'suppressrevision' ) || $wgUser->isBlocked() ) {
+ } elseif( !$user->isAllowed( 'suppressrevision' ) || $user->isBlocked() ) {
$this->mConds[] = $db->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) .
' != ' . LogPage::SUPPRESSED_ACTION;
}
# Avoid usage of the wrong index by limiting
# the choices of available indexes. This mainly
# avoids site-breaking filesorts.
- } elseif( $this->title || $this->pattern || $this->user ) {
+ } elseif( $this->title || $this->pattern || $this->performer ) {
$index['logging'] = array( 'page_time', 'user_time' );
if( count($this->types) == 1 ) {
$index['logging'][] = 'log_user_type_time';
if( $this->getNumRows() > 0 ) {
$lb = new LinkBatch;
foreach ( $this->mResult as $row ) {
- $row->user_name = $this->mLogEventsList->fixUserName($row->user_name, $row->log_user);
- if ( empty($row->user_name) ) {
- continue;
- }
$lb->add( $row->log_namespace, $row->log_title );
$lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
$lb->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
/**
* @return string
*/
- public function getUser() {
- return $this->user;
+ public function getPerformer() {
+ return $this->performer;
}
/**