Skip to content

Commit

Permalink
Type change lock for some modules
Browse files Browse the repository at this point in the history
  • Loading branch information
rskrzypczak committed Dec 12, 2021
1 parent fba8a4a commit cde1fbc
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 13 deletions.
4 changes: 2 additions & 2 deletions config/version.php
@@ -1,7 +1,7 @@
<?php

return [
'appVersion' => '6.3.0',
'patchVersion' => '2021.12.10',
'appVersion' => '6.3.1',
'patchVersion' => '2021.12.12',
'lib_roundcube' => '0.2.3',
];
22 changes: 12 additions & 10 deletions layouts/basic/modules/Settings/LayoutEditor/Index.tpl
Expand Up @@ -18,23 +18,25 @@
<div class="col-md-6">
{include file=\App\Layout::getTemplatePath('BreadCrumbs.tpl', $QUALIFIED_MODULE)}
</div>
<div class="float-right col-md-6 form-inline">
<div class="form-group float-right col-md-6">
<div class="float-right col-md-6 m-auto">
<div class="float-right col-md-6">
<select class="select2 form-control" name="layoutEditorModules">
{foreach item=MODULE_NAME from=$SUPPORTED_MODULES}
<option value="{$MODULE_NAME}" {if $MODULE_NAME eq $SELECTED_MODULE_NAME} selected {/if}>{App\Language::translate($MODULE_NAME, $MODULE_NAME)}</option>
{/foreach}
</select>
</div>
<div class="form-group float-right">
<div class="btn-group">
<button class="js-switch--inventory btn btn-outline-primary{if !$IS_INVENTORY} active{/if}" type="button" data-js="click" {if $CHANGE_MODULE_TYPE_DISABLED}disabled="disabled" {/if} data-value="{Vtiger_Module_Model::STANDARD_TYPE}" autocomplete="off">
{App\Language::translate('LBL_BASIC_MODULE',$QUALIFIED_MODULE)}
</button>
<button class="js-switch--inventory btn btn-outline-primary{if $IS_INVENTORY} active{/if}" type="button" data-js="click" {if $CHANGE_MODULE_TYPE_DISABLED}disabled="disabled" {/if} data-value="{Vtiger_Module_Model::ADVANCED_TYPE}" autocomplete="off">
{App\Language::translate('LBL_ADVANCED_MODULE',$QUALIFIED_MODULE)}</button>
{if $SELECTED_MODULE_MODEL->isTypeChangeAllowed()}
<div class="float-right">
<div class="btn-group">
<button class="js-switch--inventory btn btn-outline-primary{if !$IS_INVENTORY} active{/if}" type="button" data-js="click" {if $CHANGE_MODULE_TYPE_DISABLED}disabled="disabled" {/if} data-value="{Vtiger_Module_Model::STANDARD_TYPE}" autocomplete="off">
{App\Language::translate('LBL_BASIC_MODULE',$QUALIFIED_MODULE)}
</button>
<button class="js-switch--inventory btn btn-outline-primary{if $IS_INVENTORY} active{/if}" type="button" data-js="click" {if $CHANGE_MODULE_TYPE_DISABLED}disabled="disabled" {/if} data-value="{Vtiger_Module_Model::ADVANCED_TYPE}" autocomplete="off">
{App\Language::translate('LBL_ADVANCED_MODULE',$QUALIFIED_MODULE)}</button>
</div>
</div>
</div>
{/if}
</div>
</div>
<hr>
Expand Down
3 changes: 3 additions & 0 deletions modules/Accounts/models/Module.php
Expand Up @@ -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.
*
Expand Down
3 changes: 3 additions & 0 deletions modules/Calendar/models/Module.php
Expand Up @@ -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.
*
Expand Down
3 changes: 3 additions & 0 deletions modules/Contacts/models/Module.php
Expand Up @@ -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.
*
Expand Down
4 changes: 4 additions & 0 deletions modules/Documents/models/Module.php
Expand Up @@ -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.
*
Expand Down
14 changes: 13 additions & 1 deletion modules/Vtiger/models/Module.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand All @@ -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.
*
Expand Down

0 comments on commit cde1fbc

Please sign in to comment.