new: show highlighted tags in event index

pull/8794/head
Luciano Righetti 2022-11-30 15:07:41 +01:00
parent d7fdbf9db9
commit 65004e89ed
No known key found for this signature in database
GPG Key ID: CB91F2A37C557248
5 changed files with 37 additions and 11 deletions

View File

@ -1022,6 +1022,7 @@ class EventsController extends AppController
if (in_array('tags', $columns, true) || in_array('clusters', $columns, true)) {
$events = $this->Event->attachTagsToEvents($events);
$events = $this->GalaxyCluster->attachClustersToEventIndex($user, $events, true);
$events = $this->__attachHighlightedTagsToEvents($events);
}
if (in_array('correlations', $columns, true)) {
@ -6227,7 +6228,23 @@ class EventsController extends AppController
private function __setHighlightedTags($event)
{
$this->loadModel('Taxonomy');
$highlightedTags = $this->Taxonomy->getHighlightedTags($event['EventTag']);
$this->set('highlightedTaxonomies', $highlightedTags);
$highlightedTags = $this->Taxonomy->getHighlightedTags($this->Taxonomy->getHighlightedTaxonomies(), $event['EventTag']);
$this->set('highlightedTags', $highlightedTags);
}
/**
*
* @param array $events
* @return array
*/
private function __attachHighlightedTagsToEvents($events)
{
$this->loadModel('Taxonomy');
$highlightedTaxonomies = $this->Taxonomy->getHighlightedTaxonomies();
foreach ($events as $k => $event) {
$events[$k]['Event']['highlightedTags'] = $this->Taxonomy->getHighlightedTags($highlightedTaxonomies, $event['EventTag']);
}
return $events;
}
}

View File

@ -367,7 +367,7 @@ class TagsController extends AppController
// Remove galaxy tags
$event = $this->Tag->removeGalaxyClusterTags($user, $event);
$highlightedTags = $this->Taxonomy->getHighlightedTags($event['EventTag']);
$highlightedTags = $this->Taxonomy->getHighlightedTags($this->Taxonomy->getHighlightedTaxonomies(), $event['EventTag']);
$this->set('highlightedTaxonomies', $highlightedTags);
$this->set('tags', $event['EventTag']);

View File

@ -880,20 +880,28 @@ class Taxonomy extends AppModel
}
/**
*
* @param array $tags
* @return array
*/
public function getHighlightedTags($tags)
public function getHighlightedTaxonomies()
{
$highlitedTaxonomies = $this->find('all', [
return $this->find('all', [
'conditions' => [
'highlighted' => 1,
]
]);
}
/**
*
* @param array $highlightedTaxonomies
* @param array $tags
* @return array
*/
public function getHighlightedTags($highlightedTaxonomies, $tags)
{
$highlightedTags = [];
if (is_array($highlitedTaxonomies) && !empty($highlitedTaxonomies)) {
foreach ($highlitedTaxonomies as $k => $taxonomy) {
if (is_array($highlightedTaxonomies) && !empty($highlightedTaxonomies)) {
foreach ($highlightedTaxonomies as $k => $taxonomy) {
$highlightedTags[$k] = [
'taxonomy' => $taxonomy,

View File

@ -94,6 +94,7 @@
'columnised' => true,
'static_tags_only' => 1,
'tag_display_style' => Configure::check('MISP.full_tags_on_event_index') ? Configure::read('MISP.full_tags_on_event_index') : 1,
'highlightedTags' => $event['Event']['highlightedTags'] ?? [],
]);
?>
</td>

View File

@ -48,8 +48,8 @@
}
$highlitedTags = "";
if (isset($highlightedTaxonomies) && $scope == 'event') {
foreach ($highlightedTaxonomies as $hTaxonomy) {
if (isset($highlightedTags) && $scope == 'event') {
foreach ($highlightedTags as $hTaxonomy) {
$hButtonData = [];
if ($full) {
$hButtonData[] = sprintf(