Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20318: Add is_public setting on Custom groups #10028

Merged
merged 1 commit into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion CRM/Core/BAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static function create(&$params) {
'help_pre',
'help_post',
'is_active',
'is_public',
'is_multiple',
);
foreach ($fields as $field) {
Expand Down Expand Up @@ -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'.
Expand All @@ -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');
Expand Down Expand Up @@ -414,6 +417,7 @@ public static function getTree(
'extends_entity_column_id',
'extends_entity_column_value',
'max_multiple',
'is_public',
),
);

Expand Down Expand Up @@ -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,
Expand Down
19 changes: 18 additions & 1 deletion CRM/Core/DAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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']);
}
Expand Down
5 changes: 4 additions & 1 deletion CRM/Custom/Form/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Page/EventInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CRM/Upgrade/Incremental/php/FourSeven.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?'");
}

/*
Expand Down
4 changes: 4 additions & 0 deletions templates/CRM/Custom/Form/Group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
<td>&nbsp;</td>
<td>{$form.is_active.html} {$form.is_active.label}</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>{$form.is_public.html} {$form.is_public.label}</td>
</tr>
<tr class="html-adjust">
<td class="label">{$form.help_pre.label} <!--{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_custom_group' field='help_pre' id=$gid}{/if}-->{help id="id-help_pre"}</td>
<td>{$form.help_pre.html}</td>
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Utils/Migrate/fixtures/Activity-text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<is_multiple>0</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<is_reserved>0</is_reserved>
<is_public>1</is_public>
</CustomGroup>
</CustomGroups>
<CustomFields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<is_multiple>0</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<is_reserved>0</is_reserved>
<is_public>1</is_public>
</CustomGroup>
</CustomGroups>
<CustomFields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<is_multiple>0</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<is_reserved>0</is_reserved>
<is_public>1</is_public>
</CustomGroup>
</CustomGroups>
<CustomFields>
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/CRM/Utils/Migrate/fixtures/Contact-text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<is_multiple>0</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<is_reserved>0</is_reserved>
<is_public>1</is_public>
</CustomGroup>
</CustomGroups>
<CustomFields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<is_multiple>0</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<is_reserved>0</is_reserved>
<is_public>1</is_public>
</CustomGroup>
</CustomGroups>
<CustomFields>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<is_multiple>0</is_multiple>
<collapse_adv_display>0</collapse_adv_display>
<is_reserved>0</is_reserved>
<is_public>1</is_public>
</CustomGroup>
</CustomGroups>
<CustomFields>
Expand Down
8 changes: 8 additions & 0 deletions xml/schema/Core/CustomGroup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,12 @@
<comment>Is this a reserved Custom Group?</comment>
<add>4.4</add>
</field>
<field>
<name>is_public</name>
<type>boolean</type>
<title>Custom Group Is Public?</title>
<default>1</default>
<comment>Is this property public?</comment>
<add>4.7</add>
</field>
</table>