CRM-13966 - Switch to entityRef for tags
authorColeman Watts <coleman@civicrm.org>
Tue, 29 Apr 2014 17:39:39 +0000 (10:39 -0700)
committerColeman Watts <coleman@civicrm.org>
Wed, 30 Apr 2014 03:19:21 +0000 (20:19 -0700)
16 files changed:
CRM/Core/Form/Tag.php
templates/CRM/Activity/Form/Activity.tpl
templates/CRM/Activity/Form/Search/Common.tpl
templates/CRM/Activity/Form/Task/AddToTag.tpl
templates/CRM/Activity/Form/Task/RemoveFromTag.tpl
templates/CRM/Case/Form/Activity.tpl
templates/CRM/Case/Form/Case.tpl
templates/CRM/Case/Form/CaseView.tpl
templates/CRM/Case/Form/Search/Common.tpl
templates/CRM/Contact/Form/Edit/TagsAndGroups.tpl
templates/CRM/Contact/Form/Search/Criteria/Basic.tpl
templates/CRM/Contact/Form/Task/AddToTag.tpl
templates/CRM/Contact/Form/Task/RemoveFromTag.tpl
templates/CRM/Form/attachment.tpl
templates/CRM/Tag/Form/Tag.tpl
templates/CRM/common/Tagset.tpl [new file with mode: 0644]

index 36906cc31d8b8cec93dcd41e71099126aadaf11d..05adaefbe5daad4912cc59fe849351b1c7124651 100644 (file)
@@ -43,7 +43,7 @@ class CRM_Core_Form_Tag {
   /**
    * Function to build tag widget if correct parent is passed
    *
-   * @param object  $form form object
+   * @param CRM_Core_Form  $form form object
    * @param string  $parentName parent name ( tag name)
    * @param string  $entityTable entitytable 'eg: civicrm_contact'
    * @param int     $entityId    entityid  'eg: contact id'
@@ -109,7 +109,12 @@ class CRM_Core_Form_Tag {
 
         $tagset[$tagsetItem]['tagsetElementName'] = $tagsetElementName;
         if ($tagsetElementName) {
-          $form->add('text', "{$tagsetElementName}[{$parentId}]", NULL);
+          $form->addEntityRef("{$tagsetElementName}[{$parentId}]", NULL, array(
+            'entity' => 'tag',
+            'multiple' => TRUE,
+            'create' => TRUE,
+            'api' => array('params' => array('parent_id' => $parentId)))
+          );
         }
 
         if ($entityId) {
@@ -223,7 +228,9 @@ class CRM_Core_Form_Tag {
       // assign current tagsets which is used in postProcess
       $form->_tagsetInfo = $tagset;
       $form->assign("tagsetType", $mode);
-      $form->assign("tagsetInfo_$mode", $tagset);
+      $tagsetInfo = (array) $form->get_template_vars("tagsetInfo");
+      $tagsetInfo[$mode] = $tagset;
+      $form->assign("tagsetInfo", $tagsetInfo);
       $form->assign("isTagset", TRUE);
     }
   }
index c6c529de2aac71983a42b557423f7d8a2cd82a7e..40279480030c1f3eb760c8c47d0dc458e95d10d2 100644 (file)
   {/if}
 
   {if $tagsetInfo_activity}
-  <tr class="crm-activity-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tag.tpl" tagsetType='activity'}</td></tr>
+  <tr class="crm-activity-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tagset.tpl" tagsetType='activity'}</td></tr>
   {/if}
 
   {if $action neq 4 OR $viewCustomData}
index 484459981722ea76971829f28a105f23aa71f397..a57f25860823cb94065f51279f767f506d20e601 100644 (file)
            <label>{$form.activity_result.label}</label><br />
            {$form.activity_result.html}
          </td>
-               <td colspan="2">{include file="CRM/common/Tag.tpl" tagsetType='activity'}</td>
+               <td colspan="2">{include file="CRM/common/Tagset.tpl" tagsetType='activity'}</td>
        </tr>
 {else}
        <tr>
-               <td colspan="3">{include file="CRM/common/Tag.tpl" tagsetType='activity'}</td>
+               <td colspan="3">{include file="CRM/common/Tagset.tpl" tagsetType='activity'}</td>
        </tr>
 {/if}
 
index 5b2894d93dda28cc9c78e4ff4fef3ea5c0879857..5597c2cb66fb18a645ac1c2b893e263c96bcee49 100644 (file)
@@ -42,7 +42,7 @@
     </tr>
     <tr>
         <td>
-            {include file="CRM/common/Tag.tpl"}
+            {include file="CRM/common/Tagset.tpl"}
         </td>
     </tr>
 
index 9882c801e98c064b7a583f3dd9a20030867b20af..55d2e8a2d74a1333ef9fd971d76242b9027ecc48 100644 (file)
@@ -42,7 +42,7 @@
     </tr>
     <tr>
         <td>
-            {include file="CRM/common/Tag.tpl"}
+            {include file="CRM/common/Tagset.tpl"}
         </td>
     </tr>
 
index 7019686c9008c72e9df35b66dfed3bf1e044be5a..4e27e8e99c833181d51625fec3707321709fffb1 100644 (file)
       </td>
     </tr>
     {/if}
-  <tr class="crm-case-activity-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tag.tpl" tagsetType='activity'}</td></tr>
+  <tr class="crm-case-activity-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tagset.tpl" tagsetType='activity'}</td></tr>
   </table>
 
   {/if}
index 4147889e257700f2e7d7816ac20365837f5bd246..2edfc5e8187f1248540baad2b39146f1693aa3f0 100644 (file)
     </td>
 </tr>
 
-<tr class="crm-case-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tag.tpl" tagsetType='case'}</td></tr>
+<tr class="crm-case-form-block-tag_set"><td colspan="2">{include file="CRM/common/Tagset.tpl" tagsetType='case'}</td></tr>
 
 </table>
 {/if}
index 97be9a32556596ab5092b4c2b69bd76aff982e83..af815849889c218de0d8602a8471e636aee87fd9 100644 (file)
     {assign var="tagExits" value=1}
   {/if}
 
-   {foreach from=$tagsetInfo_case item=displayTagset}
+   {foreach from=$tagsetInfo.case item=displayTagset}
      {if $displayTagset.entityTagsArray}
        <div class="crm-block crm-content-block crm-case-caseview-display-tagset">
          &nbsp;&nbsp;{$displayTagset.parentName}:
   <div class="label">{$form.case_tag.label}</div>
   <div class="view-value"><div class="crm-select-container">{$form.case_tag.html}</div>
     <br/>
-    <div style="text-align:left;">{include file="CRM/common/Tag.tpl" tagsetType='case'}</div>
+    <div style="text-align:left;">{include file="CRM/common/Tagset.tpl" tagsetType='case'}</div>
     <br/>
     <div class="clear"></div>
   </div>
index b84ef3396b18db61f7e29de725e97fa0fe33ad6d..7a1fd343191a4b2453a8091d7d2f17829615cde1 100644 (file)
@@ -77,7 +77,7 @@
   {/if}
 </tr>
 
-<tr><td colspan="3">{include file="CRM/common/Tag.tpl" tagsetType='case'}</td></tr>
+<tr><td colspan="3">{include file="CRM/common/Tagset.tpl" tagsetType='case'}</td></tr>
 
   {if $caseGroupTree}
   <tr>
index 944d34d0aacf83c6824fbe9516d79336962e6299..7db44d910aeb489607b28a7ba6059e823c85f697 100644 (file)
@@ -62,7 +62,7 @@
       {/foreach}
     </tr>
     {if !$type || $type eq 'tag'}
-      <tr><td>{include file="CRM/common/Tag.tpl"}</td></tr>
+      <tr><td>{include file="CRM/common/Tagset.tpl"}</td></tr>
     {/if}
   </table>
 {if $title}
index 6b32376c00d6fb75f3764d2d472b21aac002f980..e4664a1e43b0427218e9cf2a717a64005a940f5c 100644 (file)
       <td>&nbsp;</td>
     {/if}
     {if $isTagset}
-      <td colspan="2">{include file="CRM/common/Tag.tpl"}</td>
+      <td colspan="2">{include file="CRM/common/Tagset.tpl"}</td>
     {/if}
     <td>{$form.tag_search.label}  {help id="id-all-tags"}<br />{$form.tag_search.html}</td>
     {if ! $isTagset}
index 0ef87321360390fddf70e7ae96b1211bb2f68d43..c4fe1ec2f32dc631b081f7c97efdb218c1288ed3 100644 (file)
@@ -42,7 +42,7 @@
     </tr>
     <tr>
         <td>
-            {include file="CRM/common/Tag.tpl"}
+            {include file="CRM/common/Tagset.tpl"}
         </td>
     </tr>
 
index ff9a32d599271fba8f3cd24157767ca71d4ce8c8..747043c239f9865c47e80c378bd64b80847f6a51 100644 (file)
@@ -43,7 +43,7 @@
     </tr>
     <tr>
       <td>
-        {include file="CRM/common/Tag.tpl"}
+        {include file="CRM/common/Tagset.tpl"}
       </td>
     </tr>
 
index 97640108f5b99c7a006a39e97d55408e9e1a1038..9a5877baa4316ea619fb4badcce267c3f86781e4 100644 (file)
@@ -73,8 +73,8 @@
             <td><label>{$form.tag_1.label}</label> <div class="crm-select-container crm-attachment-tags">{$form.tag_1.html}</div></td>
           </tr>
         {/if}
-        {if $tagsetInfo_attachment}
-          <tr><td></td><td>{include file="CRM/common/Tag.tpl" tagsetType='attachment' tagsetNumber=1 }</td></tr>
+        {if $tagsetInfo.attachment}
+          <tr><td></td><td>{include file="CRM/common/Tagset.tpl" tagsetType='attachment' tagsetNumber=1 }</td></tr>
         {/if}
         {section name=attachLoop start=2 loop=$numAttachments+1}
           {assign var=index value=$smarty.section.attachLoop.index}
@@ -90,8 +90,8 @@
               <td></td>
               <td><label>{$form.$tagElement.label}</label> <div class="crm-select-container crm-attachment-tags">{$form.$tagElement.html}</div></td>
             </tr>
-            {if $tagsetInfo_attachment}
-              <tr><td></td><td>{include file="CRM/common/Tag.tpl" tagsetType='attachment' tagsetNumber=$index}</td></tr>
+            {if $tagsetInfo.attachment}
+              <tr><td></td><td>{include file="CRM/common/Tagset.tpl" tagsetType='attachment' tagsetNumber=$index}</td></tr>
             {/if}
         {/section}
 
index dd6fe06e9bff728ff9c0bb70a831e8fa6ef1fc45..94f5750e826e1ce4ca670d2fcdd50844237829d2 100644 (file)
     </ul>
   </div>
   <br />
-{include file="CRM/common/Tag.tpl" context="contactTab"}
+{include file="CRM/common/Tagset.tpl" context="contactTab"}
 </div>
diff --git a/templates/CRM/common/Tagset.tpl b/templates/CRM/common/Tagset.tpl
new file mode 100644 (file)
index 0000000..8d19c9a
--- /dev/null
@@ -0,0 +1,45 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.5                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+*}
+{if empty($tagsetType)}
+  {capture assign="tagsetType"}contact{/capture}
+{/if}
+{foreach from=$tagsetInfo.$tagsetType item=tagset}
+  <div class="crm-section tag-section {$tagsetType}-tagset {$tagsetType}-tagset-{$tagset.parentID}-section">
+    <label>{$tagset.parentName}</label>
+    <div class="crm-clearfix"{if $context EQ "contactTab"} style="margin-top:-15px;"{/if}>
+      {assign var=elemName  value = $tagset.tagsetElementName}
+      {assign var=parID     value = $tagset.parentID}
+      {assign var=editTagSet value=false}
+      {$form.$elemName.$parID.html}
+      {if $action ne 4 }
+        {assign var=editTagSet value=true}
+        {if $action eq 16 and !($permission eq 'edit') }
+          {assign var=editTagSet value=false}
+        {/if}
+      {/if}
+    </div>
+  </div>
+{/foreach}