/** * Called whenever an object is index and to be added to the search-index. * Use this callback to add additional content to the objects search-document. * * @param string $strEventName * @param array $arrArguments * * @return bool */ public function handleEvent($strEventName, array $arrArguments) { //unwrap arguments /** @var class_model $objObject */ $objObject = $arrArguments[0]; /** @var class_module_search_document $objSearchDocument */ $objSearchDocument = $arrArguments[1]; if (class_module_system_module::getModuleByName("tags") == null) { return true; } //load tags for the object $objTags = class_module_tags_tag::getTagsForSystemid($objObject->getSystemid()); foreach ($objTags as $objOneTag) { $objSearchDocument->addContent("tag", $objOneTag->getStrName()); } return true; }
public function testTagAssignmentRemoval() { //related to checkin #6111 $objTag = new class_module_tags_tag(); $objTag->setStrName(generateSystemid()); $objTag->updateObjectToDb(); $objAspect = new class_module_system_aspect(); $objAspect->setStrName(generateSystemid()); $objAspect->updateObjectToDb(); $objTag->assignToSystemrecord($objAspect->getSystemid()); $this->flushDBCache(); $this->assertEquals(count($objTag->getArrAssignedRecords()), 1); $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid())), 1); $objTag->removeFromSystemrecord($objAspect->getSystemid(), ""); $this->flushDBCache(); $this->assertEquals(count($objTag->getArrAssignedRecords()), 0); $this->assertEquals(count(class_module_tags_tag::getTagsForSystemid($objAspect->getSystemid())), 0); $objTag->deleteObjectFromDatabase(); $objAspect->deleteObjectFromDatabase(); }
/** * Loads the list of tags assigned to the passed system-record and renders them using the toolkit. * * @return string * @permissions view */ protected function actionTagList() { $strReturn = ""; $strSystemid = $this->getSystemid(); $strAttribute = $this->getParam("attribute"); $bitDelete = $this->getParam("delete") != "false"; $arrTags = class_module_tags_tag::getTagsForSystemid($strSystemid, $strAttribute); $strReturn .= " <tags>"; foreach ($arrTags as $objOneTag) { $strReturn .= $this->objToolkit->getTagEntry($objOneTag, $strSystemid, $strAttribute); } $strReturn .= "</tags>"; return $strReturn; }