r24484 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24483‎ | r24484 | r24485 >
Date:13:03, 31 July 2007
Author:yaron
Status:old
Tags:
Comment:
Addeds support for new 'restricted' property
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc
@@ -199,6 +199,7 @@
200200 // cycle through the other components
201201 $is_mandatory = false;
202202 $is_hidden = false;
 203+ $is_restricted = false;
203204 $input_type = null;
204205 $no_autocomplete = false;
205206 $autocomplete_category = null;
@@ -213,6 +214,8 @@
214215 $is_mandatory = true;
215216 } elseif ($component == 'hidden') {
216217 $is_hidden = true;
 218+ } elseif ($component == 'restricted') {
 219+ $is_restricted = true;
217220 } else {
218221 $sub_components = explode('=', $component);
219222 if (count($sub_components) == 2) {
@@ -258,7 +261,18 @@
259262 $cur_value = Sanitizer::safeEncodeAttribute($cur_value);
260263 }
261264 }
262 - $template_display_name = $query_template_name;
 265+
 266+ // hack - if this is a 'restricted' field, and the user isn't
 267+ // a sysop, set the global $gDisabledText temporarily to
 268+ // 'disabled' - set it back at the end of this function
 269+ $actual_disabled_text = $gDisabledText;
 270+ // determine whether user is a sysop by whether or not they're
 271+ // allowed to delete things - if there's a better way, please let
 272+ // me know
 273+ if ($is_restricted && ! $wgUser->isAllowed('delete')) {
 274+ $gDisabledText = "disabled";
 275+ }
 276+
263277 // handle non-template fields - 'page title' and 'free text'
264278 if ($template_name == '') {
265279 if ($field_name == 'page title') {
@@ -328,7 +342,7 @@
329343 else
330344 $input_name = $query_template_name . '[' . $field_name . ']';
331345 $new_text = SFFormPrinter::formTemplateFieldHTML($field_name, $input_name, $allow_multiple,
332 - $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete,
 346+ $cur_value, $is_mandatory, $is_hidden, $is_restricted, $input_type, $size, $num_rows, $num_cols, $no_autocomplete,
333347 $autocomplete_category, $all_fields, $strict_parsing);
334348 if ($new_text) {
335349 if (is_numeric($field_name)) {
@@ -352,6 +366,8 @@
353367 $start_position = $brackets_end_loc;
354368 }
355369 }
 370+ // restore back to actual value, if it changed
 371+ $gDisabledText = $actual_disabled_text;
356372 } else { // tag is not one of the three allowed values
357373 // ignore tag
358374 $start_position = $brackets_end_loc;
@@ -511,7 +527,7 @@
512528 return array($form_text, $javascript_text, $title, $data_text);
513529 }
514530
515 - function formTemplateFieldHTML($field_name, $input_name, $part_of_multiple, $cur_value, $is_mandatory, $is_hidden, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $all_fields, $strict_parsing) {
 531+ function formTemplateFieldHTML($field_name, $input_name, $part_of_multiple, $cur_value, $is_mandatory, $is_hidden, $is_restricted, $input_type, $size, $num_rows, $num_cols, $no_autocomplete, $autocomplete_category, $all_fields, $strict_parsing) {
516532 global $gTabIndex;
517533
518534 // see if this field matches one of the fields defined for this template -
@@ -540,6 +556,7 @@
541557 // populate field object with settings from the form definition file
542558 $the_field->is_mandatory = $is_mandatory;
543559 $the_field->is_hidden = $is_hidden;
 560+ $the_field->is_restricted = $is_restricted;
544561 $the_field->input_type = $input_type;
545562 $the_field->size = $size;
546563 $the_field->num_rows = $num_rows;

Status & tagging log