From 592dd7d8a5ed9e06b977cdf2911877b23933bb94 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 17 Jun 2017 14:43:40 -0400 Subject: [PATCH] CRM-20743 - Check tag permissions in UI and BAO --- CRM/Core/BAO/Tag.php | 14 ++++++++++++++ templates/CRM/Tag/Page/Tag.tpl | 13 ++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index a8316323b7..f2840268ea 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -413,6 +413,20 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { return NULL; } + // Check permission to create or modify reserved tag + if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('administer reserved tags')) { + if (!empty($params['is_reserved']) || ($id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_reserved'))) { + throw new CRM_Core_Exception('Insufficient permission to administer reserved tag.'); + } + } + + // Check permission to create or modify tagset + if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('administer Tagsets')) { + if (!empty($params['is_tagset']) || ($id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_tagset'))) { + throw new CRM_Core_Exception('Insufficient permission to administer tagset.'); + } + } + $tag = new CRM_Core_DAO_Tag(); // if parent id is set then inherit used for and is hidden properties diff --git a/templates/CRM/Tag/Page/Tag.tpl b/templates/CRM/Tag/Page/Tag.tpl index c30187d1b6..81729b5fd8 100644 --- a/templates/CRM/Tag/Page/Tag.tpl +++ b/templates/CRM/Tag/Page/Tag.tpl @@ -389,6 +389,9 @@ div.tag-info input[type=color] { cursor: pointer; } + div.tag-info input[disabled] { + cursor: default; + } div.tag-info .tdl { font-weight: bold; color: #999; @@ -432,15 +435,15 @@