From ce1a9db4b4c16924ffc1a8a7b72614cc4932e604 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 12 Jan 2018 13:23:56 +1100 Subject: [PATCH] CRM-21225 Changes to UI to implement the frontend_title field to allow for overriding of the Profile title --- CRM/Core/BAO/UFGroup.php | 7 ++++++- CRM/UF/Form/Group.php | 1 + CRM/UF/Page/Group.php | 1 + js/model/crm.uf.js | 7 +++++++ js/view/crm.designer.js | 2 +- templates/CRM/UF/Form/Fields.tpl | 2 +- templates/CRM/UF/Form/Group.tpl | 4 ++++ templates/CRM/UF/Page/Group.tpl | 4 ++++ 8 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index c2bc2bef46..6ff7ded948 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -484,6 +484,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { 'name' => $name, 'groupTitle' => $group->title, 'groupName' => $group->name, + 'groupDisplayTitle' => (!empty($group->frontend_title)) ? $group->frontend_title : $group->title, 'groupHelpPre' => empty($group->help_pre) ? '' : $group->help_pre, 'groupHelpPost' => empty($group->help_post) ? '' : $group->help_post, 'title' => $title, @@ -1673,11 +1674,15 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) public static function getModuleUFGroup($moduleName = NULL, $count = 0, $skipPermission = TRUE, $op = CRM_Core_Permission::VIEW, $returnFields = NULL) { $selectFields = array('id', 'title', 'created_id', 'is_active', 'is_reserved', 'group_type'); - if (!CRM_Core_Config::isUpgradeMode()) { + if (CRM_Core_DAO::checkFieldExists('civicrm_uf_group', 'description')) { // CRM-13555, since description field was added later (4.4), and to avoid any problems with upgrade $selectFields[] = 'description'; } + if (CRM_Core_DAO::checkFieldExists('civicrm_uf_group', 'frontend_title')) { + $selectFields[] = 'frontend_title'; + } + if (!empty($returnFields)) { $selectFields = array_merge($returnFields, array_diff($selectFields, $returnFields)); } diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index dc0086baef..ac78b3ecb5 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -136,6 +136,7 @@ class CRM_UF_Form_Group extends CRM_Core_Form { // title $this->add('text', 'title', ts('Profile Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'title'), TRUE); + $this->add('text', 'frontend_title', ts('Public Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'frontend_title')); $this->add('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'description')); //add checkboxes diff --git a/CRM/UF/Page/Group.php b/CRM/UF/Page/Group.php index e664706f47..e4bfb1b2fd 100644 --- a/CRM/UF/Page/Group.php +++ b/CRM/UF/Page/Group.php @@ -326,6 +326,7 @@ class CRM_UF_Page_Group extends CRM_Core_Page { $ufGroup[$id] = array(); $ufGroup[$id]['id'] = $id; $ufGroup[$id]['title'] = $value['title']; + $ufGroup[$id]['frontend_title'] = $value['frontend_title']; $ufGroup[$id]['created_id'] = $value['created_id']; $ufGroup[$id]['created_by'] = CRM_Contact_BAO_Contact::displayName($value['created_id']); $ufGroup[$id]['description'] = $value['description']; diff --git a/js/model/crm.uf.js b/js/model/crm.uf.js index 043d08a5fa..c64dcda0b4 100644 --- a/js/model/crm.uf.js +++ b/js/model/crm.uf.js @@ -491,6 +491,13 @@ editorAttrs: {maxlength: 64}, validators: ['required'] }, + 'frontend_title': { + title: ts('Public Title'), + help: ts(''), + type: 'Text', + editorAttrs: {maxlength: 64}, + validators: [] + }, 'group_type': { // For a description of group_type, see CRM_Core_BAO_UFGroup::updateGroupTypes // title: ts(''), diff --git a/js/view/crm.designer.js b/js/view/crm.designer.js index a92ac6d606..807508db4e 100644 --- a/js/view/crm.designer.js +++ b/js/view/crm.designer.js @@ -866,7 +866,7 @@ initialize: function() { this.form = new Backbone.Form({ model: this.model, - fields: ['title', 'help_pre', 'help_post', 'is_active'] + fields: ['title', 'frontend_title', 'help_pre', 'help_post', 'is_active'] }); this.form.on('change', this.form.commit, this.form); }, diff --git a/templates/CRM/UF/Form/Fields.tpl b/templates/CRM/UF/Form/Fields.tpl index 155a936da1..77fbc9b3a0 100644 --- a/templates/CRM/UF/Form/Fields.tpl +++ b/templates/CRM/UF/Form/Fields.tpl @@ -21,7 +21,7 @@ {/if} {if $mode ne 8 && $action ne 1028 && $action ne 4 && !$hideFieldset} -
{$field.groupTitle} +
{$field.groupDisplayTitle} {/if} {if ($form.formName eq 'Confirm' OR $form.formName eq 'ThankYou') AND $prefix neq 'honor'} diff --git a/templates/CRM/UF/Form/Group.tpl b/templates/CRM/UF/Form/Group.tpl index 68e1692758..68d82fcb11 100644 --- a/templates/CRM/UF/Form/Group.tpl +++ b/templates/CRM/UF/Form/Group.tpl @@ -50,6 +50,10 @@ {$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_uf_group' field='title' id=$gid}{/if} {$form.title.html} + + {$form.frontend_title.label} + {$form.frontend_title.html} + {$form.description.label} {help id='id-description' file="CRM/UF/Form/Group.hlp"} {$form.description.html} diff --git a/templates/CRM/UF/Page/Group.tpl b/templates/CRM/UF/Page/Group.tpl index c219dc8e1c..557d07e5d3 100644 --- a/templates/CRM/UF/Page/Group.tpl +++ b/templates/CRM/UF/Page/Group.tpl @@ -73,6 +73,7 @@ {ts}Profile Title{/ts} + {ts}Public Title{/ts} {ts}Created By{/ts} {ts}Description{/ts} {ts}Type{/ts} @@ -86,6 +87,7 @@ {if !$row.is_reserved } {$row.title} + {$row.frontend_title} {if $row.created_id && $row.created_by} {ts}{$row.created_by}{/ts} @@ -116,6 +118,7 @@ {ts}Profile Title{/ts} + {ts}Public Title{/ts} {ts}Created By{/ts} {ts}Description{/ts} {ts}Type{/ts} @@ -129,6 +132,7 @@ {if $row.is_reserved} {$row.title} + {$row.frontend_title} {if $row.created_id && $row.created_by} {ts}{$row.created_by}{/ts} -- 2.25.1