Index: trunk/extensions/AbuseFilter/SpecialAbuseFilter.php |
— | — | @@ -45,9 +45,9 @@ |
46 | 46 | $view = 'AbuseFilterViewTools'; |
47 | 47 | } |
48 | 48 | |
49 | | - if (!empty($params[0]) && $params[0] == 'history') { |
| 49 | + if (!empty($params[0]) && ($params[0] == 'history' || $params[0] == 'log') ) { |
50 | 50 | if (count($params) == 1) { |
51 | | - // ... useless? |
| 51 | + $view = 'AbuseFilterViewHistory'; |
52 | 52 | } elseif (count($params) == 2) { |
53 | 53 | ## Second param is a filter ID |
54 | 54 | $view = 'AbuseFilterViewHistory'; |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | |
16 | 16 | // Quick links |
17 | 17 | $wgOut->addWikiMsg( 'abusefilter-links' ); |
18 | | - $lists = array( 'tools' ); |
| 18 | + $lists = array( 'tools', 'log' ); |
19 | 19 | if ($this->canEdit()) |
20 | 20 | $lists[] = 'new'; |
21 | 21 | $links = ''; |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php |
— | — | @@ -16,16 +16,41 @@ |
17 | 17 | global $wgUser; |
18 | 18 | |
19 | 19 | $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 | + } |
20 | 36 | |
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 ); |
27 | 38 | $wgOut->addHTML( Xml::tags( 'p', null, $backlinks ) ); |
28 | 39 | |
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 ); |
30 | 55 | $table = $pager->getBody(); |
31 | 56 | |
32 | 57 | $wgOut->addHTML( $pager->getNavigationBar() . $table . $pager->getNavigationBar() ); |
— | — | @@ -34,9 +59,10 @@ |
35 | 60 | |
36 | 61 | class AbuseFilterHistoryPager extends TablePager { |
37 | 62 | |
38 | | - function __construct( $filter, $page ) { |
| 63 | + function __construct( $filter, $page, $user ) { |
39 | 64 | $this->mFilter = $filter; |
40 | 65 | $this->mPage = $page; |
| 66 | + $this->mUser = $user; |
41 | 67 | $this->mDefaultDirection = true; |
42 | 68 | parent::__construct(); |
43 | 69 | } |
— | — | @@ -51,6 +77,11 @@ |
52 | 78 | $headers = array( 'afh_timestamp' => 'abusefilter-history-timestamp', 'afh_user_text' => 'abusefilter-history-user', 'afh_public_comments' => 'abusefilter-history-public', |
53 | 79 | 'afh_flags' => 'abusefilter-history-flags', 'afh_pattern' => 'abusefilter-history-filter', 'afh_comments' => 'abusefilter-history-comments', 'afh_actions' => 'abusefilter-history-actions' ); |
54 | 80 | |
| 81 | + if (!$this->mFilter) { |
| 82 | + // awful hack |
| 83 | + $headers = array( 'afh_filter' => 'abusefilter-history-filterid' ) + $headers; |
| 84 | + } |
| 85 | + |
55 | 86 | $headers = array_map( 'wfMsg', $headers ); |
56 | 87 | |
57 | 88 | return $headers; |
— | — | @@ -98,17 +129,29 @@ |
99 | 130 | $display_actions = Xml::tags( 'ul', null, $display_actions ); |
100 | 131 | |
101 | 132 | return $display_actions; |
| 133 | + case 'afh_filter': |
| 134 | + $title = $this->getTitle( $value ); |
| 135 | + return $sk->link( $title, $value ); |
102 | 136 | } |
103 | 137 | |
104 | 138 | return "Unable to format name $name\n"; |
105 | 139 | } |
106 | 140 | |
107 | 141 | function getQueryInfo() { |
108 | | - return array( |
| 142 | + $info = array( |
109 | 143 | '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(), |
112 | 148 | ); |
| 149 | + |
| 150 | + global $wgRequest; |
| 151 | + if ($this->mUser) { |
| 152 | + $info['conds']['afh_user_text'] = $this->mUser; |
| 153 | + } |
| 154 | + |
| 155 | + return $info; |
113 | 156 | } |
114 | 157 | |
115 | 158 | function getIndexField() { |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -230,7 +230,9 @@ |
231 | 231 | 'abusefilter-edit-builder-vars-user-emailconfirm' => 'Time email address was confirmed', |
232 | 232 | |
233 | 233 | // Filter history |
| 234 | + 'abusefilter-log' => 'Recent filter changes', |
234 | 235 | 'abusefilter-history' => 'History for filter $1', |
| 236 | + 'abusefilter-history-foruser' => 'Changes by $1', |
235 | 237 | 'abusefilter-history-hidden' => 'hidden', |
236 | 238 | 'abusefilter-history-enabled' => 'enabled', |
237 | 239 | 'abusefilter-history-timestamp' => 'Time', |
— | — | @@ -244,6 +246,10 @@ |
245 | 247 | 'abusefilter-history-backedit' => 'Back to filter editor', |
246 | 248 | 'abusefilter-history-backlist' => 'Back to filter list', |
247 | 249 | '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', |
248 | 254 | ); |
249 | 255 | |
250 | 256 | /** Message documentation (Message documentation) |