Script: Cron: add authsource importation and also add a variable to configure the path to the csv files - refs BT#20351

pull/5766/head
NicoDucou 3 months ago
parent 6565166a93
commit 7dc242a5c9
  1. 6
      tests/scripts/synchronize_user_base_from_csv.php

@ -22,6 +22,9 @@ exit;
// Change this to the absolute path to chamilo root folder if you move the script out of tests/scripts // Change this to the absolute path to chamilo root folder if you move the script out of tests/scripts
$chamiloRoot = __DIR__.'/../../public'; $chamiloRoot = __DIR__.'/../../public';
// Change this to the absolute path to the folder of the csv files (by default it is in the same folder as the script)
$CSVFilesPath = '.';
// Set to true in order to get a trace of changes made by this script // Set to true in order to get a trace of changes made by this script
$debug = true; $debug = true;
@ -104,7 +107,7 @@ if ($firstAdmin) {
$accessUrls = api_get_access_urls(0, 100000, 'id'); $accessUrls = api_get_access_urls(0, 100000, 'id');
foreach ($accessUrls as $accessUrl) { foreach ($accessUrls as $accessUrl) {
$accessUrlId = $accessUrl['id']; $accessUrlId = $accessUrl['id'];
$filename = $chamiloRoot . "/../tests/scripts/url_" . $accessUrlId . "_synchroUsers.csv"; $filename = $CSVFilesPath . "/url_" . $accessUrlId . "_synchroUsers.csv";
if (!file_exists($filename)) { if (!file_exists($filename)) {
if ($debug) { if ($debug) {
@ -135,6 +138,7 @@ foreach ($accessUrls as $accessUrl) {
'active' => 'setActive', 'active' => 'setActive',
'language' => 'setLocale', 'language' => 'setLocale',
'password' => 'setPlainPassword' 'password' => 'setPlainPassword'
'authsource' => 'setAuthSource'
]; ];
// Create new user accounts found in the CSV and update the existing ones, re-enabling if necessary // Create new user accounts found in the CSV and update the existing ones, re-enabling if necessary

Loading…
Cancel
Save