From bff5783cffb971f0aabe2e3240725349c2df5c99 Mon Sep 17 00:00:00 2001 From: Wim De Craene Date: Wed, 6 Jan 2016 11:30:50 +0100 Subject: [PATCH] Delete all entitytags of a contact in a single api call. --- CRM/Core/BAO/EntityTag.php | 4 ++-- api/v3/EntityTag.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index 6cebea4c5c..7323357e84 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -283,7 +283,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { public static function getContactTags($contactID, $count = FALSE) { $contactTags = array(); if (!$count) { - $select = "SELECT name "; + $select = "SELECT ct.id, ct.name "; } else { $select = "SELECT count(*) as cnt"; @@ -304,7 +304,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } while ($dao->fetch()) { - $contactTags[] = $dao->name; + $contactTags[$dao->id] = $dao->name; } return $contactTags; diff --git a/api/v3/EntityTag.php b/api/v3/EntityTag.php index 3b9aec86a2..f46af28d25 100644 --- a/api/v3/EntityTag.php +++ b/api/v3/EntityTag.php @@ -133,7 +133,12 @@ function _civicrm_api3_entity_tag_common($params, $op = 'add') { } if (empty($tagIDs)) { - return civicrm_api3_create_error('tag_id is a required field'); + if ($op == 'remove') { + $tagIDs = array_keys(CRM_Core_BAO_EntityTag::getContactTags($entityIDs[0])); + } + else { + return civicrm_api3_create_error('tag_id is a required field'); + } } $values = array('is_error' => 0); -- 2.25.1