Changeset 25116 for trunk/include/functions_user.inc.php
- Timestamp:
- Oct 24, 2013, 3:01:25 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.