]>
src.bluestatic.org Git - bugdar.git/blob - user.php
b33f19f2eae32455cfba6c2f4abc8d1330960e7f
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 require_once ( './global.php' );
15 if (! can_perform ( 'canadminusers' ))
20 // ###################################################################
22 if ( empty ( $_REQUEST [ 'do' ]))
24 $_REQUEST [ 'do' ] = 'modify' ;
27 // ###################################################################
29 if ( $_REQUEST [ 'do' ] == 'kill' )
31 $user = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval ( $bugsys- > in
[ 'userid' ]));
34 $admin- > error ( $lang- > getlex ( 'error_invalid_id' ));
37 if ( $user [ 'userid' ] == $bugsys- > userinfo
[ 'userid' ])
39 $admin- > error ( $lang- > string ( 'You cannot delete your own account!' ));
42 if ( $user [ 'usergroupid' ] == 6 )
44 $count = $db- > query_first ( "SELECT COUNT(*) AS count FROM " . TABLE_PREFIX
. "user WHERE usergroupid = 6 AND userid <> $user [userid]" );
45 if ( $count [ 'count' ] < 1 )
47 $admin- > error ( $lang- > string ( 'At least one other administrator needs to be present before you can delete this user' ));
51 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "user WHERE userid = $user [userid]" );
52 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "favourite WHERE userid = $user [userid]" );
53 $db- > query ( "DELETE FROM " . TABLE_PREFIX
. "useractivation WHERE userid = $user [userid]" );
55 $admin- > redirect ( 'user.php' );
58 // ###################################################################
60 if ( $_REQUEST [ 'do' ] == 'delete' )
62 $admin- > page_confirm ( $lang- > string ( 'Are you sure you want to delete this user?' ), 'user.php?do=kill&userid=' . intval ( $bugsys- > in
[ 'userid' ]));
65 // ###################################################################
67 if ( $_POST [ 'do' ] == 'insert' )
69 $salt = $funct- > rand ( 15 );
72 INSERT INTO " . TABLE_PREFIX
. "user
73 (email, displayname, password, salt, authkey, showemail, showcolours, languageid, usergroupid, timezone)
75 ('" . $bugsys- > in
[ 'email' ] . "',
76 '" . $bugsys- > in
[ 'displayname' ] . "',
77 '" . md5 ( md5 ( $bugsys- > in
[ 'password' ]) . md5 ( $salt )) . "',
79 '" . $funct- > rand () . "',
80 " . intval ( $bugsys- > in
[ 'showemail' ]) . ",
81 " . intval ( $bugsys- > in
[ 'showcolours' ]) . ",
82 " . intval ( $bugsys- > in
[ 'languageid' ]) . ",
83 " . intval ( $bugsys- > in
[ 'usergroupid' ]) . ",
84 " . intval ( $bugsys- > in
[ 'timezone' ]) . "
90 $admin- > redirect ( 'user.php?do=edit&userid=' . $db- > insert_id ());
93 // ###################################################################
95 if ( $_POST [ 'do' ] == 'update' )
97 $user = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval ( $bugsys- > in
[ 'userid' ]));
100 $admin- > error ( $lang- > getlex ( 'error_invalid_id' ));
104 UPDATE " . TABLE_PREFIX
. "user
105 SET displayname = '" . $bugsys- > in
[ 'displayname' ] . "',
106 email = '" . $bugsys- > in
[ 'email' ] . "',
107 showcolours = " . intval ( $bugsys- > in
[ 'showcolours' ]) . ",
108 usergroupid = " . intval ( $bugsys- > in
[ 'usergroupid' ]) . ",
109 languageid = " . intval ( $bugsys- > in
[ 'languageid' ]) . ",
110 timezone = " . intval ( $bugsys- > in
[ 'timezone' ]) . ( $bugsys- > in
[ 'password' ] ? ",
111 password = '" . md5 ( md5 ( $bugsys- > in
[ 'password' ]) . md5 ( $user [ 'salt' ])) . "'" : '' ) . "
112 WHERE userid = $user [userid]"
117 $admin- > redirect ( 'user.php?do=edit&userid=' . $user [ 'userid' ]);
120 // ###################################################################
122 if ( $_REQUEST [ 'do' ] == 'edit' OR $_REQUEST [ 'do' ] == 'add' )
124 $add = ( $_REQUEST [ 'do' ] == 'add' );
129 $user = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval ( $bugsys- > in
[ 'userid' ]));
132 $admin- > error ( $lang- > getlex ( 'error_invalid_id' ));
136 $admin- > page_start (( $add ? $lang- > string ( 'Add User' ) : $lang- > string ( 'Edit User' )), 2 , 'user_manage' );
138 $admin- > form_start ( 'user.php' , ( $add ? 'insert' : 'update' ));
142 $admin- > form_hidden_field ( 'userid' , $user [ 'userid' ]);
145 $admin- > table_start ();
147 $admin- > table_head (( $add ? $lang- > string ( 'Add User' ) : sprintf ( $lang- > string ( 'Edit User (userid: %1 $s )' ), $user [ 'userid' ])));
149 $admin- > row_input ( $lang- > string ( 'Display Name' ), 'displayname' , $user [ 'displayname' ]);
150 $admin- > row_input ( $lang- > string ( 'Email' ), 'email' , $user [ 'email' ]);
151 $admin- > row_input (( $add ? $lang- > string ( 'Password' ) : $lang- > string ( 'Password (Leave blank for no change)' )), 'password' );
153 foreach ( $bugsys- > datastore
[ 'usergroup' ] AS $group )
155 $admin- > list_item ( $group [ 'title' ], $group [ 'usergroupid' ], ( $user [ 'usergroupid' ] == $group [ 'usergroupid' ]));
157 $admin- > row_list ( $lang- > string ( 'Usergroup' ), 'usergroupid' );
159 $admin- > row_yesno ( $lang- > string ( 'Show Email Publicly' ), 'showemail' , $user [ 'showemail' ]);
160 $admin- > row_yesno ( $lang- > string ( 'Show Status Colours on Bug Listings' ), 'showcolours' , $user [ 'showcolours' ]);
162 foreach ( $bugsys- > datastore
[ 'language' ] AS $language )
164 $admin- > list_item ( $language [ 'title' ], $language [ 'languageid' ], ( $user [ 'languageid' ] == $language [ 'languageid' ]));
166 $admin- > row_list ( $lang- > string ( 'Language' ), 'languageid' );
168 foreach ( $datef- > fetch_timezone_list () AS $value => $string )
170 $admin- > list_item ( $string , $value , ( $user [ 'timezone' ] == $value ));
172 $admin- > row_list ( $lang- > string ( 'Timezone' ), 'timezone' );
174 $admin- > row_submit (( $edit ? '<a href="user.php?do=delete&userid=' . $user [ 'userid' ] . '">[' . $lang- > string ( 'Delete' ) . ']</a>' : '' ), ':save:' , ':reset:' , 4 );
182 // ###################################################################
184 if ( $_REQUEST [ 'do' ] == 'search' )
188 if ( is_numeric ( $bugsys- > in
[ 'userdata' ]))
190 if ( $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "user WHERE userid = " . intval ( $bugsys- > in
[ 'userdata' ])))
192 header ( 'Location: user.php?do=edit&userid=' . intval ( $bugsys- > in
[ 'userdata' ]));
201 $bugsys- > in
[ 'userdata' ] = str_replace ( '%' , '\%' , $bugsys- > in
[ 'userdata' ]);
202 $results = $db- > query ( "SELECT * FROM " . TABLE_PREFIX
. "user WHERE email LIKE '%" . $bugsys- > in
[ 'userdata' ] . "%' OR displayname LIKE '%" . $bugsys- > in
[ 'userdata' ] . "%'" );
204 if ( $db- > num_rows ( $results ) < 1 )
210 $admin- > page_start ( $lang- > string ( 'Search Results' ));
212 $admin- > table_start ();
213 $admin- > table_head ( $lang- > string ( 'Search Results' ), 4 );
214 $admin- > table_column_head ( array ( $lang- > string ( 'Display Name' ), $lang- > string ( 'Email' ), $lang- > string ( 'User ID' ), $lang- > string ( 'Actions' )));
216 while ( $row = $db- > fetch_array ( $results ))
218 $admin- > row_multi_item ( array (
219 $row [ 'displayname' ] => 'l' ,
220 $row [ 'email' ] => 'c' ,
221 $row [ 'userid' ] => 'c' ,
222 '<a href="user.php?do=edit&userid=' . $row [ 'userid' ] . '">[' . $lang- > string ( 'Edit' ) . ']</a>' => 'c'
234 $admin- > error ( $lang- > string ( 'Sorry, we could not find any users that matched your criteria.' ));
238 // ###################################################################
240 if ( $_REQUEST [ 'do' ] == 'modify' )
242 $admin- > page_start ( $lang- > string ( 'User Search' ));
244 $admin- > form_start ( 'user.php' , 'search' );
245 $admin- > table_start ( true , '45%' );
247 $admin- > table_head ( $lang- > string ( 'User Search' ), 2 , 'user_manage' );
248 $admin- > row_input ( $lang- > string ( 'Name/Email/ID' ), 'userdata' );
250 $admin- > row_submit ( '' , ':save:' , '' );
258 /*=====================================================================*\
259 || ###################################################################
262 || ###################################################################
263 \*=====================================================================*/