Skip to content

Commit

Permalink
dev/core#4213 Make frontend_title required
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed May 18, 2023
1 parent a57570b commit 215d56a
Show file tree
Hide file tree
Showing 10 changed files with 4,453 additions and 4,455 deletions.
101 changes: 67 additions & 34 deletions CRM/Contribute/DAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contribute/ContributionPage.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:fce845eb898447e06ebfa547ae8fa37c)
* (GenCodeChecksum:1c1db207050dbb1f7e821ddb608ea1c3)
*/

/**
Expand Down Expand Up @@ -56,6 +56,24 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
*/
public $title;

/**
* Contribution Page Public title
*
* @var string|null
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $frontend_title;

/**
* Unique name for identifying contribution page
*
* @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $name;

/**
* Text and html allowed. Displayed below title.
*
Expand Down Expand Up @@ -443,15 +461,6 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
*/
public $is_billing_required;

/**
* Contribution Page Public title
*
* @var string|null
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $frontend_title;

/**
* Class constructor.
*/
Expand Down Expand Up @@ -538,6 +547,54 @@ public static function &fields() {
'localizable' => 1,
'add' => '1.3',
],
'frontend_title' => [
'name' => 'frontend_title',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Public Title'),
'description' => ts('Contribution Page Public title'),
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_contribution_page.frontend_title',
'default' => NULL,
'table_name' => 'civicrm_contribution_page',
'entity' => 'ContributionPage',
'bao' => 'CRM_Contribute_BAO_ContributionPage',
'localizable' => 1,
'html' => [
'type' => 'Text',
],
'add' => '5.20',
],
'name' => [
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Unique Name'),
'description' => ts('Unique name for identifying contribution page'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_contribution_page.name',
'table_name' => 'civicrm_contribution_page',
'entity' => 'ContributionPage',
'bao' => 'CRM_Contribute_BAO_ContributionPage',
'localizable' => 0,
'html' => [
'type' => 'Text',
],
'add' => '5.63',
],
'intro_text' => [
'name' => 'intro_text',
'type' => CRM_Utils_Type::T_TEXT,
Expand Down Expand Up @@ -1474,30 +1531,6 @@ public static function &fields() {
'localizable' => 0,
'add' => '4.6',
],
'contribution_page_frontend_title' => [
'name' => 'frontend_title',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Public Title'),
'description' => ts('Contribution Page Public title'),
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
'import' => FALSE,
'export' => FALSE,
'duplicate_matching' => FALSE,
'token' => FALSE,
],
'where' => 'civicrm_contribution_page.frontend_title',
'default' => NULL,
'table_name' => 'civicrm_contribution_page',
'entity' => 'ContributionPage',
'bao' => 'CRM_Contribute_BAO_ContributionPage',
'localizable' => 1,
'html' => [
'type' => 'Text',
],
'add' => '5.20',
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public function preProcess() {
CRM_Utils_Array::value('cancelSubscriptionUrl', $this->_values)
);

$title = !empty($this->_values['frontend_title']) ? $this->_values['frontend_title'] : $this->_values['title'];
$title = $this->_values['frontend_title'];

$this->setTitle(($this->_pcpId ? $this->_pcpInfo['title'] : $title));
$this->_defaults = [];
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ContributionPage/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function buildQuickForm() {

// name
$this->add('text', 'title', ts('Title'), $attributes['title'], TRUE);
$this->addField('contribution_page_frontend_title', ['entity' => 'ContributionPage']);
$this->addField('frontend_title', ['entity' => 'ContributionPage'], TRUE);

//CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
Expand Down
8 changes: 4 additions & 4 deletions CRM/Core/I18n/SchemaStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static function &columns() {
],
'civicrm_contribution_page' => [
'title' => "varchar(255) COMMENT 'Contribution Page title. For top of page display'",
'frontend_title' => "varchar(255) DEFAULT NULL COMMENT 'Contribution Page Public title'",
'intro_text' => "text COMMENT 'Text and html allowed. Displayed below title.'",
'pay_later_text' => "text COMMENT 'The text displayed to the user in the main form'",
'pay_later_receipt' => "text COMMENT 'The receipt sent to the user instead of the normal receipt text'",
Expand All @@ -109,7 +110,6 @@ public static function &columns() {
'receipt_from_name' => "varchar(255) COMMENT 'FROM email name used for receipts generated by contributions to this contribution page.'",
'receipt_text' => "text COMMENT 'text to include above standard receipt info on receipt email. emails are text-only, so do not allow html for now'",
'footer_text' => "text COMMENT 'Text and html allowed. Displayed at the bottom of the first page of the contribution wizard.'",
'frontend_title' => "varchar(255) DEFAULT NULL COMMENT 'Contribution Page Public title'",
],
'civicrm_product' => [
'name' => "varchar(255) NOT NULL COMMENT 'Required product/premium name'",
Expand Down Expand Up @@ -430,6 +430,9 @@ public static function &widgets() {
'title' => [
'type' => "Text",
],
'frontend_title' => [
'type' => "Text",
],
'intro_text' => [
'type' => "RichTextEditor",
'rows' => "6",
Expand Down Expand Up @@ -473,9 +476,6 @@ public static function &widgets() {
'rows' => "6",
'cols' => "50",
],
'frontend_title' => [
'type' => "Text",
],
],
'civicrm_product' => [
'name' => [
Expand Down
7 changes: 7 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveSixtyThree.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ class CRM_Upgrade_Incremental_php_FiveSixtyThree extends CRM_Upgrade_Incremental
* The version number matching this function name
*/
public function upgrade_5_63_alpha1($rev): void {
$this->addTask('Add name column to civicrm_contribution_page', 'addColumn', 'civicrm_contribution_page',
'name', "varchar(64) COMMENT 'Unique identifier for the contribution page'");
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);

$enabledComponents = Civi::settings()->get('enable_components');
$extensions = array_map(['CRM_Utils_String', 'convertStringToSnakeCase'], $enabledComponents);
$this->addExtensionTask('Enable component extensions', $extensions);

$this->addTask('Make ContributionPage.name required', 'alterColumn', 'civicrm_contribution_page', 'name', "varchar(64) NOT NULL COMMENT 'Contribution Page Name.'");
$this->addTask('Make ContributionPage.title required', 'alterColumn', 'civicrm_contribution_page', 'title', "varchar(255) NOT NULL COMMENT 'Name of Contribution Page when shown to CiviCRM administrators.'", TRUE);
$this->addTask('Make ContributionPage.frontend_title required', 'alterColumn', 'civicrm_contribution_page', 'frontend_title', "varchar(255) NOT NULL COMMENT 'Public Name of Contribution Page.'", TRUE);

}

}
9 changes: 9 additions & 0 deletions CRM/Upgrade/Incremental/sql/5.63.alpha1.mysql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ VALUES
( {$domainID}, 'https://civicrm.org/help?src=iam', '{ts escape="sql" skip="true"}Get Help{/ts}', 'Get Help', NULL, 'AND', @adminHelplastID, '1', NULL, 2 );

UPDATE IGNORE `civicrm_navigation` SET `name` = 'Register Your Site', `label` = '{ts escape="sql" skip="true"}Register Your Site{/ts}' WHERE `name` = 'Register your site';

-- Add name field, make frontend_title required (in conjunction with php function)
UPDATE civicrm_contribution_page
SET {localize field="frontend_title"}frontend_title{/localize} = {localize field="title"}title{/localize},
WHERE {localize field="frontend_title"}frontend_title{/localize} IS NULL OR {localize field="frontend_title"}frontend_title{localize} = '';

UPDATE civicrm_contribution_page
SET name = CONCAT({localize field="title"}title{/localize}, '_', id) };

Loading

0 comments on commit 215d56a

Please sign in to comment.