Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -61,9 +61,11 @@ |
62 | 62 | 'abusefilter-enabled' => 'Enabled', |
63 | 63 | 'abusefilter-disabled' => 'Disabled', |
64 | 64 | 'abusefilter-hitcount' => '$1 {{PLURAL:$1|hit|hits}}', |
| 65 | + 'abusefilter-list-new' => 'New filter', |
65 | 66 | |
66 | 67 | // The edit screen |
67 | 68 | 'abusefilter-edit-subtitle' => 'Editing filter $1', |
| 69 | + 'abusefilter-edit-new' => 'New filter', |
68 | 70 | 'abusefilter-edit-save' => 'Save Filter', |
69 | 71 | 'abusefilter-edit-id' => 'Filter ID:', |
70 | 72 | 'abusefilter-edit-description' => "Description:\n:''(publicly viewable)''", |
Index: trunk/extensions/AbuseFilter/SpecialAbuseFilter.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | $filter = $this->mFilter; |
47 | 47 | |
48 | 48 | $editToken = $wgRequest->getVal( 'wpEditToken' ); |
49 | | - $didEdit = $filter && $this->canEdit() && $wgUser->matchEditToken( $editToken, array( 'abusefilter', $filter ) ); |
| 49 | + $didEdit = $this->canEdit() && $wgUser->matchEditToken( $editToken, array( 'abusefilter', $filter ) ); |
50 | 50 | |
51 | 51 | if ($didEdit) { |
52 | 52 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | // Do the update |
106 | 106 | |
107 | 107 | $dbw->begin(); |
108 | | - $dbw->update( 'abuse_filter', $newRow, array( 'af_id' => $filter ), __METHOD__ ); |
| 108 | + $dbw->replace( 'abuse_filter', array( 'af_id' ), $newRow, __METHOD__ ); |
109 | 109 | $dbw->delete( 'abuse_filter_action', array( 'afa_filter' => $filter, 'afa_consequence' => $deadActions ), __METHOD__ ); |
110 | 110 | $dbw->replace( 'abuse_filter_action', array( array( 'afa_filter', 'afa_consequence' ) ), $actionsRows, __METHOD__ ); |
111 | 111 | $dbw->commit(); |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | } |
121 | 121 | |
122 | 122 | function buildFilterEditor( ) { |
123 | | - if (!is_numeric($this->mFilter) || $this->mFilter<=0) { |
| 123 | + if (!is_numeric($this->mFilter) && $this->mFilter != 'new') { |
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | |
— | — | @@ -130,6 +130,10 @@ |
131 | 131 | |
132 | 132 | list ($row, $actions) = $this->loadFilterData(); |
133 | 133 | |
| 134 | + if (!$row && $this->mFilter !== 'new') { |
| 135 | + return false; |
| 136 | + } |
| 137 | + |
134 | 138 | if ($row->af_hidden && !$this->canEdit()) { |
135 | 139 | return wfMsg( 'abusefilter-edit-hidden' ); |
136 | 140 | } |
— | — | @@ -137,11 +141,11 @@ |
138 | 142 | $output = ''; |
139 | 143 | $fields = array(); |
140 | 144 | |
141 | | - $fields['abusefilter-edit-id'] = $this->mFilter; |
| 145 | + $fields['abusefilter-edit-id'] = $this->mFilter == 'new' ? wfMsg( 'abusefilter-edit-new' ) : $this->mFilter; |
142 | 146 | $fields['abusefilter-edit-description'] = Xml::input( 'wpFilterDescription', 20, $row->af_public_comments ); |
143 | 147 | |
144 | 148 | // Hit count display |
145 | | - $count = $row->af_hit_count; |
| 149 | + $count = (int)$row->af_hit_count; |
146 | 150 | $count_display = wfMsgExt( 'abusefilter-hitcount', array( 'parseinline' ), array( $count ) ); |
147 | 151 | $hitCount = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'AbuseLog' ), $count_display, 'wpSearchFilter='.$row->af_id ); |
148 | 152 | |
— | — | @@ -165,9 +169,11 @@ |
166 | 170 | } |
167 | 171 | $fields['abusefilter-edit-flags'] = $flags; |
168 | 172 | |
169 | | - // Last modification details |
170 | | - $fields['abusefilter-edit-lastmod'] = $wgLang->timeanddate( $row->af_timestamp ); |
171 | | - $fields['abusefilter-edit-lastuser'] = $sk->userLink( $row->af_user, $row->af_user_text ) . $sk->userToolLinks( $row->af_user, $row->af_user_text ); |
| 173 | + if ($this->mFilter != 'new') { |
| 174 | + // Last modification details |
| 175 | + $fields['abusefilter-edit-lastmod'] = $wgLang->timeanddate( $row->af_timestamp ); |
| 176 | + $fields['abusefilter-edit-lastuser'] = $sk->userLink( $row->af_user, $row->af_user_text ) . $sk->userToolLinks( $row->af_user, $row->af_user_text ); |
| 177 | + } |
172 | 178 | |
173 | 179 | $form = Xml::buildForm( $fields ); |
174 | 180 | $form = Xml::fieldset( wfMsg( 'abusefilter-edit-main' ), $form ); |
— | — | @@ -265,10 +271,10 @@ |
266 | 272 | |
267 | 273 | $filter = $subpage; |
268 | 274 | |
269 | | - if (!is_numeric($filter)) { |
| 275 | + if (!is_numeric($filter) && $subpage != 'new') { |
270 | 276 | $filter = $wgRequest->getIntOrNull( 'wpFilter' ); |
271 | 277 | |
272 | | - if (!$filter) { |
| 278 | + if ($filter === null && $filter != 'new') { |
273 | 279 | return; |
274 | 280 | } |
275 | 281 | } |
— | — | @@ -287,9 +293,9 @@ |
288 | 294 | } |
289 | 295 | |
290 | 296 | function showList() { |
291 | | - global $wgOut,$wgUser;; |
| 297 | + global $wgOut,$wgUser; |
292 | 298 | |
293 | | - $this->mSkin = $wgUser->getSkin(); |
| 299 | + $sk = $this->mSkin = $wgUser->getSkin(); |
294 | 300 | |
295 | 301 | $output = ''; |
296 | 302 | |
— | — | @@ -316,6 +322,10 @@ |
317 | 323 | |
318 | 324 | $output .= Xml::tags( 'table', array( 'class' => 'wikitable' ), Xml::tags( 'tbody', null, $list ) ); |
319 | 325 | |
| 326 | + if ($this->canEdit()) { |
| 327 | + $output .= $sk->makeKnownLinkObj( $this->getTitle( 'new' ), wfMsg( 'abusefilter-list-new' ) ); |
| 328 | + } |
| 329 | + |
320 | 330 | $wgOut->addHTML( $output ); |
321 | 331 | } |
322 | 332 | |