Changeset 25116
- Timestamp:
- Oct 24, 2013, 3:01:25 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/user_list.php
r25018 r25116 205 205 else 206 206 { 207 $page['errors'] = register_user( 208 $_POST['login'], $_POST['password'], $_POST['email'], false); 207 register_user($_POST['login'], 208 $_POST['password'], 209 $_POST['email'], 210 false, 211 $page['errors']); 209 212 210 213 if (count($page['errors']) == 0) … … 219 222 if (isset($_POST['submit_add'])) 220 223 { 221 $page['errors'] = register_user( 222 $_POST['login'], $_POST['password'], $_POST['email'], false); 224 register_user($_POST['login'], 225 $_POST['password'], 226 $_POST['email'], 227 false, 228 $page['errors']); 223 229 224 230 if (count($page['errors']) == 0) -
trunk/include/functions_user.inc.php
r25019 r25116 120 120 return $users_found[0]; 121 121 } 122 123 /** 124 * create a new user 125 * @param string $login 126 * @param string $password 127 * @param string $mail_adress 128 * @param bool $with_notifications 129 * @param &array $errors 130 * @return int|bool 131 */ 122 132 function register_user($login, $password, $mail_address, 123 $with_notification = true, $errors = array())133 $with_notification = true, &$errors = array()) 124 134 { 125 135 global $conf; … … 172 182 if (count($errors) == 0) 173 183 { 174 // what will be the inserted id ?175 $query = '176 SELECT MAX('.$conf['user_fields']['id'].') + 1177 FROM '.USERS_TABLE.'178 ;';179 list($next_id) = pwg_db_fetch_row(pwg_query($query));180 181 184 $insert = 182 185 array( 183 $conf['user_fields']['id'] => $next_id,184 186 $conf['user_fields']['username'] => pwg_db_real_escape_string($login), 185 187 $conf['user_fields']['password'] => $conf['password_hash']($password), … … 188 190 189 191 single_insert(USERS_TABLE, $insert); 192 $user_id = pwg_db_insert_id(); 190 193 191 194 // Assign by default groups 192 { 193 $query = ' 195 $query = ' 194 196 SELECT id 195 197 FROM '.GROUPS_TABLE.' … … 197 199 ORDER BY id ASC 198 200 ;'; 199 $result = pwg_query($query); 200 201 $inserts = array(); 202 while ($row = pwg_db_fetch_assoc($result)) 203 { 204 $inserts[] = array( 205 'user_id' => $next_id, 206 'group_id' => $row['id'] 207 ); 208 } 201 $result = pwg_query($query); 202 203 $inserts = array(); 204 while ($row = pwg_db_fetch_assoc($result)) 205 { 206 $inserts[] = array( 207 'user_id' => $user_id, 208 'group_id' => $row['id'] 209 ); 209 210 } 210 211 … … 220 221 $override=null; 221 222 } 222 create_user_infos($ next_id, $override);223 create_user_infos($user_id, $override); 223 224 224 225 if ($with_notification and $conf['email_admin_on_new_user']) … … 245 246 trigger_action('register_user', 246 247 array( 247 'id'=>$ next_id,248 'id'=>$user_id, 248 249 'username'=>$login, 249 250 'email'=>$mail_address, 250 251 ) 251 252 ); 252 } 253 254 return $errors; 253 254 return $user_id; 255 } 256 else 257 { 258 return false; 259 } 255 260 } 256 261 -
trunk/include/user.inc.php
r20599 r25116 61 61 if (!($user['id'] = get_userid($remote_user))) 62 62 { 63 register_user($remote_user, '', '', false); 64 $user['id'] = get_userid($remote_user); 63 $user['id'] = register_user($remote_user, '', '', false); 65 64 } 66 65 } -
trunk/register.php
r25018 r25116 53 53 } 54 54 55 $page['errors'] = 56 register_user($_POST['login'], 57 $_POST['password'], 58 $_POST['mail_address'], 59 true, 60 $page['errors']); 55 register_user($_POST['login'], 56 $_POST['password'], 57 $_POST['mail_address'], 58 true, 59 $page['errors']); 61 60 62 61 if (count($page['errors']) == 0)
Note: See TracChangeset
for help on using the changeset viewer.