FIxes unit tests

This commit is contained in:
Anne-Cath
2026-06-15 16:51:02 +02:00
parent ed1cfc3b08
commit caa1b8652d
10 changed files with 79 additions and 77 deletions

View File

@@ -3805,7 +3805,7 @@ HTML;
return $aWriteableAttList;
}
/**
/**
* Compute the attribute flags depending on the object state
*/
public function GetFormAttributeFlags($sAttCode)

View File

@@ -1078,7 +1078,6 @@ JS
if ($aCounts[$sStateValue] == 0) {
$aCounts[$sStateValue] = ['link' => '-', 'label' => $aCounts[$sStateValue]];
;
} else {
$oSingleGroupByValueFilter = $this->m_oFilter->DeepClone();
$oSingleGroupByValueFilter->AddCondition($sStateAttrCode, $sStateValue, '=');
@@ -1948,7 +1947,7 @@ class MenuBlock extends DisplayBlock
// Check rights on class
$bIsBulkModifyAllowed = (!MetaModel::IsAbstract($sSelectedClass)) && UserRights::IsActionAllowed($sSelectedClass, UR_ACTION_BULK_MODIFY) && (($oReflectionClass->IsSubclassOf(cmdbAbstractObject::class) || $sSelectedClass === SynchroReplica::class));
$bIsBulkDeleteAllowed = (bool) UserRights::IsActionAllowed($sSelectedClass, UR_ACTION_BULK_DELETE);
$bIsBulkDeleteAllowed = (bool)UserRights::IsActionAllowed($sSelectedClass, UR_ACTION_BULK_DELETE);
// Refine filter on selected class so bullk actions occur on the right class
$oSelectedClassFilter = $this->GetFilter()->DeepClone();
@@ -1958,12 +1957,12 @@ class MenuBlock extends DisplayBlock
// Action label dict code has a specific suffix for "Link" / "Remote" aliases to allow dedicated labels in linksets.
$sActionLabelCodeSuffix = in_array($sSelectedAlias, ['Link', 'Remote']) ? $sSelectedAlias : 'Class';
if ($bIsBulkModifyAllowed) {
if($sSelectedClass === SynchroReplica::class){
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:UnlinkAll:', Dict::S('Class:SynchroReplica/Action:unlink_all'),'unlink');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:UnLinkSynchroAll:', Dict::S('Class:SynchroReplica/Action:unlinksynchro_all'),'unlinksynchro');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:SynchroAll:', Dict::S('Class:SynchroReplica/Action:synchro_all'),'synchro');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:AllowDeleteAll:', Dict::S('Class:SynchroReplica/Action:allowdelete_all'),'allowdelete');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:DenyDeleteAll:', Dict::S('Class:SynchroReplica/Action:denydelete_all'),'denydelete');
if ($sSelectedClass === SynchroReplica::class) {
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:UnlinkAll:', Dict::S('Class:SynchroReplica/Action:unlink_all'), 'unlink');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:UnLinkSynchroAll:', Dict::S('Class:SynchroReplica/Action:unlinksynchro_all'), 'unlinksynchro');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:SynchroAll:', Dict::S('Class:SynchroReplica/Action:synchro_all'), 'synchro');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:AllowDeleteAll:', Dict::S('Class:SynchroReplica/Action:allowdelete_all'), 'allowdelete');
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:DenyDeleteAll:', Dict::S('Class:SynchroReplica/Action:denydelete_all'), 'denydelete');
} else {
$this->AddBulkModifyObjectsMenuAction($aRegularActions, $sSelectedClass, $oSelectedClassFilter->serialize(), 'UI:Menu:ModifyAll:'.$sSelectedAlias, Dict::Format('UI:Menu:ModifyAll_'.$sActionLabelCodeSuffix, $sSelectedClassName));
}
@@ -2489,8 +2488,8 @@ class MenuBlock extends DisplayBlock
protected function AddBulkModifyObjectsMenuAction(array &$aActions, string $sClass, string $sFilter, string $sActionIdentifier = 'UI:Menu:ModifyAll', $sActionLabel = 'UI:Menu:ModifyAll', $sOperationName = 'modify'): void
{
$aActions[$sActionIdentifier] = [
'label' => Dict::S($sActionLabel),
'url' => $this->PrepareUrlForStandardMenuAction($sClass, 'operation=select_for_'.$sOperationName.'_all&class='.$sClass.'&filter='.urlencode($sFilter)),
'label' => Dict::S($sActionLabel),
'url' => $this->PrepareUrlForStandardMenuAction($sClass, 'operation=select_for_'.$sOperationName.'_all&class='.$sClass.'&filter='.urlencode($sFilter)),
] + $this->GetDefaultParamsForMenuAction();
}

View File

@@ -965,7 +965,7 @@ The hyperlink is displayed in the tooltip appearing on the “Lock” symbol of
'Core:SynchroReplica:PublicData' => 'Public Data',
'Core:SynchroReplica:PrivateDetails' => 'Private Details',
'Core:SynchroReplica:BackToDataSource' => 'Go Back to the Synchro Data Source: %1$s',
'Core:SynchroReplica:ListOfReplicas' => 'List of Replica',
'Core:SynchroReplica:ListOfReplicas' => 'Replicas of the data source: %1$s',
'Core:SynchroAttExtKey:ReconciliationById' => 'id (Primary Key)',
'Core:SynchroAtt:attcode' => 'Attribute',
'Core:SynchroAtt:attcode+' => 'Field of the object',

View File

@@ -928,7 +928,7 @@ Plusieurs champs peuvent ainsi être modifiés lors d\'une "mise à jour" en app
'Core:SynchroReplica:PublicData' => 'Données synchronisées',
'Core:SynchroReplica:PrivateDetails' => 'Informations internes',
'Core:SynchroReplica:BackToDataSource' => 'Retourner aux détails de la source de données: %1$s',
'Core:SynchroReplica:ListOfReplicas' => 'Liste des réplica',
'Core:SynchroReplica:ListOfReplicas' => 'Liste des réplicas de %1$s',
'Core:SynchroAttExtKey:ReconciliationById' => 'id (clé primaire)',
'Core:SynchroAtt:attcode' => 'Champ',
'Core:SynchroAtt:attcode+' => '',

View File

@@ -882,7 +882,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', [
'Core:SynchroReplica:PublicData' => 'Public Data~~',
'Core:SynchroReplica:PrivateDetails' => 'Private Details~~',
'Core:SynchroReplica:BackToDataSource' => 'Go Back to the Synchro Data Source: %1$s~~',
'Core:SynchroReplica:ListOfReplicas' => 'List of Replica~~',
'Core:SynchroReplica:ListOfReplicas' => 'Replicas of the data source: %1$s~~',
'Core:SynchroAttExtKey:ReconciliationById' => 'id (Primary Key)~~',
'Core:SynchroAtt:attcode' => 'Атрибут',
'Core:SynchroAtt:attcode+' => 'Поле объекта',

View File

@@ -587,20 +587,20 @@ try {
break;
case 'form_for_unlink_all': // Form to modify multiple objects (bulk modify)
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext,'unlink');
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext, 'unlink');
break;
case 'form_for_unlinksynchro_all': // Form to modify multiple objects (bulk modify)
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext,'unlinksynchro');
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext, 'unlinksynchro');
break;
case 'form_for_synchro_all': // Form to modify multiple objects (bulk modify)
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext,'synchro');
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext, 'synchro');
break;
case 'form_for_allowdelete_all': // Form to modify multiple objects (bulk modify)
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext,'allowdelete');
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext, 'allowdelete');
break;
case 'form_for_denydelete_all': // Form to modify multiple objects (bulk modify)
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext,'denydelete');
SynchroReplicaHelper::OperationUnlinkAll($oP, $oAppContext, 'denydelete');
break;
///////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -31,7 +31,7 @@ class BulkHelper
* @throws \CoreException
* @throws \OQLException
*/
public static function OperationSelectForModifyAll(iTopWebPage $oP, $sTitleTab = 'UI:ModifyAllPageTitle', $sTitleCode = 'UI:Modify_ObjectsOf_Class', $sNextOperation = 'form_for_modify_all'): void
public static function OperationSelectForModifyAll(iTopWebPage $oP, $sTitleTab = 'UI:ModifyAllPageTitle', $sTitleCode = 'UI:Modify_ObjectsOf_Class', $sNextOperation = 'form_for_modify_all'): void
{
$oP->DisableBreadCrumb();
$oP->set_title(Dict::S($sTitleTab));
@@ -47,10 +47,10 @@ class BulkHelper
$sClassName = MetaModel::GetName($sClass);
$aDisplayParams = [
'icon' => MetaModel::GetClassIcon($sClass, false),
'title' => Dict::Format($sTitleCode, $sClassName),
'icon' => MetaModel::GetClassIcon($sClass, false),
'title' => Dict::Format($sTitleCode, $sClassName),
];
self::DisplayMultipleSelectionForm($oP, $oFilter, $sNextOperation, $oChecker, [], $aDisplayParams);
self::DisplayMultipleSelectionForm($oP, $oFilter, $sNextOperation, $oChecker, [], $aDisplayParams);
}
/**
@@ -74,47 +74,49 @@ class BulkHelper
// Add user filter
$oFullSetFilter->UpdateContextFromUser();
$aSelectedObj = utils::ReadMultipleSelection($oFullSetFilter);
$sCancelUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search&filter=' . urlencode($sFilter) . '&' . $oAppContext->GetForLink();
$aContext = array('filter' => utils::EscapeHtml($sFilter));
cmdbAbstractObject::DisplayBulkModifyForm($oP, $sClass, $aSelectedObj, 'preview_or_modify_all', $sCancelUrl, array(), $aContext);
$sCancelUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search&filter='.urlencode($sFilter).'&'.$oAppContext->GetForLink();
$aContext = array('filter' => utils::EscapeHtml($sFilter));
cmdbAbstractObject::DisplayBulkModifyForm($oP, $sClass, $aSelectedObj, 'preview_or_modify_all', $sCancelUrl, array(), $aContext);
}
/**
* Operation preview_or_modify_all
*
* @param iTopWebPage $oP
* @param \ApplicationContext $oAppContext
*
* @throws \ApplicationException
* @throws \ArchivedObjectException
* @throws \CoreCannotSaveObjectException
* @throws \CoreException
* @throws \DictExceptionMissingString
* @throws \OQLException
*/
public static function OperationPreviewOrModifyAll(iTopWebPage $oP, ApplicationContext $oAppContext): void
{
$oP->DisableBreadCrumb();
$sFilter = utils::ReadParam('filter', '', false, 'raw_data');
$oFilter = DBObjectSearch::unserialize($sFilter); // TO DO : check that the filter is valid
// Add user filter
$oFilter->UpdateContextFromUser();
/**
* Operation preview_or_modify_all
*
* @param iTopWebPage $oP
* @param \ApplicationContext $oAppContext
*
* @throws \ApplicationException
* @throws \ArchivedObjectException
* @throws \CoreCannotSaveObjectException
* @throws \CoreException
* @throws \DictExceptionMissingString
* @throws \OQLException
*/
public static function OperationPreviewOrModifyAll(iTopWebPage $oP, ApplicationContext $oAppContext): void
{
$oP->DisableBreadCrumb();
$sFilter = utils::ReadParam('filter', '', false, 'raw_data');
$oFilter = DBObjectSearch::unserialize($sFilter); // TO DO : check that the filter is valid
// Add user filter
$oFilter->UpdateContextFromUser();
$sClass = utils::ReadParam('class', '', false, 'class');
$bPreview = utils::ReadParam('preview_mode', '');
$sSelectedObj = utils::ReadParam('selectObj', '', false, 'raw_data');
if (empty($sClass) || empty($sSelectedObj)) // TO DO: check that the class name is valid !
{
throw new ApplicationException(Dict::Format('UI:Error:2ParametersMissing', 'class', 'selectObj'));
}
$aSelectedObj = explode(',', $sSelectedObj);
$sCancelUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search&filter=' . urlencode($sFilter) . '&' . $oAppContext->GetForLink();
$aContext = array(
'filter' => utils::EscapeHtml($sFilter),
'selectObj' => $sSelectedObj,
);
cmdbAbstractObject::DoBulkModify($oP, $sClass, $aSelectedObj, 'preview_or_modify_all', $bPreview, $sCancelUrl, $aContext);
}/**
$sClass = utils::ReadParam('class', '', false, 'class');
$bPreview = utils::ReadParam('preview_mode', '');
$sSelectedObj = utils::ReadParam('selectObj', '', false, 'raw_data');
if (empty($sClass) || empty($sSelectedObj)) // TO DO: check that the class name is valid !
{
throw new ApplicationException(Dict::Format('UI:Error:2ParametersMissing', 'class', 'selectObj'));
}
$aSelectedObj = explode(',', $sSelectedObj);
$sCancelUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search&filter='.urlencode($sFilter).'&'.$oAppContext->GetForLink();
$aContext = array(
'filter' => utils::EscapeHtml($sFilter),
'selectObj' => $sSelectedObj,
);
cmdbAbstractObject::DoBulkModify($oP, $sClass, $aSelectedObj, 'preview_or_modify_all', $bPreview, $sCancelUrl, $aContext);
}
/**
* Displays a form (checkboxes) to select the objects for which to apply a given action
* Only the objects for which the action is valid can be checked. By default all valid objects are checked
*
@@ -128,8 +130,8 @@ class BulkHelper
* @throws \ApplicationException
* @throws \ArchivedObjectException
* @throws \CoreException
*@since 3.0.0 $aDisplayParams parameter
*
* @since 3.0.0 $aDisplayParams parameter
*
*/
public static function DisplayMultipleSelectionForm(WebPage $oP, DBSearch $oFilter, string $sNextOperation, ActionChecker $oChecker, array $aExtraFormParams = [], array $aDisplayParams = [])
{
@@ -145,7 +147,7 @@ class BulkHelper
}
$oForm = new Form();
$oForm->SetAction( utils::GetAbsoluteUrlAppRoot().'pages/UI.php');
$oForm->SetAction(utils::GetAbsoluteUrlAppRoot().'pages/UI.php');
$oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('operation', $sNextOperation));
$oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('class', $oFilter->GetClass()));
$oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden('filter', utils::HtmlEntities($oFilter->Serialize())));

View File

@@ -27,7 +27,7 @@ class SynchroReplicaHelper
// Add user filter
$oFullSetFilter->UpdateContextFromUser();
$aSelectObject = utils::ReadMultipleSelection($oFullSetFilter);
if ( empty($sClass) || empty($aSelectObject)) // TO DO: check that the class name is valid !
if (empty($sClass) || empty($aSelectObject)) // TO DO: check that the class name is valid !
{
throw new ApplicationException(Dict::Format('UI:Error:2ParametersMissing', 'class', 'selectObject[]'));
}
@@ -67,7 +67,7 @@ class SynchroReplicaHelper
$bResult = true;
try {
if (in_array($sOperation, ['unlink', 'unlinksynchro'])) {
$oReplica->UnLink();
$oReplica->UnLink();
}
if (in_array($sOperation, ['synchro', 'unlinksynchro'])) {
$oStatLog = $oReplica->ReSynchro();

View File

@@ -18,10 +18,10 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\Helper\BulkHelper;
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory;
use Combodo\iTop\Application\WebPage\iTopWebPage;
use Combodo\iTop\Application\Helper\BulkHelper;
require_once('../approot.inc.php');
require_once(APPROOT.'/application/application.inc.php');
@@ -37,7 +37,6 @@ $oP = new iTopWebPage("iTop - Synchro Replicas");
// Main program
$sOperation = utils::ReadParam('operation', 'details');
try {
switch ($sOperation) {
case 'details':
@@ -53,7 +52,7 @@ try {
$iSourceId = utils::ReadParam('datasource', null);
if ($iSourceId != null) {
$oSource = MetaModel::GetObject(SynchroDataSource::class, $iSourceId);
$oBackButton = ButtonUIBlockFactory::MakeLinkNeutral( ApplicationContext::MakeObjectUrl(SynchroDataSource::class, $iSourceId), Dict::Format('Core:SynchroReplica:BackToDataSource', $oSource->GetName()), 'fas fa-chevron-left');
$oBackButton = ButtonUIBlockFactory::MakeLinkNeutral(ApplicationContext::MakeObjectUrl(SynchroDataSource::class, $iSourceId), Dict::Format('Core:SynchroReplica:BackToDataSource', $oSource->GetName()), 'fas fa-chevron-left');
$oP->AddUiBlock($oBackButton);
$oP->AddUiBlock(TitleUIBlockFactory::MakeForPage(Dict::Format('Core:SynchroReplica:ListOfReplicas', $oSource->GetName())));
}
@@ -115,7 +114,7 @@ try {
throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'id'));
}
$oReplica = MetaModel::GetObject(SynchroReplica::class, $iId);
$oStatLog = $oReplica->Set('status_dest_creator',1);
$oStatLog = $oReplica->Set('status_dest_creator', 1);
$oReplica->DisplayDetails($oP);
break;
@@ -130,23 +129,23 @@ try {
break;
case 'select_for_unlink_all': // Select the list of objects to be modified (bulk modify)
BulkHelper::OperationSelectForModifyAll($oP,'UI:UnlinkAllTabTitle', 'UI:UnlinkAllPageTitle', 'form_for_unlink_all');
BulkHelper::OperationSelectForModifyAll($oP, 'UI:UnlinkAllTabTitle', 'UI:UnlinkAllPageTitle', 'form_for_unlink_all');
break;
case 'select_for_unlinksynchro_all': // Select the list of objects to be modified (bulk modify)
BulkHelper::OperationSelectForModifyAll($oP,'UI:UnlinkSynchroAllTabTitle', 'UI:UnlinkSynchroAllPageTitle', 'form_for_unlinksynchro_all');
BulkHelper::OperationSelectForModifyAll($oP, 'UI:UnlinkSynchroAllTabTitle', 'UI:UnlinkSynchroAllPageTitle', 'form_for_unlinksynchro_all');
break;
case 'select_for_synchro_all': // Select the list of objects to be modified (bulk modify)
BulkHelper::OperationSelectForModifyAll($oP,'UI:SynchroAllTabTitle', 'UI:SynchroAllPageTitle','form_for_synchro_all');
BulkHelper::OperationSelectForModifyAll($oP, 'UI:SynchroAllTabTitle', 'UI:SynchroAllPageTitle', 'form_for_synchro_all');
break;
case 'select_for_allowdelete_all': // Select the list of objects to be modified (bulk modify)
BulkHelper::OperationSelectForModifyAll($oP,'UI:AllowDeleteAllTabTitle', 'UI:AllowDeleteAllPageTitle','form_for_allowdelete_all');
BulkHelper::OperationSelectForModifyAll($oP, 'UI:AllowDeleteAllTabTitle', 'UI:AllowDeleteAllPageTitle', 'form_for_allowdelete_all');
break;
case 'select_for_denydelete_all': // Select the list of objects to be modified (bulk modify)
BulkHelper::OperationSelectForModifyAll($oP,'UI:DenyDeleteAllTabTitle', 'UI:DenyDeleteAllPageTitle','form_for_denydelete_all');
BulkHelper::OperationSelectForModifyAll($oP, 'UI:DenyDeleteAllTabTitle', 'UI:DenyDeleteAllPageTitle', 'form_for_denydelete_all');
break;
}
} catch (CoreException $e) {

View File

@@ -5,12 +5,12 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\WebPage\WebPage;
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlockUIBlockFactory;
use Combodo\iTop\Application\WebPage\WebPage;
use Combodo\iTop\Core\CMDBChange\CMDBChangeOrigin;
class SynchroDataSource extends cmdbAbstractObject
@@ -2204,7 +2204,8 @@ class SynchroReplica extends DBObject implements iDisplay
/*
* Disassociate the replica from the destination object and set the status to "new" to be synchronized with the next operation
*/
public function UnLink(){
public function UnLink()
{
$this->Set('dest_id', '');
$this->Set('dest_class', '');
$this->Set('status', 'new');
@@ -2793,6 +2794,7 @@ class SynchroReplica extends DBObject implements iDisplay
$oPage->SetCurrentTab('UI:PropertiesTab');
$this->DisplayBareProperties($oPage, $bEditMode);
}
public function DisplayBareHeader(WebPage $oPage, $bEditMode = false)
{
$oBlock = UIContentBlockUIBlockFactory::MakeStandard('title-for-replica', ['ibo-page-header--replica-title']);