* @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 ) );
// If an edit was hidden from a page give a review link to the history
} elseif( self::typeAction( $row, array( 'delete', 'suppress' ), 'revision', 'deletedhistory' ) ) {
$revert = RevisionDeleter::getLogLinks( $title, $paramArray,
- $this->skin, $this->message );
+ $this->message );
// Hidden log items, give review link
} elseif( self::typeAction( $row, array( 'delete', 'suppress' ), 'event', 'deletedhistory' ) ) {
if( count($paramArray) >= 1 ) {
array( 'known', 'noclasses' )
) . ')';
}
- // Self-created users
- } elseif( self::typeAction( $row, 'newusers', 'create2' ) ) {
- if( isset( $paramArray[0] ) ) {
- $revert = Linker::userToolLinks( $paramArray[0], $title->getDBkey(), true );
- } else {
- # Fall back to a blue contributions link
- $revert = Linker::userToolLinks( 1, $title->getDBkey() );
- }
- if( wfTimestamp( TS_MW, $row->log_timestamp ) < '20080129000000' ) {
- # Suppress $comment from old entries (before 2008-01-29),
- # not needed and can contain incorrect links
- $comment = '';
- }
// Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
} else {
wfRunHooks( 'LogLine', array( $row->log_type, $row->log_action, $title, $paramArray,
}
$del = '';
// Don't show useless link to people who cannot hide revisions
- if( $wgUser->isAllowed( 'deletedhistory' ) && !$wgUser->isBlocked() ) {
+ if( $wgUser->isAllowed( 'deletedhistory' ) ) {
if( $row->log_deleted || $wgUser->isAllowed( 'deleterevision' ) ) {
$canHide = $wgUser->isAllowed( 'deleterevision' );
// If event was hidden from sysops
*
* @param $row Row
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public static function userCan( $row, $field ) {
- return self::userCanBitfield( $row->log_deleted, $field );
+ public static function userCan( $row, $field, User $user = null ) {
+ return self::userCanBitfield( $row->log_deleted, $field, $user );
}
/**
*
* @param $bitfield Integer (current field)
* @param $field Integer
+ * @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
- public static function userCanBitfield( $bitfield, $field ) {
+ public static function userCanBitfield( $bitfield, $field, User $user = null ) {
if( $bitfield & $field ) {
- global $wgUser;
-
if ( $bitfield & LogPage::DELETED_RESTRICTED ) {
$permission = 'suppressrevision';
} else {
$permission = 'deletedhistory';
}
wfDebug( "Checking for $permission due to $field match on $bitfield\n" );
- return $wgUser->isAllowed( $permission );
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
+ return $user->isAllowed( $permission );
} else {
return true;
}
* Show log extract. Either with text and a box (set $msgKey) or without (don't set $msgKey)
*
* @param $out OutputPage|String-by-reference
- * @param $types String or Array
- * @param $page String The page title to show log entries for
+ * @param $types String|Array Log types to show
+ * @param $page String|Title The page title to show log entries for
* @param $user String The user who made the log entries
* @param $param Associative Array with the following additional options:
* - lim Integer Limit of items to show, default is 50
$logBody .
$loglist->endLogEventsList();
} else {
- if ( $showIfEmpty )
+ if ( $showIfEmpty ) {
$s = Html::rawElement( 'div', array( 'class' => 'mw-warning-logempty' ),
wfMsgExt( 'logempty', array( 'parseinline' ) ) );
+ }
}
if( $pager->getNumRows() > $pager->mLimit ) { # Show "Full log" link
$urlParam = array();
- if ( $page != '')
+ if ( $page instanceof Title ) {
+ $urlParam['page'] = $page->getPrefixedDBkey();
+ } elseif ( $page != '' ) {
$urlParam['page'] = $page;
+ }
if ( $user != '')
$urlParam['user'] = $user;
if ( !is_array( $types ) ) # Make it an array, if it isn't
$s .= '</div>';
}
- if ( $wrap!='' ) { // Wrap message in html
+ if ( $wrap != '' ) { // Wrap message in html
$s = str_replace( '$1', $s, $wrap );
}
/* 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))) {
- return $pager->getNumRows();
+ if ( wfRunHooks( 'LogEventsListShowLogExtract', array( &$s, $types, $page, $user, $param ) ) ) {
+ // $out can be either an OutputPage object or a String-by-reference
+ if ( $out instanceof OutputPage ){
+ $out->addHTML( $s );
+ } else {
+ $out = $s;
+ }
}
- // $out can be either an OutputPage object or a String-by-reference
- if( $out instanceof OutputPage ){
- $out->addHTML( $s );
- } else {
- $out = $s;
- }
return $pager->getNumRows();
}
/**
* SQL clause to skip forbidden log types for this user
*
- * @param $db Database
+ * @param $db DatabaseBase
* @param $audience string, public/user
* @return Mixed: string or false
*/
}
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
* @param $list LogEventsList
* @param $types String or Array: log types to show
* @param $performer String: the user who made the log entries
- * @param $title String or Title: the page title the log entries are for
+ * @param $title String|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
$this->mConds['log_user'] = $userid;
// Paranoia: avoid brute force searches (bug 17342)
$user = $this->getUser();
- if( !$user->isAllowed( 'deletedhistory' ) || $user->isBlocked() ) {
+ if( !$user->isAllowed( 'deletedhistory' ) ) {
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::DELETED_USER) . ' = 0';
- } elseif( !$user->isAllowed( 'suppressrevision' ) || $user->isBlocked() ) {
+ } elseif( !$user->isAllowed( 'suppressrevision' ) ) {
$this->mConds[] = $this->mDb->bitAnd('log_deleted', LogPage::SUPPRESSED_USER) .
' != ' . LogPage::SUPPRESSED_USER;
}
}
// Paranoia: avoid brute force searches (bug 17342)
$user = $this->getUser();
- if( !$user->isAllowed( 'deletedhistory' ) || $user->isBlocked() ) {
+ if( !$user->isAllowed( 'deletedhistory' ) ) {
$this->mConds[] = $db->bitAnd('log_deleted', LogPage::DELETED_ACTION) . ' = 0';
- } elseif( !$user->isAllowed( 'suppressrevision' ) || $user->isBlocked() ) {
+ } elseif( !$user->isAllowed( 'suppressrevision' ) ) {
$this->mConds[] = $db->bitAnd('log_deleted', LogPage::SUPPRESSED_ACTION) .
' != ' . LogPage::SUPPRESSED_ACTION;
}
return $info;
}
- // Checks if $this->mConds has $field matched to a *single* value
+ /**
+ * Checks if $this->mConds has $field matched to a *single* value
+ * @param $field
+ * @return bool
+ */
protected function hasEqualsClause( $field ) {
return (
array_key_exists( $field, $this->mConds ) &&
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 ) );