Skip to content
Snippets Groups Projects
Commit b3caa3a7 authored by Kurund Jalmi's avatar Kurund Jalmi
Browse files

worked on #2 fixes, CRM-14052

----------------------------------------
* CRM-14052: Tagset fixes
  http://issues.civicrm.org/jira/browse/CRM-14052
parent 0cc0faa9
No related branches found
No related tags found
No related merge requests found
......@@ -404,7 +404,7 @@ LIMIT $limit";
if (!is_numeric($tagID)) {
$tagID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $tagID, 'id', 'name');
}
if ($entityId) {
if (!$skipEntityAction && $entityId) {
// delete this tag entry for the entity
$params = array(
'entity_table' => $entityTable,
......
......@@ -236,6 +236,7 @@ class CRM_Core_Form_Tag {
*
*/
static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact', &$form) {
$allTagIds = array();
foreach ($params as $parentId => $value) {
if (!$value) {
continue;
......@@ -260,6 +261,7 @@ class CRM_Core_Form_Tag {
}
}
$allTagIds[] = $tagId;
if ($form && $form->_action != CRM_Core_Action::UPDATE) {
$insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) ";
}
......@@ -274,6 +276,14 @@ class CRM_Core_Form_Tag {
}
}
}
// delete tags that are missing
if (!empty($allTagIds)) {
$validTagIds = implode(',', $allTagIds);
$deleteSQL = "DELETE FROM civicrm_entity_tag WHERE entity_id={$entityId} AND entity_table='{$entityTable}'
AND tag_id NOT IN ({$validTagIds})";
CRM_Core_DAO::executeQuery($deleteSQL);
}
}
}
......@@ -63,7 +63,9 @@
setVal[x] = valArray[x];
}
}
CRM.alert('', '{/literal}{ts escape='js'}Removed{/ts}{literal}', 'success');
if (!skipEntityAction) {
CRM.alert('', '{/literal}{ts escape='js'}Removed{/ts}{literal}', 'success');
}
}
else {
CRM.alert('', '{/literal}{ts escape='js'}Saved{/ts}{literal}', 'success');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment