Changeset 9 for trunk/admin/user_modify.php
- Timestamp:
- May 13, 2003, 12:02:06 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/user_modify.php
r8 r9 19 19 $sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_modify.vtp' ); 20 20 $error = array(); 21 $tpl = array( 'user_err_modify', 'user_err_unknown' ); 22 templatize_array( $tpl, 'lang' ); 21 $tpl = array( 'adduser_info_message', 'adduser_info_back', 'adduser_fill_form', 22 'login', 'new', 'password', 'mail_address', 'adduser_status', 23 'submit', 'adduser_info_password_updated' ); 24 templatize_array( $tpl, 'lang', $sub ); 23 25 //--------------------------------------------------------- form criteria check 26 $error = array(); 24 27 $display_form = true; 25 28 29 // retrieving information in the database about the user identified by its 30 // id in $_GET['user_id'] 26 31 $query = 'select'; 27 32 $query.= ' username,status,mail_address'; … … 31 36 $row = mysql_fetch_array( mysql_query( $query ) ); 32 37 33 $username = $row['username']; 34 $status = $row['status']; 35 $mail_address = $row['mail_address']; 36 37 if ( $ username== 'guest'38 or ( $ username== $conf['webmaster']38 // user is not modifiable if : 39 // 1. the selected user is the user "guest" 40 // 2. the selected user is the webmaster and the user making the modification 41 // is not the webmaster 42 if ( $row['username'] == 'guest' 43 or ( $row['username'] == $conf['webmaster'] 39 44 and $user['username'] != $conf['webmaster'] ) ) 40 45 { 41 $vtp->addSession( $sub, 'err_modify' ); 42 $vtp->closeSession( $sub, 'err_modify' ); 46 array_push( $error, $lang['user_err_modify'] ); 43 47 $display_form = false; 44 48 } 45 if ( $username == '' ) 49 // if the user was not found in the database, no modification possible 50 if ( $row['username'] == '' ) 46 51 { 47 $vtp->addSession( $sub, 'err_unknown' ); 48 $vtp->closeSession( $sub, 'err_unknown' ); 52 array_push( $error, $lang['user_err_unknown'] ); 49 53 $display_form = false; 50 54 } 51 55 52 if ( $display_formand isset( $_POST['submit'] ) )56 if ( sizeof( $error ) == 0 and isset( $_POST['submit'] ) ) 53 57 { 58 // shall we use a new password and overwrite the old one ? 54 59 $use_new_password = false; 55 60 if ( $_POST['use_new_pwd'] == 1) … … 57 62 $use_new_password = true; 58 63 } 59 $error = update_user( 60 $_GET['user_id'], $_POST['mail_address'], $_POST['status'], 61 $use_new_password, $POST['password'] ); 64 $error = array_merge( $error, update_user( 65 $_GET['user_id'], $_POST['mail_address'], 66 $_POST['status'], $use_new_password, 67 $_POST['password'] ) ); 62 68 } 69 //-------------------------------------------------------------- errors display 70 if ( sizeof( $error ) != 0 ) 71 { 72 $vtp->addSession( $sub, 'errors' ); 73 for ( $i = 0; $i < sizeof( $error ); $i++ ) 74 { 75 $vtp->addSession( $sub, 'li' ); 76 $vtp->setVar( $sub, 'li.li', $error[$i] ); 77 $vtp->closeSession( $sub, 'li' ); 78 } 79 $vtp->closeSession( $sub, 'errors' ); 80 } 81 //---------------------------------------------------------------- confirmation 82 if ( sizeof( $error ) == 0 and isset( $_POST['submit'] ) ) 83 { 84 $vtp->addSession( $sub, 'confirmation' ); 85 $vtp->setVar( $sub, 'confirmation.username', $row['username'] ); 86 $url = add_session_id( './admin.php?page=user_list' ); 87 $vtp->setVar( $sub, 'confirmation.url', $url ); 88 $vtp->closeSession( $sub, 'confirmation' ); 89 if ( $use_new_pwd ) 90 { 91 $vtp->addSession( $sub, 'password_updated' ); 92 $vtp->closeSession( $sub, 'password_updated' ); 93 } 94 $display_form = false; 95 } 96 //------------------------------------------------------------------------ form 97 if ( $display_form ) 98 { 99 $vtp->addSession( $sub, 'form' ); 100 $action = './admin.php?page=user_modify&user_id='.$_GET['user_id']; 101 $vtp->setVar( $sub, 'form.form_action', add_session_id( $action ) ); 102 $vtp->setVar( $sub, 'form.user:username', $row['username'] ); 103 $vtp->setVar( $sub, 'form.user:password', $_POST['password'] ); 104 $vtp->setVar( $sub, 'form.user:mail_address', $_POST['mail_address'] ); 105 106 if ( !isset( $_POST['status'] ) ) 107 { 108 $_POST['status'] = 'guest'; 109 } 110 $option = get_enums( $prefixeTable.'users', 'status' ); 111 for ( $i = 0; $i < sizeof( $option ); $i++ ) 112 { 113 $vtp->addSession( $sub, 'status_option' ); 114 $vtp->setVar( $sub, 'status_option.value', $option[$i] ); 115 $vtp->setVar( $sub, 'status_option.option', 116 $lang['adduser_status_'.$option[$i]] ); 117 if( $option[$i] == $_POST['status'] ) 118 { 119 $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' ); 120 } 121 $vtp->closeSession( $sub, 'status_option' ); 122 } 123 $url = add_session_id( './admin.php?page=user_list' ); 124 $vtp->setVar( $sub, 'form.url_back', $url ); 125 $vtp->closeSession( $sub, 'form' ); 126 } 127 //----------------------------------------------------------- sending html code 128 $vtp->Parse( $handle , 'sub', $sub ); 63 129 ?>
Note: See TracChangeset
for help on using the changeset viewer.