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/api_user.php');
35 if (!bugdar
::$userinfo['userid'])
37 $message->errorPermission();
40 $userapi = new UserAPI();
41 $userapi->set('userid', bugdar
::$userinfo['userid']);
42 $userapi->setCondition();
44 $userinfo = bugdar
::$userinfo;
46 // ###################################################################
48 if (empty($_REQUEST['do']))
50 $_REQUEST['do'] = 'modify';
53 // ###################################################################
55 if ($_POST['do'] == 'killsearch')
57 $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT
) . " AND userid = " . bugdar
::$userinfo['userid']);
60 $message->errorPermission();
63 $db->query("DELETE FROM " . TABLE_PREFIX
. "search WHERE searchid = " . $input->in
['searchid']);
65 $message->redirect(T('This saved search has been removed from your list.'), 'userctrl.php');
68 // ###################################################################
70 if ($_REQUEST['do'] == 'deletesearch')
72 $search = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "search WHERE searchid = " . $input->inputClean('searchid', TYPE_UINT
) . " AND userid = " . bugdar
::$userinfo['userid']);
75 $message->errorPermission();
78 $message->confirm(T('Are you sure you want to delete this saved search?'), 'userctrl.php', 'killsearch', T('Delete'), T('Cancel'), array('searchid' => $input->in
['searchid']));
81 // ###################################################################
83 if ($_POST['do'] == 'update')
85 // -------------------------------------------------------------------
87 if (!empty($input->in
['password_change']) OR !empty($input->in
['email_change']))
89 if (empty($input->in
['validate']))
91 $message->addError(T('You need to enter your current password to change your email or password'));
95 if (md5(md5($input->in
['validate']) . md5(bugdar
::$userinfo['salt'])) != bugdar
::$userinfo['password'])
97 $message->addError(T('Your authentication password does not match the one in our records'));
102 // -------------------------------------------------------------------
104 if (!empty($input->in
['email_change']))
106 if (!empty($input->in
['email_change']) AND empty($input->in
['email_confirm']))
108 $message->addError(T('You need to enter both the email and confirm email fields to change your address'));
111 if ($input->in
['email_change'] != $input->in
['email_confirm'])
113 $message->addError(T('Your email and confirm email addresses do not match'));
116 $userapi->set('email', $input->in
['email_change']);
119 // -------------------------------------------------------------------
120 // password validation
121 if (!empty($input->in
['password_change']))
123 if (!empty($input->in
['password_change']) AND empty($input->in
['password_confirm']))
125 $message->addError(T('You need to enter both the password and confirm password fields to change your password'));
129 if ($input->in
['password_change'] != $input->in
['password_confirm'])
131 $message->addError(T('Your password and confirm password do not match'));
135 $userapi->set('password', $input->in
['password_change']);
138 $userapi->set('displayname', $input->in
['displayname']);
139 $userapi->set('showemail', $input->in
['showemail']);
140 $userapi->set('showcolors', $input->in
['showcolors']);
141 $userapi->set('languageid', $input->in
['languageid']);
142 $userapi->set('timezone', $input->in
['timezone']);
143 $userapi->set('usedst', $input->in
['usedst']);
144 $userapi->set('hidestatuses', $input->in
['hidestatuses']);
145 $userapi->set('defaultsortkey', $input->in
['defaultsortkey']);
146 $userapi->set('defaultsortas', $input->in
['defaultsortas']);
147 $userapi->set('columnoptions', $input->inputClean('columnoptions', TYPE_UINT
));
149 // -------------------------------------------------------------------
151 $userinfo['displayname'] = $input->in
['displayname'];
152 $userinfo['showemail'] = $input->in
['showemail'];
153 $userinfo['showcolors'] = $input->in
['showcolors'];
154 $userinfo['languageid'] = $input->in
['languageid'];
155 $userinfo['timezone'] = $input->in
['timezone'];
156 $userinfo['usedst'] = $input->in
['usedst'];
157 $userinfo['hidestatuses'] = $input->in
['hidestatuses'];
158 $userinfo['defaultsorkey'] = $input->in
['defaultsorkey'];
159 $userinfo['defaultsortas'] = $input->in
['defaultsortas'];
160 $userinfo['columnoptions'] = $input->in
['columnoptions'];
162 $email = $input->in
['email_change'];
163 $email_confirm = $input->in
['email_confirm'];
165 // -------------------------------------------------------------------
167 if ($message->hasErrors())
169 $show['errors'] = true
;
170 $_REQUEST['do'] = 'modify';
176 $db->query("DELETE FROM " . TABLE_PREFIX
. "useremail WHERE userid = " . bugdar
::$userinfo['userid']);
177 $input->inputClean('emailopts', TYPE_INT
);
178 if (is_array($input->in
['emailopts']))
180 foreach ($input->in
['emailopts'] AS $relation => $bitarr)
183 if (is_array($bitarr))
185 foreach ($bitarr AS $option => $yes)
187 $bitmask +
= $option * $yes;
190 $db->query("INSERT INTO " . TABLE_PREFIX
. "useremail (userid, relation, mask) VALUES (" . bugdar
::$userinfo['userid'] . ", $relation, $bitmask)");
194 $message->redirect(T('The changes to your account have been made.'), 'userctrl.php');
198 // ###################################################################
200 if ($_REQUEST['do'] == 'modify')
202 $langselect = construct_datastore_select('language', 'title', 'languageid', $userinfo['languageid']);
204 $hidestatuses = construct_datastore_select('status', 'status', 'statusid', (!is_array($userinfo['hidestatuses']) ?
explode(',', $userinfo['hidestatuses']) : $userinfo['hidestatuses']), 0);
205 $hidestatusesnum = (sizeof(bugdar
::$datastore['status']) < 8 ?
sizeof(bugdar
::$datastore['status']) +
1 : 8);
207 $defaultsortkey = construct_option_select('defaultsortkey', ListSorter
::fetch_by_text(false
), $userinfo['defaultsortkey']);
208 $defaultsortas = construct_option_select('defaultsortas', ListSorter
::fetch_as_text(false
), $userinfo['defaultsortas']);
210 foreach ($datef->fetch_timezone_list() as $value => $label)
212 $tpl = new BSTemplate('selectoption');
216 'selected' => ($value == $userinfo['timezone'])
218 $tzselect .= $tpl->evaluate()->getTemplate();
222 if (!is_array($input->in
['emailopts']))
224 $options = $db->query("SELECT * FROM " . TABLE_PREFIX
. "useremail WHERE userid = " . bugdar
::$userinfo['userid']);
225 foreach ($options as $opt)
227 foreach (bugdar
::$emailOptions['notifications'] AS $name => $notif)
229 foreach (bugdar
::$emailOptions['relations'] AS $name => $relation)
231 if ($opt['mask'] & $notif AND $opt['relation'] == $relation)
233 $checked["$relation"]["$notif"] = HTML_CHECKED
;
241 $checked = $input->in
['emailopts'];
242 foreach ($checked AS $key1 => $value1)
244 foreach ($value1 AS $key2 => $value2)
248 $checked["$key1"]["$key2"] = HTML_CHECKED
;
256 require_once('./includes/class_sort.php');
257 if (!is_array($input->in
['columnoptions']))
259 foreach (ListSorter
::fetch_by_text(false
) AS $column => $name)
261 if (is_array(bugdar
::$userinfo['columnoptions']))
263 $columns["$column"] = bugdar
::$userinfo['columnoptions']["$column"];
267 $columns["$column"] = bugdar
::$options['columnoptions']["$column"];
269 $tpl = new BSTemplate('userctrl_column');
271 'columns' => $columns,
275 $columnOptions .= $tpl->evaluate()->getTemplate();
280 $columns = $input->in
['columnoptions'];
281 foreach (ListSorter
::fetch_by_text(false
) as $column => $name)
283 $tpl = new BSTemplate('userctrl_column');
285 'columns' => $columns,
289 $columnOptions .= $tpl->evaluate()->getTemplate();
295 $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX
. "search WHERE name IS NOT NULL AND userid = " . bugdar
::$userinfo['userid']);
296 foreach ($searchesFetch as $search)
298 $tpl = new BSTemplate('userctrl_search');
299 $tpl->vars
= array('search' => $search);
300 $searches .= $tpl->evaluate()->getTemplate();
303 $tpl = new BSTemplate('userctrl');
305 'checked' => $checked,
306 'userinfo' => $userinfo,
307 'searches' => $searches,
308 'defaultsortkey' => $defaultsortkey,
309 'hidestatusesnum' => $hidestatusesnum,
310 'hidestatuses' => $hidestatuses,
311 'defaultsortas' => $defaultsortas,
312 'columnOptions' => $columnOptions,
313 'langselect' => $langselect,
314 'tzselect' => $tzselect
316 $tpl->evaluate()->flush();
319 /*=====================================================================*\
320 || ###################################################################
323 || ###################################################################
324 \*=====================================================================*/