/** * This function returns all entities assigned to a specific tag * * @param object $tag an object of a tag. * * @return array $contactIds array of contact ids * @access public */ function getEntitiesByTag($tag) { $contactIds = array(); $entityTagDAO = new CRM_Core_DAO_EntityTag(); $entityTagDAO->tag_id = $tag['id']; $entityTagDAO->find(); while ($entityTagDAO->fetch()) { $contactIds[] = $entityTagDAO->entity_id; } return $contactIds; }
/** * Function to delete the tag * * @param int $id tag id * * @return boolean * @access public * @static * */ static function del($id) { // delete all crm_entity_tag records with the selected tag id require_once 'CRM/Core/DAO/EntityTag.php'; $entityTag = new CRM_Core_DAO_EntityTag(); $entityTag->tag_id = $id; if ($entityTag->find()) { while ($entityTag->fetch()) { $entityTag->delete(); } } // delete from tag table $tag = new CRM_Core_DAO_Tag(); $tag->id = $id; require_once 'CRM/Utils/Hook.php'; CRM_Utils_Hook::pre('delete', 'Tag', $id, $tag); if ($tag->delete()) { CRM_Utils_Hook::post('delete', 'Tag', $id, $tag); CRM_Core_Session::setStatus(ts('Selected Tag has been Deleted Successfuly.')); return true; } return false; }
/** * This function returns all entities assigned to a specific tag. * * @param object $tag * An object of a tag. * * @return array * array of entity ids */ public function getEntitiesByTag($tag) { $entityIds = array(); $entityTagDAO = new CRM_Core_DAO_EntityTag(); $entityTagDAO->tag_id = $tag->id; $entityTagDAO->find(); while ($entityTagDAO->fetch()) { $entityIds[] = $entityTagDAO->entity_id; } return $entityIds; }
/** * Function to delete the tag * * @param int $id tag id * * @return boolean * @access public * @static * */ static function del($id) { // delete all crm_entity_tag records with the selected tag id $entityTag = new CRM_Core_DAO_EntityTag(); $entityTag->tag_id = $id; if ($entityTag->find()) { while ($entityTag->fetch()) { $entityTag->delete(); } } // delete from tag table $tag = new CRM_Core_DAO_Tag(); $tag->id = $id; CRM_Utils_Hook::pre('delete', 'Tag', $id, $tag); if ($tag->delete()) { CRM_Utils_Hook::post('delete', 'Tag', $id, $tag); CRM_Core_Session::setStatus(ts('Selected tag has been deleted successfully.')); return TRUE; } return FALSE; }