291d11d8f1f05f6b70dc724282aba2af49a7b141
6 * Displays the options page. Pulls from proper user preference files
7 * and config.php. Displays preferences as selected and other options.
9 * @copyright © 1999-2006 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @package squirrelmail
17 * Include the SquirrelMail initialization file.
19 require('../include/init.php');
21 /* SquirrelMail required files. */
23 //include(SM_PATH . 'functions/imap_general.php');
24 require_once(SM_PATH
. 'functions/options.php');
25 require_once(SM_PATH
. 'functions/forms.php');
27 /*********************************/
28 /*** Build the resultant page. ***/
29 /*********************************/
31 define('SMOPT_MODE_DISPLAY', 'display');
32 define('SMOPT_MODE_SUBMIT', 'submit');
33 define('SMOPT_MODE_LINK', 'link');
35 define('SMOPT_PAGE_MAIN', 'main');
36 define('SMOPT_PAGE_PERSONAL', 'personal');
37 define('SMOPT_PAGE_DISPLAY', 'display');
38 define('SMOPT_PAGE_COMPOSE', 'compose');
39 define('SMOPT_PAGE_HIGHLIGHT', 'highlight');
40 define('SMOPT_PAGE_FOLDER', 'folder');
41 define('SMOPT_PAGE_ORDER', 'order');
43 function process_optionmode_submit($optpage, $optpage_data) {
44 /* Initialize the maximum option refresh level. */
45 $max_refresh = SMOPT_REFRESH_NONE
;
47 /* Save each option in each option group. */
48 foreach ($optpage_data['options'] as $option_grp) {
49 foreach ($option_grp['options'] as $option) {
50 /* Remove Debug Mode Until Needed
51 echo "name = '$option->name', "
52 . "value = '$option->value', "
53 . "new_value = '$option->new_value'\n";
56 if ($option->changed()) {
58 $max_refresh = max($max_refresh, $option->refresh_level
);
63 /* Return the max refresh level. */
64 return ($max_refresh);
67 function process_optionmode_link($optpage) {
68 /* There will be something here, later. */
73 /* ---------------------------- main ---------------------------- */
75 /* get the globals that we may need */
76 sqgetGlobalVar('key', $key, SQ_COOKIE
);
77 sqgetGlobalVar('username', $username, SQ_SESSION
);
78 sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION
);
79 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
81 sqgetGlobalVar('optpage', $optpage);
82 sqgetGlobalVar('optmode', $optmode, SQ_FORM
);
83 sqgetGlobalVar('optpage_data',$optpage_data, SQ_POST
);
84 /* end of getting globals */
86 /* Make sure we have an Option Page set. Default to main. */
87 if ( !isset($optpage) ||
$optpage == '' ) {
88 $optpage = SMOPT_PAGE_MAIN
;
90 $optpage = strip_tags( $optpage );
93 /* Make sure we have an Option Mode set. Default to display. */
94 if (!isset($optmode)) {
95 $optmode = SMOPT_MODE_DISPLAY
;
99 * First, set the load information for each option page.
102 /* Initialize load information variables. */
105 $optpage_loader = '';
107 /* Set the load information for each page. */
109 case SMOPT_PAGE_MAIN
:
111 case SMOPT_PAGE_PERSONAL
:
112 $optpage_name = _("Personal Information");
113 $optpage_file = SM_PATH
. 'include/options/personal.php';
114 $optpage_loader = 'load_optpage_data_personal';
115 $optpage_loadhook = 'optpage_loadhook_personal';
117 case SMOPT_PAGE_DISPLAY
:
118 $optpage_name = _("Display Preferences");
119 $optpage_file = SM_PATH
. 'include/options/display.php';
120 $optpage_loader = 'load_optpage_data_display';
121 $optpage_loadhook = 'optpage_loadhook_display';
123 case SMOPT_PAGE_COMPOSE
:
124 $optpage_name = _("Compose Preferences");
125 $optpage_file = SM_PATH
. 'include/options/compose.php';
126 $optpage_loader = 'load_optpage_data_compose';
127 $optpage_loadhook = 'optpage_loadhook_compose';
129 case SMOPT_PAGE_HIGHLIGHT
:
130 $optpage_name = _("Message Highlighting");
131 $optpage_file = SM_PATH
. 'include/options/highlight.php';
132 $optpage_loader = 'load_optpage_data_highlight';
133 $optpage_loadhook = 'optpage_loadhook_highlight';
135 case SMOPT_PAGE_FOLDER
:
136 $optpage_name = _("Folder Preferences");
137 $optpage_file = SM_PATH
. 'include/options/folder.php';
138 $optpage_loader = 'load_optpage_data_folder';
139 $optpage_loadhook = 'optpage_loadhook_folder';
141 case SMOPT_PAGE_ORDER
:
142 $optpage_name = _("Index Order");
143 $optpage_file = SM_PATH
. 'include/options/order.php';
144 $optpage_loader = 'load_optpage_data_order';
145 $optpage_loadhook = 'optpage_loadhook_order';
147 default: do_hook('optpage_set_loadinfo');
150 /**********************************************************/
151 /*** Second, load the option information for this page. ***/
152 /**********************************************************/
154 if ( !@is_file
( $optpage_file ) ) {
155 $optpage = SMOPT_PAGE_MAIN
;
156 } else if ($optpage != SMOPT_PAGE_MAIN
) {
157 /* Include the file for this optionpage. */
159 require_once($optpage_file);
161 /* Assemble the data for this option page. */
162 $optpage_data = array();
163 $optpage_data = $optpage_loader();
164 do_hook($optpage_loadhook);
165 $optpage_data['options'] =
166 create_option_groups($optpage_data['grps'], $optpage_data['vals']);
169 /***********************************************************/
170 /*** Next, process anything that needs to be processed. ***/
171 /***********************************************************/
173 $optpage_save_error=array();
175 if ( isset( $optpage_data ) ) {
177 case SMOPT_MODE_SUBMIT
:
178 $max_refresh = process_optionmode_submit($optpage, $optpage_data);
180 case SMOPT_MODE_LINK
:
181 $max_refresh = process_optionmode_link($optpage, $optpage_data);
186 /*******************************************************************/
187 /* DO OLD SAVING OF SUBMITTED OPTIONS. THIS WILL BE REMOVED LATER. */
188 /*******************************************************************/
190 /* If in submit mode, select a save hook name and run it. */
191 if ($optmode == SMOPT_MODE_SUBMIT
) {
192 /* Select a save hook name. */
194 case SMOPT_PAGE_PERSONAL
:
195 $save_hook_name = 'options_personal_save';
197 case SMOPT_PAGE_DISPLAY
:
198 $save_hook_name = 'options_display_save';
200 case SMOPT_PAGE_COMPOSE
:
201 $save_hook_name = 'options_compose_save';
203 case SMOPT_PAGE_FOLDER
:
204 $save_hook_name = 'options_folder_save';
207 $save_hook_name = 'options_save';
211 /* Run the options save hook. */
212 do_hook($save_hook_name);
215 /***************************************************************/
216 /* Apply logic to decide what optpage we want to display next. */
217 /***************************************************************/
219 /* If this is the result of an option page being submitted, then */
220 /* show the main page. Otherwise, show whatever page was called. */
222 if ($optmode == SMOPT_MODE_SUBMIT
) {
223 $optpage = SMOPT_PAGE_MAIN
;
227 if (isset($max_refresh)) $oTemplate->assign('max_refresh',$max_refresh);
228 $oTemplate->assign('color',$color);
229 $oTemplate->assign('optpage',$optpage);
230 $oTemplate->assign('optpage_name',$optpage_name);
231 $oTemplate->assign('optpage_data',$optpage_data);
232 $oTemplate->assign('optmode',$optmode);
235 $oTemplate->display('options.tpl');
236 $oTemplate->display('footer.tpl');