Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / account_prefs_inc.php
blob984a16991c2639cb6ee0ce4761577510365157a3
1 <?php
2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
23 * @uses authentication_api.php
24 * @uses config_api.php
25 * @uses constant_inc.php
26 * @uses event_api.php
27 * @uses form_api.php
28 * @uses helper_api.php
29 * @uses html_api.php
30 * @uses lang_api.php
31 * @uses print_api.php
32 * @uses user_api.php
33 * @uses user_pref_api.php
34 * @uses utility_api.php
37 require_api( 'authentication_api.php' );
38 require_api( 'config_api.php' );
39 require_api( 'constant_inc.php' );
40 require_api( 'event_api.php' );
41 require_api( 'form_api.php' );
42 require_api( 'helper_api.php' );
43 require_api( 'html_api.php' );
44 require_api( 'lang_api.php' );
45 require_api( 'print_api.php' );
46 require_api( 'user_api.php' );
47 require_api( 'user_pref_api.php' );
48 require_api( 'utility_api.php' );
50 function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_accounts_menu = true, $p_redirect_url = '') {
51 if ( null === $p_user_id ) {
52 $p_user_id = auth_get_current_user_id();
55 $t_redirect_url = $p_redirect_url;
56 if ( is_blank( $t_redirect_url ) ) {
57 $t_redirect_url = 'account_prefs_page.php';
60 # protected account check
61 if ( user_is_protected( $p_user_id ) ) {
62 if ( $p_error_if_protected ) {
63 trigger_error( ERROR_PROTECTED_ACCOUNT, ERROR );
64 } else {
65 return;
69 # prefix data with u_
70 $t_pref = user_pref_get( $p_user_id );
72 # Account Preferences Form BEGIN
74 <br />
75 <div align="center">
76 <form method="post" action="account_prefs_update.php">
77 <?php echo form_security_field( 'account_prefs_update' ) ?>
78 <input type="hidden" name="user_id" value="<?php echo $p_user_id ?>" />
79 <input type="hidden" name="redirect_url" value="<?php echo $t_redirect_url ?>" />
80 <table class="width75" cellspacing="1">
81 <tr>
82 <td class="form-title">
83 <?php echo lang_get( 'default_account_preferences_title' ) ?>
84 </td>
85 <td class="right">
86 <?php
87 if ( $p_accounts_menu ) {
88 print_account_menu( 'account_prefs_page.php' );
91 </td>
92 </tr>
93 <tr <?php echo helper_alternate_class() ?>>
94 <td class="category" width="50%">
95 <?php echo lang_get( 'default_project' ) ?>
96 </td>
97 <td width="50%">
98 <select name="default_project">
99 <?php print_project_option_list( $t_pref->default_project ) ?>
100 </select>
101 </td>
102 </tr>
103 <tr <?php echo helper_alternate_class() ?>>
104 <td class="category">
105 <?php echo lang_get( 'refresh_delay' ) ?>
106 </td>
107 <td>
108 <input type="text" name="refresh_delay" size="4" maxlength="4" value="<?php echo $t_pref->refresh_delay ?>" /> <?php echo lang_get( 'minutes' ) ?>
109 </td>
110 </tr>
111 <tr <?php echo helper_alternate_class() ?>>
112 <td class="category">
113 <?php echo lang_get( 'redirect_delay' ) ?>
114 </td>
115 <td>
116 <input type="text" name="redirect_delay" size="4" maxlength="3" value="<?php echo $t_pref->redirect_delay ?>" /> <?php echo lang_get( 'seconds' ) ?>
117 </td>
118 </tr>
119 <tr <?php echo helper_alternate_class() ?>>
120 <td class="category">
121 <?php echo lang_get( 'bugnote_order' ) ?>
122 </td>
123 <td>
124 <label><input type="radio" name="bugnote_order" value="ASC" <?php check_checked( $t_pref->bugnote_order, 'ASC' ); ?> /><?php echo lang_get( 'bugnote_order_asc' ) ?></label>
125 <label><input type="radio" name="bugnote_order" value="DESC" <?php check_checked( $t_pref->bugnote_order, 'DESC' ); ?> /><?php echo lang_get( 'bugnote_order_desc' ) ?></label>
126 </td>
127 </tr>
128 <?php
129 if ( ON == config_get( 'enable_email_notification' ) ) {
131 <tr <?php echo helper_alternate_class() ?>>
132 <td class="category">
133 <?php echo lang_get( 'email_on_new' ) ?>
134 </td>
135 <td>
136 <input type="checkbox" name="email_on_new" <?php check_checked( $t_pref->email_on_new, ON ); ?> />
137 <?php echo lang_get( 'with_minimum_severity' ) ?>
138 <select name="email_on_new_min_severity">
139 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
140 <option disabled="disabled">-----</option>
141 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_new_min_severity ) ?>
142 </select>
143 </td>
144 </tr>
145 <tr <?php echo helper_alternate_class() ?>>
146 <td class="category">
147 <?php echo lang_get( 'email_on_assigned' ) ?>
148 </td>
149 <td>
150 <input type="checkbox" name="email_on_assigned" <?php check_checked( $t_pref->email_on_assigned, ON ); ?> />
151 <?php echo lang_get( 'with_minimum_severity' ) ?>
152 <select name="email_on_assigned_min_severity">
153 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
154 <option disabled="disabled">-----</option>
155 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_assigned_min_severity ) ?>
156 </select>
157 </td>
158 </tr>
159 <tr <?php echo helper_alternate_class() ?>>
160 <td class="category">
161 <?php echo lang_get( 'email_on_feedback' ) ?>
162 </td>
163 <td>
164 <input type="checkbox" name="email_on_feedback" <?php check_checked( $t_pref->email_on_feedback, ON ); ?> />
165 <?php echo lang_get( 'with_minimum_severity' ) ?>
166 <select name="email_on_feedback_min_severity">
167 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
168 <option disabled="disabled">-----</option>
169 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_feedback_min_severity ) ?>
170 </select>
171 </td>
172 </tr>
173 <tr <?php echo helper_alternate_class() ?>>
174 <td class="category">
175 <?php echo lang_get( 'email_on_resolved' ) ?>
176 </td>
177 <td>
178 <input type="checkbox" name="email_on_resolved" <?php check_checked( $t_pref->email_on_resolved, ON ); ?> />
179 <?php echo lang_get( 'with_minimum_severity' ) ?>
180 <select name="email_on_resolved_min_severity">
181 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
182 <option disabled="disabled">-----</option>
183 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_resolved_min_severity ) ?>
184 </select>
185 </td>
186 </tr>
187 <tr <?php echo helper_alternate_class() ?>>
188 <td class="category">
189 <?php echo lang_get( 'email_on_closed' ) ?>
190 </td>
191 <td>
192 <input type="checkbox" name="email_on_closed" <?php check_checked( $t_pref->email_on_closed, ON ); ?> />
193 <?php echo lang_get( 'with_minimum_severity' ) ?>
194 <select name="email_on_closed_min_severity">
195 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
196 <option disabled="disabled">-----</option>
197 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_closed_min_severity ) ?>
198 </select>
199 </td>
200 </tr>
201 <tr <?php echo helper_alternate_class() ?>>
202 <td class="category">
203 <?php echo lang_get( 'email_on_reopened' ) ?>
204 </td>
205 <td>
206 <input type="checkbox" name="email_on_reopened" <?php check_checked( $t_pref->email_on_reopened, ON ); ?> />
207 <?php echo lang_get( 'with_minimum_severity' ) ?>
208 <select name="email_on_reopened_min_severity">
209 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
210 <option disabled="disabled">-----</option>
211 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_reopened_min_severity ) ?>
212 </select>
213 </td>
214 </tr>
215 <tr <?php echo helper_alternate_class() ?>>
216 <td class="category">
217 <?php echo lang_get( 'email_on_bugnote_added' ) ?>
218 </td>
219 <td>
220 <input type="checkbox" name="email_on_bugnote" <?php check_checked( $t_pref->email_on_bugnote, ON ); ?> />
221 <?php echo lang_get( 'with_minimum_severity' ) ?>
222 <select name="email_on_bugnote_min_severity">
223 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
224 <option disabled="disabled">-----</option>
225 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_bugnote_min_severity ) ?>
226 </select>
227 </td>
228 </tr>
229 <tr <?php echo helper_alternate_class() ?>>
230 <td class="category">
231 <?php echo lang_get( 'email_on_status_change' ) ?>
232 </td>
233 <td>
234 <input type="checkbox" name="email_on_status" <?php check_checked( $t_pref->email_on_status, ON ); ?> />
235 <?php echo lang_get( 'with_minimum_severity' ) ?>
236 <select name="email_on_status_min_severity">
237 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
238 <option disabled="disabled">-----</option>
239 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_status_min_severity ) ?>
240 </select>
241 </td>
242 </tr>
243 <tr <?php echo helper_alternate_class() ?>>
244 <td class="category">
245 <?php echo lang_get( 'email_on_priority_change' ) ?>
246 </td>
247 <td>
248 <input type="checkbox" name="email_on_priority" <?php check_checked( $t_pref->email_on_priority , ON); ?> />
249 <?php echo lang_get( 'with_minimum_severity' ) ?>
250 <select name="email_on_priority_min_severity">
251 <option value="<?php echo OFF ?>"><?php echo lang_get( 'any' ) ?></option>
252 <option disabled="disabled">-----</option>
253 <?php print_enum_string_option_list( 'severity', $t_pref->email_on_priority_min_severity ) ?>
254 </select>
255 </td>
256 </tr>
257 <tr <?php echo helper_alternate_class() ?>>
258 <td class="category">
259 <?php echo lang_get( 'email_bugnote_limit' ) ?>
260 </td>
261 <td>
262 <input type="text" name="email_bugnote_limit" maxlength="2" size="2" value="<?php echo $t_pref->email_bugnote_limit ?>" />
263 </td>
264 </tr>
265 <?php } else { ?>
266 <input type="hidden" name="email_on_new" value="<?php echo $t_pref->email_on_new ?>" />
267 <input type="hidden" name="email_on_assigned" value="<?php echo $t_pref->email_on_assigned ?>" />
268 <input type="hidden" name="email_on_feedback" value="<?php echo $t_pref->email_on_feedback ?>" />
269 <input type="hidden" name="email_on_resolved" value="<?php echo $t_pref->email_on_resolved ?>" />
270 <input type="hidden" name="email_on_closed" value="<?php echo $t_pref->email_on_closed ?>" />
271 <input type="hidden" name="email_on_reopened" value="<?php echo $t_pref->email_on_reopened ?>" />
272 <input type="hidden" name="email_on_bugnote" value="<?php echo $t_pref->email_on_bugnote ?>" />
273 <input type="hidden" name="email_on_status" value="<?php echo $t_pref->email_on_status ?>" />
274 <input type="hidden" name="email_on_priority" value="<?php echo $t_pref->email_on_priority ?>" />
275 <input type="hidden" name="email_on_new_min_severity" value="<?php echo $t_pref->email_on_new_min_severity ?>" />
276 <input type="hidden" name="email_on_assigned_min_severity" value="<?php echo $t_pref->email_on_assigned_min_severity ?>" />
277 <input type="hidden" name="email_on_feedback_min_severity" value="<?php echo $t_pref->email_on_feedback_min_severity ?>" />
278 <input type="hidden" name="email_on_resolved_min_severity" value="<?php echo $t_pref->email_on_resolved_min_severity ?>" />
279 <input type="hidden" name="email_on_closed_min_severity" value="<?php echo $t_pref->email_on_closed_min_severity ?>" />
280 <input type="hidden" name="email_on_reopened_min_severity" value="<?php echo $t_pref->email_on_reopened_min_severity ?>" />
281 <input type="hidden" name="email_on_bugnote_min_severity" value="<?php echo $t_pref->email_on_bugnote_min_severity ?>" />
282 <input type="hidden" name="email_on_status_min_severity" value="<?php echo $t_pref->email_on_status_min_severity ?>" />
283 <input type="hidden" name="email_on_priority_min_severity" value="<?php echo $t_pref->email_on_priority_min_severity ?>" />
284 <input type="hidden" name="email_bugnote_limit" value="<?php echo $t_pref->email_bugnote_limit ?>" />
285 <?php } ?>
286 <tr <?php echo helper_alternate_class() ?>>
287 <td class="category">
288 <?php echo lang_get( 'timezone' ) ?>
289 </td>
290 <td>
291 <select name="timezone">
292 <?php print_timezone_option_list( $t_pref->timezone ? $t_pref->timezone : config_get_global( 'default_timezone' ) ) ?>
293 </select>
294 </td>
295 </tr>
296 <tr <?php echo helper_alternate_class() ?>>
297 <td class="category">
298 <?php echo lang_get( 'language' ) ?>
299 </td>
300 <td>
301 <select name="language">
302 <?php print_language_option_list( $t_pref->language ) ?>
303 </select>
304 </td>
305 </tr>
306 <?php event_signal( 'EVENT_ACCOUNT_PREF_UPDATE_FORM', array( $p_user_id ) ); ?>
307 <tr>
308 <td colspan="2" class="center">
309 <input type="submit" class="button" value="<?php echo lang_get( 'update_prefs_button' ) ?>" />
310 </td>
311 </tr>
312 </table>
313 </form>
314 </div>
316 <br />
318 <div class="border center">
319 <form method="post" action="account_prefs_reset.php">
320 <?php echo form_security_field( 'account_prefs_reset' ) ?>
321 <input type="hidden" name="user_id" value="<?php echo $p_user_id ?>" />
322 <input type="hidden" name="redirect_url" value="<?php echo $t_redirect_url ?>" />
323 <input type="submit" class="button" value="<?php echo lang_get( 'reset_prefs_button' ) ?>" />
324 </form>
325 </div>
327 <?php
328 } # end of edit_account_prefs()