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(
27 define('SVN', '$Id$');
29 $focus['user
'] = 'focus
';
31 require_once('./global.php
');
32 require_once('./includes
/class_api_error
.php
');
33 require_once('./includes
/api_user
.php
');
35 APIError(array(new API_Error_Handler($message), 'user_cumulative
'));
37 if (!$bugsys->userinfo['userid
'])
39 $message->error_permission();
42 $userapi = new UserAPI($bugsys);
43 $userapi->set('userid
', $bugsys->userinfo['userid
']);
44 $userapi->set_condition();
46 $userinfo = $bugsys->userinfo;
48 // ###################################################################
50 if (empty($_REQUEST['do']))
52 $_REQUEST['do'] = 'modify
';
55 // ###################################################################
57 if ($_POST['do'] == 'update
')
59 // -------------------------------------------------------------------
61 if (!empty($bugsys->in['password_change
']) OR !empty($bugsys->in['email_change
']))
63 if (empty($bugsys->in['validate
']))
65 $message->add_error(_('You need to enter your current password to change your email
or password
'));
69 if (md5(md5($bugsys->in['validate
']) . md5($bugsys->userinfo['salt
'])) != $bugsys->userinfo['password
'])
71 $message->add_error(_('Your authentication password does not match the one in our records
'));
76 // -------------------------------------------------------------------
78 if (!empty($bugsys->in['email_change
']))
80 if (!empty($bugsys->in['email_change
']) AND empty($bugsys->in['email_confirm
']))
82 $message->add_error(_('You need to enter both the email
and confirm email fields to change your address
'));
85 if ($bugsys->in['email_change
'] != $bugsys->in['email_confirm
'])
87 $message->add_error(_('Your email
and confirm email addresses
do not match
'));
90 $userapi->set('email
', $bugsys->in['email_change
']);
93 // -------------------------------------------------------------------
94 // password validation
95 if (!empty($bugsys->in['password_change
']))
97 if (!empty($bugsys->in['password_change
']) AND empty($bugsys->in['password_confirm
']))
99 $message->add_error(_('You need to enter both the password
and confirm password fields to change your password
'));
103 if ($bugsys->in['password_change
'] != $bugsys->in['password_confirm
'])
105 $message->add_error(_('Your password
and confirm password
do not match
'));
109 $userapi->set('password
', $bugsys->in['password_change
']);
112 $userapi->set('displayname
', $bugsys->in['displayname
']);
113 $userapi->set('showemail
', $bugsys->in['showemail
']);
114 $userapi->set('showcolors
', $bugsys->in['showcolors
']);
115 $userapi->set('languageid
', $bugsys->in['languageid
']);
116 $userapi->set('timezone
', $bugsys->in['timezone
']);
117 $userapi->set('usedst
', $bugsys->in['usedst
']);
118 $userapi->set('hidestatuses
', $bugsys->in['hidestatuses
']);
119 $userapi->set('defaultsortkey
', $bugsys->in['defaultsortkey
']);
120 $userapi->set('defaultsortas
', $bugsys->in['defaultsortas
']);
122 // -------------------------------------------------------------------
124 $userinfo['displayname
'] = $bugsys->in['displayname
'];
125 $userinfo['showemail
'] = $bugsys->in['showemail
'];
126 $userinfo['showcolors
'] = $bugsys->in['showcolors
'];
127 $userinfo['languageid
'] = $bugsys->in['languageid
'];
128 $userinfo['timezone
'] = $bugsys->in['timezone
'];
129 $userinfo['usedst
'] = $bugsys->in['usedst
'];
130 $userinfo['hidestatuses
'] = $bugsys->in['hidestatuses
'];
131 $userinfo['defaultsorkey
'] = $bugsys->in['defaultsorkey
'];
132 $userinfo['defaultsortas
'] = $bugsys->in['defaultsortas
'];
134 $email = $bugsys->in['email_change
'];
135 $email_confirm = $bugsys->in['email_confirm
'];
137 // -------------------------------------------------------------------
141 $message->error_list_process();
143 $show['errors
'] = true;
144 $_REQUEST['do'] = 'modify
';
150 if (can_perform('canbeassignedto
'))
152 require_once('./includes
/functions_datastore
.php
');
156 $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $bugsys->userinfo['userid
']);
157 $bugsys->input_clean('emailopts
', TYPE_INT);
158 if (is_array($bugsys->in['emailopts
']))
160 foreach ($bugsys->in['emailopts
'] AS $relation => $bitarr)
163 if (is_array($bitarr))
165 foreach ($bitarr AS $option => $yes)
167 $bitmask += $option * $yes;
170 $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . $bugsys->userinfo['userid
'] . ", $relation, $bitmask)");
174 $message->redirect(_('The changes to your account have been made
.'), 'userctrl
.php
');
178 // ###################################################################
180 if ($_REQUEST['do'] == 'modify
')
182 $langselect = construct_datastore_select('language
', 'title
', 'languageid
', $userinfo['languageid
']);
184 $hidestatuses = construct_datastore_select('status
', 'status
', 'statusid
', (!is_array($userinfo['hidestatuses
']) ? explode(',', $userinfo['hidestatuses
']) : $userinfo['hidestatuses
']), 0);
185 $hidestatusesnum = (sizeof($bugsys->datastore['status
']) < 8 ? sizeof($bugsys->datastore['status
']) + 1 : 8);
187 $defaultsortkey = construct_option_select('defaultsortkey
', ListSorter::fetch_by_text(false), $userinfo['defaultsortkey
']);
188 $defaultsortas = construct_option_select('defaultsortas
', ListSorter::fetch_as_text(false), $userinfo['defaultsortas
']);
190 foreach ($datef->fetch_timezone_list() AS $value => $label)
192 $selected = ($value == $userinfo['timezone
']);
193 eval('$tzselect .= "' . $template->fetch('selectoption') . '";');
197 if (!is_array($bugsys->in['emailopts
']))
199 $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . $bugsys->userinfo['userid
']);
200 while ($opt = $db->fetch_array($options))
202 foreach ($bugsys->emailoptions['notifications
'] AS $name => $notif)
204 foreach ($bugsys->emailoptions['relations
'] AS $name => $relation)
206 if ($opt['mask
'] & $notif AND $opt['relation
'] == $relation)
208 $checked["$relation"]["$notif"] = HTML_CHECKED;
216 $checked = $bugsys->in['emailopts
'];
217 foreach ($checked AS $key1 => $value1)
219 foreach ($value1 AS $key2 => $value2)
223 $checked["$key1"]["$key2"] = HTML_CHECKED;
231 $array = ((is_array($bugsys->userinfo['columnoptions
']) AND sizeof($bugsys->userinfo['columnoptions
']) == sizeof($bugsys->columns)) ? $bugsys->userinfo['columnoptions
'] : $bugsys->columns);
232 foreach ($array AS $column => $mask)
234 $columnName = $bugsys->columnNames["$column"];
235 eval('$columnOptions .= "' . $template->fetch('userctrl_column') . '";');
241 if (!is_array($bugsys->in['columns
']))
243 $columns = '{
"' . implode('": "', $bugsys->userinfo['columnoptions']) . '"}';
246 eval('$template->flush("' . $template->fetch('userctrl') . '");');
249 /*=====================================================================*\
250 || ###################################################################
253 || ###################################################################
254 \*=====================================================================*/