} if ($http->hasPostVariable('NoButton')) { return $Module->redirectToView('id', array($tagID)); } if ($http->hasPostVariable('YesButton')) { $db = eZDB::instance(); $db->begin(); $parentTag = $tag->getParent(); if ($parentTag instanceof eZTagsObject) { $parentTag->updateModified(); } $mainTagID = $tag->attribute('main_tag_id'); $tag->registerSearchObjects(); if ($http->hasPostVariable('TransferObjectsToMainTag')) { foreach ($tag->getTagAttributeLinks() as $tagAttributeLink) { $link = eZTagsAttributeLinkObject::fetchByObjectAttributeAndKeywordID($tagAttributeLink->attribute('objectattribute_id'), $tagAttributeLink->attribute('objectattribute_version'), $tagAttributeLink->attribute('object_id'), $mainTagID); if (!$link instanceof eZTagsAttributeLinkObject) { $tagAttributeLink->setAttribute('keyword_id', $mainTagID); $tagAttributeLink->store(); } else { $tagAttributeLink->remove(); } } } else { foreach ($tag->getTagAttributeLinks() as $tagAttributeLink) { $tagAttributeLink->remove(); } } $tag->remove(); $db->commit(); return $Module->redirectToView('id', array($mainTagID));
/** * Transfers all objects related to this tag, to another tag * * @param eZTagsObject|int $destination */ public function transferObjectsToAnotherTag($destination) { if (!$destination instanceof self) { $destination = self::fetchWithMainTranslation((int) $destination); if (!$destination instanceof self) { return; } } foreach ($this->getTagAttributeLinks() as $tagAttributeLink) { $link = eZTagsAttributeLinkObject::fetchByObjectAttributeAndKeywordID($tagAttributeLink->attribute('objectattribute_id'), $tagAttributeLink->attribute('objectattribute_version'), $tagAttributeLink->attribute('object_id'), $destination->attribute('id')); if (!$link instanceof eZTagsAttributeLinkObject) { $tagAttributeLink->setAttribute('keyword_id', $destination->attribute('id')); $tagAttributeLink->store(); } else { $tagAttributeLink->remove(); } } }