|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
<?php // $Id: user_add.php 17362 2008-12-17 23:21:17Z cfasanando $
|
|
|
|
|
<?php // $Id: user_add.php 17479 2008-12-29 20:24:11Z cfasanando $
|
|
|
|
|
/* |
|
|
|
|
============================================================================== |
|
|
|
|
Dokeos - elearning and course management software |
|
|
|
@ -316,14 +316,44 @@ if( $form->validate()) |
|
|
|
|
$picture_element = & $form->getElement('picture'); |
|
|
|
|
$picture = $picture_element->getValue(); |
|
|
|
|
$picture_uri = ''; |
|
|
|
|
if (strlen($picture['name']) > 0 ) { |
|
|
|
|
$picture_uri = uniqid('').'_'.replace_dangerous_char($picture['name']); |
|
|
|
|
} |
|
|
|
|
$lastname = $user['lastname']; |
|
|
|
|
$firstname = $user['firstname']; |
|
|
|
|
$official_code = $user['official_code']; |
|
|
|
|
$email = $user['email']; |
|
|
|
|
$phone = $user['phone']; |
|
|
|
|
$username = $user['username']; |
|
|
|
|
$status = intval($user['status']); |
|
|
|
|
$picture = $_FILES['picture']; |
|
|
|
|
$platform_admin = intval($user['admin']['platform_admin']); |
|
|
|
|
$send_mail = intval($user['mail']['send_mail']); |
|
|
|
|
$hr_dept_id = intval($user['hr_dept_id']); |
|
|
|
|
if(count($extAuthSource) > 0 && $user['password']['password_auto'] == '2') |
|
|
|
|
{ |
|
|
|
|
$auth_source = $user['password']['auth_source']; |
|
|
|
|
$password = 'PLACEHOLDER'; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$auth_source = PLATFORM_AUTH_SOURCE; |
|
|
|
|
$password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; |
|
|
|
|
} |
|
|
|
|
if ($user['radio_expiration_date']=='1' ) |
|
|
|
|
{ |
|
|
|
|
$expiration_date=$user['expiration_date']; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$expiration_date='0000-00-00 00:00:00'; |
|
|
|
|
} |
|
|
|
|
$active = intval($user['active']); |
|
|
|
|
|
|
|
|
|
$user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active, $hr_dept_id); |
|
|
|
|
|
|
|
|
|
// get the next id from a user |
|
|
|
|
$sql = "SHOW TABLE STATUS FROM $database LIKE 'user'"; |
|
|
|
|
$result = api_sql_query($sql,__FILE__,__LINE__); |
|
|
|
|
$array = Database::fetch_array($result); |
|
|
|
|
$auto_increment = $array['Auto_increment']; |
|
|
|
|
// picture path |
|
|
|
|
$picture_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$auto_increment.'/'; |
|
|
|
|
$picture_path = api_get_path(SYS_CODE_PATH).'upload/users/'.$user_id.'/'; |
|
|
|
|
|
|
|
|
|
if (strlen($picture['name']) > 0 ) { |
|
|
|
|
if (!is_dir($picture_path)) { |
|
|
|
@ -333,7 +363,6 @@ if( $form->validate()) |
|
|
|
|
chmod($picture_path,$perm); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$picture_uri = uniqid('').'_'.replace_dangerous_char($picture['name']); |
|
|
|
|
$picture_location = $picture_path.$picture_uri; |
|
|
|
|
$big_picture_location = $picture_path.'big_'.$picture_uri; |
|
|
|
|
|
|
|
|
@ -366,38 +395,6 @@ if( $form->validate()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
$lastname = $user['lastname']; |
|
|
|
|
$firstname = $user['firstname']; |
|
|
|
|
$official_code = $user['official_code']; |
|
|
|
|
$email = $user['email']; |
|
|
|
|
$phone = $user['phone']; |
|
|
|
|
$username = $user['username']; |
|
|
|
|
$status = intval($user['status']); |
|
|
|
|
$picture = $_FILES['picture']; |
|
|
|
|
$platform_admin = intval($user['admin']['platform_admin']); |
|
|
|
|
$send_mail = intval($user['mail']['send_mail']); |
|
|
|
|
$hr_dept_id = intval($user['hr_dept_id']); |
|
|
|
|
if(count($extAuthSource) > 0 && $user['password']['password_auto'] == '2') |
|
|
|
|
{ |
|
|
|
|
$auth_source = $user['password']['auth_source']; |
|
|
|
|
$password = 'PLACEHOLDER'; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$auth_source = PLATFORM_AUTH_SOURCE; |
|
|
|
|
$password = $user['password']['password_auto'] == '1' ? api_generate_password() : $user['password']['password']; |
|
|
|
|
} |
|
|
|
|
if ($user['radio_expiration_date']=='1' ) |
|
|
|
|
{ |
|
|
|
|
$expiration_date=$user['expiration_date']; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$expiration_date='0000-00-00 00:00:00'; |
|
|
|
|
} |
|
|
|
|
$active = intval($user['active']); |
|
|
|
|
|
|
|
|
|
$user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active, $hr_dept_id); |
|
|
|
|
|
|
|
|
|
$extras = array(); |
|
|
|
|
foreach($user as $key => $value) |
|
|
|
|