// see if we have any tagsets which can be assigned to cases
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
+ $tagSetTagNames = array();
if ($parentNames) {
- $this->assign('showTagsets', TRUE);
- }
- else {
- $this->assign('showTagsets', FALSE);
+ $this->assign('showTags', TRUE);
+ $tagSetItems = civicrm_api3('entityTag', 'get', array(
+ 'entity_id' => $this->_caseID,
+ 'entity_table' => 'civicrm_case',
+ 'options' => array('limit' => 0),
+ ));
+ if ($tagSetItems['count']) {
+ $tagSetTags = civicrm_api3('tag', 'get', array(
+ 'id' => array('IN' => array_keys($tagSetItems['values'])),
+ 'parent_id.is_tagset' => 1,
+ 'return' => array("parent_id", "parent_id.name", "name"),
+ 'options' => array('limit' => 0),
+ ));
+ foreach ($tagSetTags['values'] as $id => $tag) {
+ $tagSetTagNames += array(
+ $tag['parent_id'] => array(
+ 'name' => $tag['parent_id.name'],
+ 'items' => array(),
+ ),
+ );
+ $tagSetTagNames[$tag['parent_id']]['items'][$id] = $tag['name'];
+ }
+ }
}
+ $this->assign('tagSetTags', $tagSetTagNames);
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE);
$this->addButtons(array(
$tagIds = explode(',', $tags);
}
- if (!empty($tagIds)) {
- $params = array(
- 'entity_id' => $caseId,
- 'entity_table' => 'civicrm_case',
- );
-
- CRM_Core_BAO_EntityTag::del($params);
-
- foreach ($tagIds as $tagid) {
- if (is_numeric($tagid)) {
- $params['tag_id'] = $tagid;
- CRM_Core_BAO_EntityTag::add($params);
- }
+ $params = array(
+ 'entity_id' => $caseId,
+ 'entity_table' => 'civicrm_case',
+ );
+
+ CRM_Core_BAO_EntityTag::del($params);
+
+ foreach ($tagIds as $tagid) {
+ if (is_numeric($tagid)) {
+ $params['tag_id'] = $tagid;
+ CRM_Core_BAO_EntityTag::add($params);
}
}
if (!empty($tagList)) {
- CRM_Core_Form_Tag::postProcess($tagList, $caseId, 'civicrm_case', CRM_Core_DAO::$_nullObject);
+ CRM_Core_Form_Tag::postProcess($tagList, $caseId, 'civicrm_case');
}
$session = CRM_Core_Session::singleton();
* @param CRM_Core_Form $form
* Form object.
*/
- public static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact', &$form) {
+ public static function postProcess(&$params, $entityId, $entityTable = 'civicrm_contact', &$form = NULL) {
if ($form && !empty($form->_entityTagValues)) {
$existingTags = $form->_entityTagValues;
}
{include file="CRM/Case/Form/ActivityToCase.tpl"}
{* pane to display / edit regular tags or tagsets for cases *}
-{if $showTags OR $showTagsets}
-
+{if $showTags}
<div id="casetags" class="crm-accordion-wrapper crm-case-tags-block">
<div class="crm-accordion-header">
{ts}Case Tags{/ts}
</div><!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
- {assign var="tagExits" value=0}
{if $tags}
- <div class="crm-block crm-content-block crm-case-caseview-display-tags"> {$tags}</div>
- {assign var="tagExits" value=1}
+ <p class="crm-block crm-content-block crm-case-caseview-display-tags"> {$tags}</p>
{/if}
- {foreach from=$tagsetInfo.case item=displayTagset}
- {if $displayTagset.entityTagsArray}
- <div class="crm-block crm-content-block crm-case-caseview-display-tagset">
- {$displayTagset.parentName}:
- {foreach from=$displayTagset.entityTagsArray item=val name="tagsetList"}
- {$val.name}{if !$smarty.foreach.tagsetList.last},{/if}
- {/foreach}
- </div>
- {assign var="tagExits" value=1}
- {/if}
+ {foreach from=$tagSetTags item=displayTagset}
+ <p class="crm-block crm-content-block crm-case-caseview-display-tagset">
+ <strong>{$displayTagset.name}:</strong>
+ {', '|implode:$displayTagset.items}
+ </p>
{/foreach}
- {if !$tagExits }
+ {if !$tags && !$tagSetTags }
<div class="status">
{ts}There are no tags currently assigned to this case.{/ts}
</div>
{/if}
<div class="crm-submit-buttons">
- <a class="button case-miniform" href="#manageTagsDialog" data-key="{crmKey name='civicrm/case/ajax/processtags'}">{if $tagExits}{ts}Edit Tags{/ts}{else}{ts}Add Tags{/ts}{/if}</a>
+ <a class="button case-miniform" href="#manageTagsDialog" data-key="{crmKey name='civicrm/case/ajax/processtags'}">
+ {if $tags || $tagSetTags}{ts}Edit Tags{/ts}{else}{ts}Add Tags{/ts}{/if}
+ </a>
</div>
</div><!-- /.crm-accordion-body -->