From 3b6b96b9e19b0ef402fea3f7f73c4cce84886ab0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 27 May 2021 09:08:49 +0200 Subject: [PATCH] Fix user creation --- public/main/admin/user_add.php | 19 ++++++++++++------- public/main/inc/lib/usermanager.lib.php | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/public/main/admin/user_add.php b/public/main/admin/user_add.php index 09ae00c2c9..d044e32625 100644 --- a/public/main/admin/user_add.php +++ b/public/main/admin/user_add.php @@ -5,7 +5,6 @@ use Chamilo\CoreBundle\Framework\Container; $cidReset = true; -// Including necessary libraries. require_once __DIR__.'/../inc/global.inc.php'; // Section for the tabs @@ -341,8 +340,7 @@ $form->addGroup($html_results_enabled); if ($form->validate()) { $check = Security::check_token('post'); if (true) { - $user = $form->exportValues(); - + $user = $form->getSubmitValues(); $lastname = $user['lastname']; $firstname = $user['firstname']; $official_code = $user['official_code']; @@ -352,8 +350,15 @@ if ($form->validate()) { $status = (int) $user['status']; $language = $user['language']; $picture = $_FILES['picture']; - $platform_admin = (int) $user['admin']['platform_admin']; - $send_mail = (int) $user['mail']['send_mail']; + $platform_admin = 0; + if (isset($user['admin']) && isset($user['admin']['platform_admin'])) { + $platform_admin = (int) $user['admin']['platform_admin']; + } + $send_mail = 0; + if (isset($user['mail']) && isset($user['mail']['send_mail'])) { + $send_mail = (int) $user['mail']['send_mail']; + } + $hr_dept_id = isset($user['hr_dept_id']) ? (int) $user['hr_dept_id'] : 0; if (isset($extAuthSource) && count($extAuthSource) > 0 && @@ -363,11 +368,11 @@ if ($form->validate()) { $password = 'PLACEHOLDER'; } else { $auth_source = PLATFORM_AUTH_SOURCE; - $password = '1' == $user['password']['password_auto'] ? api_generate_password() : $user['password']['password']; + $password = '1' === $user['password']['password_auto'] ? api_generate_password() : $user['password']['password']; } $expiration_date = null; - if ('1' == $user['radio_expiration_date']) { + if ('1' === $user['radio_expiration_date']) { $expiration_date = $user['expiration_date']; } diff --git a/public/main/inc/lib/usermanager.lib.php b/public/main/inc/lib/usermanager.lib.php index 4deb45672b..4b6dab8d92 100644 --- a/public/main/inc/lib/usermanager.lib.php +++ b/public/main/inc/lib/usermanager.lib.php @@ -1948,7 +1948,7 @@ class UserManager * When deletion is requested returns empty string. * In case of internal error or negative validation returns FALSE. */ - public static function update_user_picture($userId, UploadedFile $file, $crop = '') + public static function update_user_picture($userId, UploadedFile $file, string $crop = '') { if (empty($userId) || empty($file)) { return false;