2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 $fetchtemplates = array(
26 define('SVN', '$Id$');
28 $focus['user'] = 'focus';
30 require_once('./global.php');
31 require_once('./includes/class_api_error.php');
32 require_once('./includes/api_user.php');
34 APIError(array(new API_Error_Handler($message), 'user_cumulative'));
36 if (!$bugsys->userinfo
['userid'])
38 $message->error_permission();
41 $userapi = new UserAPI($bugsys);
42 $userapi->set('userid', $bugsys->userinfo
['userid']);
43 $userapi->set_condition();
45 $userinfo = $bugsys->userinfo
;
47 // ###################################################################
49 if (empty($_REQUEST['do']))
51 $_REQUEST['do'] = 'modify';
54 // ###################################################################
56 if ($_POST['do'] == 'update')
58 // -------------------------------------------------------------------
60 if (!empty($bugsys->in
['password']) OR !empty($bugsys->in
['email']))
62 if (empty($bugsys->in
['validate']))
64 $message->add_error(_('You need to enter your current password to change your email or password'));
68 if (md5(md5($bugsys->in
['validate']) . md5($bugsys->userinfo
['salt'])) != $bugsys->userinfo
['password'])
70 $message->add_error(_('Your authentication password does not match the one in our records'));
75 // -------------------------------------------------------------------
77 if (!empty($bugsys->in
['email']))
79 if (!empty($bugsys->in
['email']) AND empty($bugsys->in
['email_confirm']))
81 $message->add_error(_('You need to enter both the email and confirm email fields to change your address'));
84 if ($bugsys->in
['email'] != $bugsys->in
['email_confirm'])
86 $message->add_error(_('Your email and confirm email addresses do not match'));
89 $userapi->set('email', $bugsys->in
['email']);
92 // -------------------------------------------------------------------
93 // password validation
94 if (!empty($bugsys->in
['password']))
96 if (!empty($bugsys->in
['password']) AND empty($bugsys->in
['password_confirm']))
98 $message->add_error(_('You need to enter both the password and confirm password fields to change your password'));
102 if ($bugsys->in
['password'] != $bugsys->in
['password_confirm'])
104 $message->add_error(_('Your password and confirm password do not match'));
108 $userapi->set('password', $bugsys->in
['password']);
111 $userapi->set('displayname', $bugsys->in
['displayname']);
112 $userapi->set('showemail', $bugsys->in
['showemail']);
113 $userapi->set('showcolors', $bugsys->in
['showcolors']);
114 $userapi->set('languageid', $bugsys->in
['languageid']);
115 $userapi->set('timezone', $bugsys->in
['timezone']);
116 $userapi->set('usedst', $bugsys->in
['usedst']);
117 $userapi->set('hidestatuses', $bugsys->in
['hidestatuses']);
118 $userapi->set('defaultsortkey', $bugsys->in
['defaultsortkey']);
119 $userapi->set('defaultsortas', $bugsys->in
['defaultsortas']);
121 // -------------------------------------------------------------------
123 $userinfo['displayname'] = $bugsys->in
['displayname'];
124 $userinfo['showemail'] = $bugsys->in
['showemail'];
125 $userinfo['showcolors'] = $bugsys->in
['showcolors'];
126 $userinfo['languageid'] = $bugsys->in
['languageid'];
127 $userinfo['timezone'] = $bugsys->in
['timezone'];
128 $userinfo['usedst'] = $bugsys->in
['usedst'];
129 $userinfo['hidestatuses'] = $bugsys->in
['hidestatuses'];
130 $userinfo['defaultsorkey'] = $bugsys->in
['defaultsorkey'];
131 $userinfo['defaultsortas'] = $bugsys->in
['defaultsortas'];
133 $email = $bugsys->in
['email'];
134 $email_confirm = $bugsys->in
['email_confirm'];
136 // -------------------------------------------------------------------
140 $message->error_list_process();
142 $show['errors'] = true
;
143 $_REQUEST['do'] = 'modify';
149 if (can_perform('canbeassignedto'))
151 require_once('./includes/functions_datastore.php');
155 $db->query("DELETE FROM " . TABLE_PREFIX
. "useremail WHERE userid = " . $bugsys->userinfo
['userid']);
156 $bugsys->input_clean('emailopts', TYPE_INT
);
157 if (is_array($bugsys->in
['emailopts']))
159 foreach ($bugsys->in
['emailopts'] AS $relation => $bitarr)
162 if (is_array($bitarr))
164 foreach ($bitarr AS $option => $yes)
166 $bitmask +
= $option * $yes;
169 $db->query("INSERT INTO " . TABLE_PREFIX
. "useremail (userid, relation, mask) VALUES (" . $bugsys->userinfo
['userid'] . ", $relation, $bitmask)");
173 $message->redirect(_('The changes to your account have been made.'), 'userctrl.php');
177 // ###################################################################
179 if ($_REQUEST['do'] == 'modify')
181 $langselect = construct_datastore_select('language', 'title', 'languageid', $userinfo['languageid']);
183 $hidestatuses = construct_datastore_select('status', 'status', 'statusid', (!is_array($userinfo['hidestatuses']) ?
explode(',', $userinfo['hidestatuses']) : $userinfo['hidestatuses']), 0);
184 $hidestatusesnum = (sizeof($bugsys->datastore
['status']) < 8 ?
sizeof($bugsys->datastore
['status']) +
1 : 8);
186 $defaultsortkey = construct_option_select('defaultsortkey', ListSorter
::fetch_by_text(false
), $userinfo['defaultsortkey']);
187 $defaultsortas = construct_option_select('defaultsortas', ListSorter
::fetch_as_text(false
), $userinfo['defaultsortas']);
189 foreach ($datef->fetch_timezone_list() AS $value => $label)
191 $selected = ($value == $userinfo['timezone']);
192 eval('$tzselect .= "' . $template->fetch('selectoption') . '";');
196 if (!is_array($bugsys->in
['emailopts']))
198 $options = $db->query("SELECT * FROM " . TABLE_PREFIX
. "useremail WHERE userid = " . $bugsys->userinfo
['userid']);
199 while ($opt = $db->fetch_array($options))
201 foreach ($bugsys->emailoptions
['notifications'] AS $name => $notif)
203 foreach ($bugsys->emailoptions
['relations'] AS $name => $relation)
205 if ($opt['mask'] & $notif AND $opt['relation'] == $relation)
207 $checked["$relation"]["$notif"] = HTML_CHECKED
;
215 $checked = $bugsys->in
['emailopts'];
216 foreach ($checked AS $key1 => $value1)
218 foreach ($value1 AS $key2 => $value2)
222 $checked["$key1"]["$key2"] = HTML_CHECKED
;
228 eval('$template->flush("' . $template->fetch('userctrl') . '");');
231 /*=====================================================================*\
232 || ###################################################################
235 || ###################################################################
236 \*=====================================================================*/