From cde1fbcb632265dadc2168329ae14691a4168a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Skrzypczak?= Date: Sun, 12 Dec 2021 15:47:24 +0100 Subject: [PATCH] Type change lock for some modules --- config/version.php | 4 ++-- .../modules/Settings/LayoutEditor/Index.tpl | 22 ++++++++++--------- modules/Accounts/models/Module.php | 3 +++ modules/Calendar/models/Module.php | 3 +++ modules/Contacts/models/Module.php | 3 +++ modules/Documents/models/Module.php | 4 ++++ modules/Vtiger/models/Module.php | 14 +++++++++++- 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/config/version.php b/config/version.php index a8ca3d22b511..4d3fd730f99f 100644 --- a/config/version.php +++ b/config/version.php @@ -1,7 +1,7 @@ '6.3.0', - 'patchVersion' => '2021.12.10', + 'appVersion' => '6.3.1', + 'patchVersion' => '2021.12.12', 'lib_roundcube' => '0.2.3', ]; diff --git a/layouts/basic/modules/Settings/LayoutEditor/Index.tpl b/layouts/basic/modules/Settings/LayoutEditor/Index.tpl index 88a521d60feb..f12473ef74f8 100644 --- a/layouts/basic/modules/Settings/LayoutEditor/Index.tpl +++ b/layouts/basic/modules/Settings/LayoutEditor/Index.tpl @@ -18,23 +18,25 @@
{include file=\App\Layout::getTemplatePath('BreadCrumbs.tpl', $QUALIFIED_MODULE)}
-
-
+
+
-
-
- - + {if $SELECTED_MODULE_MODEL->isTypeChangeAllowed()} +
+
+ + +
-
+ {/if}

diff --git a/modules/Accounts/models/Module.php b/modules/Accounts/models/Module.php index 2afbb5a61e0b..b2f35593eac9 100644 --- a/modules/Accounts/models/Module.php +++ b/modules/Accounts/models/Module.php @@ -11,6 +11,9 @@ class Accounts_Module_Model extends Vtiger_Module_Model { + /** {@inheritdoc} */ + public $allowTypeChange = false; + /** * Function to get list view query for popup window. * diff --git a/modules/Calendar/models/Module.php b/modules/Calendar/models/Module.php index 3d07e29ec563..24d45c3af475 100644 --- a/modules/Calendar/models/Module.php +++ b/modules/Calendar/models/Module.php @@ -15,6 +15,9 @@ */ class Calendar_Module_Model extends Vtiger_Module_Model { + /** {@inheritdoc} */ + public $allowTypeChange = false; + /** * Function returns the default view for the Calendar module. * diff --git a/modules/Contacts/models/Module.php b/modules/Contacts/models/Module.php index 094b61ad3b30..7eb3abbb3f62 100644 --- a/modules/Contacts/models/Module.php +++ b/modules/Contacts/models/Module.php @@ -11,6 +11,9 @@ class Contacts_Module_Model extends Vtiger_Module_Model { + /** {@inheritdoc} */ + public $allowTypeChange = false; + /** * Function to get list view query for popup window. * diff --git a/modules/Documents/models/Module.php b/modules/Documents/models/Module.php index a7935ffa8e0f..43dcc5c4760f 100644 --- a/modules/Documents/models/Module.php +++ b/modules/Documents/models/Module.php @@ -6,10 +6,14 @@ * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. + * Contributor(s): YetiForce Sp. z o.o. * *********************************************************************************** */ class Documents_Module_Model extends Vtiger_Module_Model { + /** {@inheritdoc} */ + public $allowTypeChange = false; + /** * Functions tells if the module supports workflow. * diff --git a/modules/Vtiger/models/Module.php b/modules/Vtiger/models/Module.php index aeac91dea225..c247a9d6140d 100644 --- a/modules/Vtiger/models/Module.php +++ b/modules/Vtiger/models/Module.php @@ -26,6 +26,8 @@ class Vtiger_Module_Model extends \vtlib\Module protected $relations; protected $moduleType = '0'; protected $entityInstance; + /** @var bool */ + public $allowTypeChange = true; /** * Function to get the Module/Tab id. @@ -1416,7 +1418,7 @@ public function getValuesFromSource(App\Request $request, $moduleName = false) public function changeType(int $type): bool { $result = false; - if ($type !== $this->getModuleType() && \in_array($type, [static::ADVANCED_TYPE, static::STANDARD_TYPE])) { + if ($this->isTypeChangeAllowed() && $type !== $this->getModuleType() && \in_array($type, [static::ADVANCED_TYPE, static::STANDARD_TYPE])) { $result = \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['type' => $type], ['name' => $this->getName()])->execute(); if ($result && $type === static::ADVANCED_TYPE) { Vtiger_Inventory_Model::getInstance($this->getName())->createInventoryTables(); @@ -1432,6 +1434,16 @@ public function changeType(int $type): bool return $result; } + /** + * Check if change module type is supported. + * + * @return bool + */ + public function isTypeChangeAllowed(): bool + { + return $this->allowTypeChange; + } + /** * Get layout type for quick create. *