summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialLog.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialLog.php')
-rw-r--r--includes/specials/SpecialLog.php115
1 files changed, 76 insertions, 39 deletions
diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php
index dc33801d..e44ce5f5 100644
--- a/includes/specials/SpecialLog.php
+++ b/includes/specials/SpecialLog.php
@@ -29,17 +29,6 @@
* @ingroup SpecialPage
*/
class SpecialLog extends SpecialPage {
- /**
- * List log type for which the target is a user
- * Thus if the given target is in NS_MAIN we can alter it to be an NS_USER
- * Title user instead.
- */
- private $typeOnUser = array(
- 'block',
- 'newusers',
- 'rights',
- );
-
public function __construct() {
parent::__construct( 'Log' );
}
@@ -47,6 +36,7 @@ class SpecialLog extends SpecialPage {
public function execute( $par ) {
$this->setHeaders();
$this->outputHeader();
+ $this->getOutput()->addModules( 'mediawiki.userSuggest' );
$opts = new FormOptions;
$opts->add( 'type', '' );
@@ -94,13 +84,18 @@ class SpecialLog extends SpecialPage {
} elseif ( $offender && IP::isIPAddress( $offender->getName() ) ) {
$qc = array( 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() );
}
+ } else {
+ // Allow extensions to add relations to their search types
+ Hooks::run(
+ 'SpecialLogAddLogSearchRelations',
+ array( $opts->getValue( 'type' ), $this->getRequest(), &$qc )
+ );
}
# Some log types are only for a 'User:' title but we might have been given
# only the username instead of the full title 'User:username'. This part try
# to lookup for a user by that name and eventually fix user input. See bug 1697.
- wfRunHooks( 'GetLogTypesOnUser', array( &$this->typeOnUser ) );
- if ( in_array( $opts->getValue( 'type' ), $this->typeOnUser ) ) {
+ if ( in_array( $opts->getValue( 'type' ), self::getLogTypesOnUser() ) ) {
# ok we have a type of log which expect a user title.
$target = Title::newFromText( $opts->getValue( 'page' ) );
if ( $target && $target->getNamespace() === NS_MAIN ) {
@@ -115,17 +110,38 @@ class SpecialLog extends SpecialPage {
}
/**
- * Return an array of subpages beginning with $search that this special page will accept.
+ * List log type for which the target is a user
+ * Thus if the given target is in NS_MAIN we can alter it to be an NS_USER
+ * Title user instead.
*
- * @param string $search Prefix to search for
- * @param int $limit Maximum number of results to return
- * @return string[] Matching subpages
+ * @since 1.25
+ * @return array
*/
- public function prefixSearchSubpages( $search, $limit = 10 ) {
+ public static function getLogTypesOnUser() {
+ static $types = null;
+ if ( $types !== null ) {
+ return $types;
+ }
+ $types = array(
+ 'block',
+ 'newusers',
+ 'rights',
+ );
+
+ Hooks::run( 'GetLogTypesOnUser', array( &$types ) );
+ return $types;
+ }
+
+ /**
+ * Return an array of subpages that this special page will accept.
+ *
+ * @return string[] subpages
+ */
+ public function getSubpagesForPrefixSearch() {
$subpages = $this->getConfig()->get( 'LogTypes' );
$subpages[] = 'all';
sort( $subpages );
- return self::prefixSearchArray( $search, $limit, $subpages );
+ return $subpages;
}
private function parseParams( FormOptions $opts, $par ) {
@@ -149,7 +165,7 @@ class SpecialLog extends SpecialPage {
$loglist = new LogEventsList(
$this->getContext(),
null,
- LogEventsList::USE_REVDEL_CHECKBOXES
+ LogEventsList::USE_CHECKBOXES
);
$pager = new LogPager(
$loglist,
@@ -187,7 +203,7 @@ class SpecialLog extends SpecialPage {
if ( $logBody ) {
$this->getOutput()->addHTML(
$pager->getNavigationBar() .
- $this->getRevisionButton(
+ $this->getActionButtons(
$loglist->beginLogEventsList() .
$logBody .
$loglist->endLogEventsList()
@@ -199,30 +215,50 @@ class SpecialLog extends SpecialPage {
}
}
- private function getRevisionButton( $formcontents ) {
- # If the user doesn't have the ability to delete log entries,
- # don't bother showing them the button.
- if ( !$this->getUser()->isAllowedAll( 'deletedhistory', 'deletelogentry' ) ) {
+ private function getActionButtons( $formcontents ) {
+ $user = $this->getUser();
+ $canRevDelete = $user->isAllowedAll( 'deletedhistory', 'deletelogentry' );
+ $showTagEditUI = ChangeTags::showTagEditingUI( $user );
+ # If the user doesn't have the ability to delete log entries nor edit tags,
+ # don't bother showing them the button(s).
+ if ( !$canRevDelete && !$showTagEditUI ) {
return $formcontents;
}
- # Show button to hide log entries
+ # Show button to hide log entries and/or edit change tags
$s = Html::openElement(
'form',
array( 'action' => wfScript(), 'id' => 'mw-log-deleterevision-submit' )
) . "\n";
- $s .= Html::hidden( 'title', SpecialPage::getTitleFor( 'Revisiondelete' ) ) . "\n";
- $s .= Html::hidden( 'target', SpecialPage::getTitleFor( 'Log' ) ) . "\n";
+ $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
$s .= Html::hidden( 'type', 'logging' ) . "\n";
- $button = Html::element(
- 'button',
- array(
- 'type' => 'submit',
- 'class' => "deleterevision-log-submit mw-log-deleterevision-button"
- ),
- $this->msg( 'showhideselectedlogentries' )->text()
- ) . "\n";
- $s .= $button . $formcontents . $button;
+
+ $buttons = '';
+ if ( $canRevDelete ) {
+ $buttons .= Html::element(
+ 'button',
+ array(
+ 'type' => 'submit',
+ 'name' => 'revisiondelete',
+ 'value' => '1',
+ 'class' => "deleterevision-log-submit mw-log-deleterevision-button"
+ ),
+ $this->msg( 'showhideselectedlogentries' )->text()
+ ) . "\n";
+ }
+ if ( $showTagEditUI ) {
+ $buttons .= Html::element(
+ 'button',
+ array(
+ 'type' => 'submit',
+ 'name' => 'editchangetags',
+ 'value' => '1',
+ 'class' => "editchangetags-log-submit mw-log-editchangetags-button"
+ ),
+ $this->msg( 'log-edit-tags' )->text()
+ ) . "\n";
+ }
+ $s .= $buttons . $formcontents . $buttons;
$s .= Html::closeElement( 'form' );
return $s;
@@ -235,8 +271,9 @@ class SpecialLog extends SpecialPage {
*/
protected function addHeader( $type ) {
$page = new LogPage( $type );
- $this->getOutput()->setPageTitle( $page->getName()->text() );
- $this->getOutput()->addHTML( $page->getDescription()->parseAsBlock() );
+ $this->getOutput()->setPageTitle( $page->getName() );
+ $this->getOutput()->addHTML( $page->getDescription()
+ ->setContext( $this->getContext() )->parseAsBlock() );
}
protected function getGroupName() {