Changeset 21 for trunk/admin/user_modify.php
- Timestamp:
- Jul 1, 2003, 11:27:20 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/user_modify.php
r10 r21 21 21 $tpl = array( 'adduser_info_message', 'adduser_info_back', 'adduser_fill_form', 22 22 'login', 'new', 'password', 'mail_address', 'adduser_status', 23 'submit', 'adduser_info_password_updated' ); 23 'submit', 'adduser_info_password_updated','menu_groups', 24 'dissociate','adduser_associate' ); 24 25 templatize_array( $tpl, 'lang', $sub ); 25 26 //--------------------------------------------------------- form criteria check … … 35 36 $query.= ';'; 36 37 $row = mysql_fetch_array( mysql_query( $query ) ); 37 38 $page['username'] = $row['username']; 39 $page['status'] = $row['status']; 40 $page['mail_address'] = $row['mail_address']; 38 41 // user is not modifiable if : 39 42 // 1. the selected user is the user "guest" … … 67 70 $_POST['password'] ) ); 68 71 } 72 // association with groups management 73 if ( isset( $_POST['submit'] ) ) 74 { 75 // deletion of checked groups 76 $query = 'SELECT id,name'; 77 $query.= ' FROM '.PREFIX_TABLE.'groups'; 78 $query.= ' ORDER BY id ASC'; 79 $query.= ';'; 80 $result = mysql_query( $query ); 81 while ( $row = mysql_fetch_array( $result ) ) 82 { 83 $dissociate = 'dissociate-'.$row['id']; 84 if ( $_POST[$dissociate] == 1 ) 85 { 86 $query = 'DELETE FROM '.PREFIX_TABLE.'user_group'; 87 $query.= ' WHERE user_id = '.$_GET['user_id']; 88 $query.= ' AND group_id ='.$row['id']; 89 $query.= ';'; 90 mysql_query( $query ); 91 } 92 } 93 // create a new association between the user and a group 94 $query = 'INSERT INTO '.PREFIX_TABLE.'user_group'; 95 $query.= ' (user_id,group_id) VALUES'; 96 $query.= ' ('.$_GET['user_id'].','.$_POST['associate'].')'; 97 $query.= ';'; 98 mysql_query( $query ); 99 } 69 100 //-------------------------------------------------------------- errors display 70 101 if ( sizeof( $error ) != 0 ) … … 83 114 { 84 115 $vtp->addSession( $sub, 'confirmation' ); 85 $vtp->setVar( $sub, 'confirmation.username', $ row['username'] );116 $vtp->setVar( $sub, 'confirmation.username', $page['username'] ); 86 117 $url = add_session_id( './admin.php?page=user_list' ); 87 118 $vtp->setVar( $sub, 'confirmation.url', $url ); … … 92 123 $vtp->closeSession( $sub, 'password_updated' ); 93 124 } 94 $display_form = false;95 125 } 96 126 //------------------------------------------------------------------------ form … … 100 130 $action = './admin.php?page=user_modify&user_id='.$_GET['user_id']; 101 131 $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'; 132 $vtp->setVar( $sub, 'form.user:username', $page['username'] ); 133 if ( isset( $_POST['mail_address'] ) ) 134 { 135 $page['mail_address'] = $_POST['mail_address']; 136 } 137 $vtp->setVar( $sub, 'form.user:mail_address', $page['mail_address'] ); 138 if ( isset( $_POST['status'] ) ) 139 { 140 $page['status'] = $_POST['status']; 109 141 } 110 142 $option = get_enums( PREFIX_TABLE.'users', 'status' ); … … 115 147 $vtp->setVar( $sub, 'status_option.option', 116 148 $lang['adduser_status_'.$option[$i]] ); 117 if( $option[$i] == $ _POST['status'] )149 if( $option[$i] == $page['status'] ) 118 150 { 119 151 $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' ); … … 121 153 $vtp->closeSession( $sub, 'status_option' ); 122 154 } 155 // groups linked with this user 156 $query = 'SELECT id,name'; 157 $query.= ' FROM '.PREFIX_TABLE.'user_group, '.PREFIX_TABLE.'groups'; 158 $query.= ' WHERE group_id = id'; 159 $query.= ' AND user_id = '.$_GET['user_id']; 160 $query.= ';'; 161 $result = mysql_query( $query ); 162 $user_groups = array(); 163 if ( mysql_num_rows( $result ) > 0 ) 164 { 165 $vtp->addSession( $sub, 'groups' ); 166 while ( $row = mysql_fetch_array( $result ) ) 167 { 168 $vtp->addSession( $sub, 'group' ); 169 $vtp->setVar( $sub, 'group.name', $row['name'] ); 170 $vtp->setVar( $sub, 'group.dissociate_id', $row['id'] ); 171 $vtp->closeSession( $sub, 'group' ); 172 array_push( $user_groups, $row['id'] ); 173 } 174 $vtp->closeSession( $sub, 'groups' ); 175 } 176 // empty group not to take into account 177 $vtp->addSession( $sub, 'associate_group' ); 178 $vtp->setVar( $sub, 'associate_group.value', 'undef' ); 179 $vtp->setVar( $sub, 'associate_group.option', '' ); 180 $vtp->closeSession( $sub, 'associate_group' ); 181 // groups not linked yet to the user 182 $query = 'SELECT id,name'; 183 $query.= ' FROM '.PREFIX_TABLE.'groups'; 184 $query.= ' ORDER BY id ASC'; 185 $query.= ';'; 186 $result = mysql_query( $query ); 187 while ( $row = mysql_fetch_array( $result ) ) 188 { 189 if ( !in_array( $row['id'], $user_groups ) ) 190 { 191 $vtp->addSession( $sub, 'associate_group' ); 192 $vtp->setVar( $sub, 'associate_group.value', $row['id'] ); 193 $vtp->setVar( $sub, 'associate_group.option', $row['name'] ); 194 $vtp->closeSession( $sub, 'associate_group' ); 195 } 196 } 197 123 198 $url = add_session_id( './admin.php?page=user_list' ); 124 199 $vtp->setVar( $sub, 'form.url_back', $url );
Note: See TracChangeset
for help on using the changeset viewer.