fix: Fixed an issue where tags couldn't be added anymore since the last commit

pull/3371/head
iglocska 2018-06-22 11:33:11 +02:00
parent 0241ddc0fa
commit 9df31f3f5d
1 changed files with 15 additions and 11 deletions

View File

@ -3154,25 +3154,29 @@ class Attribute extends AppModel {
));
} else {
$tags = array();
if (isset($attribute['Tag'])) {
$tags = $attribute['Tag'];
}
if (isset($attribute['AttributeTag'])) {
foreach ($attribute['AttributeTag'] as $at) {
$tags[] = $at['Tag'];
}
}
foreach ($tags as $tag) {
$tag_id = $this->AttributeTag->Tag->captureTag($tag, $user);
if ($tag_id) {
unset($at['id']);
$this->AttributeTag->create();
$at = array();
$at['attribute_id'] = $this->id;
$at['event_id'] = $eventId;
$at['tag_id'] = $tag_id;
$this->AttributeTag->save($at);
}
}
if (isset($attribute['Tag'])) {
foreach ($attribute['Tag'] as $tag) {
$tag_id = $this->AttributeTag->Tag->captureTag($tag, $user);
if ($tag_id) {
$this->AttributeTag->create();
$at = array();
$at['attribute_id'] = $this->id;
$at['event_id'] = $eventId;
$at['tag_id'] = $tag_id;
$this->AttributeTag->save($at);
}
}
}
if (!empty($attribute['Sighting'])) {
foreach ($attribute['Sighting'] as $k => $sighting) {
$this->Sighting->captureSighting($sighting, $this->id, $eventId, $user);