Add setting "update_users_email_to_dummy_except_admins" see #12302

remotes/angel/1.11.x
Julio 8 years ago
parent 9b2763f7ea
commit ffb966dbc2
  1. 39
      main/cron/import_csv.php
  2. 3
      main/install/configuration.dist.php

@ -48,6 +48,7 @@ class ImportCsv
public $daysCoachAccessBeforeBeginning = 14;
public $daysCoachAccessAfterBeginning = 14;
public $conditions;
private $updateEmailToDummy;
/**
* @param Monolog\Logger $logger
@ -57,6 +58,7 @@ class ImportCsv
{
$this->logger = $logger;
$this->conditions = $conditions;
$this->updateEmailToDummy = false;
}
/**
@ -522,6 +524,8 @@ class ImportCsv
if ($moveFile) {
$this->moveFile($file);
}
$this->updateUsersEmails();
}
/**
@ -748,6 +752,8 @@ class ImportCsv
if ($moveFile) {
$this->moveFile($file);
}
$this->updateUsersEmails();
}
/**
@ -767,6 +773,8 @@ class ImportCsv
private function importCalendarStatic($file, $moveFile = true)
{
$this->fixCSVFile($file);
$this->updateUsersEmails();
$data = Import::csvToArray($file);
if (!empty($data)) {
@ -2253,6 +2261,35 @@ class ImportCsv
fwrite($f, '";');
}*/
}
/**
* @return mixed
*/
public function getUpdateEmailToDummy()
{
return $this->updateEmailToDummy;
}
/**
* @param mixed $updateEmailToDummy
*/
public function setUpdateEmailToDummy($updateEmailToDummy)
{
$this->updateEmailToDummy = $updateEmailToDummy;
}
/**
* Change emails of all users except admins
*
*/
public function updateUsersEmails()
{
if ($this->getUpdateEmailToDummy() === true) {
$sql = "UPDATE user SET email = CONCAT(username,'@example.com') WHERE id NOT IN (SELECT user_id FROM admin)";
Database::query($sql);
}
}
}
use Monolog\Logger;
@ -2310,6 +2347,8 @@ if (isset($_configuration['import_csv_disable_dump']) &&
$import->setDumpValues($dump);
}
$import->setUpdateEmailToDummy(api_get_configuration_value('update_users_email_to_dummy_except_admins'));
// Do not moves the files to treated
if (isset($_configuration['import_csv_test'])) {
$import->test = $_configuration['import_csv_test'];

@ -279,3 +279,6 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
// $_configuration['assignment_prevent_duplicate_upload'] = false;
// Set ConsideredWorkingTime work extra field variable to show in MyStudents page works report
// $_configuration['considered_working_time'] = 'work_time';
// During CSV special imports update users emails to x@example.com
// $_configuration['update_users_email_to_dummy_except_admins'] = false;

Loading…
Cancel
Save