mirror of https://github.com/MISP/MISP
chg: rename findTags() to findEventIdsByTagNames()
parent
3c57dfb873
commit
542437be54
|
@ -1247,8 +1247,8 @@ class AttributesController extends AppController {
|
|||
else $include[] = $tagname;
|
||||
}
|
||||
$this->loadModel('Tag');
|
||||
if (!empty($include)) $conditions['AND'][] = array('OR' => array('Attribute.event_id' => $this->Tag->findTags($include)));
|
||||
if (!empty($exclude)) $conditions['AND'][] = array('Attribute.event_id !=' => $this->Tag->findTags($exclude));
|
||||
if (!empty($include)) $conditions['AND'][] = array('OR' => array('Attribute.event_id' => $this->Tag->findEventIdsByTagNames($include)));
|
||||
if (!empty($exclude)) $conditions['AND'][] = array('Attribute.event_id !=' => $this->Tag->findEventIdsByTagNames($exclude));
|
||||
}
|
||||
if ($type != 'ALL') {
|
||||
$conditions['Attribute.type ='] = $type;
|
||||
|
|
|
@ -69,17 +69,16 @@ class Tag extends AppModel {
|
|||
$acceptIds = array();
|
||||
$rejectIds = array();
|
||||
if (!empty($accept)) {
|
||||
$acceptIds = $this->findTags($accept);
|
||||
$acceptIds = $this->findEventIdsByTagNames($accept);
|
||||
if (empty($acceptIds)) $acceptIds[] = -1;
|
||||
}
|
||||
if (!empty($reject)) {
|
||||
$rejectIds = $this->findTags($reject);
|
||||
$rejectIds = $this->findEventIdsByTagNames($reject);
|
||||
}
|
||||
return array($acceptIds, $rejectIds);
|
||||
}
|
||||
|
||||
// find all of the event Ids that belong to tags with certain names
|
||||
public function findTags($array) {
|
||||
public function findEventIdsByTagNames($array) {
|
||||
$ids = array();
|
||||
foreach ($array as $a) {
|
||||
$conditions['OR'][] = array('LOWER(name) like' => strtolower($a));
|
||||
|
@ -87,7 +86,6 @@ class Tag extends AppModel {
|
|||
$params = array(
|
||||
'recursive' => 1,
|
||||
'contain' => 'EventTag',
|
||||
//'fields' => array('id', 'name'),
|
||||
'conditions' => $conditions
|
||||
);
|
||||
$result = $this->find('all', $params);
|
||||
|
|
Loading…
Reference in New Issue