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/>.
19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright (C) 2002 - 2011 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
28 * @uses helper_api.php
33 * @uses user_pref_api.php
34 * @uses utility_api.php
37 if ( !defined( 'ACCOUNT_PREFS_INC_ALLOW' ) ) {
41 require_api( 'authentication_api.php' );
42 require_api( 'config_api.php' );
43 require_api( 'constant_inc.php' );
44 require_api( 'event_api.php' );
45 require_api( 'form_api.php' );
46 require_api( 'helper_api.php' );
47 require_api( 'html_api.php' );
48 require_api( 'lang_api.php' );
49 require_api( 'print_api.php' );
50 require_api( 'user_api.php' );
51 require_api( 'user_pref_api.php' );
52 require_api( 'utility_api.php' );
54 function edit_account_prefs($p_user_id = null, $p_error_if_protected = true, $p_accounts_menu = true, $p_redirect_url = '') {
55 if ( null === $p_user_id ) {
56 $p_user_id = auth_get_current_user_id();
59 $t_redirect_url = $p_redirect_url;
60 if ( is_blank( $t_redirect_url ) ) {
61 $t_redirect_url = 'account_prefs_page.php';
64 # protected account check
65 if ( user_is_protected( $p_user_id ) ) {
66 if ( $p_error_if_protected ) {
67 trigger_error( ERROR_PROTECTED_ACCOUNT
, ERROR
);
74 $t_pref = user_pref_get( $p_user_id );
76 # Account Preferences Form BEGIN
79 <div id
="account-prefs-update-div" class="form-container">
80 <form id
="account-prefs-update-form" method
="post" action
="account_prefs_update.php">
82 <legend
><span
><?php
echo lang_get( 'default_account_preferences_title' ) ?
></span
></legend
>
83 <?php
echo form_security_field( 'account_prefs_update' ) ?
>
84 <input type
="hidden" name
="user_id" value
="<?php echo $p_user_id ?>" />
85 <input type
="hidden" name
="redirect_url" value
="<?php echo $t_redirect_url ?>" />
87 if ( $p_accounts_menu ) {
88 print_account_menu( 'account_prefs_page.php' );
91 <div
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
92 <label
for="default-project-id"><span
><?php
echo lang_get( 'default_project' ) ?
></span
></label
>
94 <select id
="default-project-id" name
="default_project">
95 <?php
print_project_option_list( $t_pref->default_project
) ?
>
98 <span
class="label-style"></span
>
100 <div
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
101 <label
for="refresh-delay"><span
><?php
echo lang_get( 'refresh_delay' ) ?
></span
></label
>
102 <span
class="input"><input id
="refresh-delay" type
="text" name
="refresh_delay" size
="4" maxlength
="4" value
="<?php echo $t_pref->refresh_delay ?>" /> <?php
echo lang_get( 'minutes' ) ?
></span
>
103 <span
class="label-style"></span
>
105 <div
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
106 <label
for="redirect-delay"><span
><?php
echo lang_get( 'redirect_delay' ) ?
></span
></label
>
107 <span
class="input"><input id
="redirect-delay" type
="text" name
="redirect_delay" size
="4" maxlength
="3" value
="<?php echo $t_pref->redirect_delay ?>" /> <?php
echo lang_get( 'seconds' ) ?
></span
>
108 <span
class="label-style"></span
>
110 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
111 <legend
><span
><?php
echo lang_get( 'bugnote_order' ) ?
></span
></legend
>
112 <span
class="radio"><input id
="bugnote-order-desc" type
="radio" name
="bugnote_order" value
="DESC" <?php
check_checked( $t_pref->bugnote_order
, 'DESC' ); ?
> /></span
>
113 <label
for="bugnote-order-desc"><span
><?php
echo lang_get( 'bugnote_order_desc' ) ?
></span
></label
>
114 <span
class="radio"><input id
="bugnote-order-asc" type
="radio" name
="bugnote_order" value
="ASC" <?php
check_checked( $t_pref->bugnote_order
, 'ASC' ); ?
> /></span
>
115 <label
for="bugnote-order-asc"><span
><?php
echo lang_get( 'bugnote_order_asc' ) ?
></span
></label
>
116 <span
class="label-style"></span
>
118 <?php
if ( ON
== config_get( 'enable_email_notification' ) ) { ?
>
119 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
120 <legend
><label
for="email-on-new"><?php
echo lang_get( 'email_on_new' ) ?
></label
></legend
>
121 <span
class="checkbox"><input id
="email-on-new" type
="checkbox" name
="email_on_new" <?php
check_checked( $t_pref->email_on_new
, ON
); ?
> /></span
>
122 <label
for="email-on-new-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
123 <span
class="select email-on-severity">
124 <select id
="email-on-new-min-severity" name
="email_on_new_min_severity">
125 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
126 <option disabled
="disabled">-----</option
>
127 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_new_min_severity
) ?
>
130 <span
class="label-style"></span
>
132 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
133 <legend
><label
for="email-on-assigned"><?php
echo lang_get( 'email_on_assigned' ) ?
></label
></legend
>
134 <span
class="checkbox"><input id
="email-on-assigned" type
="checkbox" name
="email_on_assigned" <?php
check_checked( $t_pref->email_on_assigned
, ON
); ?
> /></span
>
135 <label
for="email-on-assigned-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
136 <span
class="select email-on-severity">
137 <select id
="email-on-assigned-min-severity" name
="email_on_assigned_min_severity">
138 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
139 <option disabled
="disabled">-----</option
>
140 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_assigned_min_severity
) ?
>
143 <span
class="label-style"></span
>
145 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
146 <legend
><label
for="email-on-feedback"><?php
echo lang_get( 'email_on_feedback' ) ?
></label
></legend
>
147 <span
class="checkbox"><input id
="email-on-feedback" type
="checkbox" name
="email_on_feedback" <?php
check_checked( $t_pref->email_on_feedback
, ON
); ?
> /></span
>
148 <label
for="email-on-feedback-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
149 <span
class="select email-on-severity">
150 <select id
="email-on-feedback-min-severity" name
="email_on_feedback_min_severity">
151 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
152 <option disabled
="disabled">-----</option
>
153 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_feedback_min_severity
) ?
>
156 <span
class="label-style"></span
>
158 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
159 <legend
><label
for="email-on-resolved"><?php
echo lang_get( 'email_on_resolved' ) ?
></label
></legend
>
160 <span
class="checkbox"><input id
="email-on-resolved" type
="checkbox" name
="email_on_resolved" <?php
check_checked( $t_pref->email_on_resolved
, ON
); ?
> /></span
>
161 <label
for="email-on-resolved-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
162 <span
class="select email-on-severity">
163 <select id
="email-on-resolved-min-severity" name
="email_on_resolved_min_severity">
164 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
165 <option disabled
="disabled">-----</option
>
166 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_resolved_min_severity
) ?
>
169 <span
class="label-style"></span
>
171 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
172 <legend
><label
for="email-on-closed"><?php
echo lang_get( 'email_on_closed' ) ?
></label
></legend
>
173 <span
class="checkbox"><input id
="email-on-closed" type
="checkbox" name
="email_on_closed" <?php
check_checked( $t_pref->email_on_closed
, ON
); ?
> /></span
>
174 <label
for="email-on-closed-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
175 <span
class="select email-on-severity">
176 <select id
="email-on-closed-min-severity" name
="email_on_closed_min_severity">
177 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
178 <option disabled
="disabled">-----</option
>
179 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_closed_min_severity
) ?
>
182 <span
class="label-style"></span
>
184 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
185 <legend
><label
for="email-on-reopened"><?php
echo lang_get( 'email_on_reopened' ) ?
></label
></legend
>
186 <span
class="checkbox"><input id
="email-on-reopened" type
="checkbox" name
="email_on_reopened" <?php
check_checked( $t_pref->email_on_reopened
, ON
); ?
> /></span
>
187 <label
for="email-on-reopened-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
188 <span
class="select email-on-severity">
189 <select id
="email-on-reopened-min-severity" name
="email_on_reopened_min_severity">
190 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
191 <option disabled
="disabled">-----</option
>
192 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_reopened_min_severity
) ?
>
195 <span
class="label-style"></span
>
197 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
198 <legend
><label
for="email-on-bugnote-added"><?php
echo lang_get( 'email_on_bugnote_added' ) ?
></label
></legend
>
199 <span
class="checkbox"><input id
="email-on-bugnote-added" type
="checkbox" name
="email_on_bugnote" <?php
check_checked( $t_pref->email_on_bugnote
, ON
); ?
> /></span
>
200 <label
for="email-on-bugnote-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
201 <span
class="select email-on-severity">
202 <select id
="email-on-bugnote-min-severity" name
="email_on_bugnote_min_severity">
203 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
204 <option disabled
="disabled">-----</option
>
205 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_bugnote_min_severity
) ?
>
208 <span
class="label-style"></span
>
210 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
211 <legend
><label
for="email-on-status"><?php
echo lang_get( 'email_on_status_change' ) ?
></label
></legend
>
212 <span
class="checkbox"><input id
="email-on-status" type
="checkbox" name
="email_on_status" <?php
check_checked( $t_pref->email_on_status
, ON
); ?
> /></span
>
213 <label
for="email-on-status-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
214 <span
class="select email-on-severity">
215 <select id
="email-on-status-min-severity" name
="email_on_status_min_severity">
216 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
217 <option disabled
="disabled">-----</option
>
218 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_status_min_severity
) ?
>
221 <span
class="label-style"></span
>
223 <fieldset
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
224 <legend
><label
for="email-on-priority-change"><?php
echo lang_get( 'email_on_priority_change' ) ?
></label
></legend
>
225 <span
class="checkbox"><input id
="email-on-priority-change" type
="checkbox" name
="email_on_priority" <?php
check_checked( $t_pref->email_on_priority
, ON
); ?
> /></span
>
226 <label
for="email-on-priority-min-severity" class="email-on-severity-label"><span
><?php
echo lang_get( 'with_minimum_severity' ) ?
></span
></label
>
227 <span
class="select email-on-severity">
228 <select id
="email-on-priority-min-severity" name
="email_on_priority_min_severity">
229 <option value
="<?php echo OFF ?>"><?php
echo lang_get( 'any' ) ?
></option
>
230 <option disabled
="disabled">-----</option
>
231 <?php
print_enum_string_option_list( 'severity', $t_pref->email_on_priority_min_severity
) ?
>
234 <span
class="label-style"></span
>
236 <div
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
237 <label
for="email-bugnote-limit"><span
><?php
echo lang_get( 'email_bugnote_limit' ) ?
></span
></label
>
238 <span
class="input"><input id
="email-bugnote-limit" type
="text" name
="email_bugnote_limit" maxlength
="2" size
="2" value
="<?php echo $t_pref->email_bugnote_limit ?>" /></span
>
239 <span
class="label-style"></span
>
242 <input type
="hidden" name
="email_on_new" value
="<?php echo $t_pref->email_on_new ?>" />
243 <input type
="hidden" name
="email_on_assigned" value
="<?php echo $t_pref->email_on_assigned ?>" />
244 <input type
="hidden" name
="email_on_feedback" value
="<?php echo $t_pref->email_on_feedback ?>" />
245 <input type
="hidden" name
="email_on_resolved" value
="<?php echo $t_pref->email_on_resolved ?>" />
246 <input type
="hidden" name
="email_on_closed" value
="<?php echo $t_pref->email_on_closed ?>" />
247 <input type
="hidden" name
="email_on_reopened" value
="<?php echo $t_pref->email_on_reopened ?>" />
248 <input type
="hidden" name
="email_on_bugnote" value
="<?php echo $t_pref->email_on_bugnote ?>" />
249 <input type
="hidden" name
="email_on_status" value
="<?php echo $t_pref->email_on_status ?>" />
250 <input type
="hidden" name
="email_on_priority" value
="<?php echo $t_pref->email_on_priority ?>" />
251 <input type
="hidden" name
="email_on_new_min_severity" value
="<?php echo $t_pref->email_on_new_min_severity ?>" />
252 <input type
="hidden" name
="email_on_assigned_min_severity" value
="<?php echo $t_pref->email_on_assigned_min_severity ?>" />
253 <input type
="hidden" name
="email_on_feedback_min_severity" value
="<?php echo $t_pref->email_on_feedback_min_severity ?>" />
254 <input type
="hidden" name
="email_on_resolved_min_severity" value
="<?php echo $t_pref->email_on_resolved_min_severity ?>" />
255 <input type
="hidden" name
="email_on_closed_min_severity" value
="<?php echo $t_pref->email_on_closed_min_severity ?>" />
256 <input type
="hidden" name
="email_on_reopened_min_severity" value
="<?php echo $t_pref->email_on_reopened_min_severity ?>" />
257 <input type
="hidden" name
="email_on_bugnote_min_severity" value
="<?php echo $t_pref->email_on_bugnote_min_severity ?>" />
258 <input type
="hidden" name
="email_on_status_min_severity" value
="<?php echo $t_pref->email_on_status_min_severity ?>" />
259 <input type
="hidden" name
="email_on_priority_min_severity" value
="<?php echo $t_pref->email_on_priority_min_severity ?>" />
260 <input type
="hidden" name
="email_bugnote_limit" value
="<?php echo $t_pref->email_bugnote_limit ?>" />
262 <div
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
263 <label
for="timezone"><span
><?php
echo lang_get( 'timezone' ) ?
></span
></label
>
264 <span
class="select">
265 <select id
="timezone" name
="timezone">
266 <?php
print_timezone_option_list( $t_pref->timezone ?
$t_pref->timezone
: config_get_global( 'default_timezone' ) ) ?
>
269 <span
class="label-style"></span
>
271 <div
class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
272 <label
for="language"><span
><?php
echo lang_get( 'language' ) ?
></span
></label
>
273 <span
class="select">
274 <select id
="language" name
="language">
275 <?php
print_language_option_list( $t_pref->language
) ?
>
278 <span
class="label-style"></span
>
281 <?php
event_signal( 'EVENT_ACCOUNT_PREF_UPDATE_FORM', array( $p_user_id ) ); ?
>
282 <span
class="submit-button"><input type
="submit" class="button" value
="<?php echo lang_get( 'update_prefs_button' ) ?>" /></span
>
287 <div id
="account-prefs-reset-div" class="form-container">
288 <form id
="account-prefs-reset-form" method
="post" action
="account_prefs_reset.php">
290 <?php
echo form_security_field( 'account_prefs_reset' ) ?
>
291 <input type
="hidden" name
="user_id" value
="<?php echo $p_user_id ?>" />
292 <input type
="hidden" name
="redirect_url" value
="<?php echo $t_redirect_url ?>" />
293 <span
class="submit-button"><input type
="submit" class="button" value
="<?php echo lang_get( 'reset_prefs_button' ) ?>" /></span
>
299 } # end of edit_account_prefs()