]>
src.bluestatic.org Git - bugdar.git/blob - userctrl.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)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 (
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- > errorPermission ();
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' ] == 'killsearch' )
59 $search = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "search WHERE searchid = " . $bugsys- > input_clean ( 'searchid' , TYPE_UINT
) . " AND userid = " . $bugsys- > userinfo
[ 'userid' ]);
62 $message- > errorPermission ();
65 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "search WHERE searchid = " . $bugsys- > in
[ 'searchid' ]);
67 $message- > redirect ( T ( 'This saved search has been removed from your list.' ), 'userctrl.php' );
70 // ###################################################################
72 if ( $_REQUEST [ 'do' ] == 'deletesearch' )
74 $search = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "search WHERE searchid = " . $bugsys- > input_clean ( 'searchid' , TYPE_UINT
) . " AND userid = " . $bugsys- > userinfo
[ 'userid' ]);
77 $message- > errorPermission ();
80 $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' ]));
83 // ###################################################################
85 if ( $_POST [ 'do' ] == 'update' )
87 // -------------------------------------------------------------------
89 if (! empty ( $bugsys- > in
[ 'password_change' ]) OR ! empty ( $bugsys- > in
[ 'email_change' ]))
91 if ( empty ( $bugsys- > in
[ 'validate' ]))
93 $message- > addError ( T ( 'You need to enter your current password to change your email or password' ));
97 if ( md5 ( md5 ( $bugsys- > in
[ 'validate' ]) . md5 ( $bugsys- > userinfo
[ 'salt' ])) != $bugsys- > userinfo
[ 'password' ])
99 $message- > addError ( T ( 'Your authentication password does not match the one in our records' ));
104 // -------------------------------------------------------------------
106 if (! empty ( $bugsys- > in
[ 'email_change' ]))
108 if (! empty ( $bugsys- > in
[ 'email_change' ]) AND empty ( $bugsys- > in
[ 'email_confirm' ]))
110 $message- > addError ( T ( 'You need to enter both the email and confirm email fields to change your address' ));
113 if ( $bugsys- > in
[ 'email_change' ] != $bugsys- > in
[ 'email_confirm' ])
115 $message- > addError ( T ( 'Your email and confirm email addresses do not match' ));
118 $userapi- > set ( 'email' , $bugsys- > in
[ 'email_change' ]);
121 // -------------------------------------------------------------------
122 // password validation
123 if (! empty ( $bugsys- > in
[ 'password_change' ]))
125 if (! empty ( $bugsys- > in
[ 'password_change' ]) AND empty ( $bugsys- > in
[ 'password_confirm' ]))
127 $message- > addError ( T ( 'You need to enter both the password and confirm password fields to change your password' ));
131 if ( $bugsys- > in
[ 'password_change' ] != $bugsys- > in
[ 'password_confirm' ])
133 $message- > addError ( T ( 'Your password and confirm password do not match' ));
137 $userapi- > set ( 'password' , $bugsys- > in
[ 'password_change' ]);
140 $userapi- > set ( 'displayname' , $bugsys- > in
[ 'displayname' ]);
141 $userapi- > set ( 'showemail' , $bugsys- > in
[ 'showemail' ]);
142 $userapi- > set ( 'showcolors' , $bugsys- > in
[ 'showcolors' ]);
143 $userapi- > set ( 'languageid' , $bugsys- > in
[ 'languageid' ]);
144 $userapi- > set ( 'timezone' , $bugsys- > in
[ 'timezone' ]);
145 $userapi- > set ( 'usedst' , $bugsys- > in
[ 'usedst' ]);
146 $userapi- > set ( 'hidestatuses' , $bugsys- > in
[ 'hidestatuses' ]);
147 $userapi- > set ( 'defaultsortkey' , $bugsys- > in
[ 'defaultsortkey' ]);
148 $userapi- > set ( 'defaultsortas' , $bugsys- > in
[ 'defaultsortas' ]);
149 $userapi- > set ( 'columnoptions' , $bugsys- > input_clean ( 'columnoptions' , TYPE_UINT
));
151 // -------------------------------------------------------------------
153 $userinfo [ 'displayname' ] = $bugsys- > in
[ 'displayname' ];
154 $userinfo [ 'showemail' ] = $bugsys- > in
[ 'showemail' ];
155 $userinfo [ 'showcolors' ] = $bugsys- > in
[ 'showcolors' ];
156 $userinfo [ 'languageid' ] = $bugsys- > in
[ 'languageid' ];
157 $userinfo [ 'timezone' ] = $bugsys- > in
[ 'timezone' ];
158 $userinfo [ 'usedst' ] = $bugsys- > in
[ 'usedst' ];
159 $userinfo [ 'hidestatuses' ] = $bugsys- > in
[ 'hidestatuses' ];
160 $userinfo [ 'defaultsorkey' ] = $bugsys- > in
[ 'defaultsorkey' ];
161 $userinfo [ 'defaultsortas' ] = $bugsys- > in
[ 'defaultsortas' ];
162 $userinfo [ 'columnoptions' ] = $bugsys- > in
[ 'columnoptions' ];
164 $email = $bugsys- > in
[ 'email_change' ];
165 $email_confirm = $bugsys- > in
[ 'email_confirm' ];
167 // -------------------------------------------------------------------
169 if ( $message- > hasErrors ())
171 $show [ 'errors' ] = true ;
172 $_REQUEST [ 'do' ] = 'modify' ;
178 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "useremail WHERE userid = " . $bugsys- > userinfo
[ 'userid' ]);
179 $bugsys- > input_clean ( 'emailopts' , TYPE_INT
);
180 if ( is_array ( $bugsys- > in
[ 'emailopts' ]))
182 foreach ( $bugsys- > in
[ 'emailopts' ] AS $relation => $bitarr )
185 if ( is_array ( $bitarr ))
187 foreach ( $bitarr AS $option => $yes )
189 $bitmask +
= $option * $yes ;
192 $db- > query ( "INSERT INTO " . TABLE_PREFIX
. "useremail (userid, relation, mask) VALUES (" . $bugsys- > userinfo
[ 'userid' ] . ", $relation , $bitmask )" );
196 $message- > redirect ( T ( 'The changes to your account have been made.' ), 'userctrl.php' );
200 // ###################################################################
202 if ( $_REQUEST [ 'do' ] == 'modify' )
204 $langselect = construct_datastore_select ( 'language' , 'title' , 'languageid' , $userinfo [ 'languageid' ]);
206 $hidestatuses = construct_datastore_select ( 'status' , 'status' , 'statusid' , (! is_array ( $userinfo [ 'hidestatuses' ]) ? explode ( ',' , $userinfo [ 'hidestatuses' ]) : $userinfo [ 'hidestatuses' ]), 0 );
207 $hidestatusesnum = ( sizeof ( bugdar
:: $datastore [ 'status' ]) < 8 ? sizeof ( bugdar
:: $datastore [ 'status' ]) +
1 : 8 );
209 $defaultsortkey = construct_option_select ( 'defaultsortkey' , ListSorter
:: fetch_by_text ( false ), $userinfo [ 'defaultsortkey' ]);
210 $defaultsortas = construct_option_select ( 'defaultsortas' , ListSorter
:: fetch_as_text ( false ), $userinfo [ 'defaultsortas' ]);
212 foreach ( $datef- > fetch_timezone_list () AS $value => $label )
214 $selected = ( $value == $userinfo [ 'timezone' ]);
215 eval ( ' $tzselect .= "' . $template- > fetch ( 'selectoption' ) . '";' );
219 if (! is_array ( $bugsys- > in
[ 'emailopts' ]))
221 $options = $db- > query ( "SELECT * FROM " . TABLE_PREFIX
. "useremail WHERE userid = " . $bugsys- > userinfo
[ 'userid' ]);
222 while ( $opt = $db- > fetch_array ( $options ))
224 foreach ( $bugsys- > emailoptions
[ 'notifications' ] AS $name => $notif )
226 foreach ( $bugsys- > emailoptions
[ 'relations' ] AS $name => $relation )
228 if ( $opt [ 'mask' ] & $notif AND $opt [ 'relation' ] == $relation )
230 $checked [ " $relation" ][" $notif" ] = HTML_CHECKED
;
238 $checked = $bugsys- > in
[ 'emailopts' ];
239 foreach ( $checked AS $key1 => $value1 )
241 foreach ( $value1 AS $key2 => $value2 )
245 $checked [ " $key1" ][" $key2" ] = HTML_CHECKED
;
253 if (! is_array ( $bugsys- > in
[ 'columnoptions' ]))
255 foreach ( $bugsys- > columns
AS $column => $mask )
257 if ( is_array ( $bugsys- > userinfo
[ 'columnoptions' ]))
259 $columns [ " $column" ] = $bugsys- >userinfo['columnoptions'][" $column" ];
263 $columns [ " $column" ] = $bugsys- >options['columnoptions'][" $column" ];
265 eval ( ' $columnOptions .= "' . $template- > fetch ( 'userctrl_column' ) . '";' );
270 $columns = $bugsys- > in
[ 'columnoptions' ];
271 foreach ( $bugsys- > columns
AS $column => $mask )
273 eval ( ' $columnOptions .= "' . $template- > fetch ( 'userctrl_column' ) . '";' );
279 $searchesFetch = $db- > query ( "SELECT * FROM " . TABLE_PREFIX
. "search WHERE name IS NOT NULL AND userid = " . $bugsys- > userinfo
[ 'userid' ]);
280 while ( $search = $db- > fetch_array ( $searchesFetch ))
282 eval ( ' $searches .= "' . $template- > fetch ( 'userctrl_search' ) . '";' );
285 eval ( ' $template- >flush("' . $template- > fetch ( 'userctrl' ) . '");' );