X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FEntityTag.php;h=c0ef14f1f3c51f547e1dbc46c9aa665a0e686e08;hb=17d83a01db1059f95af45e3bd8898e353e52c02c;hp=e6b2d4bebbb7e96e0c93055ef6be79f8d0f392ab;hpb=76773c5a5191673e990d6e9ee4e8d2c9a664e819;p=civicrm-core.git diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index e6b2d4bebb..c0ef14f1f3 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -40,13 +40,14 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * Given a contact id, it returns an array of tag id's the * contact belongs to. * - * @param int $entityID id of the entity usually the contactID. - * @param string $entityTable name of the entity table usually 'civicrm_contact' + * @param int $entityID + * Id of the entity usually the contactID. + * @param string $entityTable + * Name of the entity table usually 'civicrm_contact'. * * @return array( - ) reference $tag array of category id's the contact belongs to. + * ) reference $tag array of category id's the contact belongs to. * - * @static */ public static function &getTag($entityID, $entityTable = 'civicrm_contact') { $tags = array(); @@ -69,10 +70,10 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * group object. the params array could contain additional unused name/value * pairs * - * @param array $params (reference ) an assoc array of name/value pairs + * @param array $params + * (reference ) an assoc array of name/value pairs. * - * @return CRM_Core_BAO_EntityTag object - * @static + * @return CRM_Core_BAO_EntityTag */ public static function add(&$params) { $dataExists = self::dataExists($params); @@ -99,10 +100,10 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { /** * Check if there is data to create the object * - * @param array $params an assoc array of name/value pairs + * @param array $params + * An assoc array of name/value pairs. * * @return boolean - * @static */ public static function dataExists($params) { return !($params['tag_id'] == 0); @@ -111,11 +112,10 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { /** * Delete the tag for a contact * - * @param array $params (reference ) an assoc array of name/value pairs - * - * @return CRM_Core_BAO_EntityTag object - * @static + * @param array $params + * (reference ) an assoc array of name/value pairs. * + * @return CRM_Core_BAO_EntityTag */ public static function del(&$params) { $entityTag = new CRM_Core_BAO_EntityTag(); @@ -130,23 +130,26 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { /** * Given an array of entity ids and entity table, add all the entity to the tags * - * @param array $entityIds (reference ) the array of entity ids to be added - * @param int $tagId the id of the tag - * @param string $entityTable name of entity table default:civicrm_contact + * @param array $entityIds + * (reference ) the array of entity ids to be added. + * @param int $tagId + * The id of the tag. + * @param string $entityTable + * Name of entity table default:civicrm_contact. * - * @return array (total, added, notAdded) count of enities added to tag - * @static + * @return array + * (total, added, notAdded) count of enities added to tag */ public static function addEntitiesToTag(&$entityIds, $tagId, $entityTable = 'civicrm_contact') { - $numEntitiesAdded = 0; + $numEntitiesAdded = 0; $numEntitiesNotAdded = 0; - $entityIdsAdded = array(); + $entityIdsAdded = array(); foreach ($entityIds as $entityId) { $tag = new CRM_Core_DAO_EntityTag(); - $tag->entity_id = $entityId; - $tag->tag_id = $tagId; + $tag->entity_id = $entityId; + $tag->tag_id = $tagId; $tag->entity_table = $entityTable; if (!$tag->find()) { $tag->save(); @@ -172,12 +175,15 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { /** * Given an array of entity ids and entity table, remove entity(s) tags * - * @param array $entityIds (reference ) the array of entity ids to be removed - * @param int $tagId the id of the tag - * @param string $entityTable name of entity table default:civicrm_contact + * @param array $entityIds + * (reference ) the array of entity ids to be removed. + * @param int $tagId + * The id of the tag. + * @param string $entityTable + * Name of entity table default:civicrm_contact. * - * @return array (total, removed, notRemoved) count of entities removed from tags - * @static + * @return array + * (total, removed, notRemoved) count of entities removed from tags */ public static function removeEntitiesFromTag(&$entityIds, $tagId, $entityTable = 'civicrm_contact') { $numEntitiesRemoved = 0; @@ -187,8 +193,8 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { foreach ($entityIds as $entityId) { $tag = new CRM_Core_DAO_EntityTag(); - $tag->entity_id = $entityId; - $tag->tag_id = $tagId; + $tag->entity_id = $entityId; + $tag->tag_id = $tagId; $tag->entity_table = $entityTable; if ($tag->find()) { $tag->delete(); @@ -214,12 +220,12 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { /** * Takes an associative array and creates tag entity record for all tag entities * - * @param array $params (reference) an assoc array of name/value pairs + * @param array $params + * (reference) an assoc array of name/value pairs. * @param $entityTable * @param int $entityID * * @return void - * @static */ public static function create(&$params, $entityTable, $entityID) { // get categories for the entity id @@ -258,9 +264,11 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { /** * This function returns all entities assigned to a specific tag * - * @param object $tag an object of a tag. + * @param object $tag + * An object of a tag. * - * @return array $entityIds array of entity ids + * @return array + * array of entity ids */ public function getEntitiesByTag($tag) { $entityIds = array(); @@ -332,14 +340,15 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * Merge two tags: tag B into tag A. */ public function mergeTags($tagAId, $tagBId) { - $queryParams = array(1 => array($tagBId, 'Integer'), + $queryParams = array( + 1 => array($tagBId, 'Integer'), 2 => array($tagAId, 'Integer'), ); // re-compute used_for field $query = "SELECT id, name, used_for FROM civicrm_tag WHERE id IN (%1, %2)"; - $dao = CRM_Core_DAO::executeQuery($query, $queryParams); - $tags = array(); + $dao = CRM_Core_DAO::executeQuery($query, $queryParams); + $tags = array(); while ($dao->fetch()) { $label = ($dao->id == $tagAId) ? 'tagA' : 'tagB'; $tags[$label] = $dao->name; @@ -383,9 +392,11 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * Get options for a given field. * @see CRM_Core_DAO::buildOptions * - * @param String $fieldName - * @param String $context : @see CRM_Core_DAO::buildOptionsContext - * @param Array $props : whatever is known about this dao object + * @param string $fieldName + * @param string $context + * @see CRM_Core_DAO::buildOptionsContext. + * @param array $props + * whatever is known about this dao object. * * @return Array|bool */