r46272 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46271‎ | r46272 | r46273 >
Date:18:50, 26 January 2009
Author:werdna
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/AbuseFilter/SpecialAbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/SpecialAbuseFilter.php
@@ -45,9 +45,9 @@
4646 $view = 'AbuseFilterViewTools';
4747 }
4848
49 - if (!empty($params[0]) && $params[0] == 'history') {
 49+ if (!empty($params[0]) && ($params[0] == 'history' || $params[0] == 'log') ) {
5050 if (count($params) == 1) {
51 - // ... useless?
 51+ $view = 'AbuseFilterViewHistory';
5252 } elseif (count($params) == 2) {
5353 ## Second param is a filter ID
5454 $view = 'AbuseFilterViewHistory';
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php
@@ -14,7 +14,7 @@
1515
1616 // Quick links
1717 $wgOut->addWikiMsg( 'abusefilter-links' );
18 - $lists = array( 'tools' );
 18+ $lists = array( 'tools', 'log' );
1919 if ($this->canEdit())
2020 $lists[] = 'new';
2121 $links = '';
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php
@@ -16,16 +16,41 @@
1717 global $wgUser;
1818
1919 $filter = $this->mFilter;
 20+
 21+ if ($filter)
 22+ $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) );
 23+ else
 24+ $wgOut->setPageTitle( wfMsg( 'abusefilter-log' ) );
 25+
 26+ $sk = $wgUser->getSkin();
 27+
 28+ $links = array();
 29+ if ($filter)
 30+ $links['abusefilter-history-backedit'] = $this->getTitle( $filter );
 31+ $links['abusefilter-history-backlist'] = $this->getTitle();
 32+
 33+ foreach( $links as $msg => $title ) {
 34+ $links[$msg] = $sk->link( $title, wfMsgExt( $msg, 'parseinline' ) );
 35+ }
2036
21 - $sk = $wgUser->getSkin();
22 - $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) );
23 - $backToFilter_label = wfMsgExt( 'abusefilter-history-backedit', array('parseinline') );
24 - $backToList_label = wfMsgExt( 'abusefilter-history-backlist', array('parseinline') );
25 - $backlinks = $sk->makeKnownLinkObj( $this->getTitle( $filter ), $backToFilter_label ) . ' • ' .
26 - $sk->makeKnownLinkObj( $this->getTitle( ), $backToList_label );
 37+ $backlinks = implode( ' • ', $links );
2738 $wgOut->addHTML( Xml::tags( 'p', null, $backlinks ) );
2839
29 - $pager = new AbuseFilterHistoryPager( $filter, $this );
 40+ $user = $wgRequest->getText( 'user' );
 41+ if ($user) {
 42+ $wgOut->setSubtitle( wfMsg( 'abusefilter-history-foruser', $sk->userLink( 1 /* We don't really need to get a user ID */, $user ) ) );
 43+ }
 44+
 45+ // Add filtering of changes et al.
 46+ $fields['abusefilter-history-select-user'] = wfInput( 'user', 45, $user );
 47+
 48+ $filterForm = Xml::buildForm( $fields, 'abusefilter-history-select-submit' );
 49+ $filterForm .= "\n" . Xml::hidden( 'title', $this->getTitle( "history/$filter" ) );
 50+ $filterForm = Xml::tags( 'form', array( 'action' => $this->getTitle( "history/$filter" )->getLocalURL(), 'method' => 'get' ), $filterForm );
 51+ $filterForm = Xml::fieldset( wfMsg( 'abusefilter-history-select-legend' ), $filterForm );
 52+ $wgOut->addHTML( $filterForm );
 53+
 54+ $pager = new AbuseFilterHistoryPager( $filter, $this, $user );
3055 $table = $pager->getBody();
3156
3257 $wgOut->addHTML( $pager->getNavigationBar() . $table . $pager->getNavigationBar() );
@@ -34,9 +59,10 @@
3560
3661 class AbuseFilterHistoryPager extends TablePager {
3762
38 - function __construct( $filter, $page ) {
 63+ function __construct( $filter, $page, $user ) {
3964 $this->mFilter = $filter;
4065 $this->mPage = $page;
 66+ $this->mUser = $user;
4167 $this->mDefaultDirection = true;
4268 parent::__construct();
4369 }
@@ -51,6 +77,11 @@
5278 $headers = array( 'afh_timestamp' => 'abusefilter-history-timestamp', 'afh_user_text' => 'abusefilter-history-user', 'afh_public_comments' => 'abusefilter-history-public',
5379 'afh_flags' => 'abusefilter-history-flags', 'afh_pattern' => 'abusefilter-history-filter', 'afh_comments' => 'abusefilter-history-comments', 'afh_actions' => 'abusefilter-history-actions' );
5480
 81+ if (!$this->mFilter) {
 82+ // awful hack
 83+ $headers = array( 'afh_filter' => 'abusefilter-history-filterid' ) + $headers;
 84+ }
 85+
5586 $headers = array_map( 'wfMsg', $headers );
5687
5788 return $headers;
@@ -98,17 +129,29 @@
99130 $display_actions = Xml::tags( 'ul', null, $display_actions );
100131
101132 return $display_actions;
 133+ case 'afh_filter':
 134+ $title = $this->getTitle( $value );
 135+ return $sk->link( $title, $value );
102136 }
103137
104138 return "Unable to format name $name\n";
105139 }
106140
107141 function getQueryInfo() {
108 - return array(
 142+ $info = array(
109143 'tables' => 'abuse_filter_history',
110 - 'fields' => array( 'afh_timestamp', 'afh_user_text', 'afh_public_comments', 'afh_flags', 'afh_pattern', 'afh_comments', 'afh_actions', 'afh_id', 'afh_user' ),
111 - 'conds' => array( 'afh_filter' => $this->mFilter ),
 144+ 'fields' => $this->mFilter ?
 145+ array( 'afh_timestamp', 'afh_user_text', 'afh_public_comments', 'afh_flags', 'afh_pattern', 'afh_comments', 'afh_actions', 'afh_id', 'afh_user' ) :
 146+ array( 'afh_filter', 'afh_timestamp', 'afh_user_text', 'afh_public_comments', 'afh_flags', 'afh_comments', 'afh_actions', 'afh_id', 'afh_user' ),
 147+ 'conds' => $this->mFilter ? array( 'afh_filter' => $this->mFilter ) : array(),
112148 );
 149+
 150+ global $wgRequest;
 151+ if ($this->mUser) {
 152+ $info['conds']['afh_user_text'] = $this->mUser;
 153+ }
 154+
 155+ return $info;
113156 }
114157
115158 function getIndexField() {
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -230,7 +230,9 @@
231231 'abusefilter-edit-builder-vars-user-emailconfirm' => 'Time email address was confirmed',
232232
233233 // Filter history
 234+ 'abusefilter-log' => 'Recent filter changes',
234235 'abusefilter-history' => 'History for filter $1',
 236+ 'abusefilter-history-foruser' => 'Changes by $1',
235237 'abusefilter-history-hidden' => 'hidden',
236238 'abusefilter-history-enabled' => 'enabled',
237239 'abusefilter-history-timestamp' => 'Time',
@@ -244,6 +246,10 @@
245247 'abusefilter-history-backedit' => 'Back to filter editor',
246248 'abusefilter-history-backlist' => 'Back to filter list',
247249 'abusefilter-history-deleted' => 'Deleted',
 250+ 'abusefilter-history-filterid' => 'Filter',
 251+ 'abusefilter-history-select-legend' => 'Refine search',
 252+ 'abusefilter-history-select-user' => 'User:',
 253+ 'abusefilter-history-select-submit' => 'Refine',
248254 );
249255
250256 /** Message documentation (Message documentation)

Follow-up revisions

RevisionCommit summaryAuthorDate
r46275Fix up Abuse Log, by adding descriptions for variables, styling the variable ...werdna19:23, 26 January 2009

Status & tagging log