From: Inforgetics Date: Thu, 13 Oct 2016 21:34:41 +0000 (+0200) Subject: CRM-15371 - add tag management permission and move tag management out of admin path... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=eaaaef83ebd841d4743e411e3072168711b4143f;p=civicrm-core.git CRM-15371 - add tag management permission and move tag management out of admin path and folders ---------------------------------------- * CRM-15371: Allow non-administrative users to see and manage tags without Administer CiviCRM permission https://issues.civicrm.org/jira/browse/CRM-15371 --- diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index 857698a3f7..766837ab13 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -396,10 +396,10 @@ class CRM_Core_Block { )); } - if (CRM_Core_Permission::check('administer CiviCRM')) { + if (CRM_Core_Permission::check('manage tags')) { $shortCuts = array_merge($shortCuts, array( array( - 'path' => 'civicrm/admin/tag', + 'path' => 'civicrm/tag', 'query' => 'reset=1&action=add', 'ref' => 'new-tag', 'title' => ts('Tag'), diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index 2e6aedfb40..6194e203ab 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -767,6 +767,10 @@ class CRM_Core_Permission { $prefix . ts('translate CiviCRM'), ts('Allow User to enable multilingual'), ), + 'manage tags' => array( + $prefix . ts('manage tags'), + ts('Create and rename tags'), + ), 'administer reserved groups' => array( $prefix . ts('administer reserved groups'), ts('Edit and disable Reserved Groups (Needs Edit Groups)'), diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index 74b9e99950..e1b77920c6 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -88,21 +88,6 @@ CRM_UF_Form_AdvanceSetting 0 - - civicrm/admin/tag - Tags (Categories) - Tags are useful for segmenting the contacts in your database into categories (e.g. Staff Member, Donor, Volunteer, etc.). Create and edit available tags here. - CRM_Admin_Page_Tag - Customize Data and Screens - admin/small/11.png - 25 - - - civicrm/admin/tag/add - New Tag - CRM_Admin_Page_Tag - action=add - civicrm/admin/options/activity_type Activity Types diff --git a/CRM/Core/xml/Menu/Tag.xml b/CRM/Core/xml/Menu/Tag.xml new file mode 100644 index 0000000000..104f896806 --- /dev/null +++ b/CRM/Core/xml/Menu/Tag.xml @@ -0,0 +1,21 @@ + + + + + civicrm/tag + Tags (Categories) + Tags are useful for segmenting the contacts in your database into categories (e.g. Staff Member, Donor, Volunteer, etc.). Create and edit available tags here. + CRM_Tag_Page_Tag + administer CiviCRM;manage tags + Customize Data and Screens + admin/small/11.png + 25 + + + civicrm/tag/add + New Tag + CRM_Tag_Page_Tag + action=add + administer CiviCRM;manage tags + + diff --git a/CRM/Admin/Form/Tag.php b/CRM/Tag/Form/Edit.php similarity index 98% rename from CRM/Admin/Form/Tag.php rename to CRM/Tag/Form/Edit.php index 98bc99e023..be3b6db482 100644 --- a/CRM/Admin/Form/Tag.php +++ b/CRM/Tag/Form/Edit.php @@ -34,7 +34,7 @@ /** * This class generates form components for Tag. */ -class CRM_Admin_Form_Tag extends CRM_Admin_Form { +class CRM_Tag_Form_Edit extends CRM_Admin_Form { protected $_isTagSet; /** @@ -52,7 +52,7 @@ class CRM_Admin_Form_Tag extends CRM_Admin_Form { if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_id && $tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id')) { - $url = CRM_Utils_System::url('civicrm/admin/tag', "reset=1"); + $url = CRM_Utils_System::url('civicrm/tag', "reset=1"); CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $url); } if ($this->_values['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved tags')) { diff --git a/CRM/Admin/Page/Tag.php b/CRM/Tag/Page/Tag.php similarity index 96% rename from CRM/Admin/Page/Tag.php rename to CRM/Tag/Page/Tag.php index 938746037a..20ed8e097e 100644 --- a/CRM/Admin/Page/Tag.php +++ b/CRM/Tag/Page/Tag.php @@ -34,7 +34,7 @@ /** * Page for displaying list of categories. */ -class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic { +class CRM_Tag_Page_Tag extends CRM_Core_Page_Basic { public $useLivePageJS = TRUE; @@ -66,13 +66,13 @@ class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic { self::$_links = array( CRM_Core_Action::UPDATE => array( 'name' => ts('Edit'), - 'url' => 'civicrm/admin/tag', + 'url' => 'civicrm/tag', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Tag'), ), CRM_Core_Action::DELETE => array( 'name' => ts('Delete'), - 'url' => 'civicrm/admin/tag', + 'url' => 'civicrm/tag', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Tag'), ), @@ -93,7 +93,7 @@ class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic { * Classname of edit form. */ public function editForm() { - return 'CRM_Admin_Form_Tag'; + return 'CRM_Tag_Form_Edit'; } /** @@ -125,7 +125,7 @@ class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic { * user context. */ public function userContext($mode = NULL) { - return 'civicrm/admin/tag'; + return 'civicrm/tag'; } /** @@ -135,7 +135,7 @@ class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic { * Classname of delete form. */ public function deleteForm() { - return 'CRM_Admin_Form_Tag'; + return 'CRM_Tag_Form_Edit'; } /** diff --git a/CRM/Upgrade/Incremental/sql/4.7.13.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.13.mysql.tpl index 7e2bb5b6ab..99ee850bc9 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.13.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.13.mysql.tpl @@ -4,3 +4,18 @@ ALTER TABLE `civicrm_price_field_value` CHANGE `deductible_amount` `non_deductible_amount` DECIMAL( 20, 2 ) NOT NULL DEFAULT '0.00' COMMENT 'Portion of total amount which is NOT tax deductible.'; ALTER TABLE `civicrm_line_item` CHANGE `deductible_amount` `non_deductible_amount` DECIMAL( 20, 2 ) NOT NULL DEFAULT '0.00' COMMENT 'Portion of total amount which is NOT tax deductible.'; + +-- CRM-15371 Manage tags with new *manage tags* permission (used to need *administer CiviCRM* permission) +UPDATE civicrm_navigation SET + `url` = 'civicrm/tag?reset=1&action=add', + `permission` = 'manage tags' +WHERE `name` = 'Manage Tags (Categories)'; + +UPDATE civicrm_navigation SET + `url` = 'civicrm/admin/tag?reset=1', + `permission` = 'manage tags' +WHERE `name` = 'New Tag'; + +UPDATE civicrm_navigation SET + `url` = 'civicrm/admin/tag?reset=1' +WHERE `name` = 'Tags (Categories)'; diff --git a/templates/CRM/Admin/Page/ConfigTaskList.tpl b/templates/CRM/Admin/Page/ConfigTaskList.tpl index 1070571eee..ff23a0be4c 100644 --- a/templates/CRM/Admin/Page/ConfigTaskList.tpl +++ b/templates/CRM/Admin/Page/ConfigTaskList.tpl @@ -125,7 +125,7 @@ {ts}Organize your contacts{/ts} - {ts}Tags (Categories){/ts} + {ts}Tags (Categories){/ts} {ts}Tags can be assigned to any contact record, and are a convenient way to find contacts. You can create as many tags as needed to organize and segment your records.{/ts} diff --git a/templates/CRM/Admin/Form/Tag.tpl b/templates/CRM/Tag/Form/Edit.tpl similarity index 100% rename from templates/CRM/Admin/Form/Tag.tpl rename to templates/CRM/Tag/Form/Edit.tpl diff --git a/templates/CRM/Admin/Page/Tag.tpl b/templates/CRM/Tag/Page/Tag.tpl similarity index 98% rename from templates/CRM/Admin/Page/Tag.tpl rename to templates/CRM/Tag/Page/Tag.tpl index bb6dfd9289..f79b083fa7 100644 --- a/templates/CRM/Admin/Page/Tag.tpl +++ b/templates/CRM/Tag/Page/Tag.tpl @@ -27,7 +27,7 @@ {capture assign=docLink}{docURL page="user/organising-your-data/groups-and-tags"}{/capture} {if $action eq 1 or $action eq 2 or $action eq 8} - {include file="CRM/Admin/Form/Tag.tpl"} + {include file="CRM/Tag/Form/Edit.tpl"} {else}
@@ -91,7 +91,7 @@ {else}
  - {capture assign=crmURL}{crmURL p='civicrm/admin/tag' q="action=add&reset=1"}{/capture} + {capture assign=crmURL}{crmURL p='civicrm/tag' q="action=add&reset=1"}{/capture} {ts 1=$crmURL}There are no Tags present. You can add one.{/ts}
{/if} diff --git a/xml/templates/civicrm_navigation.tpl b/xml/templates/civicrm_navigation.tpl index fcb2ceb363..38fd1f8e12 100644 --- a/xml/templates/civicrm_navigation.tpl +++ b/xml/templates/civicrm_navigation.tpl @@ -110,8 +110,8 @@ VALUES ( @domainID, 'civicrm/import/activity?reset=1', '{ts escape="sql" skip="true"}Import Activities{/ts}', 'Import Activities', 'import contacts', '', @contactlastID, '1', '1', 8 ), ( @domainID, 'civicrm/group/add?reset=1', '{ts escape="sql" skip="true"}New Group{/ts}', 'New Group', 'edit groups', '', @contactlastID, '1', NULL, 9 ), ( @domainID, 'civicrm/group?reset=1', '{ts escape="sql" skip="true"}Manage Groups{/ts}', 'Manage Groups', 'access CiviCRM', '', @contactlastID, '1', '1', 10 ), - ( @domainID, 'civicrm/admin/tag?reset=1&action=add', '{ts escape="sql" skip="true"}New Tag{/ts}', 'New Tag', 'administer CiviCRM', '', @contactlastID, '1', NULL, 11 ), - ( @domainID, 'civicrm/admin/tag?reset=1', '{ts escape="sql" skip="true"}Manage Tags (Categories){/ts}', 'Manage Tags (Categories)', 'administer CiviCRM', '', @contactlastID, '1','1', 12 ), + ( @domainID, 'civicrm/tag?reset=1&action=add', '{ts escape="sql" skip="true"}New Tag{/ts}', 'New Tag', 'manage tags', '', @contactlastID, '1', NULL, 11 ), + ( @domainID, 'civicrm/tag?reset=1', '{ts escape="sql" skip="true"}Manage Tags (Categories){/ts}', 'Manage Tags (Categories)', 'manage tags', '', @contactlastID, '1','1', 12 ), ( @domainID, 'civicrm/contact/deduperules?reset=1', '{ts escape="sql" skip="true"}Find and Merge Duplicate Contacts{/ts}', 'Find and Merge Duplicate Contacts', 'administer dedupe rules,merge duplicate contacts', 'OR', @contactlastID, '1', NULL, 13 ); INSERT INTO civicrm_navigation @@ -309,7 +309,7 @@ INSERT INTO civicrm_navigation VALUES ( @domainID, 'civicrm/admin/custom/group?reset=1', '{ts escape="sql" skip="true"}Custom Fields{/ts}', 'Custom Fields', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 1 ), ( @domainID, 'civicrm/admin/uf/group?reset=1', '{ts escape="sql" skip="true"}Profiles{/ts}', 'Profiles', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 2 ), - ( @domainID, 'civicrm/admin/tag?reset=1', '{ts escape="sql" skip="true"}Tags (Categories){/ts}', 'Tags (Categories)', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 3 ), + ( @domainID, 'civicrm/tag?reset=1', '{ts escape="sql" skip="true"}Tags (Categories){/ts}', 'Tags (Categories)', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 3 ), ( @domainID, 'civicrm/admin/options/activity_type?reset=1', '{ts escape="sql" skip="true"}Activity Types{/ts}', 'Activity Types', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 4 ), ( @domainID, 'civicrm/admin/reltype?reset=1', '{ts escape="sql" skip="true"}Relationship Types{/ts}', 'Relationship Types', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 5 ), ( @domainID, 'civicrm/admin/options/subtype?reset=1', '{ts escape="sql" skip="true"}Contact Types{/ts}','Contact Types', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 6 ),