88 if ( $this->linkRenderer !==
null ) {
91 return MediaWikiServices::getInstance()->getLinkRenderer();
111 public function showOptions( $types = [], $user =
'', $page =
'', $pattern =
false, $year = 0,
112 $month = 0, $day = 0,
$filter =
null, $tagFilter =
'', $action =
null
115 $types = ( $types ===
'' ) ? [] : (array)$types;
117 $formDescriptor = [];
130 is_array( $extraInputsDescriptor ) &&
131 !empty( $extraInputsDescriptor )
133 $formDescriptor[
'extra' ] = $extraInputsDescriptor;
135 is_string( $extraInputsDescriptor ) &&
136 $extraInputsDescriptor !==
''
139 $extraInputsString = $extraInputsDescriptor;
140 wfDeprecated(
'$input in LogEventsListGetExtraInputs hook',
'1.32' );
144 if ( !$this->
getConfig()->
get(
'MiserMode' ) ) {
149 $formDescriptor[
'date'] = [
151 'label-message' =>
'date',
152 'default' => $year && $month && $day ? sprintf(
"%04d-%02d-%02d", $year, $month, $day ) :
'',
156 $formDescriptor[
'tagfilter'] = [
157 'type' =>
'tagfilter',
158 'name' =>
'tagfilter',
159 'label-raw' => $this->
msg(
'tag-filter' )->parse(),
170 $this->allowedActions !==
null &&
171 count( $this->allowedActions ) > 0
180 ->setSubmitText( $this->
msg(
'logeventslist-submit' )->text() )
182 ->setWrapperLegendMsg(
'log' );
185 if ( isset( $extraInputsString ) ) {
193 $htmlForm->prepareForm()->displayForm(
false );
204 $optionsMsg[
"logeventslist-{$type}-log"] =
$type;
206 if ( $val ===
false ) {
211 'class' =>
'HTMLMultiSelectField',
212 'label-message' =>
'logeventslist-more-filters',
214 'options-messages' => $optionsMsg,
215 'default' => $default,
224 $queryType = count( $queryTypes ) == 1 ? $queryTypes[0] :
'';
230 $restriction = $page->getRestriction();
231 if ( MediaWikiServices::getInstance()
233 ->userHasRight( $this->
getUser(), $restriction )
235 $typesByName[
$type] = $page->getName()->text();
240 asort( $typesByName );
243 $public = $typesByName[
''];
244 unset( $typesByName[
''] );
245 $typesByName = [
'' => $public ] + $typesByName;
248 'class' =>
'HTMLSelectField',
250 'options' => array_flip( $typesByName ),
251 'default' => $queryType,
261 'class' =>
'HTMLUserTextField',
262 'label-message' =>
'specialloguserlabel',
274 'class' =>
'HTMLTitleTextField',
275 'label-message' =>
'speciallogtitlelabel',
288 'label-message' =>
'log-title-wildcard',
298 if ( count( $types ) == 1 ) {
299 if ( $types[0] ==
'suppress' ) {
302 'label-message' =>
'revdelete-offender',
303 'name' =>
'offender',
309 $formDescriptor = [];
310 Hooks::run(
'LogEventsListGetExtraInputs', [ $types[0], $this, &$input, &$formDescriptor ] );
312 return empty( $formDescriptor ) ? $input : $formDescriptor;
327 $actionOptions[
'log-action-filter-all' ] =
'';
329 foreach ( $this->allowedActions as $value ) {
330 $msgKey =
'log-action-filter-' . $types[0] .
'-' . $value;
331 $actionOptions[ $msgKey ] = $value;
335 'class' =>
'HTMLSelectField',
337 'options-messages' => $actionOptions,
338 'default' => $action,
339 'label' => $this->
msg(
'log-action-filter-' . $types[0] )->text(),
350 $this->allowedActions = $actions;
374 $formatter->setContext( $this->
getContext() );
376 $formatter->setShowUserToolLinks( !( $this->flags & self::NO_EXTRA_USER_LINKS ) );
378 $time = htmlspecialchars( $this->
getLanguage()->userTimeAndDate(
379 $entry->getTimestamp(), $this->getUser() ) );
381 $action = $formatter->getActionText();
383 if ( $this->flags & self::NO_ACTION_LINK ) {
386 $revert = $formatter->getActionLinks();
387 if ( $revert !=
'' ) {
388 $revert =
'<span class="mw-logevent-actionlink">' . $revert .
'</span>';
392 $comment = $formatter->getComment();
403 $classes = array_merge(
404 [
'mw-logline-' . $entry->getType() ],
408 'data-mw-logid' => $entry->getId(),
409 'data-mw-logaction' => $entry->getFullType(),
411 $ret =
"$del $time $action $comment $revert $tagDisplay";
414 Hooks::run(
'LogEventsListLineEnding', [ $this, &$ret, $entry, &$classes, &$attribs ] );
415 $attribs = array_filter( $attribs,
416 [ Sanitizer::class,
'isReservedDataAttribute' ],
419 $attribs[
'class'] = implode(
' ', $classes );
430 if ( $this->flags == self::NO_ACTION_LINK ) {
437 if ( $this->flags & self::USE_CHECKBOXES && $this->showTagEditUI ) {
441 [
'name' =>
'ids[' . $row->log_id .
']' ]
446 if ( $row->log_type ==
'suppress' ) {
451 $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
453 if ( $permissionManager->userHasRight( $user,
'deletedhistory' ) ) {
454 $canHide = $permissionManager->userHasRight( $user,
'deletelogentry' );
455 $canViewSuppressedOnly = $permissionManager->userHasRight( $user,
'viewsuppressed' ) &&
456 !$permissionManager->userHasRight( $user,
'suppressrevision' );
458 $canViewThisSuppressedEntry = $canViewSuppressedOnly && $entryIsSuppressed;
459 if ( $row->log_deleted || $canHide ) {
461 if ( $canHide && $this->flags & self::USE_CHECKBOXES && !$canViewThisSuppressedEntry ) {
464 $del =
Xml::check(
'deleterevisions',
false, [
'disabled' =>
'disabled' ] );
469 [
'name' =>
'ids[' . $row->log_id .
']' ]
480 'ids' => $row->log_id,
485 $canHide && !$canViewThisSuppressedEntry
503 $match = is_array(
$type ) ?
504 in_array( $row->log_type,
$type ) : $row->log_type ==
$type;
506 $match = is_array( $action ) ?
507 in_array( $row->log_action, $action ) : $row->log_action == $action;
508 if ( $match && $right ) {
510 $match = MediaWikiServices::getInstance()
511 ->getPermissionManager()
512 ->userHasRight( $wgUser, $right );
528 public static function userCan( $row, $field,
User $user =
null ) {
543 if ( $bitfield & $field ) {
544 if ( $user ===
null ) {
549 $permissions = [
'suppressrevision',
'viewsuppressed' ];
551 $permissions = [
'deletedhistory' ];
553 $permissionlist = implode(
', ', $permissions );
554 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
555 return MediaWikiServices::getInstance()
556 ->getPermissionManager()
557 ->userHasAnyRight( $user, ...$permissions );
571 if ( $user ===
null ) {
575 $logRestrictions = MediaWikiServices::getInstance()->getMainConfig()->get(
'LogRestrictions' );
576 if ( isset( $logRestrictions[
$type] ) && !MediaWikiServices::getInstance()
578 ->userHasRight( $user, $logRestrictions[
$type] )
591 return ( $row->log_deleted & $field ) == $field;
620 &$out, $types = [], $page =
'', $user =
'', $param = []
622 $defaultParameters = [
625 'showIfEmpty' =>
true,
629 'useRequestParams' =>
false,
630 'useMaster' =>
false,
631 'extraUrlParams' =>
false,
633 # The + operator appends elements of remaining keys from the right
634 # handed array to the left handed, whereas duplicated keys are NOT overwritten.
635 $param += $defaultParameters;
636 # Convert $param array to individual variables
637 $lim = $param[
'lim'];
638 $conds = $param[
'conds'];
639 $showIfEmpty = $param[
'showIfEmpty'];
640 $msgKey = $param[
'msgKey'];
641 $wrap = $param[
'wrap'];
643 $extraUrlParams = $param[
'extraUrlParams'];
645 $useRequestParams = $param[
'useRequestParams'];
646 if ( !is_array( $msgKey ) ) {
647 $msgKey = [ $msgKey ];
657 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
659 # Insert list of top 50 (or top $lim) items
661 $pager =
new LogPager( $loglist, $types, $user, $page,
'', $conds );
662 if ( !$useRequestParams ) {
663 # Reset vars that may have been taken from the request
665 $pager->mDefaultLimit = 50;
666 $pager->mOffset =
"";
667 $pager->mIsBackwards =
false;
670 if ( $param[
'useMaster'] ) {
673 if ( isset( $param[
'offset'] ) ) { # Tell pager to ignore
WebRequest offset
674 $pager->setOffset( $param[
'offset'] );
678 $pager->mLimit = $lim;
681 $logBody = $pager->getBody();
682 $numRows = $pager->getNumRows();
692 'class' =>
"mw-warning-with-logexcerpt mw-content-$dir",
697 if ( count( $msgKey ) == 1 ) {
701 array_shift(
$args );
705 $s .= $loglist->beginLogEventsList() .
707 $loglist->endLogEventsList();
710 } elseif ( $showIfEmpty ) {
715 if ( $numRows > $pager->mLimit ) { # Show
"Full log" link
717 if ( $page instanceof
Title ) {
718 $urlParam[
'page'] = $page->getPrefixedDBkey();
719 } elseif ( $page !=
'' ) {
720 $urlParam[
'page'] = $page;
724 $urlParam[
'user'] = $user;
727 if ( !is_array( $types ) ) { # Make it an array,
if it isn
't
731 # If there is exactly one log type, we can link to Special:Log?type=foo
732 if ( count( $types ) == 1 ) {
733 $urlParam['type
'] = $types[0];
736 if ( $extraUrlParams !== false ) {
737 $urlParam = array_merge( $urlParam, $extraUrlParams );
740 $s .= $linkRenderer->makeKnownLink(
741 SpecialPage::getTitleFor( 'Log
' ),
742 $context->msg( 'log-fulllog
' )->text(),
748 if ( $logBody && $msgKey[0] ) {
752 if ( $wrap != '' ) { // Wrap message in html
753 $s = str_replace( '$1
', $s, $wrap );
756 /* hook can return false, if we don't want the message to be emitted (Wikia BugId:7093) */
757 if (
Hooks::run(
'LogEventsListShowLogExtract', [ &
$s, $types, $page, $user, $param ] ) ) {
780 if ( $audience !=
'public' && $user ===
null ) {
790 if ( $audience ==
'public' || !MediaWikiServices::getInstance()
792 ->userHasRight( $user, $right )
794 $hiddenLogs[] = $logType;
797 if ( count( $hiddenLogs ) == 1 ) {
798 return 'log_type != ' . $db->addQuotes( $hiddenLogs[0] );
799 } elseif ( $hiddenLogs ) {
800 return 'log_type NOT IN (' . $db->makeList( $hiddenLogs ) .
')';