Add convenience function; keep track of multi-value widget types in one place
[squirrelmail.git] / functions / options.php
1 <?php
2
3 /**
4 * options.php
5 *
6 * Functions needed to display the options pages.
7 *
8 * @copyright &copy; 1999-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @version $Id$
11 * @package squirrelmail
12 * @subpackage prefs
13 */
14
15 /**********************************************/
16 /* Define constants used in the options code. */
17 /**********************************************/
18
19 /* Define constants for the various option types. */
20 define('SMOPT_TYPE_STRING', 0);
21 define('SMOPT_TYPE_STRLIST', 1);
22 define('SMOPT_TYPE_TEXTAREA', 2);
23 define('SMOPT_TYPE_INTEGER', 3);
24 define('SMOPT_TYPE_FLOAT', 4);
25 define('SMOPT_TYPE_BOOLEAN', 5);
26 define('SMOPT_TYPE_HIDDEN', 6);
27 define('SMOPT_TYPE_COMMENT', 7);
28 define('SMOPT_TYPE_FLDRLIST', 8);
29 define('SMOPT_TYPE_FLDRLIST_MULTI', 9);
30 define('SMOPT_TYPE_EDIT_LIST', 10);
31 define('SMOPT_TYPE_STRLIST_MULTI', 11);
32
33 /* Define constants for the options refresh levels. */
34 define('SMOPT_REFRESH_NONE', 0);
35 define('SMOPT_REFRESH_FOLDERLIST', 1);
36 define('SMOPT_REFRESH_ALL', 2);
37
38 /* Define constants for the options size. */
39 define('SMOPT_SIZE_TINY', 0);
40 define('SMOPT_SIZE_SMALL', 1);
41 define('SMOPT_SIZE_MEDIUM', 2);
42 define('SMOPT_SIZE_LARGE', 3);
43 define('SMOPT_SIZE_HUGE', 4);
44 define('SMOPT_SIZE_NORMAL', 5);
45
46 define('SMOPT_SAVE_DEFAULT', 'save_option');
47 define('SMOPT_SAVE_NOOP', 'save_option_noop');
48
49 /**
50 * SquirrelOption: An option for SquirrelMail.
51 *
52 * @package squirrelmail
53 * @subpackage prefs
54 */
55 class SquirrelOption {
56 /**
57 * The name of this setting
58 * @var string
59 */
60 var $name;
61 /**
62 * The text that prefaces setting on the preferences page
63 * @var string
64 */
65 var $caption;
66 /**
67 * The type of INPUT element
68 *
69 * See SMOPT_TYPE_* defines
70 * @var integer
71 */
72 var $type;
73 /**
74 * Indicates if a link should be shown to refresh part
75 * or all of the window
76 *
77 * See SMOPT_REFRESH_* defines
78 * @var integer
79 */
80 var $refresh_level;
81 /**
82 * Specifies the size of certain input items
83 *
84 * See SMOPT_SIZE_* defines
85 * @var integer
86 */
87 var $size;
88 /**
89 * Text that follows a text input or
90 * select list input on the preferences page
91 *
92 * useful for indicating units, meanings of special values, etc.
93 * @var string
94 */
95 var $trailing_text;
96 /**
97 * text displayed to the user
98 *
99 * Used with SMOPT_TYPE_COMMENT options
100 * @var string
101 */
102 var $comment;
103 /**
104 * additional javascript or other widget attributes added to the
105 * user input; must be an array where keys are attribute names
106 * ("onclick", etc) and values are the attribute values.
107 * @var array
108 */
109 var $aExtraAttribs;
110 /**
111 * script (usually Javascript) that will be placed after (outside of)
112 * the INPUT tag
113 * @var string
114 */
115 var $post_script;
116
117 /**
118 * The name of the Save Function for this option.
119 * @var string
120 */
121 var $save_function;
122
123 /* The various 'values' for this options. */
124 /**
125 * default/preselected value for this option
126 * @var mixed
127 */
128 var $value;
129 /**
130 * new option value
131 * @var mixed
132 */
133 var $new_value;
134 /**
135 * associative array, where each key is an actual input value
136 * and the corresponding value is what is displayed to the user
137 * for that list item in the drop-down list
138 * @var array
139 */
140 var $possible_values;
141 /**
142 * disables html sanitizing.
143 *
144 * WARNING - don't use it, if user input is possible in option
145 * or use own sanitizing functions. Currently only works for SMOPT_TYPE_STRLIST.
146 * @var bool
147 */
148 var $htmlencoded=false;
149 /**
150 * Controls folder list limits in SMOPT_TYPE_FLDRLIST and
151 * SMOPT_TYPE_FLDRLIST_MULTI widgets.
152 * See $flag argument in sqimap_mailbox_option_list() function.
153 * @var string
154 * @since 1.5.1
155 */
156 var $folder_filter='noselect';
157
158 /**
159 * Constructor function
160 * @param string $name
161 * @param string $caption
162 * @param integer $type
163 * @param integer $refresh_level
164 * @param mixed $initial_value
165 * @param array $possible_values
166 * @param bool $htmlencoded
167 */
168 function SquirrelOption
169 ($name, $caption, $type, $refresh_level, $initial_value = '', $possible_values = '', $htmlencoded = false) {
170 /* Set the basic stuff. */
171 $this->name = $name;
172 $this->caption = $caption;
173 $this->type = $type;
174 $this->refresh_level = $refresh_level;
175 $this->possible_values = $possible_values;
176 $this->htmlencoded = $htmlencoded;
177 $this->size = SMOPT_SIZE_MEDIUM;
178 $this->trailing_text = '';
179 $this->comment = '';
180 $this->aExtraAttribs = array();
181 $this->post_script = '';
182
183 //Check for a current value.
184 if (isset($GLOBALS[$name])) {
185 $this->value = $GLOBALS[$name];
186 } else if (!empty($initial_value)) {
187 $this->value = $initial_value;
188 } else {
189 $this->value = '';
190 }
191
192 /* Check for a new value. */
193 if ( !sqgetGlobalVar("new_$name", $this->new_value, SQ_POST ) ) {
194 $this->new_value = '';
195 }
196
197 /* Set the default save function. */
198 if (($type != SMOPT_TYPE_HIDDEN) && ($type != SMOPT_TYPE_COMMENT)) {
199 $this->save_function = SMOPT_SAVE_DEFAULT;
200 } else {
201 $this->save_function = SMOPT_SAVE_NOOP;
202 }
203 }
204
205 /** Convenience function that identifies which types of
206 widgets are stored as (serialized) array values. */
207 function is_multiple_valued() {
208 return ($this->type == SMOPT_TYPE_FLDRLIST_MULTI
209 || $this->type == SMOPT_TYPE_STRLIST_MULTI
210 || $this->type == SMOPT_TYPE_EDIT_LIST);
211 }
212
213 /**
214 * Set the value for this option.
215 * @param mixed $value
216 */
217 function setValue($value) {
218 $this->value = $value;
219 }
220
221 /**
222 * Set the new value for this option.
223 * @param mixed $new_value
224 */
225 function setNewValue($new_value) {
226 $this->new_value = $new_value;
227 }
228
229 /**
230 * Set the size for this option.
231 * @param integer $size
232 */
233 function setSize($size) {
234 $this->size = $size;
235 }
236
237 /**
238 * Set the trailing_text for this option.
239 * @param string $trailing_text
240 */
241 function setTrailingText($trailing_text) {
242 $this->trailing_text = $trailing_text;
243 }
244
245 /**
246 * Set the comment for this option.
247 * @param string $comment
248 */
249 function setComment($comment) {
250 $this->comment = $comment;
251 }
252
253 /**
254 * Set the extra attributes for this option.
255 * @param array $aExtraAttribs
256 */
257 function setExtraAttributes($aExtraAttribs) {
258 $this->aExtraAttribs = $aExtraAttribs;
259 }
260
261 /**
262 * Set the "post script" for this option.
263 * @param string $post_script
264 */
265 function setPostScript($post_script) {
266 $this->post_script = $post_script;
267 }
268
269 /**
270 * Set the save function for this option.
271 * @param string $save_function
272 */
273 function setSaveFunction($save_function) {
274 $this->save_function = $save_function;
275 }
276
277 /**
278 * Set the trailing_text for this option.
279 * @param string $folder_filter
280 * @since 1.5.1
281 */
282 function setFolderFilter($folder_filter) {
283 $this->folder_filter = $folder_filter;
284 }
285
286 /**
287 * Creates fields on option pages according to option type
288 *
289 * This is the function that calls all other createWidget* functions.
290 *
291 * @return string The formated option field
292 *
293 */
294 function createWidget() {
295 global $color;
296
297 // Use new value if available
298 if (!empty($this->new_value)) {
299 $tempValue = $this->value;
300 $this->value = $this->new_value;
301 }
302
303 /* Get the widget for this option type. */
304 switch ($this->type) {
305 case SMOPT_TYPE_STRING:
306 $result = $this->createWidget_String();
307 break;
308 case SMOPT_TYPE_STRLIST:
309 $result = $this->createWidget_StrList();
310 break;
311 case SMOPT_TYPE_TEXTAREA:
312 $result = $this->createWidget_TextArea();
313 break;
314 case SMOPT_TYPE_INTEGER:
315 $result = $this->createWidget_Integer();
316 break;
317 case SMOPT_TYPE_FLOAT:
318 $result = $this->createWidget_Float();
319 break;
320 case SMOPT_TYPE_BOOLEAN:
321 $result = $this->createWidget_Boolean();
322 break;
323 case SMOPT_TYPE_HIDDEN:
324 $result = $this->createWidget_Hidden();
325 break;
326 case SMOPT_TYPE_COMMENT:
327 $result = $this->createWidget_Comment();
328 break;
329 case SMOPT_TYPE_FLDRLIST:
330 $result = $this->createWidget_FolderList();
331 break;
332 case SMOPT_TYPE_FLDRLIST_MULTI:
333 $result = $this->createWidget_FolderList(TRUE);
334 break;
335 case SMOPT_TYPE_EDIT_LIST:
336 $result = $this->createWidget_EditList();
337 break;
338 case SMOPT_TYPE_STRLIST_MULTI:
339 $result = $this->createWidget_StrList(TRUE);
340 break;
341 default:
342 error_box (
343 sprintf(_("Option Type '%s' Not Found"), $this->type)
344 );
345 }
346
347 /* Add the "post script" for this option. */
348 $result .= $this->post_script;
349
350 // put correct value back if need be
351 if (!empty($this->new_value)) {
352 $this->value = $tempValue;
353 }
354
355 /* Now, return the created widget. */
356 return $result;
357 }
358
359 /**
360 * Create string field
361 * @return string html formated option field
362 */
363 function createWidget_String() {
364 switch ($this->size) {
365 case SMOPT_SIZE_TINY:
366 $width = 5;
367 break;
368 case SMOPT_SIZE_SMALL:
369 $width = 12;
370 break;
371 case SMOPT_SIZE_LARGE:
372 $width = 38;
373 break;
374 case SMOPT_SIZE_HUGE:
375 $width = 50;
376 break;
377 case SMOPT_SIZE_NORMAL:
378 default:
379 $width = 25;
380 }
381
382 return addInput('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . htmlspecialchars($this->trailing_text);
383 }
384
385 /**
386 * Create selection box
387 *
388 * When $this->htmlencoded is TRUE, the keys and values in
389 * $this->possible_values are assumed to be display-safe.
390 * Use with care!
391 *
392 * @param boolean $multiple_select When TRUE, the select widget
393 * will allow multiple selections
394 * (OPTIONAL; default is FALSE
395 * (single select list))
396 *
397 * @return string html formated selection box
398 *
399 */
400 function createWidget_StrList($multiple_select=FALSE) {
401 //FIXME: Currently, $this->htmlencoded is ignored here -- was removed when changing to template-based output; a fix is available as part of proposed centralized sanitizing patch
402
403 switch ($this->size) {
404 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
405 case SMOPT_SIZE_TINY:
406 $height = 3;
407 break;
408 case SMOPT_SIZE_SMALL:
409 $height = 8;
410 break;
411 case SMOPT_SIZE_LARGE:
412 $height = 15;
413 break;
414 case SMOPT_SIZE_HUGE:
415 $height = 25;
416 break;
417 case SMOPT_SIZE_NORMAL:
418 default:
419 $height = 5;
420 }
421
422 return addSelect('new_' . $this->name, $this->possible_values, $this->value, TRUE, $this->aExtraAttribs, $multiple_select, $height, !$this->htmlencoded) . htmlspecialchars($this->trailing_text);
423
424 }
425
426 /**
427 * Create folder selection box
428 *
429 * @param boolean $multiple_select When TRUE, the select widget
430 * will allow multiple selections
431 * (OPTIONAL; default is FALSE
432 * (single select list))
433 *
434 * @return string html formated selection box
435 *
436 */
437 function createWidget_FolderList($multiple_select=FALSE) {
438
439 switch ($this->size) {
440 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
441 case SMOPT_SIZE_TINY:
442 $height = 3;
443 break;
444 case SMOPT_SIZE_SMALL:
445 $height = 8;
446 break;
447 case SMOPT_SIZE_LARGE:
448 $height = 15;
449 break;
450 case SMOPT_SIZE_HUGE:
451 $height = 25;
452 break;
453 case SMOPT_SIZE_NORMAL:
454 default:
455 $height = 5;
456 }
457
458 // possible values might include a nested array of
459 // possible values (list of folders)
460 //
461 $option_list = array();
462 foreach ($this->possible_values as $value => $text) {
463
464 // list of folders (boxes array)
465 //
466 if (is_array($text)) {
467 $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter));
468
469 // just one option here
470 //
471 } else {
472 $option_list = array_merge($option_list, array($value => $text));
473 }
474
475 }
476 if (empty($option_list))
477 $option_list = array('ignore' => _("unavailable"));
478
479
480 return addSelect('new_' . $this->name, $option_list, $this->value, TRUE, $this->aExtraAttribs, $multiple_select, $height) . htmlspecialchars($this->trailing_text);
481
482 }
483
484 /**
485 * Creates textarea
486 * @return string html formated textarea field
487 */
488 function createWidget_TextArea() {
489 switch ($this->size) {
490 case SMOPT_SIZE_TINY: $rows = 3; $cols = 10; break;
491 case SMOPT_SIZE_SMALL: $rows = 4; $cols = 30; break;
492 case SMOPT_SIZE_LARGE: $rows = 10; $cols = 60; break;
493 case SMOPT_SIZE_HUGE: $rows = 20; $cols = 80; break;
494 case SMOPT_SIZE_NORMAL:
495 default: $rows = 5; $cols = 50;
496 }
497 return addTextArea('new_' . $this->name, $this->value, $cols, $rows, $this->aExtraAttribs);
498 }
499
500 /**
501 * Creates field for integer
502 *
503 * Difference from createWidget_String is visible only when javascript is enabled
504 * @return string html formated option field
505 */
506 function createWidget_Integer() {
507
508 // add onChange javascript handler to a regular string widget
509 // which will strip out all non-numeric chars
510 if (checkForJavascript())
511 $this->aExtraAttribs['onchange'] = 'origVal=this.value; newVal=\'\'; '
512 . 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
513 . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
514 . 'this.value=newVal;';
515
516 return $this->createWidget_String();
517 }
518
519 /**
520 * Creates field for floating number
521 * Difference from createWidget_String is visible only when javascript is enabled
522 * @return string html formated option field
523 */
524 function createWidget_Float() {
525
526 // add onChange javascript handler to a regular string widget
527 // which will strip out all non-numeric (period also OK) chars
528 if (checkForJavascript())
529 $this->aExtraAttribs['onchange'] = 'origVal=this.value; newVal=\'\'; '
530 . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
531 . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
532 . 'newVal += origVal.charAt(i); } this.value=newVal;';
533
534 return $this->createWidget_String();
535 }
536
537 /**
538 * Creates radio field (yes/no)
539 * @return string html formated radio field
540 */
541 function createWidget_Boolean() {
542
543 global $oTemplate, $nbsp;
544
545 /* Build the yes choice. */
546 $yes_option = addRadioBox('new_' . $this->name, ($this->value != SMPREF_NO), SMPREF_YES, array_merge(array('id' => 'new_' . $this->name . '_yes'), $this->aExtraAttribs)) . $nbsp . create_label(_("Yes"), 'new_' . $this->name . '_yes');
547
548 /* Build the no choice. */
549 $no_option = addRadioBox('new_' . $this->name, ($this->value == SMPREF_NO), SMPREF_NO, array_merge(array('id' => 'new_' . $this->name . '_no'), $this->aExtraAttribs)) . $nbsp . create_label(_("No"), 'new_' . $this->name . '_no');
550
551 /* Build and return the combined "boolean widget". */
552 $result = "$yes_option$nbsp$nbsp$nbsp$nbsp$no_option";
553 return ($result);
554 }
555
556 /**
557 * Creates hidden field
558 * @return string html formated hidden input field
559 */
560 function createWidget_Hidden() {
561 return addHidden('new_' . $this->name, $this->value, $this->aExtraAttribs);
562 }
563
564 /**
565 * Creates comment
566 * @return string comment
567 */
568 function createWidget_Comment() {
569 $result = $this->comment;
570 return ($result);
571 }
572
573 /**
574 * Creates an edit list
575 * @return string html formated list of edit fields and
576 * their associated controls
577 */
578 function createWidget_EditList() {
579
580 global $oTemplate;
581
582 switch ($this->size) {
583 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
584 case SMOPT_SIZE_TINY:
585 $height = 3;
586 break;
587 case SMOPT_SIZE_SMALL:
588 $height = 8;
589 break;
590 case SMOPT_SIZE_LARGE:
591 $height = 15;
592 break;
593 case SMOPT_SIZE_HUGE:
594 $height = 25;
595 break;
596 case SMOPT_SIZE_NORMAL:
597 default:
598 $height = 5;
599 }
600
601 if (empty($this->possible_values)) $this->possible_values = array();
602 if (!is_array($this->possible_values)) $this->possible_values = array($this->possible_values);
603
604 //FIXME: $this->aExtraAttribs probably should only be used in one place
605 $oTemplate->assign('input_widget', addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs));
606 $oTemplate->assign('trailing_text', $this->trailing_text);
607 $oTemplate->assign('select_widget', addSelect('new_' . $this->name, $this->possible_values, $this->value, FALSE, !checkForJavascript() ? $this->aExtraAttribs : array_merge(array('onchange' => 'if (typeof(window.addinput) == \'undefined\') { var f = document.forms.length; var i = 0; var pos = -1; while( pos == -1 && i < f ) { var e = document.forms[i].elements.length; var j = 0; while( pos == -1 && j < e ) { if ( document.forms[i].elements[j].type == \'text\' && document.forms[i].elements[j].name == \'add_' . $this->name . '\' ) { pos = j; } j++; } i++; } if( pos >= 0 ) { window.addinput = document.forms[i-1].elements[pos]; } } for (x = 0; x < this.length; x++) { if (this.options[x].selected) { window.addinput.value = this.options[x].value; break; } }'), $this->aExtraAttribs), TRUE, $height));
608 $oTemplate->assign('checkbox_widget', addCheckBox('delete_' . $this->name, FALSE, SMPREF_YES, array_merge(array('id' => 'delete_' . $this->name), $this->aExtraAttribs)));
609 $oTemplate->assign('name', $this->name);
610 return $oTemplate->fetch('edit_list_widget.tpl');
611
612 }
613
614 /**
615 *
616 */
617 function save() {
618 $function = $this->save_function;
619 $function($this);
620 }
621
622 /**
623 *
624 */
625 function changed() {
626
627 // edit lists have a lot going on, so we'll always process them
628 //
629 if ($this->type == SMOPT_TYPE_EDIT_LIST) return TRUE;
630
631 return ($this->value != $this->new_value);
632 }
633 } /* End of SquirrelOption class*/
634
635 /**
636 * Saves the option value (this is the default save function
637 * unless overridden by the user)
638 *
639 * @param object $option object that holds option name and new_value
640 */
641 function save_option($option) {
642
643 // Can't save the pref if we don't have the username
644 //
645 if ( !sqgetGlobalVar('username', $username, SQ_SESSION ) ) {
646 return;
647 }
648
649 global $data_dir;
650
651 // edit lists: first add new elements to list, then
652 // remove any selected ones (note that we must add
653 // before deleting because the javascript that populates
654 // the "add" textbox when selecting items in the list
655 // (for deletion))
656 //
657 if ($option->type == SMOPT_TYPE_EDIT_LIST) {
658
659 if (empty($option->possible_values)) $option->possible_values = array();
660 if (!is_array($option->possible_values)) $option->possible_values = array($option->possible_values);
661
662 // add element if given
663 //
664 if (sqGetGlobalVar('add_' . $option->name, $new_element, SQ_POST)) {
665 $new_element = trim($new_element);
666 if (!empty($new_element)
667 && !in_array($new_element, $option->possible_values))
668 $option->possible_values[] = $new_element;
669 }
670
671 // delete selected elements if needed
672 //
673 if (is_array($option->new_value)
674 && sqGetGlobalVar('delete_' . $option->name, $ignore, SQ_POST))
675 $option->possible_values = array_diff($option->possible_values, $option->new_value);
676
677 // save full list (stored in "possible_values")
678 //
679 setPref($data_dir, $username, $option->name, serialize($option->possible_values));
680
681 // Certain option types need to be serialized because
682 // they are not scalar
683 //
684 } else if ($option->is_multiple_valued())
685 setPref($data_dir, $username, $option->name, serialize($option->new_value));
686
687 else
688 setPref($data_dir, $username, $option->name, $option->new_value);
689
690 }
691
692 /**
693 * save function that does not save
694 * @param object $option
695 */
696 function save_option_noop($option) {
697 /* Do nothing here... */
698 }
699
700 /**
701 * Create hidden 'optpage' input field with value set by argument
702 * @param string $optpage identification of option page
703 * @return string html formated hidden input field
704 */
705 function create_optpage_element($optpage) {
706 return addHidden('optpage', $optpage);
707 }
708
709 /**
710 * Create hidden 'optmode' input field with value set by argument
711 * @param string $optmode
712 * @return string html formated hidden input field
713 */
714 function create_optmode_element($optmode) {
715 return addHidden('optmode', $optmode);
716 }
717
718 /**
719 * @param array $optgrps
720 * @param array $optvals
721 * @return array
722 */
723 function create_option_groups($optgrps, $optvals) {
724 /* Build a simple array with which to start. */
725 $result = array();
726
727 /* Create option group for each option group name. */
728 foreach ($optgrps as $grpkey => $grpname) {
729 $result[$grpkey] = array();
730 $result[$grpkey]['name'] = $grpname;
731 $result[$grpkey]['options'] = array();
732 }
733
734 /* Create a new SquirrelOption for each set of option values. */
735 foreach ($optvals as $grpkey => $grpopts) {
736 foreach ($grpopts as $optset) {
737 /* Create a new option with all values given. */
738 $next_option = new SquirrelOption(
739 $optset['name'],
740 $optset['caption'],
741 $optset['type'],
742 (isset($optset['refresh']) ? $optset['refresh'] : SMOPT_REFRESH_NONE),
743 (isset($optset['initial_value']) ? $optset['initial_value'] : ''),
744 (isset($optset['posvals']) ? $optset['posvals'] : ''),
745 (isset($optset['htmlencoded']) ? $optset['htmlencoded'] : false)
746 );
747
748 /* If provided, set the size for this option. */
749 if (isset($optset['size'])) {
750 $next_option->setSize($optset['size']);
751 }
752
753 /* If provided, set the trailing_text for this option. */
754 if (isset($optset['trailing_text'])) {
755 $next_option->setTrailingText($optset['trailing_text']);
756 }
757
758 /* If provided, set the comment for this option. */
759 if (isset($optset['comment'])) {
760 $next_option->setComment($optset['comment']);
761 }
762
763 /* If provided, set the save function for this option. */
764 if (isset($optset['save'])) {
765 $next_option->setSaveFunction($optset['save']);
766 }
767
768 /* If provided, set the extra attributes for this option. */
769 if (isset($optset['extra_attributes'])) {
770 $next_option->setExtraAttributes($optset['extra_attributes']);
771 }
772
773 /* If provided, set the "post script" for this option. */
774 if (isset($optset['post_script'])) {
775 $next_option->setPostScript($optset['post_script']);
776 }
777
778 /* If provided, set the folder_filter for this option. */
779 if (isset($optset['folder_filter'])) {
780 $next_option->setFolderFilter($optset['folder_filter']);
781 }
782
783 /* Add this option to the option array. */
784 $result[$grpkey]['options'][] = $next_option;
785 }
786 }
787
788 /* Return our resulting array. */
789 return ($result);
790 }
791