From 47d0c41a55e295b490f3660f0aae199ad94c8050 Mon Sep 17 00:00:00 2001 From: Jason Kendall Date: Tue, 18 Feb 2020 14:11:54 -0500 Subject: [PATCH] Allow forcing tag creation for galaxies --- app/Model/Galaxy.php | 2 +- app/Model/Tag.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Model/Galaxy.php b/app/Model/Galaxy.php index bd9c84f4c..2939f391c 100644 --- a/app/Model/Galaxy.php +++ b/app/Model/Galaxy.php @@ -220,7 +220,7 @@ class Galaxy extends AppModel throw new NotFoundException(__('Invalid %s.', $target_type)); } $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))); if (!empty($existingTag)) { return 'Cluster already attached.'; diff --git a/app/Model/Tag.php b/app/Model/Tag.php index b9ff9de60..d672081c3 100644 --- a/app/Model/Tag.php +++ b/app/Model/Tag.php @@ -299,14 +299,14 @@ class Tag extends AppModel return $ids; } - public function captureTag($tag, $user) + public function captureTag($tag, $user, $force=false) { $existingTag = $this->find('first', array( 'recursive' => -1, 'conditions' => array('LOWER(name)' => strtolower($tag['name'])) )); if (empty($existingTag)) { - if ($user['Role']['perm_tag_editor']) { + if ($force || $user['Role']['perm_tag_editor']) { $this->create(); if (!isset($tag['colour']) || empty($tag['colour'])) { $tag['colour'] = $this->random_color();