Add abusefilter-view-private right for viewing private abuse filters. Patch by Haza-w with stylistic and other minor adjustments

This commit is contained in:
Andrew Garrett 2009-07-03 14:17:05 +00:00
parent d1d27eede6
commit 4e3f9ab256
4 changed files with 17 additions and 3 deletions

View file

@ -61,6 +61,7 @@ Rule description: $1',
'right-abusefilter-private' => 'View private data in the abuse log',
'right-abusefilter-modify-restricted' => 'Modify abuse filters with restricted actions',
'right-abusefilter-revert' => 'Revert all changes by a given abuse filter',
'right-abusefilter-view-private' => 'View abuse filters marked as private',
'action-abusefilter-modify' => 'modify abuse filters',
'action-abusefilter-view' => 'view abuse filters',
@ -69,6 +70,7 @@ Rule description: $1',
'action-abusefilter-private' => 'view private data in the abuse log',
'action-abusefilter-modify-restricted' => 'modify abuse filters with restricted actions',
'action-abusefilter-revert' => 'revert all changes by a given abuse filter',
'action-abusefilter-view-private' => 'view abuse filters marked as private',
// Abuse Log
'abusefilter-log' => 'Abuse filter log',

View file

@ -78,6 +78,7 @@ $wgAvailableRights[] = 'abusefilter-log';
$wgAvailableRights[] = 'abusefilter-private';
$wgAvailableRights[] = 'abusefilter-modify-restricted';
$wgAvailableRights[] = 'abusefilter-revert';
$wgAvailableRights[] = 'abusefilter-view-private';
$wgLogTypes[] = 'abusefilter';
$wgLogNames['abusefilter'] = 'abusefilter-log-name';

View file

@ -17,14 +17,25 @@ abstract class AbuseFilterView {
function canEdit() {
global $wgUser;
static $canEdit = 'unset';
static $canEdit = null;
if ($canEdit == 'unset') {
if ( is_null( $canEdit ) ) {
$canEdit = $wgUser->isAllowed( 'abusefilter-modify' );
}
return $canEdit;
}
function canViewPrivate() {
global $wgUser;
static $canView = null;
if ( is_null( $canView ) ) {
$canView = $this->canEdit() || $wgUser->isAllowed( 'abusefilter-view-private' );
}
return $canView;
}
}
class AbuseFilterChangesList extends OldChangesList {

View file

@ -219,7 +219,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
$wgOut->setSubtitle( wfMsg( 'abusefilter-edit-subtitle', $filter, $history_id ) );
// Hide hidden filters.
if (isset($row->af_hidden) && $row->af_hidden && !$this->canEdit()) {
if ( isset($row->af_hidden) && $row->af_hidden && !$this->canViewPrivate() ) {
return wfMsg( 'abusefilter-edit-denied' );
}