From b3f1028cd88920a00eb3d189a9e93c9414ba4bcb Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Tue, 27 Mar 2018 11:41:56 +0530 Subject: [PATCH] core-32 - Add option to disable cancel button on a profile form --- CRM/Core/DAO/UFGroup.php | 20 +++++++++++++++++++- CRM/Profile/Form/Edit.php | 1 + CRM/UF/Form/AdvanceSetting.php | 2 ++ CRM/UF/Form/Group.php | 1 + CRM/Upgrade/Incremental/php/FiveOne.php | 11 +++++++++++ templates/CRM/Profile/Form/Dynamic.tpl | 18 +++++++++++------- templates/CRM/UF/Form/AdvanceSetting.tpl | 19 +++++++++++++++++-- templates/CRM/UF/Form/Group.hlp | 11 +++++++++-- xml/schema/Core/UFGroup.xml | 8 ++++++++ 9 files changed, 79 insertions(+), 12 deletions(-) diff --git a/CRM/Core/DAO/UFGroup.php b/CRM/Core/DAO/UFGroup.php index c0b5d43b47..53e1c18927 100644 --- a/CRM/Core/DAO/UFGroup.php +++ b/CRM/Core/DAO/UFGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/UFGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:a6776694df1be240b3f7be798792175d) + * (GenCodeChecksum:a48f9522d0bd2e1d485064ebfc66f9a2) */ /** @@ -208,6 +208,13 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { */ public $submit_button_text; + /** + * Should a Cancel button be included in this Profile form. + * + * @var boolean + */ + public $add_cancel_button; + /** * Class constructor. */ @@ -545,6 +552,17 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { 'bao' => 'CRM_Core_BAO_UFGroup', 'localizable' => 1, ], + 'add_cancel_button' => [ + 'name' => 'add_cancel_button', + 'type' => CRM_Utils_Type::T_BOOLEAN, + 'title' => ts('Include Cancel Button'), + 'description' => 'Should a Cancel button be included in this Profile form.', + 'default' => '1', + 'table_name' => 'civicrm_uf_group', + 'entity' => 'UFGroup', + 'bao' => 'CRM_Core_BAO_UFGroup', + 'localizable' => 0, + ], ]; CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); } diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index 99348457ff..c01a868c06 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -222,6 +222,7 @@ SELECT module,is_reserved $cancelButtonValue = !empty($this->_ufGroup['cancel_button_text']) ? $this->_ufGroup['cancel_button_text'] : ts('Cancel'); $this->assign('cancelButtonText', $cancelButtonValue); + $this->assign('includeCancelButton', CRM_Utils_Array::value('add_cancel_button', $this->_ufGroup)); if (($this->_multiRecord & CRM_Core_Action::DELETE) && $this->_recordExists) { $this->_deleteButtonName = $this->getButtonName('upload', 'delete'); diff --git a/CRM/UF/Form/AdvanceSetting.php b/CRM/UF/Form/AdvanceSetting.php index 617940127f..01db60e8b9 100644 --- a/CRM/UF/Form/AdvanceSetting.php +++ b/CRM/UF/Form/AdvanceSetting.php @@ -50,6 +50,8 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group { $form->addGroup($options, 'is_update_dupe', ts('What to do upon duplicate match')); // we do not have any url checks to allow relative urls $form->addElement('text', 'post_URL', ts('Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'post_URL')); + + $form->add('advcheckbox', 'add_cancel_button', ts('Include Cancel Button?')); $form->addElement('text', 'cancel_URL', ts('Cancel Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_URL')); $form->addElement('text', 'cancel_button_text', ts('Cancel Button Text'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_button_text')); $form->addElement('text', 'submit_button_text', ts('Submit Button Text'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'submit_button_text')); diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index 9adc248503..9fcb834176 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -270,6 +270,7 @@ class CRM_UF_Form_Group extends CRM_Core_Form { } } else { + $defaults['add_cancel_button'] = 1; $defaults['is_active'] = 1; $defaults['is_map'] = 0; $defaults['is_update_dupe'] = 0; diff --git a/CRM/Upgrade/Incremental/php/FiveOne.php b/CRM/Upgrade/Incremental/php/FiveOne.php index d97a2b6233..de6ba85d7f 100644 --- a/CRM/Upgrade/Incremental/php/FiveOne.php +++ b/CRM/Upgrade/Incremental/php/FiveOne.php @@ -61,6 +61,17 @@ class CRM_Upgrade_Incremental_php_FiveOne extends CRM_Upgrade_Incremental_Base { // } } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_1_alpha1($rev) { + $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('Add Cancel Button Setting to the Profile', 'addColumn', + 'civicrm_uf_group', 'add_cancel_button', "tinyint DEFAULT '1' COMMENT 'Should a Cancel button be included in this Profile form.'"); + } + /* * Important! All upgrade functions MUST add a 'runSql' task. * Uncomment and use the following template for a new upgrade version diff --git a/templates/CRM/Profile/Form/Dynamic.tpl b/templates/CRM/Profile/Form/Dynamic.tpl index ffb5047aeb..fe559aafce 100644 --- a/templates/CRM/Profile/Form/Dynamic.tpl +++ b/templates/CRM/Profile/Form/Dynamic.tpl @@ -36,7 +36,9 @@
{$form._qf_Edit_upload_delete.html} - {$cancelButtonText} + {if $includeCancelButton} + {$cancelButtonText} + {/if}
{else} {if ! empty( $fields )} @@ -218,12 +220,14 @@ {/if}
{include file="CRM/common/formButtons.tpl"}{if $isDuplicate}{$form._qf_Edit_upload_duplicate.html}{/if} - - - - {$cancelButtonText} - - + {if $includeCancelButton} + + + + {$cancelButtonText} + + + {/if}
{/if} {if $help_post && $action neq 4}
{$help_post}
{/if} diff --git a/templates/CRM/UF/Form/AdvanceSetting.tpl b/templates/CRM/UF/Form/AdvanceSetting.tpl index 34c1f65ac2..018ee8cb48 100644 --- a/templates/CRM/UF/Form/AdvanceSetting.tpl +++ b/templates/CRM/UF/Form/AdvanceSetting.tpl @@ -50,12 +50,17 @@ {$form.post_URL.html} {help id='id-post_URL' file="CRM/UF/Form/Group.hlp"} - + + + {$form.add_cancel_button.html} {$form.add_cancel_button.label} {help id='id-add_cancel_button' file="CRM/UF/Form/Group.hlp"} + + + {$form.cancel_URL.label} {$form.cancel_URL.html} {help id='id-cancel_URL' file="CRM/UF/Form/Group.hlp"} - + {$form.cancel_button_text.label} {$form.cancel_button_text.html} {help id='id-cancel_button_text' file="CRM/UF/Form/Group.hlp"} @@ -102,3 +107,13 @@ +{literal} + +{/literal} diff --git a/templates/CRM/UF/Form/Group.hlp b/templates/CRM/UF/Form/Group.hlp index c1f72b76fa..9f12c705b5 100644 --- a/templates/CRM/UF/Form/Group.hlp +++ b/templates/CRM/UF/Form/Group.hlp @@ -36,7 +36,7 @@ {htxt id='id-used_for'} {ts}Profiles can be used in many different ways (and a single profile can be used in multiple contexts){/ts}: