diff --git a/public/main/admin/course_import.php b/public/main/admin/course_import.php index bb00f572d5c..9ec28218d8b 100644 --- a/public/main/admin/course_import.php +++ b/public/main/admin/course_import.php @@ -7,6 +7,8 @@ * Copyright (c) 2005 Bart Mollet . */ +use Chamilo\CoreBundle\Entity\UserAuthSource; + /** * Validates imported data. * @@ -167,7 +169,7 @@ function parse_csv_courses_data($file) $this_section = SECTION_PLATFORM_ADMIN; api_protect_admin_script(); -$defined_auth_sources[] = PLATFORM_AUTH_SOURCE; +$defined_auth_sources[] = UserAuthSource::PLATFORM; if (isset($extAuthSource) && is_array($extAuthSource)) { $defined_auth_sources = array_merge($defined_auth_sources, array_keys($extAuthSource)); diff --git a/public/main/admin/ldap_synchro.php b/public/main/admin/ldap_synchro.php index 34ec98897f8..72f7e149c0f 100644 --- a/public/main/admin/ldap_synchro.php +++ b/public/main/admin/ldap_synchro.php @@ -95,7 +95,7 @@ $password = $val[0]; // Pour faciliter la gestion on ajoute le code "etape-annee" $official_code = $etape."-".$annee; - $auth_source = "ldap"; + $auth_source = ["ldap"]; // Pas de date d'expiration d'etudiant (a recuperer par rapport au shadow expire LDAP) $expiration_date = ''; $active = 1; @@ -126,7 +126,7 @@ $lastname, $username, null, - null, + [], $email, $status, $official_code, diff --git a/public/main/admin/user_add.php b/public/main/admin/user_add.php index 3a48c1fa68d..9aed0cb9d7f 100644 --- a/public/main/admin/user_add.php +++ b/public/main/admin/user_add.php @@ -2,8 +2,12 @@ /* For licensing terms, see /license.txt */ +use Chamilo\CoreBundle\Entity\AccessUrl; use Chamilo\CoreBundle\Entity\User; +use Chamilo\CoreBundle\Entity\UserAuthSource; use Chamilo\CoreBundle\Framework\Container; +use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper; +use Chamilo\CoreBundle\ServiceHelper\AuthenticationConfigHelper; $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; @@ -15,6 +19,12 @@ api_protect_admin_script(true); api_protect_limit_for_session_admin(); +/** @var AuthenticationConfigHelper $authenticationConfigHelper */ +$authenticationConfigHelper = Container::$container->get(AuthenticationConfigHelper::class); + +/** @var AccessUrl $accessUrl */ +$accessUrl = Container::$container->get(AccessUrlHelper::class)->getCurrent(); + $is_platform_admin = api_is_platform_admin() ? 1 : 0; $message = null; @@ -175,23 +185,24 @@ function updateStatus(){ // Password $group = []; +$extAuthSource = $authenticationConfigHelper->getAuthSourceAuthentications($accessUrl); $auth_sources = 0; //make available wider as we need it in case of form reset (see below) $nb_ext_auth_source_added = 0; -if (isset($extAuthSource) && count($extAuthSource) > 0) { +if (count($extAuthSource) > 0) { $auth_sources = []; - foreach ($extAuthSource as $key => $info) { + foreach ($extAuthSource as $key) { // @todo : make uniform external authentification configuration (ex : cas and external_login ldap) // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS // extAuthSource always on for CAS even if not activated // same action for file user_edit.php - if ((CAS_AUTH_SOURCE == $key && 'true' === api_get_setting('cas_activate')) || (CAS_AUTH_SOURCE != $key)) { + if ((UserAuthSource::CAS == $key && 'true' === api_get_setting('cas_activate')) || (UserAuthSource::CAS != $key)) { $auth_sources[$key] = $key; $nb_ext_auth_source_added++; } } if ($nb_ext_auth_source_added > 0) { $group[] = $form->createElement('radio', 'password_auto', null, get_lang('External authentification').' ', 2); - $group[] = $form->createElement('select', 'auth_source', null, $auth_sources); + $group[] = $form->createElement('select', 'auth_source', null, $auth_sources, ['multiple' => 'multiple']); $group[] = $form->createElement('static', '', '', '
'); } } @@ -366,7 +377,7 @@ function updateStatus(){ $auth_source = $user['password']['auth_source']; $password = 'PLACEHOLDER'; } else { - $auth_source = PLATFORM_AUTH_SOURCE; + $auth_source = [UserAuthSource::PLATFORM]; $password = '1' === $user['password']['password_auto'] ? api_generate_password() : $user['password']['password']; } diff --git a/public/main/admin/user_edit.php b/public/main/admin/user_edit.php index 720b4a741ab..c3168a8a107 100644 --- a/public/main/admin/user_edit.php +++ b/public/main/admin/user_edit.php @@ -2,8 +2,12 @@ /* For licensing terms, see /license.txt */ +use Chamilo\CoreBundle\Entity\AccessUrl; use Chamilo\CoreBundle\Entity\User; +use Chamilo\CoreBundle\Entity\UserAuthSource; use Chamilo\CoreBundle\Framework\Container; +use Chamilo\CoreBundle\ServiceHelper\AccessUrlHelper; +use Chamilo\CoreBundle\ServiceHelper\AuthenticationConfigHelper; use ChamiloSession as Session; use Chamilo\CoreBundle\Component\Utils\ActionIcon; @@ -21,6 +25,12 @@ $userObj = api_get_user_entity($user_id); $illustrationRepo = Container::getIllustrationRepository(); +/** @var AuthenticationConfigHelper $authenticationConfigHelper */ +$authenticationConfigHelper = Container::$container->get(AuthenticationConfigHelper::class); + +/** @var AccessUrl $accessUrl */ +$accessUrl = Container::$container->get(AccessUrlHelper::class)->getCurrent(); + $htmlHeadXtra[] = '