Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-15267

Delete all entitytags of a contact in a single api call

    Details

    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7
    • Fix Version/s: 4.7
    • Component/s: CiviCRM API
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      If we do not define a tag_id, all entitytags related to a contact_id should be removed, eg.:

      $result = civicrm_api3('EntityTag', 'delete', array(
      'contact_id' => -contact-id-,
      ));

      This needs the following changes:

      In getContactTags() of CRM/COre/BAO/EntityTag.php two changes:

      $select = "SELECT name ";

      becomes:

      $select = "SELECT ct.id, ct.name ";


      while ($dao->fetch())

      { $contactTags[] = $dao->name; }

      becomes:

      while ($dao->fetch())

      { $contactTags[$dao->id] = $dao->name; }

      In _civicrm_api3_entity_tag_common of api/v3/EntityTag.php:

      if (empty($tagIDs))

      { return civicrm_api3_create_error('tag_id is a required field'); }

      becomes:

      if (empty($tagIDs)) {
      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'); }

      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              wdecraene Wim De Craene
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: