872b398fd515a882404dade901249bf3ee6b15d2
[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 /**
206 * Set the value for this option.
207 * @param mixed $value
208 */
209 function setValue($value) {
210 $this->value = $value;
211 }
212
213 /**
214 * Set the new value for this option.
215 * @param mixed $new_value
216 */
217 function setNewValue($new_value) {
218 $this->new_value = $new_value;
219 }
220
221 /**
222 * Set the size for this option.
223 * @param integer $size
224 */
225 function setSize($size) {
226 $this->size = $size;
227 }
228
229 /**
230 * Set the trailing_text for this option.
231 * @param string $trailing_text
232 */
233 function setTrailingText($trailing_text) {
234 $this->trailing_text = $trailing_text;
235 }
236
237 /**
238 * Set the comment for this option.
239 * @param string $comment
240 */
241 function setComment($comment) {
242 $this->comment = $comment;
243 }
244
245 /**
246 * Set the extra attributes for this option.
247 * @param array $aExtraAttribs
248 */
249 function setExtraAttributes($aExtraAttribs) {
250 $this->aExtraAttribs = $aExtraAttribs;
251 }
252
253 /**
254 * Set the "post script" for this option.
255 * @param string $post_script
256 */
257 function setPostScript($post_script) {
258 $this->post_script = $post_script;
259 }
260
261 /**
262 * Set the save function for this option.
263 * @param string $save_function
264 */
265 function setSaveFunction($save_function) {
266 $this->save_function = $save_function;
267 }
268
269 /**
270 * Set the trailing_text for this option.
271 * @param string $folder_filter
272 * @since 1.5.1
273 */
274 function setFolderFilter($folder_filter) {
275 $this->folder_filter = $folder_filter;
276 }
277
278 /**
279 * Creates fields on option pages according to option type
280 *
281 * This is the function that calls all other createWidget* functions.
282 *
283 * @return string The formated option field
284 *
285 */
286 function createWidget() {
287 global $color;
288
289 // Use new value if available
290 if (!empty($this->new_value)) {
291 $tempValue = $this->value;
292 $this->value = $this->new_value;
293 }
294
295 /* Get the widget for this option type. */
296 switch ($this->type) {
297 case SMOPT_TYPE_STRING:
298 $result = $this->createWidget_String();
299 break;
300 case SMOPT_TYPE_STRLIST:
301 $result = $this->createWidget_StrList();
302 break;
303 case SMOPT_TYPE_TEXTAREA:
304 $result = $this->createWidget_TextArea();
305 break;
306 case SMOPT_TYPE_INTEGER:
307 $result = $this->createWidget_Integer();
308 break;
309 case SMOPT_TYPE_FLOAT:
310 $result = $this->createWidget_Float();
311 break;
312 case SMOPT_TYPE_BOOLEAN:
313 $result = $this->createWidget_Boolean();
314 break;
315 case SMOPT_TYPE_HIDDEN:
316 $result = $this->createWidget_Hidden();
317 break;
318 case SMOPT_TYPE_COMMENT:
319 $result = $this->createWidget_Comment();
320 break;
321 case SMOPT_TYPE_FLDRLIST:
322 $result = $this->createWidget_FolderList();
323 break;
324 case SMOPT_TYPE_FLDRLIST_MULTI:
325 $result = $this->createWidget_FolderList(TRUE);
326 break;
327 case SMOPT_TYPE_EDIT_LIST:
328 $result = $this->createWidget_EditList();
329 break;
330 case SMOPT_TYPE_STRLIST_MULTI:
331 $result = $this->createWidget_StrList(TRUE);
332 break;
333 default:
334 error_box (
335 sprintf(_("Option Type '%s' Not Found"), $this->type)
336 );
337 }
338
339 /* Add the "post script" for this option. */
340 $result .= $this->post_script;
341
342 // put correct value back if need be
343 if (!empty($this->new_value)) {
344 $this->value = $tempValue;
345 }
346
347 /* Now, return the created widget. */
348 return $result;
349 }
350
351 /**
352 * Create string field
353 * @return string html formated option field
354 */
355 function createWidget_String() {
356 switch ($this->size) {
357 case SMOPT_SIZE_TINY:
358 $width = 5;
359 break;
360 case SMOPT_SIZE_SMALL:
361 $width = 12;
362 break;
363 case SMOPT_SIZE_LARGE:
364 $width = 38;
365 break;
366 case SMOPT_SIZE_HUGE:
367 $width = 50;
368 break;
369 case SMOPT_SIZE_NORMAL:
370 default:
371 $width = 25;
372 }
373
374 return addInput('new_' . $this->name, $this->value, $width, 0, $this->aExtraAttribs) . htmlspecialchars($this->trailing_text);
375 }
376
377 /**
378 * Create selection box
379 *
380 * When $this->htmlencoded is TRUE, the keys and values in
381 * $this->possible_values are assumed to be display-safe.
382 * Use with care!
383 *
384 * @param boolean $multiple_select When TRUE, the select widget
385 * will allow multiple selections
386 * (OPTIONAL; default is FALSE
387 * (single select list))
388 *
389 * @return string html formated selection box
390 *
391 */
392 function createWidget_StrList($multiple_select=FALSE) {
393 //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
394
395 switch ($this->size) {
396 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
397 case SMOPT_SIZE_TINY:
398 $height = 3;
399 break;
400 case SMOPT_SIZE_SMALL:
401 $height = 8;
402 break;
403 case SMOPT_SIZE_LARGE:
404 $height = 15;
405 break;
406 case SMOPT_SIZE_HUGE:
407 $height = 25;
408 break;
409 case SMOPT_SIZE_NORMAL:
410 default:
411 $height = 5;
412 }
413
414 return addSelect('new_' . $this->name, $this->possible_values, $this->value, TRUE, $this->aExtraAttribs, $multiple_select, $height, !$this->htmlencoded) . htmlspecialchars($this->trailing_text);
415
416 }
417
418 /**
419 * Create folder selection box
420 *
421 * @param boolean $multiple_select When TRUE, the select widget
422 * will allow multiple selections
423 * (OPTIONAL; default is FALSE
424 * (single select list))
425 *
426 * @return string html formated selection box
427 *
428 */
429 function createWidget_FolderList($multiple_select=FALSE) {
430
431 switch ($this->size) {
432 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
433 case SMOPT_SIZE_TINY:
434 $height = 3;
435 break;
436 case SMOPT_SIZE_SMALL:
437 $height = 8;
438 break;
439 case SMOPT_SIZE_LARGE:
440 $height = 15;
441 break;
442 case SMOPT_SIZE_HUGE:
443 $height = 25;
444 break;
445 case SMOPT_SIZE_NORMAL:
446 default:
447 $height = 5;
448 }
449
450 // possible values might include a nested array of
451 // possible values (list of folders)
452 //
453 $option_list = array();
454 foreach ($this->possible_values as $value => $text) {
455
456 // list of folders (boxes array)
457 //
458 if (is_array($text)) {
459 $option_list = array_merge($option_list, sqimap_mailbox_option_array(0, 0, $text, $this->folder_filter));
460
461 // just one option here
462 //
463 } else {
464 $option_list = array_merge($option_list, array($value => $text));
465 }
466
467 }
468 if (empty($option_list))
469 $option_list = array('ignore' => _("unavailable"));
470
471
472 return addSelect('new_' . $this->name, $option_list, $this->value, TRUE, $this->aExtraAttribs, $multiple_select, $height) . htmlspecialchars($this->trailing_text);
473
474 }
475
476 /**
477 * Creates textarea
478 * @return string html formated textarea field
479 */
480 function createWidget_TextArea() {
481 switch ($this->size) {
482 case SMOPT_SIZE_TINY: $rows = 3; $cols = 10; break;
483 case SMOPT_SIZE_SMALL: $rows = 4; $cols = 30; break;
484 case SMOPT_SIZE_LARGE: $rows = 10; $cols = 60; break;
485 case SMOPT_SIZE_HUGE: $rows = 20; $cols = 80; break;
486 case SMOPT_SIZE_NORMAL:
487 default: $rows = 5; $cols = 50;
488 }
489 return addTextArea('new_' . $this->name, $this->value, $cols, $rows, $this->aExtraAttribs);
490 }
491
492 /**
493 * Creates field for integer
494 *
495 * Difference from createWidget_String is visible only when javascript is enabled
496 * @return string html formated option field
497 */
498 function createWidget_Integer() {
499
500 // add onChange javascript handler to a regular string widget
501 // which will strip out all non-numeric chars
502 if (checkForJavascript())
503 $this->aExtraAttribs['onchange'] = 'origVal=this.value; newVal=\'\'; '
504 . 'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
505 . '&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
506 . 'this.value=newVal;';
507
508 return $this->createWidget_String();
509 }
510
511 /**
512 * Creates field for floating number
513 * Difference from createWidget_String is visible only when javascript is enabled
514 * @return string html formated option field
515 */
516 function createWidget_Float() {
517
518 // add onChange javascript handler to a regular string widget
519 // which will strip out all non-numeric (period also OK) chars
520 if (checkForJavascript())
521 $this->aExtraAttribs['onchange'] = 'origVal=this.value; newVal=\'\'; '
522 . 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
523 . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
524 . 'newVal += origVal.charAt(i); } this.value=newVal;';
525
526 return $this->createWidget_String();
527 }
528
529 /**
530 * Creates radio field (yes/no)
531 * @return string html formated radio field
532 */
533 function createWidget_Boolean() {
534
535 global $oTemplate, $nbsp;
536
537 /* Build the yes choice. */
538 $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');
539
540 /* Build the no choice. */
541 $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');
542
543 /* Build and return the combined "boolean widget". */
544 $result = "$yes_option$nbsp$nbsp$nbsp$nbsp$no_option";
545 return ($result);
546 }
547
548 /**
549 * Creates hidden field
550 * @return string html formated hidden input field
551 */
552 function createWidget_Hidden() {
553 return addHidden('new_' . $this->name, $this->value, $this->aExtraAttribs);
554 }
555
556 /**
557 * Creates comment
558 * @return string comment
559 */
560 function createWidget_Comment() {
561 $result = $this->comment;
562 return ($result);
563 }
564
565 /**
566 * Creates an edit list
567 * @return string html formated list of edit fields and
568 * their associated controls
569 */
570 function createWidget_EditList() {
571
572 global $oTemplate;
573
574 switch ($this->size) {
575 //FIXME: not sure about these sizes... seems like we could add another on the "large" side...
576 case SMOPT_SIZE_TINY:
577 $height = 3;
578 break;
579 case SMOPT_SIZE_SMALL:
580 $height = 8;
581 break;
582 case SMOPT_SIZE_LARGE:
583 $height = 15;
584 break;
585 case SMOPT_SIZE_HUGE:
586 $height = 25;
587 break;
588 case SMOPT_SIZE_NORMAL:
589 default:
590 $height = 5;
591 }
592
593 if (empty($this->possible_values)) $this->possible_values = array();
594
595 //FIXME: $this->aExtraAttribs probably should only be used in one place
596 $oTemplate->assign('input_widget', addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs));
597 $oTemplate->assign('trailing_text', $this->trailing_text);
598 $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));
599 $oTemplate->assign('checkbox_widget', addCheckBox('delete_' . $this->name, FALSE, SMPREF_YES, array_merge(array('id' => 'delete_' . $this->name), $this->aExtraAttribs)));
600 $oTemplate->assign('name', $this->name);
601 return $oTemplate->fetch('edit_list_widget.tpl');
602
603 }
604
605 /**
606 *
607 */
608 function save() {
609 $function = $this->save_function;
610 $function($this);
611 }
612
613 /**
614 *
615 */
616 function changed() {
617
618 // edit lists have a lot going on, so we'll always process them
619 //
620 if ($this->type == SMOPT_TYPE_EDIT_LIST) return TRUE;
621
622 return ($this->value != $this->new_value);
623 }
624 } /* End of SquirrelOption class*/
625
626 /**
627 * Saves the option value (this is the default save function
628 * unless overridden by the user)
629 *
630 * @param object $option object that holds option name and new_value
631 */
632 function save_option($option) {
633
634 // Can't save the pref if we don't have the username
635 //
636 if ( !sqgetGlobalVar('username', $username, SQ_SESSION ) ) {
637 return;
638 }
639
640 global $data_dir;
641
642 // edit lists: first add new elements to list, then
643 // remove any selected ones (note that we must add
644 // before deleting because the javascript that populates
645 // the "add" textbox when selecting items in the list
646 // (for deletion))
647 //
648 if ($option->type == SMOPT_TYPE_EDIT_LIST) {
649
650 if (empty($option->possible_values)) $option->possible_values = array();
651
652 // add element if given
653 //
654 if (sqGetGlobalVar('add_' . $option->name, $new_element, SQ_POST)) {
655 $new_element = trim($new_element);
656 if (!empty($new_element)
657 && !in_array($new_element, $option->possible_values))
658 $option->possible_values[] = $new_element;
659 }
660
661 // delete selected elements if needed
662 //
663 if (is_array($option->new_value)
664 && sqGetGlobalVar('delete_' . $option->name, $ignore, SQ_POST))
665 $option->possible_values = array_diff($option->possible_values, $option->new_value);
666
667 // save full list (stored in "possible_values")
668 //
669 setPref($data_dir, $username, $option->name, serialize($option->possible_values));
670
671 // Certain option types need to be serialized because
672 // they are not scalar
673 //
674 } else if ($option->type == SMOPT_TYPE_FLDRLIST_MULTI
675 || $option->type == SMOPT_TYPE_STRLIST_MULTI)
676 setPref($data_dir, $username, $option->name, serialize($option->new_value));
677
678 else
679 setPref($data_dir, $username, $option->name, $option->new_value);
680
681 }
682
683 /**
684 * save function that does not save
685 * @param object $option
686 */
687 function save_option_noop($option) {
688 /* Do nothing here... */
689 }
690
691 /**
692 * Create hidden 'optpage' input field with value set by argument
693 * @param string $optpage identification of option page
694 * @return string html formated hidden input field
695 */
696 function create_optpage_element($optpage) {
697 return addHidden('optpage', $optpage);
698 }
699
700 /**
701 * Create hidden 'optmode' input field with value set by argument
702 * @param string $optmode
703 * @return string html formated hidden input field
704 */
705 function create_optmode_element($optmode) {
706 return addHidden('optmode', $optmode);
707 }
708
709 /**
710 * @param array $optgrps
711 * @param array $optvals
712 * @return array
713 */
714 function create_option_groups($optgrps, $optvals) {
715 /* Build a simple array with which to start. */
716 $result = array();
717
718 /* Create option group for each option group name. */
719 foreach ($optgrps as $grpkey => $grpname) {
720 $result[$grpkey] = array();
721 $result[$grpkey]['name'] = $grpname;
722 $result[$grpkey]['options'] = array();
723 }
724
725 /* Create a new SquirrelOption for each set of option values. */
726 foreach ($optvals as $grpkey => $grpopts) {
727 foreach ($grpopts as $optset) {
728 /* Create a new option with all values given. */
729 $next_option = new SquirrelOption(
730 $optset['name'],
731 $optset['caption'],
732 $optset['type'],
733 (isset($optset['refresh']) ? $optset['refresh'] : SMOPT_REFRESH_NONE),
734 (isset($optset['initial_value']) ? $optset['initial_value'] : ''),
735 (isset($optset['posvals']) ? $optset['posvals'] : ''),
736 (isset($optset['htmlencoded']) ? $optset['htmlencoded'] : false)
737 );
738
739 /* If provided, set the size for this option. */
740 if (isset($optset['size'])) {
741 $next_option->setSize($optset['size']);
742 }
743
744 /* If provided, set the trailing_text for this option. */
745 if (isset($optset['trailing_text'])) {
746 $next_option->setTrailingText($optset['trailing_text']);
747 }
748
749 /* If provided, set the comment for this option. */
750 if (isset($optset['comment'])) {
751 $next_option->setComment($optset['comment']);
752 }
753
754 /* If provided, set the save function for this option. */
755 if (isset($optset['save'])) {
756 $next_option->setSaveFunction($optset['save']);
757 }
758
759 /* If provided, set the extra attributes for this option. */
760 if (isset($optset['extra_attributes'])) {
761 $next_option->setExtraAttributes($optset['extra_attributes']);
762 }
763
764 /* If provided, set the "post script" for this option. */
765 if (isset($optset['post_script'])) {
766 $next_option->setPostScript($optset['post_script']);
767 }
768
769 /* If provided, set the folder_filter for this option. */
770 if (isset($optset['folder_filter'])) {
771 $next_option->setFolderFilter($optset['folder_filter']);
772 }
773
774 /* Add this option to the option array. */
775 $result[$grpkey]['options'][] = $next_option;
776 }
777 }
778
779 /* Return our resulting array. */
780 return ($result);
781 }
782