Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.inc |
— | — | @@ -199,6 +199,7 @@ |
200 | 200 | // cycle through the other components |
201 | 201 | $is_mandatory = false; |
202 | 202 | $is_hidden = false; |
| 203 | + $is_restricted = false; |
203 | 204 | $input_type = null; |
204 | 205 | $no_autocomplete = false; |
205 | 206 | $autocomplete_category = null; |
— | — | @@ -213,6 +214,8 @@ |
214 | 215 | $is_mandatory = true; |
215 | 216 | } elseif ($component == 'hidden') { |
216 | 217 | $is_hidden = true; |
| 218 | + } elseif ($component == 'restricted') { |
| 219 | + $is_restricted = true; |
217 | 220 | } else { |
218 | 221 | $sub_components = explode('=', $component); |
219 | 222 | if (count($sub_components) == 2) { |
— | — | @@ -258,7 +261,18 @@ |
259 | 262 | $cur_value = Sanitizer::safeEncodeAttribute($cur_value); |
260 | 263 | } |
261 | 264 | } |
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 | + |
263 | 277 | // handle non-template fields - 'page title' and 'free text' |
264 | 278 | if ($template_name == '') { |
265 | 279 | if ($field_name == 'page title') { |
— | — | @@ -328,7 +342,7 @@ |
329 | 343 | else |
330 | 344 | $input_name = $query_template_name . '[' . $field_name . ']'; |
331 | 345 | $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, |
333 | 347 | $autocomplete_category, $all_fields, $strict_parsing); |
334 | 348 | if ($new_text) { |
335 | 349 | if (is_numeric($field_name)) { |
— | — | @@ -352,6 +366,8 @@ |
353 | 367 | $start_position = $brackets_end_loc; |
354 | 368 | } |
355 | 369 | } |
| 370 | + // restore back to actual value, if it changed |
| 371 | + $gDisabledText = $actual_disabled_text; |
356 | 372 | } else { // tag is not one of the three allowed values |
357 | 373 | // ignore tag |
358 | 374 | $start_position = $brackets_end_loc; |
— | — | @@ -511,7 +527,7 @@ |
512 | 528 | return array($form_text, $javascript_text, $title, $data_text); |
513 | 529 | } |
514 | 530 | |
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) { |
516 | 532 | global $gTabIndex; |
517 | 533 | |
518 | 534 | // see if this field matches one of the fields defined for this template - |
— | — | @@ -540,6 +556,7 @@ |
541 | 557 | // populate field object with settings from the form definition file |
542 | 558 | $the_field->is_mandatory = $is_mandatory; |
543 | 559 | $the_field->is_hidden = $is_hidden; |
| 560 | + $the_field->is_restricted = $is_restricted; |
544 | 561 | $the_field->input_type = $input_type; |
545 | 562 | $the_field->size = $size; |
546 | 563 | $the_field->num_rows = $num_rows; |