From 28ad83f683e9ce50d92180511d97c1cfe5f8ea1b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 7 Jun 2023 11:58:39 +1200 Subject: [PATCH] Lower-case field name uf_group.post_URL Apiv4 can't handle it as is... --- CRM/Core/DAO/UFGroup.php | 29 ++++++++++--------- CRM/Profile/Form/Edit.php | 4 +-- CRM/UF/Form/AdvanceSetting.php | 4 +-- CRM/UF/Form/Group.php | 4 +-- .../Incremental/sql/5.64.alpha1.mysql.tpl | 7 +++++ api/v3/UFGroup.php | 2 ++ api/v3/examples/UFGroup/Create.ex.php | 8 ++--- api/v3/examples/UFGroup/Get.ex.php | 2 +- js/model/crm.uf.js | 4 +-- templates/CRM/UF/Form/AdvanceSetting.tpl | 12 ++++---- templates/CRM/UF/Form/Group.hlp | 8 ++--- tests/phpunit/api/v3/UFGroupTest.php | 8 ++--- xml/schema/Core/UFGroup.xml | 11 ++++--- 13 files changed, 59 insertions(+), 44 deletions(-) diff --git a/CRM/Core/DAO/UFGroup.php b/CRM/Core/DAO/UFGroup.php index ae54985a33..833e5091b5 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:c8d65a421dc23cef070b148a190b37b0) + * (GenCodeChecksum:e1091f92ebe03a9ff5c6c73c015e8d72) */ /** @@ -131,13 +131,13 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { public $limit_listings_group_id; /** - * Redirect to URL. + * Redirect to URL on submit. * * @var string|null * (SQL type: varchar(255)) * Note that values will be retrieved from the database as a string. */ - public $post_URL; + public $post_url; /** * foreign key to civicrm_group_id @@ -194,13 +194,13 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { public $is_update_dupe; /** - * Redirect to URL when Cancle button clik . + * Redirect to URL when Cancel button clicked . * * @var string|null * (SQL type: varchar(255)) * Note that values will be retrieved from the database as a string. */ - public $cancel_URL; + public $cancel_url; /** * Should we create a cms user for this profile @@ -542,11 +542,11 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { ], 'add' => '1.4', ], - 'post_URL' => [ - 'name' => 'post_URL', + 'post_url' => [ + 'name' => 'post_url', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Post Url'), - 'description' => ts('Redirect to URL.'), + 'description' => ts('Redirect to URL on submit.'), 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, 'usage' => [ @@ -555,7 +555,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { 'duplicate_matching' => FALSE, 'token' => FALSE, ], - 'where' => 'civicrm_uf_group.post_URL', + 'where' => 'civicrm_uf_group.post_url', 'table_name' => 'civicrm_uf_group', 'entity' => 'UFGroup', 'bao' => 'CRM_Core_BAO_UFGroup', @@ -687,11 +687,11 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { 'localizable' => 0, 'add' => '1.7', ], - 'cancel_URL' => [ - 'name' => 'cancel_URL', + 'cancel_url' => [ + 'name' => 'cancel_url', 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Profile Cancel URL'), - 'description' => ts('Redirect to URL when Cancle button clik .'), + 'description' => ts('Redirect to URL when Cancel button clicked .'), 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, 'usage' => [ @@ -700,11 +700,14 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { 'duplicate_matching' => FALSE, 'token' => FALSE, ], - 'where' => 'civicrm_uf_group.cancel_URL', + 'where' => 'civicrm_uf_group.cancel_url', 'table_name' => 'civicrm_uf_group', 'entity' => 'UFGroup', 'bao' => 'CRM_Core_BAO_UFGroup', 'localizable' => 0, + 'html' => [ + 'label' => ts("Cancel URL"), + ], 'add' => '1.4', ], 'is_cms_user' => [ diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index f58da43349..88c2198607 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -146,8 +146,8 @@ SELECT module,is_reserved $this->assign('recentlyViewed', FALSE); if ($this->_context !== 'dialog') { - $this->_postURL = $this->_ufGroup['post_URL']; - $this->_cancelURL = $this->_ufGroup['cancel_URL']; + $this->_postURL = $this->_ufGroup['post_url']; + $this->_cancelURL = $this->_ufGroup['cancel_url']; $gidString = $this->_gid; if (!empty($this->_profileIds)) { diff --git a/CRM/UF/Form/AdvanceSetting.php b/CRM/UF/Form/AdvanceSetting.php index 56a247a916..bacdbf7683 100644 --- a/CRM/UF/Form/AdvanceSetting.php +++ b/CRM/UF/Form/AdvanceSetting.php @@ -34,10 +34,10 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group { // should we allow updates on a exisitng contact $form->addRadio('is_update_dupe', ts('What to do upon duplicate match'), [ts('Issue warning and do not save'), ts('Update the matching contact'), ts('Allow duplicate contact to be created')]); // 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->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_url', ts('Cancel Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_url')); // add select for groups $group = ['' => ts('- select -')] + $form->_group; diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index 881b1ceedf..a170fee960 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -252,8 +252,8 @@ class CRM_UF_Form_Group extends CRM_Core_Form { $showAdvanced = 0; $advFields = [ 'group', - 'post_URL', - 'cancel_URL', + 'post_url', + 'cancel_url', 'add_captcha', 'is_map', 'is_uf_link', diff --git a/CRM/Upgrade/Incremental/sql/5.64.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.64.alpha1.mysql.tpl index eae5904463..883b1a10f4 100644 --- a/CRM/Upgrade/Incremental/sql/5.64.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.64.alpha1.mysql.tpl @@ -1 +1,8 @@ {* file to handle db changes in 5.64.alpha1 during upgrade *} + +-- fix mis-casing of field name. Note the php function doesn't permit the name change hence it is here +-- but field is not localised. +ALTER TABLE civicrm_uf_group +CHANGE `post_URL` `post_url` varchar(255) DEFAULT NULL COMMENT 'Redirect to URL on submit.', +CHANGE `cancel_URL` `cancel_url` varchar(255) DEFAULT NULL COMMENT 'Redirect to URL when Cancel button clicked.' +; diff --git a/api/v3/UFGroup.php b/api/v3/UFGroup.php index 2d25eedea0..784c007011 100644 --- a/api/v3/UFGroup.php +++ b/api/v3/UFGroup.php @@ -28,6 +28,8 @@ function _civicrm_api3_uf_group_create_spec(&$params) { // Default to the logged in user. $params['created_id']['api.default'] = 'user_contact_id'; $params['created_date']['api.default'] = 'now'; + $params['post_url']['api.aliases'] = ['post_URL']; + $params['cancel_url']['api.aliases'] = ['cancel_URL']; } /** diff --git a/api/v3/examples/UFGroup/Create.ex.php b/api/v3/examples/UFGroup/Create.ex.php index d4ea27b181..baab92ae8c 100644 --- a/api/v3/examples/UFGroup/Create.ex.php +++ b/api/v3/examples/UFGroup/Create.ex.php @@ -15,7 +15,7 @@ function uf_group_create_example() { 'add_captcha' => 1, 'add_contact_to_group' => 1, 'group' => 1, - 'cancel_URL' => 'http://example.org/cancel', + 'cancel_url' => 'http://example.org/cancel', 'created_date' => '2009-06-27 00:00:00', 'created_id' => 1, 'group_type' => 'Individual,Contact', @@ -30,7 +30,7 @@ function uf_group_create_example() { 'is_update_dupe' => 1, 'name' => 'Test_Group', 'notify' => 'admin@example.org', - 'post_URL' => 'http://example.org/post', + 'post_url' => 'http://example.org/post', 'title' => 'Test Group', ]; @@ -77,14 +77,14 @@ function uf_group_create_expectedresult() { 'help_pre' => 'help pre', 'help_post' => 'help post', 'limit_listings_group_id' => '1', - 'post_URL' => 'http://example.org/post', + 'post_url' => 'http://example.org/post', 'add_to_group_id' => '1', 'add_captcha' => '1', 'is_map' => '1', 'is_edit_link' => '1', 'is_uf_link' => '1', 'is_update_dupe' => '1', - 'cancel_URL' => 'http://example.org/cancel', + 'cancel_url' => 'http://example.org/cancel', 'is_cms_user' => '1', 'notify' => 'admin@example.org', 'is_reserved' => '1', diff --git a/api/v3/examples/UFGroup/Get.ex.php b/api/v3/examples/UFGroup/Get.ex.php index 25127e0bc9..274b7c0c46 100644 --- a/api/v3/examples/UFGroup/Get.ex.php +++ b/api/v3/examples/UFGroup/Get.ex.php @@ -56,7 +56,7 @@ function uf_group_get_expectedresult() { 'help_pre' => 'help pre', 'help_post' => 'help post', 'limit_listings_group_id' => '1', - 'post_URL' => 'http://example.org/post', + 'post_url' => 'http://example.org/post', 'add_to_group_id' => '1', 'add_captcha' => '1', 'is_map' => '1', diff --git a/js/model/crm.uf.js b/js/model/crm.uf.js index 636304bad7..d366b33ac5 100644 --- a/js/model/crm.uf.js +++ b/js/model/crm.uf.js @@ -514,7 +514,7 @@ help: ts('Select a group if you want contacts to be automatically added to that group when the profile is submitted.'), type: 'Number' }, - 'cancel_URL': { + 'cancel_url': { title: ts('Cancel Redirect URL'), help: ts('If you are using this profile as a contact signup or edit form, and want to redirect the user to a static URL if they click the Cancel button - enter the complete URL here. If this field is left blank, the built-in Profile form will be redisplayed.'), type: 'Text' @@ -605,7 +605,7 @@ help: ts('If you want member(s) of your organization to receive a notification email whenever this Profile form is used to enter or update contact information, enter one or more email addresses here. Multiple email addresses should be separated by a comma (e.g. jane@example.org, paula@example.org). The first email address listed will be used as the FROM address in the notifications.'), type: 'TextArea' }, - 'post_URL': { + 'post_url': { title: ts('Redirect URL'), help: ts("If you are using this profile as a contact signup or edit form, and want to redirect the user to a static URL after they've submitted the form, you can also use contact tokens in URL - enter the complete URL here. If this field is left blank, the built-in Profile form will be redisplayed with a generic status message - 'Your contact information has been saved.'"), type: 'Text' diff --git a/templates/CRM/UF/Form/AdvanceSetting.tpl b/templates/CRM/UF/Form/AdvanceSetting.tpl index 4ad7d6a6e1..554b3e7691 100644 --- a/templates/CRM/UF/Form/AdvanceSetting.tpl +++ b/templates/CRM/UF/Form/AdvanceSetting.tpl @@ -29,9 +29,9 @@ {$form.notify.html} {help id='id-notify_email' file="CRM/UF/Form/Group.hlp"} - - {$form.post_URL.label} - {$form.post_URL.html} {help id='id-post_URL' file="CRM/UF/Form/Group.hlp"} + + {$form.post_url.label} + {$form.post_url.html} {help id='id-post_url' file="CRM/UF/Form/Group.hlp"} @@ -39,9 +39,9 @@ {$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_url.label} + {$form.cancel_url.html} {help id='id-cancel_url' file="CRM/UF/Form/Group.hlp"} {foreach from=$advancedFieldsConverted item=fieldName} diff --git a/templates/CRM/UF/Form/Group.hlp b/templates/CRM/UF/Form/Group.hlp index c0d751b222..caf8ae2bdc 100644 --- a/templates/CRM/UF/Form/Group.hlp +++ b/templates/CRM/UF/Form/Group.hlp @@ -73,10 +73,10 @@ {ts}If you want member(s) of your organization to receive a notification email whenever this Profile form is used to enter or update contact information, enter one or more email addresses here. Multiple email addresses should be separated by a comma (e.g. jane@example.org, paula@example.org). The first email address listed will be used as the FROM address in the notifications.{/ts} {/htxt} -{htxt id='id-post_URL-title'} +{htxt id='id-post_url-title'} {ts}Redirect{/ts} {/htxt} -{htxt id='id-post_URL'} +{htxt id='id-post_url'} {ts}If you are using this profile as a contact signup or edit form, and want to redirect the user to a static URL after they've submitted the form, you can also use contact tokens in URL - enter the complete URL here. If this field is left blank, the built-in Profile form will be redisplayed with a generic status message - 'Your contact information has been saved.'{/ts} {/htxt} @@ -87,10 +87,10 @@ {ts}Enable/Disable this checkbox to add/remove cancel button on the profile form.{/ts} {/htxt} -{htxt id='id-cancel_URL-title'} +{htxt id='id-cancel_url-title'} {ts}Cancel Redirect{/ts} {/htxt} -{htxt id='id-cancel_URL'} +{htxt id='id-cancel_url'} {ts}If you are using this profile as a contact signup or edit form, and want to redirect the user to a static URL if they click the Cancel button - enter the complete URL here. If this field is left blank, the built-in Profile form will be redisplayed.{/ts} {/htxt} diff --git a/tests/phpunit/api/v3/UFGroupTest.php b/tests/phpunit/api/v3/UFGroupTest.php index 4af4170fe9..9d106f0512 100644 --- a/tests/phpunit/api/v3/UFGroupTest.php +++ b/tests/phpunit/api/v3/UFGroupTest.php @@ -47,7 +47,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { 'add_captcha' => 1, 'add_contact_to_group' => $this->_groupId, 'group' => $this->_groupId, - 'cancel_URL' => 'http://example.org/cancel', + 'cancel_url' => 'http://example.org/cancel', 'created_date' => '2009-06-27 00:00:00', 'created_id' => $this->_contactId, 'group_type' => 'Individual,Contact', @@ -62,7 +62,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { 'is_update_dupe' => 1, 'name' => 'Test_Group', 'notify' => 'admin@example.org', - 'post_URL' => 'http://example.org/post', + 'post_url' => 'http://example.org/post', 'title' => 'Test Group', ]; } @@ -157,7 +157,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { 'id' => $this->_ufGroupId, 'add_captcha' => 1, 'add_contact_to_group' => $this->_groupId, - 'cancel_URL' => 'http://example.org/cancel', + 'cancel_url' => 'http://example.org/cancel', 'created_date' => '2009-06-27', 'created_id' => $this->_contactId, 'group' => $this->_groupId, @@ -173,7 +173,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { 'is_update_dupe' => 1, 'name' => 'test_group', 'notify' => 'admin@example.org', - 'post_URL' => 'http://example.org/post', + 'post_url' => 'http://example.org/post', 'title' => 'Test Group', ]; $result = $this->callAPISuccess('uf_group', 'create', $params); diff --git a/xml/schema/Core/UFGroup.xml b/xml/schema/Core/UFGroup.xml index 7e1b3599f3..3f7d1aa8b7 100644 --- a/xml/schema/Core/UFGroup.xml +++ b/xml/schema/Core/UFGroup.xml @@ -133,10 +133,10 @@ SET NULL - post_URL + post_url varchar 255 - Redirect to URL. + Redirect to URL on submit. @@ -203,11 +203,14 @@ 1.7 - cancel_URL + cancel_url Profile Cancel URL varchar 255 - Redirect to URL when Cancle button clik . + Redirect to URL when Cancel button clicked. + + + 1.4 -- 2.25.1