r93252 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93251‎ | r93252 | r93253 >
Date:22:08, 26 July 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
- fixed bug where marking the free text as restricted actually disabled it
- introduced restricted=group parameter to restrict editing to the specified group or groups
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -663,7 +663,7 @@
664664 } elseif ( $component == 'hidden' ) {
665665 $is_hidden = true;
666666 } elseif ( $component == 'restricted' ) {
667 - $is_restricted = true;
 667+ $is_restricted = ( ! $wgUser || ! $wgUser->isAllowed( 'editrestrictedfields' ) );
668668 } elseif ( $component == 'uploadable' ) {
669669 $field_args['is_uploadable'] = true;
670670 } elseif ( $component == 'list' ) {
@@ -765,6 +765,11 @@
766766 // Parse value, so default filename can include parser functions.
767767 $default_filename = $wgParser->recursiveTagParse( $default_filename );
768768 $field_args['default filename'] = $default_filename;
 769+ } elseif ( $sub_components[0] == 'restricted' ) {
 770+ $is_restricted = !array_intersect(
 771+ $wgUser->getEffectiveGroups(),
 772+ array_map( 'trim', explode( ',', $sub_components[1] ) )
 773+ );
769774 }
770775 }
771776 }
@@ -992,8 +997,7 @@
993998 }
994999 // disable this field if either the whole form is disabled, or
9951000 // it's a restricted field and user doesn't have sysop privileges
996 - $is_disabled = ( $form_is_disabled ||
997 - ( $is_restricted && ( ! $wgUser || ! $wgUser->isAllowed( 'editrestrictedfields' ) ) ) );
 1001+ $is_disabled = ( $form_is_disabled || $is_restricted );
9981002 // Create an SFFormField instance based on all the parameters
9991003 // in the form definition, and any information from the template
10001004 // definition (contained in the $all_fields parameter).