Revision: 46272
Author: werdna
Date: 2009-01-26 18:50:20 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Add a handy 'Abuse Filter log' where you can see all recent changes to filters,
and narrow it down by user if you like.
Modified Paths:
--------------
trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
trunk/extensions/AbuseFilter/SpecialAbuseFilter.php
trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
Modified: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
===================================================================
--- trunk/extensions/AbuseFilter/AbuseFilter.i18n.php 2009-01-26 18:02:28 UTC
(rev 46271)
+++ trunk/extensions/AbuseFilter/AbuseFilter.i18n.php 2009-01-26 18:50:20 UTC
(rev 46272)
@@ -230,7 +230,9 @@
'abusefilter-edit-builder-vars-user-emailconfirm' => 'Time email
address was confirmed',
// Filter history
+ 'abusefilter-log' => 'Recent filter changes',
'abusefilter-history' => 'History for filter $1',
+ 'abusefilter-history-foruser' => 'Changes by $1',
'abusefilter-history-hidden' => 'hidden',
'abusefilter-history-enabled' => 'enabled',
'abusefilter-history-timestamp' => 'Time',
@@ -244,6 +246,10 @@
'abusefilter-history-backedit' => 'Back to filter editor',
'abusefilter-history-backlist' => 'Back to filter list',
'abusefilter-history-deleted' => 'Deleted',
+ 'abusefilter-history-filterid' => 'Filter',
+ 'abusefilter-history-select-legend' => 'Refine search',
+ 'abusefilter-history-select-user' => 'User:',
+ 'abusefilter-history-select-submit' => 'Refine',
);
/** Message documentation (Message documentation)
Modified: trunk/extensions/AbuseFilter/SpecialAbuseFilter.php
===================================================================
--- trunk/extensions/AbuseFilter/SpecialAbuseFilter.php 2009-01-26 18:02:28 UTC
(rev 46271)
+++ trunk/extensions/AbuseFilter/SpecialAbuseFilter.php 2009-01-26 18:50:20 UTC
(rev 46272)
@@ -45,9 +45,9 @@
$view = 'AbuseFilterViewTools';
}
- if (!empty($params[0]) && $params[0] == 'history') {
+ if (!empty($params[0]) && ($params[0] == 'history' ||
$params[0] == 'log') ) {
if (count($params) == 1) {
- // ... useless?
+ $view = 'AbuseFilterViewHistory';
} elseif (count($params) == 2) {
## Second param is a filter ID
$view = 'AbuseFilterViewHistory';
Modified: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
===================================================================
--- trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
2009-01-26 18:02:28 UTC (rev 46271)
+++ trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
2009-01-26 18:50:20 UTC (rev 46272)
@@ -16,16 +16,41 @@
global $wgUser;
$filter = $this->mFilter;
+
+ if ($filter)
+ $wgOut->setPageTitle( wfMsg( 'abusefilter-history',
$filter ) );
+ else
+ $wgOut->setPageTitle( wfMsg( 'abusefilter-log' ) );
+
+ $sk = $wgUser->getSkin();
+
+ $links = array();
+ if ($filter)
+ $links['abusefilter-history-backedit'] =
$this->getTitle( $filter );
+ $links['abusefilter-history-backlist'] = $this->getTitle();
+
+ foreach( $links as $msg => $title ) {
+ $links[$msg] = $sk->link( $title, wfMsgExt( $msg,
'parseinline' ) );
+ }
- $sk = $wgUser->getSkin();
- $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) );
- $backToFilter_label = wfMsgExt( 'abusefilter-history-backedit',
array('parseinline') );
- $backToList_label = wfMsgExt( 'abusefilter-history-backlist',
array('parseinline') );
- $backlinks = $sk->makeKnownLinkObj( $this->getTitle( $filter ),
$backToFilter_label ) . ' • ' .
- $sk->makeKnownLinkObj( $this->getTitle( ),
$backToList_label );
+ $backlinks = implode( ' • ', $links );
$wgOut->addHTML( Xml::tags( 'p', null, $backlinks ) );
- $pager = new AbuseFilterHistoryPager( $filter, $this );
+ $user = $wgRequest->getText( 'user' );
+ if ($user) {
+ $wgOut->setSubtitle( wfMsg(
'abusefilter-history-foruser', $sk->userLink( 1 /* We don't really need to get
a user ID */, $user ) ) );
+ }
+
+ // Add filtering of changes et al.
+ $fields['abusefilter-history-select-user'] = wfInput( 'user',
45, $user );
+
+ $filterForm = Xml::buildForm( $fields,
'abusefilter-history-select-submit' );
+ $filterForm .= "\n" . Xml::hidden( 'title', $this->getTitle(
"history/$filter" ) );
+ $filterForm = Xml::tags( 'form', array( 'action' =>
$this->getTitle( "history/$filter" )->getLocalURL(), 'method' => 'get' ),
$filterForm );
+ $filterForm = Xml::fieldset( wfMsg(
'abusefilter-history-select-legend' ), $filterForm );
+ $wgOut->addHTML( $filterForm );
+
+ $pager = new AbuseFilterHistoryPager( $filter, $this, $user );
$table = $pager->getBody();
$wgOut->addHTML( $pager->getNavigationBar() . $table .
$pager->getNavigationBar() );
@@ -34,9 +59,10 @@
class AbuseFilterHistoryPager extends TablePager {
- function __construct( $filter, $page ) {
+ function __construct( $filter, $page, $user ) {
$this->mFilter = $filter;
$this->mPage = $page;
+ $this->mUser = $user;
$this->mDefaultDirection = true;
parent::__construct();
}
@@ -51,6 +77,11 @@
$headers = array( 'afh_timestamp' =>
'abusefilter-history-timestamp', 'afh_user_text' => 'abusefilter-history-user',
'afh_public_comments' => 'abusefilter-history-public',
'afh_flags' =>
'abusefilter-history-flags', 'afh_pattern' => 'abusefilter-history-filter',
'afh_comments' => 'abusefilter-history-comments', 'afh_actions' =>
'abusefilter-history-actions' );
+ if (!$this->mFilter) {
+ // awful hack
+ $headers = array( 'afh_filter' =>
'abusefilter-history-filterid' ) + $headers;
+ }
+
$headers = array_map( 'wfMsg', $headers );
return $headers;
@@ -98,17 +129,29 @@
$display_actions = Xml::tags( 'ul', null,
$display_actions );
return $display_actions;
+ case 'afh_filter':
+ $title = $this->getTitle( $value );
+ return $sk->link( $title, $value );
}
return "Unable to format name $name\n";
}
function getQueryInfo() {
- return array(
+ $info = array(
'tables' => 'abuse_filter_history',
- 'fields' => array( 'afh_timestamp', 'afh_user_text',
'afh_public_comments', 'afh_flags', 'afh_pattern', 'afh_comments',
'afh_actions', 'afh_id', 'afh_user' ),
- 'conds' => array( 'afh_filter' => $this->mFilter ),
+ 'fields' => $this->mFilter ?
+ array( 'afh_timestamp', 'afh_user_text',
'afh_public_comments', 'afh_flags', 'afh_pattern', 'afh_comments',
'afh_actions', 'afh_id', 'afh_user' ) :
+ array( 'afh_filter', 'afh_timestamp',
'afh_user_text', 'afh_public_comments', 'afh_flags', 'afh_comments',
'afh_actions', 'afh_id', 'afh_user' ),
+ 'conds' => $this->mFilter ? array( 'afh_filter' =>
$this->mFilter ) : array(),
);
+
+ global $wgRequest;
+ if ($this->mUser) {
+ $info['conds']['afh_user_text'] = $this->mUser;
+ }
+
+ return $info;
}
function getIndexField() {
Modified: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
===================================================================
--- trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php 2009-01-26
18:02:28 UTC (rev 46271)
+++ trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php 2009-01-26
18:50:20 UTC (rev 46272)
@@ -14,7 +14,7 @@
// Quick links
$wgOut->addWikiMsg( 'abusefilter-links' );
- $lists = array( 'tools' );
+ $lists = array( 'tools', 'log' );
if ($this->canEdit())
$lists[] = 'new';
$links = '';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs