Skip to content

Commit d06700a

Browse files
author
Ravish Nair
committed
-- CRM-12809 civicrm#1, civicrm#2 and civicrm#3
---------------------------------------- * CRM-12809: Reserved CustomGroups http://issues.civicrm.org/jira/browse/CRM-12809
1 parent 5319181 commit d06700a

File tree

8 files changed

+33
-2
lines changed

8 files changed

+33
-2
lines changed

CRM/Custom/Form/Field.php

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function preProcess() {
106106
//custom group id
107107
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
108108

109+
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
110+
CRM_Core_Error::fatal("You cannot add or edit fields of a Reserved Custom Group");
111+
}
112+
109113
if ($this->_gid) {
110114
$url = CRM_Utils_System::url('civicrm/admin/custom/group/field',
111115
"reset=1&action=browse&gid={$this->_gid}"

CRM/Custom/Form/Group.php

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public function preProcess() {
8282
// current set id
8383
$this->_id = $this->get('id');
8484

85+
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_id, 'is_reserved', 'id')) {
86+
CRM_Core_Error::fatal("You cannot edit the settings of a Reserved Custom Group");
87+
}
8588
// setting title for html page
8689
if ($this->_action == CRM_Core_Action::UPDATE) {
8790
$title = CRM_Core_BAO_CustomGroup::getTitle($this->_id);

CRM/Custom/Form/Option.php

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public function preProcess() {
7979
$this->_fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this);
8080

8181
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
82+
83+
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
84+
CRM_Core_Error::fatal("You cannot add or edit muliple choice options of a Reserved Custom Group Field");
85+
}
8286
if (!isset($this->_gid) && $this->_fid) {
8387
$this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField',
8488
$this->_fid,

CRM/Custom/Page/Field.php

+5
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ function run() {
231231
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive',
232232
$this
233233
);
234+
235+
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
236+
CRM_Core_Error::fatal("You cannot add or edit fields of a Reserved Custom Group");
237+
}
238+
234239
$action = CRM_Utils_Request::retrieve('action', 'String',
235240
// default to 'browse'
236241
$this, FALSE, 'browse'

CRM/Custom/Page/Group.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ function browse($action = NULL) {
208208
// get all custom groups sorted by weight
209209
$customGroup = array();
210210
$dao = new CRM_Core_DAO_CustomGroup();
211-
211+
$dao->is_reserved = FALSE;
212212
$dao->orderBy('weight, title');
213213
$dao->find();
214214

CRM/Custom/Page/Option.php

+4
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ function run() {
278278
$this, FALSE, 0
279279
);
280280

281+
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
282+
CRM_Core_Error::fatal("You cannot add or edit muliple choice options of a Reserved Custom Group Field");
283+
}
284+
281285
//as url contain $gid so append breadcrumb dynamically.
282286
$breadcrumb = array(array('title' => ts('Custom Data Fields'),
283287
'url' => CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&gid=' . $this->_gid),

CRM/Upgrade/Incremental/sql/4.4.alpha1.mysql.tpl

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,8 @@ INSERT INTO civicrm_uf_field
6464
( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, {localize field='label'}label{/localize}, field_type, help_post, phone_type_id )
6565
VALUES
6666
( @uf_group_contribution_batch_entry, 'soft_credit', 0, 0, 10, 'User and User Admin Only', 0, 0, NULL, {localize}'Soft Credit'{/localize}, 'Contribution', NULL, NULL ),
67-
( @uf_group_membership_batch_entry, 'soft_credit', 0, 0, 13, 'User and User Admin Only', 0, 0, NULL, {localize}'Soft Credit'{/localize}, 'Membership', NULL, NULL );
67+
( @uf_group_membership_batch_entry, 'soft_credit', 0, 0, 13, 'User and User Admin Only', 0, 0, NULL, {localize}'Soft Credit'{/localize}, 'Membership', NULL, NULL );
68+
69+
-- CRM-12809
70+
ALTER TABLE `civicrm_custom_group`
71+
ADD COLUMN `is_reserved` tinyint(4) DEFAULT '0' COMMENT 'Is this a reserved Custom Group?';

xml/schema/Core/CustomGroup.xml

+7
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@
179179
<comment>Date and time this custom group was created.</comment>
180180
<add>3.0</add>
181181
</field>
182+
<field>
183+
<name>is_reserved</name>
184+
<type>boolean</type>
185+
<default>0</default>
186+
<comment>Is this a reserved Custom Group?</comment>
187+
<add>4.4</add>
188+
</field>
182189
</table>
183190

184191

0 commit comments

Comments
 (0)