From: cenarium Date: Thu, 31 Mar 2016 16:50:54 +0000 (+0200) Subject: Move action filter logic to LogPager X-Git-Tag: 1.31.0-rc.0~7356^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/supprimer.php?a=commitdiff_plain;h=807650f458c410e300a0e0359a3711e4433d5385;p=lhc%2Fweb%2Fwiklou.git Move action filter logic to LogPager This moves the action filtering logic from SpecialLog to LogPager, in a limitAction function, as this seems to be how this is done for other params (title, performer, etc). This also uses $pager->getPerformer and getTagFilter() for resp. performer and tag filter as the options to show, rather than the raw request values (in a WYSIWYG logic). Change-Id: I4918a8a2dca3fdbadd7d65c9c9972e6f67a1761b --- diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 8518c910ff..410c970b62 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -42,6 +42,9 @@ class LogPager extends ReverseChronologicalPager { /** @var string */ private $typeCGI = ''; + /** @var string */ + private $action = ''; + /** @var LogEventsList */ public $mLogEventsList; @@ -57,9 +60,12 @@ class LogPager extends ReverseChronologicalPager { * @param int|bool $year The year to start from. Default: false * @param int|bool $month The month to start from. Default: false * @param string $tagFilter Tag + * @param string $action Specific action (subtype) requested */ - public function __construct( $list, $types = [], $performer = '', $title = '', $pattern = '', - $conds = [], $year = false, $month = false, $tagFilter = '' ) { + public function __construct( $list, $types = [], $performer = '', $title = '', + $pattern = '', $conds = [], $year = false, $month = false, $tagFilter = '', + $action = '' + ) { parent::__construct( $list->getContext() ); $this->mConds = $conds; @@ -68,6 +74,7 @@ class LogPager extends ReverseChronologicalPager { $this->limitType( $types ); // also excludes hidden types $this->limitPerformer( $performer ); $this->limitTitle( $title, $pattern ); + $this->limitAction( $action ); $this->getDateCond( $year, $month ); $this->mTagFilter = $tagFilter; @@ -256,6 +263,31 @@ class LogPager extends ReverseChronologicalPager { } } + /** + * Set the log_action field to a specified value (or values) + * + * @param string $action + */ + private function limitAction( $action ) { + global $wgActionFilteredLogs; + // Allow to filter the log by actions + $type = $this->typeCGI; + if ( $type === '' ) { + // nothing to do + return; + } + $actions = $wgActionFilteredLogs; + if ( isset( $actions[$type] ) ) { + // log type can be filtered by actions + $this->mLogEventsList->setAllowedActions( array_keys( $actions[$type] ) ); + if ( $action !== '' && isset( $actions[$type][$action] ) ) { + // add condition to query + $this->mConds['log_action'] = $actions[$type][$action]; + $this->action = $action; + } + } + } + /** * Constructs the most part of the query. Extra conditions are sprinkled in * all over this class. @@ -381,6 +413,10 @@ class LogPager extends ReverseChronologicalPager { return $this->mTagFilter; } + public function getAction() { + return $this->action; + } + public function doQuery() { // Workaround MySQL optimizer bug $this->mDb->setBigSelects(); diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index 7132207e24..95b7b7e6b5 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -169,25 +169,6 @@ class SpecialLog extends SpecialPage { LogEventsList::USE_CHECKBOXES ); - $action = ''; - // Allow to filter the log by actions - $type = $opts->getValue( 'type' ); - if ( $type !== '' ) { - $actions = $this->getConfig()->get( 'ActionFilteredLogs' ); - if ( isset( $actions[$type] ) ) { - // log type can be filtered by actions - $loglist->setAllowedActions( array_keys( $actions[$type] ) ); - $action = $opts->getValue( 'subtype' ); - if ( $action !== '' && isset( $actions[$type][$action] ) ) { - // add condition to query - $extraConds['log_action'] = $actions[$type][$action]; - } else { - // no action or invalid action - $action = ''; - } - } - } - $pager = new LogPager( $loglist, $opts->getValue( 'type' ), @@ -197,7 +178,8 @@ class SpecialLog extends SpecialPage { $extraConds, $opts->getValue( 'year' ), $opts->getValue( 'month' ), - $opts->getValue( 'tagfilter' ) + $opts->getValue( 'tagfilter' ), + $opts->getValue( 'subtype' ) ); $this->addHeader( $opts->getValue( 'type' ) ); @@ -210,14 +192,14 @@ class SpecialLog extends SpecialPage { # Show form options $loglist->showOptions( $pager->getType(), - $opts->getValue( 'user' ), + $pager->getPerformer(), $pager->getPage(), $pager->getPattern(), $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), - $opts->getValue( 'tagfilter' ), - $action + $pager->getTagFilter(), + $pager->getAction() ); # Insert list