Merge branch 'hotfix/5.7.12'

This commit is contained in:
Yuri Kuznetsov
2020-01-21 10:30:20 +02:00
3 changed files with 46 additions and 23 deletions
@@ -99,6 +99,22 @@ class LDAP extends Espo
return $this->utils;
}
protected function getContainer()
{
return $this->getInjection('container');
}
protected function useSystemUser()
{
$systemUser = $this->getEntityManager()->getEntity('User', 'system');
if (!$systemUser) {
throw new Error("System user is not found.");
}
$this->getContainer()->setUser($systemUser);
$this->getEntityManager()->setUser($systemUser);
}
protected function getLdapClient()
{
if (!isset($this->ldapClient)) {
@@ -183,7 +199,12 @@ class LDAP extends Espo
]
]);
if (!isset($user) && $this->getUtils()->getOption('createEspoUser')) {
if (!isset($user)) {
if (!$this->getUtils()->getOption('createEspoUser')) {
$this->useSystemUser();
throw new Error($this->getContainer()->get('language')->translate('ldapUserInEspoNotFound', 'messages', 'User'));
}
$userData = $ldapClient->getEntry($userDn);
$user = $this->createUser($userData, $isPortal);
}
@@ -283,18 +304,11 @@ class LDAP extends Espo
$data[$fieldName] = $fieldValue;
}
$entityManager = $this->getEntityManager();
$this->useSystemUser();
$systemUser = $entityManager->getEntity('User', 'system');
if (!$systemUser) {
throw new Error("System user is not found");
}
$this->getInjection('container')->setUser($systemUser);
$entityManager->setUser($systemUser);
$user = $entityManager->getEntity('User');
$user = $this->getEntityManager()->getEntity('User');
$user->set($data);
$entityManager->saveEntity($user);
$this->getEntityManager()->saveEntity($user);
return $this->getEntityManager()->getEntity('User', $user->id);
}
@@ -282,6 +282,9 @@ class Converter
protected function prepareManyMany($entityName, $relationParams, $tables)
{
$tableName = Util::toUnderScore($relationParams['relationName']);
$GLOBALS['log']->debug('DBAL: prepareManyMany invoked for ' . $entityName, [
'tableName' => $tableName, 'parameters' => $relationParams
]);
if ($this->getSchema()->hasTable($tableName)) {
$GLOBALS['log']->debug('DBAL: Table ['.$tableName.'] exists.');
@@ -297,17 +300,22 @@ class Converter
//add midKeys to a schema
$uniqueIndex = array();
foreach($relationParams['midKeys'] as $index => $midKey) {
$columnName = Util::toUnderScore($midKey);
$table->addColumn($columnName, $this->idParams['dbType'], $this->getDbFieldParams(array(
'type' => 'foreignId',
'len' => $this->idParams['len'],
)));
$table->addIndex(array($columnName), SchemaUtils::generateIndexName($columnName));
$uniqueIndex[] = $columnName;
}
if (empty($relationParams['midKeys'])) {
$GLOBALS['log']->debug('REBUILD: midKeys are empty!', [
'scope' => $entityName, 'tableName' => $tableName,
'parameters' => $relationParams
]);
} else {
foreach($relationParams['midKeys'] as $index => $midKey) {
$columnName = Util::toUnderScore($midKey);
$table->addColumn($columnName, $this->idParams['dbType'], $this->getDbFieldParams(array(
'type' => 'foreignId',
'len' => $this->idParams['len'],
)));
$table->addIndex(array($columnName), SchemaUtils::generateIndexName($columnName));
$uniqueIndex[] = $columnName;
}
}
//END: add midKeys to a schema
//add additionalColumns
@@ -109,7 +109,8 @@
"enterTotpCode": "Enter a code from your authenticator app.",
"verifyTotpCode": "Scan the QR-code with your mobile authenticator app. If you have a trouble with scanning, you can enter the secret manually. After that you will see a 6-digit code in your application. Enter this code in the field below.",
"generateAndSendNewPassword": "A new password will be generated and sent to the user's email address.",
"security2FaResetConfimation": "Are you sure you want to reset the current 2FA settings?"
"security2FaResetConfimation": "Are you sure you want to reset the current 2FA settings?",
"ldapUserInEspoNotFound": "User is not found in EspoCRM. Contact your administrator to create the user."
},
"options": {
"gender": {