diff --git a/application/utils.inc.php b/application/utils.inc.php index c28d776ef..56c82996a 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2502,25 +2502,35 @@ class utils ); // Mentions - // Note: Endpoints are defaults only and should be overloaded by other GUIs such as the end-users portal - $sMentionsEndpoint = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=cke_mentions&target_class=Person&needle={encodedQuery}'; - $sMentionItemUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class=Person&id={id}'; - $sMentionItemTemplate = <<{friendlyname} + $aMentionsAllowedClasses = MetaModel::GetConfig()->Get('mentions.allowed_classes'); + if(!empty($aMentionsAllowedClasses)) { + $aDefaultConf['mentions'] = []; + + foreach($aMentionsAllowedClasses as $sMentionChar => $sMentionClass) { + // Note: Endpoints are defaults only and should be overloaded by other GUIs such as the end-users portal + $sMentionEndpoint = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=cke_mentions&target_class='.$sMentionClass.'&needle={encodedQuery}'; + $sMentionItemUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=details&class='.$sMentionClass.'&id={id}'; + + $sMentionItemPictureTemplate = (empty(MetaModel::GetImageAttributeCode($sMentionClass))) ? '' : << HTML; - $sMentionOutputTemplate = <<@{friendlyname} + $sMentionItemTemplate = <<{$sMentionItemPictureTemplate}{friendlyname} HTML; - $aDefaultConf['mentions'] = array( - array( - 'feed' => $sMentionsEndpoint, - 'marker' => '@', - 'minChars' => 1, //MetaModel::GetConfig()->Get('min_autocomplete_chars'), - 'itemTemplate' => $sMentionItemTemplate, - 'outputTemplate' => $sMentionOutputTemplate, - 'throttle' => 500, - ), - ); + $sMentionOutputTemplate = <<{$sMentionChar}{friendlyname} +HTML; + + $aDefaultConf['mentions'][] = [ + 'feed' => $sMentionEndpoint, + 'marker' => $sMentionChar, + 'minChars' => MetaModel::GetConfig()->Get('min_autocomplete_chars'), + 'itemTemplate' => $sMentionItemTemplate, + 'outputTemplate' => $sMentionOutputTemplate, + 'throttle' => 500, + ]; + } + } $aRichTextConfig = json_decode(appUserPreferences::GetPref('richtext_config', '{}'), true); diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 8fd45b9f0..63d62a9ef 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1152,6 +1152,16 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], + 'mentions.allowed_classes' => [ + 'type' => 'array', + 'description' => 'Classes which can be mentioned through the autocomplete in the caselogs. Key of the array must be a single character that will trigger the autocomplete (eg. "@" => "Person")', + 'default' => [ + '@' => 'Person', + ], + 'value' => false, + 'source_of_value' => '', + 'show_in_conf_sample' => true, + ], 'global_search.enabled' => [ 'type' => 'bool', 'description' => 'Whether or not the global search is enabled', diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 1abcf4080..ffce35383 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -2576,6 +2576,7 @@ EOF $oPage->add(""); break; + // TODO 3.0.0: Move this to new ajax render controller? case 'cke_mentions': $oPage->SetContentType('application/json'); $sTargetClass = utils::ReadParam('target_class', '', false, 'class');