mirror of https://github.com/MISP/MISP
new: [tags] refactor of the tag picker
- massive performance boost - re-introduction of the custom tagspull/4416/head
parent
bb42cf79ba
commit
6f6e41b497
|
@ -587,6 +587,10 @@ class TagsController extends AppController
|
|||
'value' => "/tags/selectTag/" . h($id) . "/collections/" . h($scope)
|
||||
);
|
||||
}
|
||||
$items[] = array(
|
||||
'name' => __('Custom Tags'),
|
||||
'value' => "/tags/selectTag/" . h($id) . "/0/" . h($scope)
|
||||
);
|
||||
$items[] = array(
|
||||
'name' => __('All Tags'),
|
||||
'value' => "/tags/selectTag/" . h($id) . "/all/" . h($scope)
|
||||
|
@ -658,7 +662,12 @@ class TagsController extends AppController
|
|||
}
|
||||
} else {
|
||||
if ($taxonomy_id === '0') {
|
||||
$tags = $this->Taxonomy->getAllTaxonomyTags(true);
|
||||
$temp = $this->Taxonomy->getAllTaxonomyTags(true, false, true);
|
||||
$tags = array();
|
||||
foreach ($temp as $tag) {
|
||||
$tags[$tag['Tag']['id']] = $tag['Tag'];
|
||||
}
|
||||
unset($temp);
|
||||
$expanded = $tags;
|
||||
} elseif ($taxonomy_id === 'favourites') {
|
||||
$tags = array();
|
||||
|
@ -674,15 +683,25 @@ class TagsController extends AppController
|
|||
$expanded = $tags;
|
||||
}
|
||||
} elseif ($taxonomy_id === 'all') {
|
||||
$conditions = array('Tag.org_id' => array(0, $this->Auth->user('org_id')));
|
||||
$conditions = array('Tag.user_id' => array(0, $this->Auth->user('id')));
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
$conditions = array('Tag.org_id' => array(0, $this->Auth->user('org_id')));
|
||||
$conditions = array('Tag.user_id' => array(0, $this->Auth->user('id')));
|
||||
}
|
||||
$conditions['Tag.hide_tag'] = 0;
|
||||
$allTags = $this->Tag->find('all', array('conditions' => $conditions, 'recursive' => -1, 'order' => array('name asc')));
|
||||
$allTags = $this->Tag->EventTag->Event->massageTags(array('EventTag' => $allTags), 'Event', false);
|
||||
$allTags = $allTags['EventTag'];
|
||||
$allTags = $this->Tag->find('all', array(
|
||||
'conditions' => $conditions,
|
||||
'recursive' => -1,
|
||||
'order' => array('name asc'),
|
||||
'fields' => array('Tag.id', 'Tag.name', 'Tag.colour')
|
||||
));
|
||||
$tags = array();
|
||||
foreach ($allTags as $i => $tag) {
|
||||
if (!empty($tag['Tag'])) {
|
||||
foreach ($allTags as $k => $tag) {
|
||||
$temp = explode(':', $tag['Tag']['name']);
|
||||
if (count($temp) > 1) {
|
||||
if ($temp[0] !== 'misp-galaxy') {
|
||||
$tags[$tag['Tag']['id']] = $tag['Tag'];
|
||||
}
|
||||
} else {
|
||||
$tags[$tag['Tag']['id']] = $tag['Tag'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ class Taxonomy extends AppModel
|
|||
|
||||
// returns all tags associated to a taxonomy
|
||||
// returns all tags not associated to a taxonomy if $inverse is true
|
||||
public function getAllTaxonomyTags($inverse = false, $user = false)
|
||||
public function getAllTaxonomyTags($inverse = false, $user = false, $full = false)
|
||||
{
|
||||
$this->Tag = ClassRegistry::init('Tag');
|
||||
$taxonomyIdList = $this->find('list', array('fields' => array('id')));
|
||||
|
@ -201,19 +201,45 @@ class Taxonomy extends AppModel
|
|||
if (Configure::read('MISP.incoming_tags_disabled_by_default')) {
|
||||
$conditions['Tag.hide_tag'] = 0;
|
||||
}
|
||||
$allTags = $this->Tag->find(
|
||||
'list',
|
||||
array(
|
||||
'fields' => array('name'),
|
||||
'order' => array('UPPER(Tag.name) ASC'),
|
||||
'conditions' => $conditions
|
||||
)
|
||||
);
|
||||
if ($full) {
|
||||
$allTags = $this->Tag->find(
|
||||
'all',
|
||||
array(
|
||||
'fields' => array('id', 'name', 'colour'),
|
||||
'order' => array('UPPER(Tag.name) ASC'),
|
||||
'conditions' => $conditions,
|
||||
'recursive' => -1
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$allTags = $this->Tag->find(
|
||||
'list',
|
||||
array(
|
||||
'fields' => array('name'),
|
||||
'order' => array('UPPER(Tag.name) ASC'),
|
||||
'conditions' => $conditions
|
||||
)
|
||||
);
|
||||
}
|
||||
foreach ($allTags as $k => $tag) {
|
||||
if ($inverse && in_array(strtoupper($tag), $allTaxonomyTags)) {
|
||||
unset($allTags[$k]);
|
||||
if ($full) {
|
||||
$needle = $tag['Tag']['name'];
|
||||
} else {
|
||||
$needle = $tag;
|
||||
}
|
||||
if (!$inverse && !in_array(strtoupper($tag), $allTaxonomyTags)) {
|
||||
if ($inverse) {
|
||||
if (in_array(strtoupper($needle), $allTaxonomyTags)) {
|
||||
unset($allTags[$k]);
|
||||
} else {
|
||||
$temp = explode(':', $needle);
|
||||
if (count($temp) > 1) {
|
||||
if ($temp[0] == 'misp-galaxy') {
|
||||
unset($allTags[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$inverse && !in_array(strtoupper($needle), $allTaxonomyTags)) {
|
||||
unset($allTags[$k]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue