r46371 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46370‎ | r46371 | r46372 >
Date:19:51, 27 January 2009
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Mark 'block' and 'degroup' as 'restricted' actions -- actions which, if added to a filter, require the 'abusefiilter-modify-restricted' right to edit.
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.php
@@ -57,8 +57,9 @@
5858 $wgAvailableRights[] = 'abusefilter-view';
5959 $wgAvailableRights[] = 'abusefilter-log';
6060 $wgAvailableRights[] = 'abusefilter-private';
 61+$wgAvailableRights[] = 'abusefilter-modify-restricted';
6162
62 -$wgAbuseFilterAvailableActions = array( 'flag', 'throttle', 'warn', 'disallow', 'blockautopromote', 'block', 'degroup', 'rangeblock' /*, 'tag' Disabled for now to avoid trunk changes. */ );
 63+$wgAbuseFilterAvailableActions = array( 'flag', 'throttle', 'warn', 'disallow', 'blockautopromote', 'block', 'degroup', /* Disabled because it's ridiculously excessive 'rangeblock'*/ /*, 'tag' Disabled for now to avoid trunk changes. */ );
6364
6465 // Conditions take about 4ms to check, so 100 conditions would take 400ms
6566 // Currently, has no effect.
@@ -80,4 +81,6 @@
8182 $wgAjaxExportList[] = 'AbuseFilter::ajaxReAutoconfirm';
8283
8384 // Bump the version number every time you change any of the .css/.js files
84 -$wgAbuseFilterStyleVersion = 2;
\ No newline at end of file
 85+$wgAbuseFilterStyleVersion = 2;
 86+
 87+$wgAbuseFilterRestrictedActions = array( 'block', 'degroup' );
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewEdit.php
@@ -25,7 +25,8 @@
2626 // Check syntax
2727 $syntaxerr = AbuseFilter::checkSyntax( $wgRequest->getVal( 'wpFilterRules' ) );
2828 if ($syntaxerr !== true ) {
29 - $wgOut->addHTML( $this->buildFilterEditor( wfMsgExt( 'abusefilter-edit-badsyntax', array( 'parseinline' ), array( $syntaxerr ) ), $filter, $history_id ) );
 29+ $wgOut->addHTML( $this->buildFilterEditor( wfMsgExt( 'abusefilter-edit-badsyntax', array( 'parse' ), array( $syntaxerr ) ), $filter, $history_id ) );
 30+ return;
3031 }
3132
3233 $dbw = wfGetDB( DB_MASTER );
@@ -37,11 +38,19 @@
3839 unset( $newRow->mOriginalRow );
3940 unset( $newRow->mOriginalActions );
4041
 42+ // Check for non-changes
4143 if (!count($differences)) {
4244 $wgOut->redirect( $this->getTitle()->getLocalURL() );
4345 return;
4446 }
4547
 48+ // Check for restricted actions
 49+ global $wgAbuseFilterRestrictedActions;
 50+ if ( count( array_intersect( $wgAbuseFilterRestrictedActions, array_keys( array_filter( $actions ) ) ) ) ) {
 51+ $wgOut->addHTML( $this->buildFilterEditor( wfMsgExt( 'abusefilter-edit-restricted', 'parse' ), $this->mFilter, $history_id ) );
 52+ return;
 53+ }
 54+
4655 $newRow = get_object_vars($newRow); // Convert from object to array
4756
4857 // Set last modifier.
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -162,6 +162,7 @@
163163 'abusefilter-edit-done-subtitle' => 'Filter edited',
164164 'abusefilter-edit-done' => "You have successfully saved your changes to filter $1.",
165165 'abusefilter-edit-badsyntax' => "There is a syntax error in the filter you specified. The output from the parser was: <pre>$1</pre>",
 166+ 'abusefilter-edit-restricted' => 'You cannot edit this filter, because it contains one or more restricted actions. Please ask a user with permission to add restricted actions to make the change for you.',
166167 'abusefilter-edit-viewhistory' => "View this filter's history",
167168 'abusefilter-edit-history' => 'History',
168169 'abusefilter-edit-check' => 'Check syntax',

Comments

#Comment by Brion VIBBER (talk | contribs)   20:26, 27 January 2009

Perm check in r46375

Status & tagging log