public function testDeleteTagsByItem() { $tag = new Phprojekt_Tags(); $tag->deleteTagsByItem(1, 1); $tags = $tag->getTagsByModule(1, 1); $this->assertTrue(empty($tags)); }
/** * Returns an array with tags for one item. * * Returns the metadata of the fieds and the data itself with: * <pre> * - string => The tag. * - count => Number of ocurrences. * </pre> * Also the number of rows is returned. * * OPTIONAL request parameters: * <pre> * - integer <b>id</b> id of the item. * - integer <b>limit</b> Number of results. * - integer <b>moduleName</b> Name of the module. * </pre> * * The return is in JSON format. * * @return void */ public function jsonGetTagsByModuleAction() { $tagObj = new Phprojekt_Tags(); $id = (int) $this->getRequest()->getParam('id', 0); $limit = (int) $this->getRequest()->getParam('limit', 0); $module = Cleaner::sanitize('alnum', $this->getRequest()->getParam('moduleName', 'Project')); $moduleId = (int) Phprojekt_Module::getId($module); if (!empty($id)) { $tags = $tagObj->getTagsByModule($moduleId, $id, $limit); } else { $tags = array(); } $fields = $tagObj->getFieldDefinition(); Phprojekt_Converter_Json::echoConvert($tags, $fields); }
/** * Saves this object to a new row, even if it is already backed by the * database. After a call to this function, the id will be different. * * @return int The id of the saved row. */ private function _saveToNewRow() { $tagsObject = new Phprojekt_Tags(); $moduleId = Phprojekt_Module::getId('Calendar2'); $tags = array(); foreach ($tagsObject->getTagsByModule($moduleId, $this->id) as $val) { $tags[] = $val; } $this->_fetchParticipantData(); $excludedDates = $this->getExcludedDates(); $this->_storedId = null; $this->_data['id'] = null; $this->_participantDataInDb = array(); $this->_isFirst = true; $this->save(); $tagsObject->saveTags($moduleId, $this->id, implode(' ', $tags)); return $this->id; }