mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
N°9412 - Backend cleanup must work on setup settings that differ from runtime - WIP
This commit is contained in:
@@ -22,6 +22,7 @@ use Dict;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use IssueLog;
|
use IssueLog;
|
||||||
use MetaModel;
|
use MetaModel;
|
||||||
|
use SetupUtils;
|
||||||
use utils;
|
use utils;
|
||||||
|
|
||||||
class DataFeatureRemovalController extends Controller
|
class DataFeatureRemovalController extends Controller
|
||||||
@@ -97,6 +98,50 @@ class DataFeatureRemovalController extends Controller
|
|||||||
$this->aCountClassesToCleanup = $aGetRemovedClasses;
|
$this->aCountClassesToCleanup = $aGetRemovedClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function OperationAnalysisResult(): void
|
||||||
|
{
|
||||||
|
$aParams = [];
|
||||||
|
|
||||||
|
if (SetupUtils::IsSessionSetupTokenValid()) {
|
||||||
|
//from setup wizard/mtp
|
||||||
|
SetupUtils::EraseSetupToken();
|
||||||
|
} else {
|
||||||
|
//from same module
|
||||||
|
$this->ValidateTransactionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
$sSourceEnv = MetaModel::GetEnvironment();
|
||||||
|
$oSetupAudit = new SetupAudit($sSourceEnv);
|
||||||
|
$aGetRemovedClasses = array_keys($oSetupAudit->RunDataAudit());
|
||||||
|
IssueLog::Debug(__METHOD__, null, ['aGetRemovedClasses' => $aGetRemovedClasses]);
|
||||||
|
|
||||||
|
$oDataCleanupService = new DataCleanupService();
|
||||||
|
$aDeletionPlanSummaryEntities = $oDataCleanupService->GetCleanupSummary($aGetRemovedClasses);
|
||||||
|
$aColumns = ['Class', 'DeleteCount' , 'UpdateCount', 'IssueCount'];
|
||||||
|
$aRows = [];
|
||||||
|
$iQueryCount = 0;
|
||||||
|
$bHasIssues = false;
|
||||||
|
foreach ($aDeletionPlanSummaryEntities as $oDeletionPlanSummaryEntity) {
|
||||||
|
$aRows[] = [
|
||||||
|
$oDeletionPlanSummaryEntity->sClass,
|
||||||
|
$oDeletionPlanSummaryEntity->iDeleteCount,
|
||||||
|
$oDeletionPlanSummaryEntity->iUpdateCount,
|
||||||
|
$oDeletionPlanSummaryEntity->iIssueCount,
|
||||||
|
];
|
||||||
|
$bHasIssues |= ($oDeletionPlanSummaryEntity->iIssueCount !== 0);
|
||||||
|
$iQueryCount += $oDeletionPlanSummaryEntity->iDeleteCount;
|
||||||
|
$iQueryCount += $oDeletionPlanSummaryEntity->iUpdateCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
$aParams['sTransactionId'] = utils::GetNewTransactionId();
|
||||||
|
$aParams['aDeletionPlanSummary'] = $this->GetTableData('Extensions', $aColumns, $aRows);
|
||||||
|
$aParams['aClasses'] = $aGetRemovedClasses;
|
||||||
|
$aParams['iQueryCount'] = $iQueryCount;
|
||||||
|
$aParams['bDeletionPossible'] = !$bHasIssues;
|
||||||
|
|
||||||
|
$this->DisplayPage($aParams);
|
||||||
|
}
|
||||||
|
|
||||||
public function OperationDeletionPlan(): void
|
public function OperationDeletionPlan(): void
|
||||||
{
|
{
|
||||||
$aParams = [];
|
$aParams = [];
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{# @copyright Copyright (C) 2010-2026 Combodo SARL #}
|
||||||
|
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||||
|
|
||||||
|
{% UIPanel ForInformation { sTitle:'DataFeatureRemoval:DeletionPlan:Title'|dict_s, sSubTitle: 'DataFeatureRemoval:DeletionPlan:SubTitle'|dict_format(iQueryCount) } %}
|
||||||
|
{% UIDataTable ForForm { sRef:'aDeletionPlanSummary', aColumns:aDeletionPlanSummary.Columns, aData:aDeletionPlanSummary.Data} %}{% EndUIDataTable %}
|
||||||
|
{% EndUIPanel %}
|
||||||
|
|
||||||
|
{% if bDeletionPossible %}
|
||||||
|
{% UIForm Standard {} %}
|
||||||
|
{% UIInput ForHidden { sName:'transaction_id', sValue:sTransactionId} %}
|
||||||
|
{% UIInput ForHidden { sName:'operation', sValue:'DoDeletion'} %}
|
||||||
|
{% for sKey, sClass in aClasses %}
|
||||||
|
{% UIInput ForHidden { sName:"classes[" ~ sKey ~ "]", sValue:sClass } %}
|
||||||
|
{% endfor %}
|
||||||
|
{% UIToolbar ForButton {} %}
|
||||||
|
{% UIButton ForPrimaryAction {sLabel:'UI:Button:DoDeletion'|dict_s, sName:'btn_deletion', sId:'btn_deletion', bIsSubmit:true} %}
|
||||||
|
{% EndUIToolbar %}
|
||||||
|
{% EndUIForm %}
|
||||||
|
{% else %}
|
||||||
|
{{ 'DataFeatureRemoval:DeletionPlan:Error:Issues'|dict_s }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% UIForm Standard {} %}
|
||||||
|
{% UIInput ForHidden { sName:'transaction_id', sValue:sTransactionId} %}
|
||||||
|
{% UIInput ForHidden { sName:'operation', sValue:'Main'} %}
|
||||||
|
{% UIToolbar ForButton {} %}
|
||||||
|
{% UIButton ForPrimaryAction {sLabel:'UI:Button:BackToMain'|dict_s, sName:'btn_back', sId:'btn_back', bIsSubmit:true} %}
|
||||||
|
{% EndUIToolbar %}
|
||||||
|
{% EndUIForm %}
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Combodo\iTop\Application\Helper\Session;
|
||||||
use Combodo\iTop\Application\WebPage\WebPage;
|
use Combodo\iTop\Application\WebPage\WebPage;
|
||||||
|
|
||||||
require_once(APPROOT.'setup/sequencers/DataAuditSequencer.php');
|
require_once(APPROOT.'setup/sequencers/DataAuditSequencer.php');
|
||||||
@@ -112,11 +113,12 @@ JS);
|
|||||||
<input type="hidden" name="aExtensions[$sSafeExtCode][enable]" value="on"/>
|
<input type="hidden" name="aExtensions[$sSafeExtCode][enable]" value="on"/>
|
||||||
INPUT;
|
INPUT;
|
||||||
}
|
}
|
||||||
|
$sUID = Session::Get('setup_token');
|
||||||
$oPage->add(
|
$oPage->add(
|
||||||
<<<HTML
|
<<<HTML
|
||||||
<form id="data-feature-removal" class="ibo-setup--wizard ibo-is-hidden" method="post" action="$sApplicationUrl">
|
<form id="data-feature-removal" class="ibo-setup--wizard ibo-is-hidden" method="post" action="$sApplicationUrl">
|
||||||
<input type="hidden" name="operation" value="Analyze"/>
|
<input type="hidden" name="operation" value="AnalysisResult"/>
|
||||||
|
<input type="hidden" name="setup_token" value="$sUID"/>
|
||||||
$aHiddenRemovedExtensionInputs
|
$aHiddenRemovedExtensionInputs
|
||||||
</form>
|
</form>
|
||||||
HTML
|
HTML
|
||||||
|
|||||||
@@ -509,6 +509,7 @@ EOF
|
|||||||
$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
|
$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
|
||||||
if (isset($aChoice['modules'])) {
|
if (isset($aChoice['modules'])) {
|
||||||
if (count($aChoice['modules']) === 0 && (!isset($aChoice['missing']) || $aChoice['missing'] === false)) {
|
if (count($aChoice['modules']) === 0 && (!isset($aChoice['missing']) || $aChoice['missing'] === false)) {
|
||||||
|
SetupLog::Error(__METHOD__, null, ['choice' => $aChoice]);
|
||||||
throw new Exception('Extension '.$aChoice['extension_code'].' does not have any module associated');
|
throw new Exception('Extension '.$aChoice['extension_code'].' does not have any module associated');
|
||||||
}
|
}
|
||||||
foreach ($aChoice['modules'] as $sModuleId) {
|
foreach ($aChoice['modules'] as $sModuleId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user