mirror of https://github.com/MISP/MISP
Allow forcing tag creation for galaxies
parent
08fc1c77ed
commit
47d0c41a55
|
@ -220,7 +220,7 @@ class Galaxy extends AppModel
|
||||||
throw new NotFoundException(__('Invalid %s.', $target_type));
|
throw new NotFoundException(__('Invalid %s.', $target_type));
|
||||||
}
|
}
|
||||||
$target = $target[0];
|
$target = $target[0];
|
||||||
$tag_id = $this->Tag->captureTag(array('name' => $cluster['GalaxyCluster']['tag_name'], 'colour' => '#0088cc', 'exportable' => 1), $user);
|
$tag_id = $this->Tag->captureTag(array('name' => $cluster['GalaxyCluster']['tag_name'], 'colour' => '#0088cc', 'exportable' => 1), $user, true);
|
||||||
$existingTag = $this->Tag->$connectorModel->find('first', array('conditions' => array($target_type . '_id' => $target_id, 'tag_id' => $tag_id)));
|
$existingTag = $this->Tag->$connectorModel->find('first', array('conditions' => array($target_type . '_id' => $target_id, 'tag_id' => $tag_id)));
|
||||||
if (!empty($existingTag)) {
|
if (!empty($existingTag)) {
|
||||||
return 'Cluster already attached.';
|
return 'Cluster already attached.';
|
||||||
|
|
|
@ -299,14 +299,14 @@ class Tag extends AppModel
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function captureTag($tag, $user)
|
public function captureTag($tag, $user, $force=false)
|
||||||
{
|
{
|
||||||
$existingTag = $this->find('first', array(
|
$existingTag = $this->find('first', array(
|
||||||
'recursive' => -1,
|
'recursive' => -1,
|
||||||
'conditions' => array('LOWER(name)' => strtolower($tag['name']))
|
'conditions' => array('LOWER(name)' => strtolower($tag['name']))
|
||||||
));
|
));
|
||||||
if (empty($existingTag)) {
|
if (empty($existingTag)) {
|
||||||
if ($user['Role']['perm_tag_editor']) {
|
if ($force || $user['Role']['perm_tag_editor']) {
|
||||||
$this->create();
|
$this->create();
|
||||||
if (!isset($tag['colour']) || empty($tag['colour'])) {
|
if (!isset($tag['colour']) || empty($tag['colour'])) {
|
||||||
$tag['colour'] = $this->random_color();
|
$tag['colour'] = $this->random_color();
|
||||||
|
|
Loading…
Reference in New Issue