mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 01:28:47 +02:00
- Bug fix: n:n wizard, context was lost when searching for objects of a derived class to be added.
- Bug fix: 'Apply stimulus multiple" was saying: "Please select at least one object" SVN:trunk[1334]
This commit is contained in:
124
pages/UI.php
124
pages/UI.php
@@ -537,23 +537,26 @@ try
|
||||
|
||||
case 'search_oql': // OQL query
|
||||
$sOQLClass = utils::ReadParam('oql_class', '');
|
||||
$sBaseClass = utils::ReadParam('base_class', $sOQLClass);
|
||||
$sOQLClause = utils::ReadParam('oql_clause', '');
|
||||
$sFormat = utils::ReadParam('format', '');
|
||||
$bSearchForm = utils::ReadParam('search_form', true);
|
||||
$sTitle = utils::ReadParam('title', 'UI:SearchResultsPageTitle');
|
||||
if (empty($sOQLClass))
|
||||
{
|
||||
throw new ApplicationException(Dict::Format('UI:Error:1ParametersMissing', 'oql_class'));
|
||||
}
|
||||
$oP->set_title(Dict::S('UI:SearchResultsPageTitle'));
|
||||
$oP->set_title(Dict::S($sTitle));
|
||||
$oP->add('<h1>'.Dict::S($sTitle).'</h1>');
|
||||
$sOQL = "SELECT $sOQLClass $sOQLClause";
|
||||
try
|
||||
{
|
||||
$oFilter = DBObjectSearch::FromOQL($sOQL);
|
||||
DisplaySearchSet($oP, $oFilter, $bSearchForm, $sBaseClass, $sFormat);
|
||||
$oFilter = DBObjectSearch::FromOQL($sOQL);
|
||||
DisplaySearchSet($oP, $oFilter, $bSearchForm, $sBaseClass, $sFormat);
|
||||
}
|
||||
catch(CoreException $e)
|
||||
{
|
||||
$oFilter = new DBObjectSearch($sOQLClass);
|
||||
$oFilter = new DBObjectSearch($sOQLClass);
|
||||
$oSet = new DBObjectSet($oFilter);
|
||||
if ($bSearchForm)
|
||||
{
|
||||
@@ -1366,7 +1369,7 @@ EOF
|
||||
}
|
||||
$oFilter = DBObjectSearch::unserialize($sFilter);
|
||||
$sClass = $oFilter->GetClass();
|
||||
$aSelectObj = utils::ReadMultipleSelection($oFilter);
|
||||
$aSelectObject = utils::ReadMultipleSelection($oFilter);
|
||||
if (count($aSelectObject) == 0)
|
||||
{
|
||||
// Nothing to do, no object was selected !
|
||||
@@ -1830,118 +1833,7 @@ EOF
|
||||
break;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
case 'modify_links': // ?? still used ??
|
||||
$sClass = utils::ReadParam('class', '');
|
||||
$sLinkAttr = utils::ReadParam('link_attr', '');
|
||||
$sTargetClass = utils::ReadParam('target_class', '');
|
||||
$id = utils::ReadParam('id', '');
|
||||
$bAddObjects = utils::ReadParam('addObjects', false);
|
||||
if ( empty($sClass) || empty($id) || empty($sLinkAttr) || empty($sTargetClass)) // TO DO: check that the class name is valid !
|
||||
{
|
||||
throw new ApplicationException(Dict::Format('UI:Error:4ParametersMissing', 'class', 'id', 'target_class', 'link_attr'));
|
||||
}
|
||||
require_once(APPROOT.'/application/uilinkswizard.class.inc.php');
|
||||
$oWizard = new UILinksWizard($sClass, $sLinkAttr, $id, $sTargetClass);
|
||||
$oWizard->Display($oP, array('StartWithAdd' => $bAddObjects));
|
||||
break;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
case 'do_modify_links': // ?? still used ??
|
||||
$aLinks = utils::ReadPostedParam('linkId', array());
|
||||
$sLinksToRemove = trim(utils::ReadPostedParam('linksToRemove', ''));
|
||||
$aLinksToRemove = array();
|
||||
if (!empty($sLinksToRemove))
|
||||
{
|
||||
$aLinksToRemove = explode(' ', trim($sLinksToRemove));
|
||||
}
|
||||
$sClass = utils::ReadPostedParam('class', '');
|
||||
$sLinkageAtt = utils::ReadPostedParam('linkage', '');
|
||||
$iObjectId = utils::ReadPostedParam('object_id', '');
|
||||
$sLinkingAttCode = utils::ReadPostedParam('linking_attcode', '');
|
||||
$oMyChange = MetaModel::NewObject("CMDBChange");
|
||||
$oMyChange->Set("date", time());
|
||||
$sUserString = CMDBChange::GetCurrentUserName();
|
||||
$oMyChange->Set("userinfo", $sUserString);
|
||||
$iChangeId = $oMyChange->DBInsert();
|
||||
|
||||
// Delete links that are to be deleted
|
||||
foreach($aLinksToRemove as $iLinkId)
|
||||
{
|
||||
if ($iLinkId > 0) // Negative IDs are objects that were not even created
|
||||
{
|
||||
$oLink = MetaModel::GetObject($sClass, $iLinkId);
|
||||
$oLink->DBDeleteTracked($oMyChange);
|
||||
}
|
||||
}
|
||||
|
||||
$aEditableFields = array();
|
||||
$aData = array();
|
||||
foreach(MetaModel::GetAttributesList($sClass) as $sAttCode)
|
||||
{
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||
if ( (!$oAttDef->IsExternalKey()) && (!$oAttDef->IsExternalField()))
|
||||
{
|
||||
$aEditableFields[] = $sAttCode;
|
||||
$aData[$sAttCode] = utils::ReadParam('attr_'.$sAttCode, array(), 'post');
|
||||
}
|
||||
}
|
||||
|
||||
// Update existing links or create new links
|
||||
foreach($aLinks as $iLinkId)
|
||||
{
|
||||
if ($iLinkId > 0)
|
||||
{
|
||||
// This is an existing link to be modified
|
||||
$oLink = MetaModel::GetObject($sClass, $iLinkId);
|
||||
|
||||
// Update all the attributes of the link
|
||||
foreach($aEditableFields as $sAttCode)
|
||||
{
|
||||
$value = $aData[$sAttCode][$iLinkId];
|
||||
$oLink->Set($sAttCode, $value);
|
||||
}
|
||||
if ($oLink->IsModified())
|
||||
{
|
||||
$oLink->DBUpdateTracked($oMyChange);
|
||||
}
|
||||
//echo "Updated link:<br/>\n";
|
||||
//var_dump($oLink);
|
||||
}
|
||||
else
|
||||
{
|
||||
// A new link must be created
|
||||
$oLink = MetaModel::NewObject($sClass);
|
||||
$oLinkedObjectId = -$iLinkId;
|
||||
// Set all the attributes of the link
|
||||
foreach($aEditableFields as $sAttCode)
|
||||
{
|
||||
$value = $aData[$sAttCode][$iLinkId];
|
||||
$oLink->Set($sAttCode, $value);
|
||||
}
|
||||
// And the two external keys
|
||||
$oLink->Set($sLinkageAtt, $iObjectId);
|
||||
$oLink->Set($sLinkingAttCode, $oLinkedObjectId);
|
||||
// then save it
|
||||
//echo "Created link:<br/>\n";
|
||||
//var_dump($oLink);
|
||||
$oLink->DBInsertTracked($oMyChange);
|
||||
}
|
||||
}
|
||||
// Display again the details of the linked object
|
||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sLinkageAtt);
|
||||
$sTargetClass = $oAttDef->GetTargetClass();
|
||||
$oObj = MetaModel::GetObject($sTargetClass, $iObjectId);
|
||||
|
||||
$oSearch = new DBObjectSearch(get_class($oObj));
|
||||
$oBlock = new DisplayBlock($oSearch, 'search', false);
|
||||
$oBlock->Display($oP, 0);
|
||||
$oObj->DisplayDetails($oP);
|
||||
break;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
case 'swf_navigator': // Graphical display of the relations "impact" / "depends on"
|
||||
$sClass = utils::ReadParam('class', '');
|
||||
$id = utils::ReadParam('id', 0);
|
||||
|
||||
@@ -158,16 +158,6 @@ try
|
||||
}
|
||||
break;
|
||||
|
||||
case 'addObjects':
|
||||
require_once(APPROOT.'/application/uilinkswizard.class.inc.php');
|
||||
$sClass = utils::ReadParam('class', '', 'get');
|
||||
$sLinkedClass = utils::ReadParam('linkedClass', '');
|
||||
$sLinkageAttr = utils::ReadParam('linkageAttr', '');
|
||||
$iObjectId = utils::ReadParam('objectId', '');
|
||||
$oLinksWizard = new UILinksWizard($sClass, $sLinkageAttr, $iObjectId, $sLinkedClass);
|
||||
$oLinksWizard->DisplayAddForm($oPage);
|
||||
break;
|
||||
|
||||
// ui.linkswidget
|
||||
case 'searchObjectsToAdd':
|
||||
$sRemoteClass = utils::ReadParam('sRemoteClass', '');
|
||||
@@ -268,10 +258,18 @@ try
|
||||
$sAttCode = utils::ReadParam('sAttCode', '');
|
||||
$iInputId = utils::ReadParam('iInputId', '');
|
||||
$sSuffix = utils::ReadParam('sSuffix', '');
|
||||
$sRemoteClass = utils::ReadParam('sRemoteClass', '');
|
||||
$sRemoteClass = utils::ReadParam('sRemoteClass', $sClass);
|
||||
$bDuplicates = (utils::ReadParam('bDuplicates', 'false') == 'false') ? false : true;
|
||||
$oWidget = new UILinksWidget($sClass, $sAttCode, $iInputId, $sSuffix, $bDuplicates);
|
||||
$oWidget->DoAddObjects($oPage, $sRemoteClass);
|
||||
if ($sFilter != '')
|
||||
{
|
||||
$oFullSetFilter = DBObjectSearch::unserialize($sFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oFullSetFilter = new DBObjectSearch($sRemoteClass);
|
||||
}
|
||||
$oWidget->DoAddObjects($oPage, $oFullSetFilter);
|
||||
break;
|
||||
|
||||
case 'wizard_helper_preview':
|
||||
@@ -357,14 +355,6 @@ try
|
||||
$oDisplayBlock->RenderContent($oPage);
|
||||
break;
|
||||
|
||||
case 'preview':
|
||||
$key = utils::ReadParam('id', 0);
|
||||
$oFilter = new DBObjectSearch($sClass);
|
||||
$oFilter->AddCondition('id', $key, '=');
|
||||
$oDisplayBlock = new DisplayBlock($oFilter, 'preview', false);
|
||||
$oDisplayBlock->RenderContent($oPage);
|
||||
break;
|
||||
|
||||
case 'pie_chart':
|
||||
$sGroupBy = utils::ReadParam('group_by', '');
|
||||
if ($sFilter != '')
|
||||
|
||||
Reference in New Issue
Block a user