N°7552 - Fix mentions not taking triggers filter into account

This commit is contained in:
Molkobain
2024-07-04 11:30:10 +02:00
parent 8c4c0ff5e1
commit c3582f0aff
6 changed files with 125 additions and 122 deletions

View File

@@ -107,7 +107,7 @@ class CKEditorHelper
'minimumCharacters' => MetaModel::GetConfig()->Get('min_autocomplete_chars'),
'feed_type' => 'ajax',
'feed_ajax_options' => [
'url' => utils::GetAbsoluteUrlAppRoot(). "pages/ajax.render.php?route=object.search&object_class=$sMentionClass&oql=SELECT $sMentionClass&search=",
'url' => utils::GetAbsoluteUrlAppRoot(). "pages/ajax.render.php?route=object.search_for_mentions&marker=".urlencode($sMentionMarker)."&needle=",
'throttle' => 500,
'marker' => $sMentionMarker,
],

View File

@@ -217,12 +217,23 @@ class CaseLogEntryForm extends UIContentBlock
$this->oTextInput = new RichText();
// Add the "host_class" to the mention endpoints so it can filter objects regarding the triggers
// Mind that `&needle=` must be ending the endpoint URL in order for the JS plugin to append the needle string
$aConfig = $this->oTextInput->GetConfig();
if (isset($aConfig['mentions'])) {
foreach ($aConfig['mentions'] as $iIdx => $aData) {
$sFeed = $aConfig['mentions'][$iIdx]['feed'];
if (isset($aConfig['mention']['feeds'])) {
foreach ($aConfig['mention']['feeds'] as $iIdx => $aData) {
$sFeed = $aConfig['mention']['feeds'][$iIdx]['feed_ajax_options']['url'];
// Remove existing "needle" parameter
$sFeed = str_replace('&needle=', '', $sFeed);
// Add new parameters
$sFeed = utils::AddParameterToUrl($sFeed, 'host_class', $this->GetObjectClass());
$aConfig['mentions'][$iIdx]['feed'] = utils::AddParameterToUrl($sFeed, 'host_id', $this->GetObjectId());
$sFeed = utils::AddParameterToUrl($sFeed, 'host_id', $this->GetObjectId());
// Re-append "needle" parameter
$sFeed = utils::AddParameterToUrl($sFeed, 'needle', '');
$aConfig['mention']['feeds'][$iIdx]['feed_ajax_options']['url'] = $sFeed;
}
}
$this->oTextInput->SetConfig($aConfig);