mirror of https://github.com/MISP/MISP
chg: [Tag search API] now also accepts synonyms as input
parent
09cbbe3b93
commit
b2a6d5cfa4
|
@ -1045,21 +1045,33 @@ class TagsController extends AppController
|
|||
} else if (!empty($this->request->data)) {
|
||||
$tag = $this->request->data;
|
||||
}
|
||||
if (is_array($tag)) {
|
||||
foreach ($tag as $k => $t) {
|
||||
$tag[$k] = strtolower($t);
|
||||
}
|
||||
} else {
|
||||
$tag = strtolower($tag);
|
||||
if (!is_array($tag)) {
|
||||
$tag = array($tag);
|
||||
}
|
||||
foreach ($tag as $k => $t) {
|
||||
$tag[$k] = strtolower($t);
|
||||
}
|
||||
$this->loadModel('GalaxyCluster');
|
||||
$conditions = array('GalaxyElement.key' => 'synonyms', 'OR' => array());
|
||||
foreach ($tag as $k => $t) {
|
||||
$conditions['OR'][] = array('LOWER(GalaxyElement.value) LIKE' => $t);
|
||||
}
|
||||
$elements = $this->GalaxyCluster->GalaxyElement->find('all', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => $conditions,
|
||||
'contain' => array('GalaxyCluster.tag_name')
|
||||
));
|
||||
foreach ($elements as $element) {
|
||||
$tag[] = strtolower($element['GalaxyCluster']['tag_name']);
|
||||
}
|
||||
$conditions = array();
|
||||
foreach ($tag as $k => $t) {
|
||||
$conditions['OR'][] = array('LOWER(Tag.name) LIKE' => $t);
|
||||
}
|
||||
$conditions = array(
|
||||
'LOWER(Tag.name) LIKE ' => $tag
|
||||
);
|
||||
$tags = $this->Tag->find('all', array(
|
||||
'conditions' => $conditions,
|
||||
'recursive' => -1
|
||||
));
|
||||
$this->loadModel('GalaxyCluster');
|
||||
$this->loadModel('Taxonomy');
|
||||
foreach ($tags as $k => $t) {
|
||||
$taxonomy = $this->Taxonomy->getTaxonomyForTag($t['Tag']['name'], true);
|
||||
|
|
Loading…
Reference in New Issue