Merge pull request #9769 from scardinius/crm-19958
[civicrm-core.git] / CRM / Tag / Form / Tag.php
index a786ebe19ff908df42c62c4e5d867492904c5795..231fb43db0a49d36f794a8d62f39d9bed2be8e90 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  * $Id$
  *
  */
@@ -76,10 +76,10 @@ class CRM_Tag_Form_Tag extends CRM_Core_Form {
     $this->assign('tagged', $entityTag);
 
     // get the list of all the categories
-    $allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
+    $allTags = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable, FALSE);
 
     // need to append the array with the " checked " if contact is tagged with the tag
-    foreach ($allTag as $tagID => $varValue) {
+    foreach ($allTags as $tagID => $varValue) {
       if (in_array($tagID, $entityTag)) {
         $tagAttribute = array(
           'checked' => 'checked',
@@ -99,20 +99,9 @@ class CRM_Tag_Form_Tag extends CRM_Core_Form {
 
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
-
-    // let's not load jstree if there are not children. This also fixes blank
-    // display at the beginning of checkboxes
-    $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
-    $this->assign('loadjsTree', FALSE);
-    if (!empty($loadJsTree)) {
-      CRM_Core_Resources::singleton()
-        ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
-        ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
-      $this->assign('loadjsTree', TRUE);
-    }
     $this->assign('tree', $tree);
 
-    $this->assign('tag', $allTag);
+    $this->assign('allTags', $allTags);
 
     //build tag widget
     $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');