Skip to content

EspoCRM – Open Source CRM Application

Parameters adminExtensionUpload, adminUpgrade

Yuriiaef3cbfd1aea
diff --git a/application/Espo/Controllers/Admin.php b/application/Espo/Controllers/Admin.php
index b047273e59..1676ee454a 100644
--- a/application/Espo/Controllers/Admin.php
+++ b/application/Espo/Controllers/Admin.php
@@ -186,8 +186,12 @@ class Admin
throw new Forbidden("Not allowed in restricted mode.");
}
+ if ($this->config->get('adminUpgrade') !== true) {
+ throw new Forbidden("Cannot upgrade via the UI as `adminUpgrade` is not enabled.");
+ }
+
if ($this->config->get('adminUpgradeDisabled')) {
- throw new Forbidden("Disabled with 'adminUpgradeDisabled' parameter.");
+ throw new Forbidden("Disabled with `adminUpgradeDisabled` parameter.");
}
}
}
diff --git a/application/Espo/Controllers/Extension.php b/application/Espo/Controllers/Extension.php
index 570999f7f7..2c7b86b3f1 100644
--- a/application/Espo/Controllers/Extension.php
+++ b/application/Espo/Controllers/Extension.php
@@ -154,8 +154,12 @@ class Extension extends RecordBase
throw new Forbidden("Not allowed in restricted mode.");
}
+ if ($this->config->get('adminExtensionUpload') !== true) {
+ throw new Forbidden("Cannot upload extensions as `adminExtensionUpload` is not enabled.");
+ }
+
if ($this->config->get('adminUpgradeDisabled')) {
- throw new Forbidden("Disabled with 'adminUpgradeDisabled' parameter.");
+ throw new Forbidden("Disabled with `adminUpgradeDisabled` parameter.");
}
}
}
diff --git a/application/Espo/Core/Upgrades/Migrations/V10_0/AfterUpgrade.php b/application/Espo/Core/Upgrades/Migrations/V10_0/AfterUpgrade.php
index 70e87fca2b..e47087fb7c 100644
--- a/application/Espo/Core/Upgrades/Migrations/V10_0/AfterUpgrade.php
+++ b/application/Espo/Core/Upgrades/Migrations/V10_0/AfterUpgrade.php
@@ -30,6 +30,7 @@
namespace Espo\Core\Upgrades\Migrations\V10_0;
use Espo\Core\Upgrades\Migration\Script;
+use Espo\Core\Utils\Config;
use Espo\Core\Utils\Config\ConfigWriter;
use Espo\Core\Utils\Metadata;
use Espo\Entities\Preferences;
@@ -43,31 +44,14 @@ class AfterUpgrade implements Script
private EntityManager $entityManager,
private ConfigWriter $configWriter,
private Metadata $metadata,
+ private Config $config,
) {}
public function run(): void
{
$this->updatePreferences();
$this->updateConfig();
-
- /** @var array<string, array<string, mixed>> $clientDefs */
- $clientDefs = $this->metadata->get('clientDefs') ?? [];
-
- foreach ($clientDefs as $name => $defs) {
- if ($name === CaseObj::ENTITY_TYPE) {
- continue;
- }
-
- if ($defs['allowInternalNotes'] ?? false) {
- $this->metadata->set('streamDefs', $name, [
- 'allowInternalNotes' => true,
- ]);
-
- $this->metadata->delete('clientDefs', $name, ['allowInternalNotes']);
- }
- }
-
- $this->metadata->save();
+ $this->updateMetadata();
}
private function updatePreferences(): void
@@ -100,6 +84,35 @@ class AfterUpgrade implements Script
private function updateConfig(): void
{
$this->configWriter->set('currencyNoJoinMode', true);
+
+ if ($this->config->get('adminUpgradeDisabled')) {
+ $this->configWriter->set('adminExtensionUpload', false);
+ } else {
+ $this->configWriter->set('adminExtensionUpload', true);
+ }
+
$this->configWriter->save();
}
+
+ private function updateMetadata(): void
+ {
+ /** @var array<string, array<string, mixed>> $clientDefs */
+ $clientDefs = $this->metadata->get('clientDefs') ?? [];
+
+ foreach ($clientDefs as $name => $defs) {
+ if ($name === CaseObj::ENTITY_TYPE) {
+ continue;
+ }
+
+ if ($defs['allowInternalNotes'] ?? false) {
+ $this->metadata->set('streamDefs', $name, [
+ 'allowInternalNotes' => true,
+ ]);
+
+ $this->metadata->delete('clientDefs', $name, ['allowInternalNotes']);
+ }
+ }
+
+ $this->metadata->save();
+ }
}
diff --git a/application/Espo/Resources/defaults/config.php b/application/Espo/Resources/defaults/config.php
index d0d021803a..cf636d188b 100644
--- a/application/Espo/Resources/defaults/config.php
+++ b/application/Espo/Resources/defaults/config.php
@@ -306,6 +306,8 @@ return [
'phoneNumberExtensions' => false,
'phoneNumberPreferredCountryList' => ['us', 'de'],
'adminUpgradeDisabled' => false,
+ 'adminUpgrade' => false,
+ 'adminExtensionUpload' => true,
'wysiwygCodeEditorDisabled' => false,
'customPrefixDisabled' => false,
'listPagination' => true,
diff --git a/application/Espo/Resources/defaults/systemConfig.php b/application/Espo/Resources/defaults/systemConfig.php
index 93b933ceee..e93d8be953 100644
--- a/application/Espo/Resources/defaults/systemConfig.php
+++ b/application/Espo/Resources/defaults/systemConfig.php
@@ -63,6 +63,8 @@ return [
'restrictedMode',
'instanceId',
'adminUpgradeDisabled',
+ 'adminUpgrade',
+ 'adminExtensionUpload',
'userLimit',
'portalUserLimit',
'stylesheet',