mirror of https://github.com/MISP/MISP
chg: [cleanup] Removal of duplicate code
parent
bf923220cd
commit
32cc726006
|
@ -1467,7 +1467,6 @@ class AttributesController extends AppController
|
||||||
if (!$this->request->is('ajax')) {
|
if (!$this->request->is('ajax')) {
|
||||||
throw new MethodNotAllowedException(__('This method can only be accessed via AJAX.'));
|
throw new MethodNotAllowedException(__('This method can only be accessed via AJAX.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
$event = $this->Attribute->Event->find('first', array(
|
$event = $this->Attribute->Event->find('first', array(
|
||||||
'conditions' => array('id' => $id),
|
'conditions' => array('id' => $id),
|
||||||
|
@ -1637,45 +1636,18 @@ class AttributesController extends AppController
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
unset($clusters);
|
unset($clusters);
|
||||||
|
$conditions = array();
|
||||||
// tags to add
|
if (!$this->_isSiteAdmin()) {
|
||||||
$banned_tags = $this->Attribute->AttributeTag->Tag->find('list', array(
|
$conditions = array('Tag.org_id' => array(0, $this->Auth->user('org_id')));
|
||||||
'conditions' => array(
|
$conditions = array('Tag.user_id' => array(0, $this->Auth->user('id')));
|
||||||
'NOT' => array(
|
$conditions = array('Tag.hide_tag' => 0);
|
||||||
'Tag.org_id' => array(
|
}
|
||||||
0,
|
|
||||||
$this->Auth->user('org_id')
|
|
||||||
),
|
|
||||||
'Tag.user_id' => array(
|
|
||||||
0,
|
|
||||||
$this->Auth->user('id')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'fields' => array('Tag.id')
|
|
||||||
));
|
|
||||||
$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->Attribute->AttributeTag->Tag->find('all', array('conditions' => $conditions, 'recursive' => -1));
|
$allTags = $this->Attribute->AttributeTag->Tag->find('all', array('conditions' => $conditions, 'recursive' => -1));
|
||||||
$tags = array();
|
$tags = array();
|
||||||
foreach ($allTags as $i => $tag) {
|
foreach ($allTags as $i => $tag) {
|
||||||
$tags[$tag['Tag']['id']] = $tag['Tag'];
|
$tags[$tag['Tag']['id']] = $tag['Tag'];
|
||||||
}
|
}
|
||||||
unset($allTags);
|
unset($allTags);
|
||||||
// Unset all tags that this user cannot use for tagging, determined by the org restriction on tags
|
|
||||||
if (!$this->_isSiteAdmin()) {
|
|
||||||
foreach ($banned_tags as $banned_tag) {
|
|
||||||
unset($tags[$banned_tag]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$hidden_tags = $this->Attribute->AttributeTag->Tag->find('list', array(
|
|
||||||
'conditions' => array('Tag.hide_tag' => 1),
|
|
||||||
'fields' => array('Tag.id')
|
|
||||||
));
|
|
||||||
foreach ($hidden_tags as $hidden_tag) {
|
|
||||||
unset($tags[$hidden_tag]);
|
|
||||||
}
|
|
||||||
$tagItemsAdd = array();
|
$tagItemsAdd = array();
|
||||||
foreach ($tags as $k => $tag) {
|
foreach ($tags as $k => $tag) {
|
||||||
$tagName = $tag['name'];
|
$tagName = $tag['name'];
|
||||||
|
|
Loading…
Reference in New Issue