EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
forbid access to system requirements
Yuri Kuznetsov889a8bfc906c
diff --git a/application/Espo/Controllers/Admin.php b/application/Espo/Controllers/Admin.phpindex 39d8fa0ff2..92a9a92817 100644--- a/application/Espo/Controllers/Admin.php+++ b/application/Espo/Controllers/Admin.php@@ -54,7 +54,8 @@ class Adminprivate Manager $adminNotificationManager,private SystemRequirements $systemRequirements,private ScheduledJob $scheduledJob,- private DataManager $dataManager+ private DataManager $dataManager,+ private Config\SystemConfig $systemConfig,) {if (!$this->user->isAdmin()) {throw new Forbidden();@@ -179,9 +180,14 @@ class Admin* database: array<string, array<string, mixed>>,* permission: array<string, array<string, mixed>>,* }+ * @throws Forbidden*/public function getActionSystemRequirementList(): object{+ if (!$this->user->isSuperAdmin() && $this->systemConfig->isRestrictedMode()) {+ throw new Forbidden();+ }+return (object) $this->systemRequirements->getAllRequiredList();}}diff --git a/application/Espo/Core/Utils/Config/SystemConfig.php b/application/Espo/Core/Utils/Config/SystemConfig.phpindex c92eac916c..949f82871c 100644--- a/application/Espo/Core/Utils/Config/SystemConfig.php+++ b/application/Espo/Core/Utils/Config/SystemConfig.php@@ -50,4 +50,14 @@ class SystemConfig{return (string) $this->config->get('version');}++ /**+ * Is restricted mode.+ *+ * @since 9.1.8+ */+ public function isRestrictedMode(): bool+ {+ return (bool) $this->config->get('restrictedMode');+ }}diff --git a/client/res/templates/admin/system-requirements/index.tpl b/client/res/templates/admin/system-requirements/index.tplindex aa31016b00..073cd85c60 100644--- a/client/res/templates/admin/system-requirements/index.tpl+++ b/client/res/templates/admin/system-requirements/index.tpl@@ -2,16 +2,23 @@<span class="breadcrumb-separator"><span></span></span>{{translate 'System Requirements' scope='Admin'}}</h3></div>-<div class="panel panel-default">- <table class="table table-striped table-no-overflow table-fixed">- <thead>+{{#if noAccess}}+ <div class="panel panel-default">+ <div class="panel-body">+ {{translate 'error403' category='messages'}}+ </div>+ </div>+{{else}}+ <div class="panel panel-default">+ <table class="table table-striped table-no-overflow table-fixed">+ <thead><tr><th><h5>{{translate 'PHP Settings' scope='Admin'}}</h5></th><th style="width: 24%"></th><th style="width: 24%"></th></tr>- </thead>- <tbody>+ </thead>+ <tbody>{{#each phpRequirementList}}<tr class="list-row"><td class="cell">@@ -21,27 +28,27 @@<td class="cell">{{#if acceptable}} <span class="text-success">{{translate 'Success' scope='Admin'}}</span>{{else}}- <span class="text-danger">{{translate 'Fail' scope='Admin'}}- {{#ifEqual type 'lib'}} ({{translate 'extension is missing' scope='Admin'}}) {{/ifEqual}}- {{#ifEqual type 'param'}} ({{required}} {{translate 'is recommended' scope='Admin'}}) {{/ifEqual}}+ <span class="text-danger">{{translate 'Fail' scope='Admin'}}+ {{#ifEqual type 'lib'}} ({{translate 'extension is missing' scope='Admin'}}) {{/ifEqual}}+ {{#ifEqual type 'param'}} ({{required}} {{translate 'is recommended' scope='Admin'}}) {{/ifEqual}}</span> {{/if}}</td></tr>{{/each}}- </tbody>- </table>-</div>+ </tbody>+ </table>+ </div>-<div class="panel panel-default">- <table class="table table-striped table-no-overflow table-fixed">- <thead>+ <div class="panel panel-default">+ <table class="table table-striped table-no-overflow table-fixed">+ <thead><tr><th><h5>{{translate 'Database Settings' scope='Admin'}}</h5></th><th style="width: 24%"></th><th style="width: 24%"></th></tr>- </thead>- <tbody>+ </thead>+ <tbody>{{#each databaseRequirementList}}<tr class=""><td class="cell">@@ -50,29 +57,29 @@<td class="cell" style="width: 24%">{{actual}}</td><td class="cell" style="width: 24%">{{#if acceptable}}- <span class="text-success">{{translate 'Success' scope='Admin'}}</span>+ <span class="text-success">{{translate 'Success' scope='Admin'}}</span>{{else}}- <span class="text-danger">{{translate 'Fail' scope='Admin'}}- {{#ifEqual type 'param'}} ({{required}} {{translate 'is recommended' scope='Admin'}}) {{/ifEqual}}+ <span class="text-danger">{{translate 'Fail' scope='Admin'}}+ {{#ifEqual type 'param'}} ({{required}} {{translate 'is recommended' scope='Admin'}}) {{/ifEqual}}</span>{{/if}}</td></tr>{{/each}}- </tbody>- </table>-</div>+ </tbody>+ </table>+ </div>-<div class="panel panel-default">- <table class="table table-striped table-no-overflow table-fixed">- <thead>+ <div class="panel panel-default">+ <table class="table table-striped table-no-overflow table-fixed">+ <thead><tr><th><h5>{{translate 'Permissions' scope='Admin'}}</h5></th><th style="width: 24%"></th><th style="width: 24%"></th></tr>- </thead>- <tbody>+ </thead>+ <tbody>{{#each permissionRequirementList}}<tr><td class="cell">@@ -81,24 +88,25 @@<td class="cell" style="width: 24%">{{translate type scope='Admin' category='systemRequirements'}}</td><td class="cell" style="width: 24%">{{#if acceptable}}- <span class="text-success">{{translate 'Success' scope='Admin'}}</span>+ <span class="text-success">{{translate 'Success' scope='Admin'}}</span>{{else}}- <span class="text-danger">{{translate 'Fail' scope='Admin'}}</span>+ <span class="text-danger">{{translate 'Fail' scope='Admin'}}</span>{{/if}}</td></tr>{{/each}}- </tbody>- </table>-</div>+ </tbody>+ </table>+ </div>-<div class="row">- <div class="col-md-12">- <div class="pull-right">- <a- target="_blank"- href="https://docs.espocrm.com/administration/server-configuration/"- ><strong>{{translate 'Configuration Instructions' scope='Admin'}}</strong></a>+ <div class="row">+ <div class="col-md-12">+ <div class="pull-right">+ <a+ target="_blank"+ href="https://docs.espocrm.com/administration/server-configuration/"+ ><strong>{{translate 'Configuration Instructions' scope='Admin'}}</strong></a>+ </div></div></div>-</div>+{{/if}}diff --git a/client/src/views/admin/system-requirements/index.js b/client/src/views/admin/system-requirements/index.jsindex 2ec2377735..38752a275a 100644--- a/client/src/views/admin/system-requirements/index.js+++ b/client/src/views/admin/system-requirements/index.js@@ -27,6 +27,7 @@************************************************************************/import View from 'view';+import Ajax from 'ajax';export default class extends View {@@ -35,25 +36,40 @@ export default class extends View {/** @type {Record} */requirements+ /**+ * @private+ * @type {boolean}+ */+ noAccess = false+data() {return {phpRequirementList: this.requirements.php,databaseRequirementList: this.requirements.database,permissionRequirementList: this.requirements.permission,+ noAccess: this.noAccess,};}setup() {this.requirements = {};+ this.wait(this.loadData());+ }++ async loadData() {Espo.Ui.notifyWait();- const promise = Espo.Ajax.getRequest('Admin/action/systemRequirementList').then(requirements => {- this.requirements = requirements;+ try {+ this.requirements = await Espo.Ajax.getRequest('Admin/action/systemRequirementList');+ } catch(e) {+ this.noAccess = true;- Espo.Ui.notify();- });+ if ('errorIsHandled' in e) {+ e.errorIsHandled = true;+ }+ }- this.wait(promise);+ Espo.Ui.notify();}}