From 460931caff88932f87287f84576bf9b81c4a719b Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 22 Mar 2017 10:23:11 +0530 Subject: [PATCH] Add is_public setting on Custom groups --- CRM/Core/BAO/CustomGroup.php | 10 +++++++++- CRM/Core/DAO/CustomGroup.php | 19 ++++++++++++++++++- CRM/Custom/Form/Group.php | 5 ++++- CRM/Event/Page/EventInfo.php | 2 +- CRM/Upgrade/Incremental/php/FourSeven.php | 2 ++ templates/CRM/Custom/Form/Group.tpl | 4 ++++ .../Utils/Migrate/fixtures/Activity-text.xml | 1 + .../Migrate/fixtures/ActivityMeeting-text.xml | 1 + .../Utils/Migrate/fixtures/Contact-select.xml | 1 + .../Utils/Migrate/fixtures/Contact-text.xml | 1 + .../Migrate/fixtures/Individual-text.xml | 1 + .../fixtures/IndividualStudent-text.xml | 1 + xml/schema/Core/CustomGroup.xml | 8 ++++++++ 13 files changed, 52 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 924fb74a2b4d..69a1bd661179 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -120,6 +120,7 @@ public static function create(&$params) { 'help_pre', 'help_post', 'is_active', + 'is_public', 'is_multiple', ); foreach ($fields as $field) { @@ -332,6 +333,7 @@ public static function autoCreateByActivityType($activityTypeId) { * @param bool $checkPermission * @param varchar $singleRecord * holds 'new' or id if view/edit/copy form for a single record is being loaded. + * @param bool $showPublicOnly * * @return array * Custom field 'tree'. @@ -356,7 +358,8 @@ public static function getTree( $onlySubType = NULL, $returnAll = FALSE, $checkPermission = TRUE, - $singleRecord = NULL + $singleRecord = NULL, + $showPublicOnly = FALSE ) { if ($entityID) { $entityID = CRM_Utils_Type::escape($entityID, 'Integer'); @@ -414,6 +417,7 @@ public static function getTree( 'extends_entity_column_id', 'extends_entity_column_value', 'max_multiple', + 'is_public', ), ); @@ -496,6 +500,10 @@ public static function getTree( ); } + if ($showPublicOnly) { + $strWhere .= "AND civicrm_custom_group.is_public = 1"; + } + $orderBy = " ORDER BY civicrm_custom_group.weight, civicrm_custom_group.title, diff --git a/CRM/Core/DAO/CustomGroup.php b/CRM/Core/DAO/CustomGroup.php index 7b11b4ff8e46..1c45988a6814 100644 --- a/CRM/Core/DAO/CustomGroup.php +++ b/CRM/Core/DAO/CustomGroup.php @@ -30,7 +30,7 @@ * * Generated from xml/schema/CRM/Core/CustomGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:5e44d08da1787dd031e8e4b81c1628a5) + * (GenCodeChecksum:5b2dac3266e0184dc4eaa6de10c9d401) */ require_once 'CRM/Core/DAO.php'; require_once 'CRM/Utils/Type.php'; @@ -170,6 +170,12 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO { * @var boolean */ public $is_reserved; + /** + * Is this property public? + * + * @var boolean + */ + public $is_public; /** * Class constructor. */ @@ -434,6 +440,17 @@ static function &fields() { 'bao' => 'CRM_Core_BAO_CustomGroup', 'localizable' => 0, ) , + 'is_public' => array( + 'name' => 'is_public', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Custom Group Is Public?') , + 'description' => 'Is this property public?', + 'default' => '1', + 'table_name' => 'civicrm_custom_group', + 'entity' => 'CustomGroup', + 'bao' => 'CRM_Core_BAO_CustomGroup', + 'localizable' => 0, + ) , ); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 05b46cccc1f5..8f1c23a38867 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -323,6 +323,9 @@ public function buildQuickForm() { // is this set active ? $this->addElement('advcheckbox', 'is_active', ts('Is this Custom Data Set active?')); + //Is this set visible on public pages? + $this->addElement('advcheckbox', 'is_public', ts('Is this Custom Data Set public?')); + // does this set have multiple record? $multiple = $this->addElement('advcheckbox', 'is_multiple', ts('Does this Custom Field Set allow multiple records?'), NULL); @@ -382,7 +385,7 @@ public function setDefaultValues() { $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_CustomGroup'); $defaults['is_multiple'] = $defaults['min_multiple'] = 0; - $defaults['is_active'] = $defaults['collapse_display'] = 1; + $defaults['is_active'] = $defaults['is_public'] = $defaults['collapse_display'] = 1; $defaults['style'] = 'Inline'; } elseif (empty($defaults['max_multiple']) && !$this->_isGroupEmpty) { diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index f4ecbddf6978..52891e8ec3eb 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -182,7 +182,7 @@ public function run() { } //retrieve custom field information - $groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_id, 0, $values['event']['event_type_id']); + $groupTree = CRM_Core_BAO_CustomGroup::getTree('Event', $this, $this->_id, 0, $values['event']['event_type_id'], NULL, TRUE, NULL, FALSE, TRUE, NULL, TRUE); CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id); $this->assign('action', CRM_Core_Action::VIEW); //To show the event location on maps directly on event info page diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 4dae2296f2b8..f06f714eb99d 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -340,6 +340,8 @@ public function upgrade_4_7_19($rev) { 'civicrm_sms_provider', 'domain_id', 'int(10) unsigned', "Which Domain is this sms provier for"); $this->addTask('CRM-19961 - Populate domain id table and perhaps add foreign key', 'populateSMSProviderDomainId'); $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('Add is_public column to civicrm_custom_group', 'addColumn', + 'civicrm_custom_group', 'is_public', "boolean DEFAULT '1' COMMENT 'Is this property public?'"); } /* diff --git a/templates/CRM/Custom/Form/Group.tpl b/templates/CRM/Custom/Form/Group.tpl index 1f571893e484..a2e5f44606bd 100644 --- a/templates/CRM/Custom/Form/Group.tpl +++ b/templates/CRM/Custom/Form/Group.tpl @@ -64,6 +64,10 @@   {$form.is_active.html} {$form.is_active.label} + +   + {$form.is_public.html} {$form.is_public.label} + {$form.help_pre.label} {help id="id-help_pre"} {$form.help_pre.html} diff --git a/tests/phpunit/CRM/Utils/Migrate/fixtures/Activity-text.xml b/tests/phpunit/CRM/Utils/Migrate/fixtures/Activity-text.xml index cdfd86852f95..b678d654d1ad 100644 --- a/tests/phpunit/CRM/Utils/Migrate/fixtures/Activity-text.xml +++ b/tests/phpunit/CRM/Utils/Migrate/fixtures/Activity-text.xml @@ -14,6 +14,7 @@ 0 0 0 + 1 diff --git a/tests/phpunit/CRM/Utils/Migrate/fixtures/ActivityMeeting-text.xml b/tests/phpunit/CRM/Utils/Migrate/fixtures/ActivityMeeting-text.xml index 5adfabad73ce..fe8d93eea5e2 100644 --- a/tests/phpunit/CRM/Utils/Migrate/fixtures/ActivityMeeting-text.xml +++ b/tests/phpunit/CRM/Utils/Migrate/fixtures/ActivityMeeting-text.xml @@ -16,6 +16,7 @@ 0 0 0 + 1 diff --git a/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-select.xml b/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-select.xml index ba6a2165a61e..b4c66d5a8d2c 100644 --- a/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-select.xml +++ b/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-select.xml @@ -16,6 +16,7 @@ 0 0 0 + 1 diff --git a/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-text.xml b/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-text.xml index 60e160b024cc..c6fd51652288 100644 --- a/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-text.xml +++ b/tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-text.xml @@ -14,6 +14,7 @@ 0 0 0 + 1 diff --git a/tests/phpunit/CRM/Utils/Migrate/fixtures/Individual-text.xml b/tests/phpunit/CRM/Utils/Migrate/fixtures/Individual-text.xml index 20d9fcb0a1f3..59768ede169a 100644 --- a/tests/phpunit/CRM/Utils/Migrate/fixtures/Individual-text.xml +++ b/tests/phpunit/CRM/Utils/Migrate/fixtures/Individual-text.xml @@ -14,6 +14,7 @@ 0 0 0 + 1 diff --git a/tests/phpunit/CRM/Utils/Migrate/fixtures/IndividualStudent-text.xml b/tests/phpunit/CRM/Utils/Migrate/fixtures/IndividualStudent-text.xml index 9b8a6650776a..2a367d908e39 100644 --- a/tests/phpunit/CRM/Utils/Migrate/fixtures/IndividualStudent-text.xml +++ b/tests/phpunit/CRM/Utils/Migrate/fixtures/IndividualStudent-text.xml @@ -16,6 +16,7 @@ 0 0 0 + 1 diff --git a/xml/schema/Core/CustomGroup.xml b/xml/schema/Core/CustomGroup.xml index afaf5ffb0f4a..a9bdbdba801b 100644 --- a/xml/schema/Core/CustomGroup.xml +++ b/xml/schema/Core/CustomGroup.xml @@ -214,4 +214,12 @@ Is this a reserved Custom Group? 4.4 + + is_public + boolean + Custom Group Is Public? + 1 + Is this property public? + 4.7 +