Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
worked on #2 fixes, CRM-14052
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-14052: Tagset fixes
  http://issues.civicrm.org/jira/browse/CRM-14052
  • Loading branch information
kurund committed Jan 6, 2014
1 parent 0cc0faa commit b3caa3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CRM/Admin/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static function processTags() {
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,
Expand Down
10 changes: 10 additions & 0 deletions CRM/Core/Form/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ static function buildQuickForm(&$form, $parentNames, $entityTable, $entityId = N
*
*/
static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact', &$form) {
$allTagIds = array();
foreach ($params as $parentId => $value) {
if (!$value) {
continue;
Expand All @@ -260,6 +261,7 @@ static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact
}
}

$allTagIds[] = $tagId;
if ($form && $form->_action != CRM_Core_Action::UPDATE) {
$insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) ";
}
Expand All @@ -274,6 +276,14 @@ static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact
}
}
}

// 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);
}
}
}

4 changes: 3 additions & 1 deletion templates/CRM/common/Tag.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit b3caa3a

Please sign in to comment.