CRM-14052 - Revert workarounds for tokenInput.js and cleanup tagset code
authorColeman Watts <coleman@civicrm.org>
Thu, 21 Aug 2014 07:51:07 +0000 (08:51 +0100)
committerColeman Watts <coleman@civicrm.org>
Thu, 21 Aug 2014 07:51:41 +0000 (08:51 +0100)
CRM/Contact/Form/Edit/TagsAndGroups.php
CRM/Core/Form/Tag.php

index 21a4f2f74e6cfd37a14a81367a0dd91db05c3269..8e09b3af29745cdd013cd4469bb6039914e09748 100644 (file)
@@ -165,7 +165,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups {
       // build tag widget
       $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
 
-      CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, TRUE, TRUE);
+      CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, FALSE, TRUE);
     }
     $form->assign('tagGroup', $form->_tagGroup);
   }
index 117c53075da296e475ee5b86217c46d4014741f0..597c3beae0cdee3d291af0745ce064395ebef023 100644 (file)
@@ -153,31 +153,12 @@ class CRM_Core_Form_Tag {
     // are deleted we will have to set $params[tagset id] = '' which is done by above logic
     foreach ($params as $parentId => $value) {
       $newTagIds = array();
-      $realTagIds = array();
+      $tagIds = array();
 
       if ($value) {
-        $tagsIDs = explode(',', $value);
-        foreach ($tagsIDs as $tagId) {
-          if (!is_numeric($tagId)) {
-            // check if user has selected existing tag or is creating new tag
-            // this is done to allow numeric tags etc.
-            $tagValue = explode(':::', $tagId);
-
-            if (isset($tagValue[1]) && $tagValue[1] == 'value') {
-              $tagParams = array(
-                'name' => $tagValue[0],
-                'parent_id' => $parentId,
-              );
-              $tagObject = CRM_Core_BAO_Tag::add($tagParams, CRM_Core_DAO::$_nullArray);
-              $tagId = $tagObject->id;
-            }
-          }
-
-          $realTagIds[] = $tagId;
-          if ($form && $form->_action != CRM_Core_Action::UPDATE) {
-            $newTagIds[] = $tagId;
-          }
-          elseif (!array_key_exists($tagId, $existingTags)) {
+        $tagIds = explode(',', $value);
+        foreach ($tagIds as $tagId) {
+          if ($form && $form->_action != CRM_Core_Action::UPDATE || !array_key_exists($tagId, $existingTags)) {
             $newTagIds[] = $tagId;
           }
         }
@@ -189,8 +170,8 @@ class CRM_Core_Form_Tag {
                     WHERE civicrm_tag.id=civicrm_entity_tag.tag_id
                       AND civicrm_entity_tag.entity_table='{$entityTable}'
                       AND entity_id={$entityId} AND parent_id={$parentId}";
-      if (!empty($realTagIds)) {
-        $deleteSQL .= " AND tag_id NOT IN (" . implode(', ', $realTagIds) . ");";
+      if (!empty($tagIds)) {
+        $deleteSQL .= " AND tag_id NOT IN (" . implode(', ', $tagIds) . ");";
       }
 
       CRM_Core_DAO::executeQuery($deleteSQL);