2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 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 2 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(
28 define('SVN', '$Id$');
30 $focus['user
'] = 'focus
';
32 require_once('./global.php
');
33 require_once('./includes
/class_api_error
.php
');
34 require_once('./includes
/api_user
.php
');
36 APIError(array(new API_Error_Handler($message), 'user_cumulative
'));
38 if (!bugdar::$userinfo['userid
'])
40 $message->errorPermission();
43 $userapi = new UserAPI($bugsys);
44 $userapi->set('userid
', bugdar::$userinfo['userid
']);
45 $userapi->set_condition();
47 $userinfo = bugdar::$userinfo;
49 // ###################################################################
51 if (empty($_REQUEST['do']))
53 $_REQUEST['do'] = 'modify
';
56 // ###################################################################
58 if ($_POST['do'] == 'killsearch
')
60 $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid
', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid
']);
63 $message->errorPermission();
66 $db->query("DELETE FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->in['searchid
']);
68 $message->redirect(T('This saved search has been removed from your
list.'), 'userctrl
.php
');
71 // ###################################################################
73 if ($_REQUEST['do'] == 'deletesearch
')
75 $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid
', TYPE_UINT) . " AND userid = " . bugdar::$userinfo['userid
']);
78 $message->errorPermission();
81 $message->confirm(T('Are you sure you want to delete this saved search
?'), 'userctrl
.php
', 'killsearch
', T('Delete
'), T('Cancel
'), array('searchid
' => $bugsys->in['searchid
']));
84 // ###################################################################
86 if ($_POST['do'] == 'update
')
88 // -------------------------------------------------------------------
90 if (!empty($bugsys->in['password_change
']) OR !empty($bugsys->in['email_change
']))
92 if (empty($bugsys->in['validate
']))
94 $message->addError(T('You need to enter your current password to change your email
or password
'));
98 if (md5(md5($bugsys->in['validate
']) . md5(bugdar::$userinfo['salt
'])) != bugdar::$userinfo['password
'])
100 $message->addError(T('Your authentication password does not match the one in our records
'));
105 // -------------------------------------------------------------------
107 if (!empty($bugsys->in['email_change
']))
109 if (!empty($bugsys->in['email_change
']) AND empty($bugsys->in['email_confirm
']))
111 $message->addError(T('You need to enter both the email
and confirm email fields to change your address
'));
114 if ($bugsys->in['email_change
'] != $bugsys->in['email_confirm
'])
116 $message->addError(T('Your email
and confirm email addresses
do not match
'));
119 $userapi->set('email
', $bugsys->in['email_change
']);
122 // -------------------------------------------------------------------
123 // password validation
124 if (!empty($bugsys->in['password_change
']))
126 if (!empty($bugsys->in['password_change
']) AND empty($bugsys->in['password_confirm
']))
128 $message->addError(T('You need to enter both the password
and confirm password fields to change your password
'));
132 if ($bugsys->in['password_change
'] != $bugsys->in['password_confirm
'])
134 $message->addError(T('Your password
and confirm password
do not match
'));
138 $userapi->set('password
', $bugsys->in['password_change
']);
141 $userapi->set('displayname
', $bugsys->in['displayname
']);
142 $userapi->set('showemail
', $bugsys->in['showemail
']);
143 $userapi->set('showcolors
', $bugsys->in['showcolors
']);
144 $userapi->set('languageid
', $bugsys->in['languageid
']);
145 $userapi->set('timezone
', $bugsys->in['timezone
']);
146 $userapi->set('usedst
', $bugsys->in['usedst
']);
147 $userapi->set('hidestatuses
', $bugsys->in['hidestatuses
']);
148 $userapi->set('defaultsortkey
', $bugsys->in['defaultsortkey
']);
149 $userapi->set('defaultsortas
', $bugsys->in['defaultsortas
']);
150 $userapi->set('columnoptions
', $bugsys->input_clean('columnoptions
', TYPE_UINT));
152 // -------------------------------------------------------------------
154 $userinfo['displayname
'] = $bugsys->in['displayname
'];
155 $userinfo['showemail
'] = $bugsys->in['showemail
'];
156 $userinfo['showcolors
'] = $bugsys->in['showcolors
'];
157 $userinfo['languageid
'] = $bugsys->in['languageid
'];
158 $userinfo['timezone
'] = $bugsys->in['timezone
'];
159 $userinfo['usedst
'] = $bugsys->in['usedst
'];
160 $userinfo['hidestatuses
'] = $bugsys->in['hidestatuses
'];
161 $userinfo['defaultsorkey
'] = $bugsys->in['defaultsorkey
'];
162 $userinfo['defaultsortas
'] = $bugsys->in['defaultsortas
'];
163 $userinfo['columnoptions
'] = $bugsys->in['columnoptions
'];
165 $email = $bugsys->in['email_change
'];
166 $email_confirm = $bugsys->in['email_confirm
'];
168 // -------------------------------------------------------------------
170 if ($message->hasErrors())
172 $show['errors
'] = true;
173 $_REQUEST['do'] = 'modify
';
179 $db->query("DELETE FROM " . TABLE_PREFIX . "useremail WHERE userid = " . bugdar::$userinfo['userid
']);
180 $bugsys->input_clean('emailopts
', TYPE_INT);
181 if (is_array($bugsys->in['emailopts
']))
183 foreach ($bugsys->in['emailopts
'] AS $relation => $bitarr)
186 if (is_array($bitarr))
188 foreach ($bitarr AS $option => $yes)
190 $bitmask += $option * $yes;
193 $db->query("INSERT INTO " . TABLE_PREFIX . "useremail (userid, relation, mask) VALUES (" . bugdar::$userinfo['userid
'] . ", $relation, $bitmask)");
197 $message->redirect(T('The changes to your account have been made
.'), 'userctrl
.php
');
201 // ###################################################################
203 if ($_REQUEST['do'] == 'modify
')
205 $langselect = construct_datastore_select('language
', 'title
', 'languageid
', $userinfo['languageid
']);
207 $hidestatuses = construct_datastore_select('status
', 'status
', 'statusid
', (!is_array($userinfo['hidestatuses
']) ? explode(',', $userinfo['hidestatuses
']) : $userinfo['hidestatuses
']), 0);
208 $hidestatusesnum = (sizeof(bugdar::$datastore['status
']) < 8 ? sizeof(bugdar::$datastore['status
']) + 1 : 8);
210 $defaultsortkey = construct_option_select('defaultsortkey
', ListSorter::fetch_by_text(false), $userinfo['defaultsortkey
']);
211 $defaultsortas = construct_option_select('defaultsortas
', ListSorter::fetch_as_text(false), $userinfo['defaultsortas
']);
213 foreach ($datef->fetch_timezone_list() AS $value => $label)
215 $selected = ($value == $userinfo['timezone
']);
216 eval('$tzselect .= "' . $template->fetch('selectoption') . '";');
220 if (!is_array($bugsys->in['emailopts
']))
222 $options = $db->query("SELECT * FROM " . TABLE_PREFIX . "useremail WHERE userid = " . bugdar::$userinfo['userid
']);
223 foreach ($options as $opt)
225 foreach ($bugsys->emailoptions['notifications
'] AS $name => $notif)
227 foreach ($bugsys->emailoptions['relations
'] AS $name => $relation)
229 if ($opt['mask
'] & $notif AND $opt['relation
'] == $relation)
231 $checked["$relation"]["$notif"] = HTML_CHECKED;
239 $checked = $bugsys->in['emailopts
'];
240 foreach ($checked AS $key1 => $value1)
242 foreach ($value1 AS $key2 => $value2)
246 $checked["$key1"]["$key2"] = HTML_CHECKED;
254 require_once('./includes
/class_sort
.php
');
255 if (!is_array($bugsys->in['columnoptions
']))
257 foreach (ListSorter::fetch_by_text(false) AS $column => $name)
259 if (is_array(bugdar::$userinfo['columnoptions
']))
261 $columns["$column"] = bugdar::$userinfo['columnoptions
']["$column"];
265 $columns["$column"] = bugdar::$options['columnoptions
']["$column"];
267 eval('$columnOptions .= "' . $template->fetch('userctrl_column') . '";');
272 $columns = $bugsys->in['columnoptions
'];
273 foreach (ListSorter::fetch_by_text(false) AS $column => $name)
275 eval('$columnOptions .= "' . $template->fetch('userctrl_column') . '";');
281 $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NOT NULL AND userid = " . bugdar::$userinfo['userid
']);
282 foreach ($searchesFetch as $search)
284 eval('$searches .= "' . $template->fetch('userctrl_search') . '";');
287 eval('$template->flush("' . $template->fetch('userctrl') . '");');
290 /*=====================================================================*\
291 || ###################################################################
294 || ###################################################################
295 \*=====================================================================*/