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

fixes #1 and #2 for CRM-14052

----------------------------------------
* CRM-14052: Tagset fixes
  http://issues.civicrm.org/jira/browse/CRM-14052
parent 94a73612
Branches
Tags
No related merge requests found
......@@ -162,7 +162,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, FALSE, TRUE);
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', $contactId, TRUE, TRUE);
}
$form->assign('tagGroup', $form->_tagGroup);
}
......
......@@ -236,7 +236,7 @@ class CRM_Core_Form_Tag {
*
*/
static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact', &$form) {
foreach ($params as $value) {
foreach ($params as $parentId => $value) {
if (!$value) {
continue;
}
......@@ -245,14 +245,27 @@ class CRM_Core_Form_Tag {
$insertSQL = NULL;
if (!empty($tagsIDs)) {
foreach ($tagsIDs as $tagId) {
if (is_numeric($tagId)) {
if ($form && $form->_action != CRM_Core_Action::UPDATE) {
$insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) ";
}
elseif (!$form || !array_key_exists($tagId, $form->_entityTagValues)) {
$insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) ";
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') {
$params = array(
'name' => $tagValue[0],
'parent_id' => $parentId,
);
$tagObject = CRM_Core_BAO_Tag::add($params, CRM_Core_DAO::$_nullArray);
$tagId = $tagObject->id;
}
}
if ($form && $form->_action != CRM_Core_Action::UPDATE) {
$insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) ";
}
elseif (!$form || !array_key_exists($tagId, $form->_entityTagValues)) {
$insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) ";
}
}
if (!empty($insertValues)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment