- }
- else {
-
- switch ($entityTable) {
- case 'civicrm_activity':
- if (!empty($form->_submitValues['activity_taglist']) && !empty($form->_submitValues['activity_taglist'][$parentId])) {
- $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $tagIds = explode(',', $form->_submitValues['activity_taglist'][$parentId]);
- foreach ($tagIds as $tagId) {
- if (is_numeric($tagId)) {
- $tagName = $allTags[$tagId];
- }
- else {
- $tagName = $tagId;
- }
- $entityTags[$tagId] = array(
- 'id' => $tagId,
- 'name' => $tagName,
- );
- }
- }
- break;
-
- case 'civicrm_case':
- if (!empty($form->_submitValues['case_taglist']) && !empty($form->_submitValues['case_taglist'][$parentId])) {
- $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $tagIds = explode(',', $form->_submitValues['case_taglist'][$parentId]);
- foreach ($tagIds as $tagId) {
- if (is_numeric($tagId)) {
- $tagName = $allTags[$tagId];
- }
- else {
- $tagName = $tagId;
- }
- $entityTags[$tagId] = array(
- 'id' => $tagId,
- 'name' => $tagName,
- );
- }
- }
- break;
- case 'civicrm_file':
- $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
- for ($i = 1; $i <= $numAttachments; $i++) {
- $tagset[$i] = $tagset[$tagsetItem];
- $tagset[$i]['tagsetElementName'] = "attachment_taglist_$i";
- $form->add('text', "attachment_taglist_{$i}[{$parentId}]", NULL);
- if (!empty($form->_submitValues["attachment_taglist_$i"]) && !empty($form->_submitValues["attachment_taglist_$i"][$parentId])) {
- $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
- $tagIds = explode(',', $form->_submitValues["attachment_taglist_$i"][$parentId]);
- foreach ($tagIds as $tagId) {
- if (is_numeric($tagId)) {
- $tagName = $allTags[$tagId];
- }
- else {
- $tagName = $tagId;
- }
- $entityTags[$tagId] = array(
- 'id' => $tagId,
- 'name' => $tagName,
- );
- }
- }
- }
- unset($tagset[$tagsetItem]);
- break;
-
- default:
- if (!empty($form->_formValues['contact_tags'])) {
- $contactTags = CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_contact', TRUE, FALSE, $parentId);
-
- foreach (array_keys($form->_formValues['contact_tags']) as $tagId) {
- if (!empty($contactTags[$tagId])) {
- $tagName = $tagId;
- if (is_numeric($tagId)) {
- $tagName = $contactTags[$tagId];
- }
-
- $entityTags[$tagId] = array(
- 'id' => $tagId,
- 'name' => $tagName,
- );
- }
- }
- }