3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for managing tags.
21 class CRM_Tag_Page_Tag
extends CRM_Core_Page
{
26 public function run() {
27 CRM_Core_Resources
::singleton()
28 ->addScriptFile('civicrm', 'bower_components/jstree/dist/jstree.min.js', 0, 'html-header')
29 ->addStyleFile('civicrm', 'bower_components/jstree/dist/themes/default/style.min.css')
30 ->addPermissions(['administer reserved tags', 'administer Tagsets']);
32 $usedFor = $tagsets = [];
34 $result = civicrm_api3('OptionValue', 'get', [
35 'return' => ["value", "name"],
36 'option_group_id' => "tag_used_for",
38 foreach ($result['values'] as $value) {
39 $usedFor[$value['value']] = $value['name'];
42 $result = civicrm_api3('Tag', 'get', [
43 'return' => ["name", "used_for", "description", "created_id.display_name", "created_date", "is_reserved"],
45 'options' => ['limit' => 0],
47 foreach ($result['values'] as $id => $tagset) {
48 $used = explode(',', CRM_Utils_Array
::value('used_for', $tagset, ''));
49 $tagset['used_for_label'] = array_values(array_intersect_key($usedFor, array_flip($used)));
50 if (isset($tagset['created_id.display_name'])) {
51 $tagset['display_name'] = $tagset['created_id.display_name'];
53 unset($tagset['created_id.display_name']);
54 $tagsets[$id] = $tagset;
57 $this->assign('usedFor', $usedFor);
58 $this->assign('tagsets', $tagsets);