mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 11:38:44 +02:00
Advanced Search: Links n:n
SVN:b1162[5438]
This commit is contained in:
@@ -387,36 +387,42 @@ EOF
|
||||
* @param WebPage $oPage
|
||||
* @param DBObject $oCurrentObj
|
||||
* @param $sJson
|
||||
* @param array $aAlreadyLinkedIds
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \DictExceptionMissingString
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetObjectPickerDialog($oPage, $oCurrentObj, $sJson)
|
||||
public function GetObjectPickerDialog($oPage, $oCurrentObj, $sJson, $aAlreadyLinkedIds = array())
|
||||
{
|
||||
$bOpen = MetaModel::GetConfig()->Get('legacy_search_drawer_open');
|
||||
$sHtml = "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
|
||||
$oFilter = new DBObjectSearch($this->m_sRemoteClass);
|
||||
$this->SetSearchDefaultFromContext($oCurrentObj, $oFilter);
|
||||
if (!$this->m_bDuplicatesAllowed && count($aAlreadyLinkedIds) > 0)
|
||||
{
|
||||
$oFilter->AddCondition('id', $aAlreadyLinkedIds, 'NOTIN');
|
||||
}
|
||||
//$this->SetSearchDefaultFromContext($oCurrentObj, $oFilter);
|
||||
$oBlock = new DisplayBlock($oFilter, 'search', false);
|
||||
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
array(
|
||||
'menu' => false,
|
||||
'open' => $bOpen,
|
||||
'table_id' => "SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
'table_id2' => 'add_'.$this->m_sAttCode,
|
||||
'table_inner_id' => "ResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}",
|
||||
'selection_mode' => true,
|
||||
'json' => $sJson,
|
||||
'cssCount' => '#count_'.$this->m_sAttCode.$this->m_sNameSuffix
|
||||
));
|
||||
$sHtml .= "<form id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\" OnSubmit=\"return oWidget{$this->m_iInputId}.DoAddObjects(this.id);\">\n";
|
||||
$sHtml .= "<div id=\"ObjectsAddForm_{$this->m_sAttCode}{$this->m_sNameSuffix}\">\n";
|
||||
$sHtml .= "<div id=\"SearchResultsToAdd_{$this->m_sAttCode}{$this->m_sNameSuffix}\" style=\"vertical-align:top;background: #fff;height:100%;overflow:auto;padding:0;border:0;\">\n";
|
||||
$sHtml .= "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>".Dict::S('UI:Message:EmptyList:UseSearchForm')."</p></div>\n";
|
||||
$sHtml .= "</div>\n";
|
||||
$sHtml .= "<input type=\"hidden\" id=\"count_{$this->m_sAttCode}{$this->m_sNameSuffix}\" value=\"0\"/>";
|
||||
$sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\"> <input id=\"btn_ok_{$this->m_sAttCode}{$this->m_sNameSuffix}\" disabled=\"disabled\" type=\"submit\" value=\"".Dict::S('UI:Button:Add')."\">";
|
||||
$sHtml .= "<input type=\"button\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('close');\"> <input id=\"btn_ok_{$this->m_sAttCode}{$this->m_sNameSuffix}\" disabled=\"disabled\" type=\"button\" onclick=\"return oWidget{$this->m_iInputId}.DoAddObjects(this.id);\" value=\"".Dict::S('UI:Button:Add')."\">";
|
||||
$sHtml .= "</div>\n";
|
||||
$sHtml .= "</div>\n";
|
||||
$sHtml .= "</form>\n";
|
||||
$oPage->add($sHtml);
|
||||
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog({ width: $(window).width()*0.8, height: $(window).height()*0.8, autoOpen: false, modal: true, resizeStop: oWidget{$this->m_iInputId}.UpdateSizes });");
|
||||
$oPage->add_ready_script("$('#dlg_{$this->m_sAttCode}{$this->m_sNameSuffix}').dialog('option', {title:'".addslashes(Dict::Format('UI:AddObjectsOf_Class_LinkedWith_Class', MetaModel::GetName($this->m_sLinkedClass), MetaModel::GetName($this->m_sClass)))."'});");
|
||||
|
||||
@@ -269,7 +269,8 @@ try
|
||||
$oObj = null;
|
||||
}
|
||||
$oWidget = new UILinksWidget($sClass, $sAttCode, $iInputId, $sSuffix, $bDuplicates);
|
||||
$oWidget->GetObjectPickerDialog($oPage, $oObj, $sJson);
|
||||
$aAlreadyLinked = utils::ReadParam('aAlreadyLinked', array());
|
||||
$oWidget->GetObjectPickerDialog($oPage, $oObj, $sJson, $aAlreadyLinked);
|
||||
break;
|
||||
|
||||
// ui.linkswidget
|
||||
@@ -1129,12 +1130,10 @@ EOF
|
||||
{
|
||||
$aResult['error'] = 'Dashboard id="'.$sMenuId.'" not found.';
|
||||
}
|
||||
}
|
||||
catch(DOMException $e)
|
||||
} catch (DOMException $e)
|
||||
{
|
||||
$aResult = array('error' => Dict::S('UI:Error:InvalidDashboardFile'));
|
||||
}
|
||||
catch(Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
$aResult = array('error' => $e->getMessage());
|
||||
}
|
||||
@@ -1421,12 +1420,14 @@ EOF
|
||||
}
|
||||
$bSkip |= array_key_exists('skip', $aRestriction) ? $aRestriction['skip'] : false;
|
||||
if (!in_array($sClass, $aSearchClasses))
|
||||
{
|
||||
if ($sClass == $sClassName)
|
||||
{
|
||||
// Class explicitely requested, do NOT skip it
|
||||
// beware: there may not be a 'query' defined for a skipped class !
|
||||
$bSkip = false;
|
||||
}
|
||||
}
|
||||
if (!$bSkip)
|
||||
{
|
||||
// NOT skipped, add the class to the list of classes to search into
|
||||
@@ -1501,8 +1502,7 @@ EOF
|
||||
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
|
||||
$('.search-class-$sClassName').html(data);
|
||||
});
|
||||
EOF
|
||||
;
|
||||
EOF;
|
||||
|
||||
|
||||
$sEnlargeButton = '';
|
||||
@@ -1546,7 +1546,9 @@ EOF
|
||||
$oPage->p(' '); // Some space ?
|
||||
}
|
||||
}
|
||||
else if (array_key_exists($sClassName, $aAccelerators))
|
||||
else
|
||||
{
|
||||
if (array_key_exists($sClassName, $aAccelerators))
|
||||
{
|
||||
$oPage->add("<div class=\"search-class-result search-class-$sClassName\">\n");
|
||||
$oPage->add("<div class=\"page_header\">\n");
|
||||
@@ -1555,6 +1557,7 @@ EOF
|
||||
$oPage->add("</div>\n");
|
||||
$oPage->p(' '); // Some space ?
|
||||
}
|
||||
}
|
||||
if ($iTune > 0)
|
||||
{
|
||||
$fDurationClass = microtime(true) - $fStartedClass;
|
||||
@@ -1917,7 +1920,8 @@ EOF
|
||||
$oSet = CMDBObjectSet::FromArray($sListClass, $aObjects);
|
||||
$oSet->SetShowObsoleteData(utils::ShowObsoleteData());
|
||||
$sHtml = "<div class=\"page_header\">\n";
|
||||
$sHtml .= "<table class=\"section\"><tr><td>".MetaModel::GetClassIcon($sListClass, true, 'width: 24px; height: 24px;')." ".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', $oSet->Count(), Metamodel::GetName($sListClass))."</td></tr></table>\n";
|
||||
$sHtml .= "<table class=\"section\"><tr><td>".MetaModel::GetClassIcon($sListClass, true, 'width: 24px; height: 24px;')." ".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', $oSet->Count(),
|
||||
Metamodel::GetName($sListClass))."</td></tr></table>\n";
|
||||
$sHtml .= "</div>\n";
|
||||
$oPage->add($sHtml);
|
||||
cmdbAbstractObject::DisplaySet($oPage, $oSet, array('table_id' => $sSourceClass.'_'.$sRelation.'_'.$sDirection.'_'.$sListClass));
|
||||
@@ -2135,8 +2139,7 @@ EOF
|
||||
break;
|
||||
|
||||
case 'export_build':
|
||||
register_shutdown_function(function()
|
||||
{
|
||||
register_shutdown_function(function () {
|
||||
$aErr = error_get_last();
|
||||
if (($aErr !== null) && ($aErr['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR)))
|
||||
{
|
||||
@@ -2220,13 +2223,11 @@ EOF
|
||||
}
|
||||
}
|
||||
$oPage->add(json_encode($aResult));
|
||||
}
|
||||
catch(BulkExportException $e)
|
||||
} catch (BulkExportException $e)
|
||||
{
|
||||
$aResult = array('code' => 'error', 'percentage' => 100, 'message' => $e->GetLocalizedMessage());
|
||||
$oPage->add(json_encode($aResult));
|
||||
}
|
||||
catch(Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
$aResult = array('code' => 'error', 'percentage' => 100, 'message' => $e->getMessage());
|
||||
$oPage->add(json_encode($aResult));
|
||||
@@ -2283,12 +2284,15 @@ EOF
|
||||
$aResult['message'] = Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName);
|
||||
$aResult['popup_message'] = Dict::Format('UI:CurrentObjectIsLockedBy_User_Explanation', $sName);
|
||||
}
|
||||
else if ($aResult['operation'] == 'expired')
|
||||
else
|
||||
{
|
||||
if ($aResult['operation'] == 'expired')
|
||||
{
|
||||
$aResult['message'] = Dict::S('UI:CurrentObjectLockExpired');
|
||||
$aResult['popup_message'] = Dict::S('UI:CurrentObjectLockExpired_Explanation');
|
||||
}
|
||||
}
|
||||
}
|
||||
$oPage->add(json_encode($aResult));
|
||||
break;
|
||||
|
||||
@@ -2350,8 +2354,7 @@ EOF
|
||||
{
|
||||
$aResult['error'] = $oDoc->GetFileName().' is not a valid image format.';
|
||||
}
|
||||
}
|
||||
catch (FileUploadException $e)
|
||||
} catch (FileUploadException $e)
|
||||
{
|
||||
$aResult['error'] = $e->GetMessage();
|
||||
}
|
||||
@@ -2379,8 +2382,7 @@ EOF
|
||||
$iAttId = $oAttachment->DBInsert();
|
||||
|
||||
}
|
||||
}
|
||||
catch (FileUploadException $e)
|
||||
} catch (FileUploadException $e)
|
||||
{
|
||||
// fail silently ??
|
||||
}
|
||||
@@ -2518,8 +2520,7 @@ EOF
|
||||
$aRenderRes = $oRenderer->Render($aRequestedFields);
|
||||
|
||||
$aResult['form']['updated_fields'] = $aRenderRes;
|
||||
}
|
||||
catch (Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
$aResult['error'] = $e->getMessage();
|
||||
}
|
||||
@@ -2531,8 +2532,7 @@ EOF
|
||||
}
|
||||
|
||||
$oPage->output();
|
||||
}
|
||||
catch (Exception $e)
|
||||
} catch (Exception $e)
|
||||
{
|
||||
// note: transform to cope with XSS attacks
|
||||
echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8');
|
||||
|
||||
@@ -57,19 +57,9 @@ try
|
||||
$sListParams = stripslashes(utils::ReadParam('list_params', '{}', false, 'raw_data'));
|
||||
$aListParams = (array) json_decode($sListParams, true);
|
||||
|
||||
|
||||
$aPassFromExtraParamsToListParams = array(
|
||||
'currentId',
|
||||
'selection_mode',
|
||||
'selection_type',// In case of single selection, the root of the HTML identifiers used is suffixed with "_results" (at least in the external keys)
|
||||
'cssCount',
|
||||
);
|
||||
foreach ($aPassFromExtraParamsToListParams as $passThroughKey)
|
||||
foreach($aListParams as $key => $value)
|
||||
{
|
||||
if (array_key_exists($passThroughKey, $aListParams))
|
||||
{
|
||||
$aExtraParams[$passThroughKey] = $aListParams[$passThroughKey];
|
||||
}
|
||||
$aExtraParams[$key] = $value;
|
||||
}
|
||||
|
||||
if (array_key_exists('table_inner_id', $aListParams))
|
||||
|
||||
@@ -61,11 +61,15 @@ class SearchForm
|
||||
$sClassName = $oSet->GetFilter()->GetClass();
|
||||
$aListParams = array();
|
||||
|
||||
foreach($aExtraParams as $key => $value)
|
||||
{
|
||||
$aListParams[$key] = $value;
|
||||
}
|
||||
|
||||
// Simple search form
|
||||
if (isset($aExtraParams['currentId']))
|
||||
{
|
||||
$sSearchFormId = $aExtraParams['currentId'];
|
||||
$aListParams['currentId'] = $aExtraParams['currentId'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -83,23 +87,13 @@ class SearchForm
|
||||
{
|
||||
$sRootClass = $sClassName;
|
||||
}
|
||||
if (array_key_exists('selection_mode', $aExtraParams))
|
||||
{
|
||||
$aListParams['selection_mode'] = $aExtraParams['selection_mode'];
|
||||
}
|
||||
if (array_key_exists('selection_type', $aExtraParams))
|
||||
{
|
||||
$aListParams['selection_type'] = $aExtraParams['selection_type'];
|
||||
}
|
||||
|
||||
$sJson = stripslashes(utils::ReadParam('json', '', false, 'raw_data'));
|
||||
if (!empty($sJson))
|
||||
{
|
||||
$aListParams['json'] = json_decode($sJson, true);
|
||||
}
|
||||
if (array_key_exists('cssCount', $aExtraParams))
|
||||
{
|
||||
$aListParams['cssCount'] = $aExtraParams['cssCount'];
|
||||
}
|
||||
|
||||
|
||||
$aSubClasses = MetaModel::GetSubclasses($sRootClass);
|
||||
if (count($aSubClasses) > 0)
|
||||
@@ -139,15 +133,14 @@ class SearchForm
|
||||
{
|
||||
$aExtraParams['table_id'] = "search_form_result_{$sSearchFormId}";
|
||||
}
|
||||
$aListParams['table_id'] = $aExtraParams['table_id'];
|
||||
if (array_key_exists('table_inner_id', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_inner_id'] = $aExtraParams['table_inner_id'];
|
||||
}
|
||||
else
|
||||
if (!array_key_exists('table_inner_id', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_inner_id'] = uniqid('table_inner_id_');
|
||||
}
|
||||
if (array_key_exists('table_id2', $aExtraParams))
|
||||
{
|
||||
$aListParams['table_id'] = $aExtraParams['table_id2'];
|
||||
}
|
||||
$aSearchParams = array(
|
||||
'criterion_outer_selector' => "#fs_{$sSearchFormId}_criterion_outer",
|
||||
'result_list_outer_selector' => "#{$aExtraParams['table_id']}",
|
||||
@@ -162,14 +155,14 @@ class SearchForm
|
||||
),
|
||||
);
|
||||
|
||||
if (isset($aSearchParams['list_params']['table_inner_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_inner_id'];
|
||||
}
|
||||
elseif (isset($aSearchParams['list_params']['table_id']))
|
||||
if (isset($aSearchParams['list_params']['table_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_id'];
|
||||
}
|
||||
elseif (isset($aSearchParams['list_params']['table_inner_id']))
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['list_params']['table_inner_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$aSearchParams['data_config_list_selector'] = '#'.$aSearchParams['result_list_outer_selector'];
|
||||
|
||||
Reference in New Issue
Block a user