Skip to content

EspoCRM – Open Source CRM Application

Fix import export csv

Yurii71ad7661215d
diff --git a/application/Espo/Tools/Import/Service.php b/application/Espo/Tools/Import/Service.php
index d580997af2..e361681fb3 100644
--- a/application/Espo/Tools/Import/Service.php
+++ b/application/Espo/Tools/Import/Service.php
@@ -447,16 +447,11 @@ class Service
* @param string $importId An import ID.
* @return ?string An attachment ID.
* @throws NotFound
+ * @throws Forbidden
*/
public function exportErrors(string $importId): ?string
{
- $import = $this->entityManager
- ->getRepositoryByClass(ImportEntity::class)
- ->getById($importId);
-
- if (!$import) {
- throw new NotFound();
- }
+ $import = $this->getImport($importId);
$count = $this->entityManager
->getRDBRepositoryByClass(ImportEntity::class)
@@ -545,4 +540,23 @@ class Service
return $attachment->getId();
}
+
+ /**
+ * @throws Forbidden
+ * @throws NotFound
+ */
+ private function getImport(string $importId): ImportEntity
+ {
+ $import = $this->entityManager->getRepositoryByClass(ImportEntity::class)->getById($importId);
+
+ if (!$import) {
+ throw new NotFound();
+ }
+
+ if (!$this->acl->checkEntityRead($import)) {
+ throw new Forbidden("No access to the import record.");
+ }
+
+ return $import;
+ }
}