use Civi\Api4\Contribution;
use Civi\Api4\LineItem;
+use Civi\Core\Event\PostEvent;
+use Civi\Core\HookInterface;
/**
* This class contains Contribution Page related functions.
*/
-class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_ContributionPage {
+class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_ContributionPage implements HookInterface {
/**
* Creates a contribution page.
* @return CRM_Contribute_DAO_ContributionPage
*/
public static function create($params) {
- $financialTypeId = NULL;
- if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) {
- $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id');
- }
-
+ // @todo - this implode is probably handled by writeRecord - test & remove.
if (isset($params['payment_processor']) && is_array($params['payment_processor'])) {
$params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']);
}
- $hook = empty($params['id']) ? 'create' : 'edit';
- CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params);
- $dao = new CRM_Contribute_DAO_ContributionPage();
- $dao->copyValues($params);
- $dao->save();
- if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
- CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']);
- }
- CRM_Utils_Hook::post($hook, 'ContributionPage', $dao->id, $dao);
+ return self::writeRecord($params);
+ }
+
+ /**
+ * Callback for hook_civicrm_post().
+ *
+ * @param \Civi\Core\Event\PostEvent $event
+ *
+ * @noinspection PhpUnusedParameterInspection
+ */
+ public static function self_hook_civicrm_post(PostEvent $event): void {
CRM_Core_PseudoConstant::flush();
- return $dao;
}
/**
*
* Generated from xml/schema/CRM/Contribute/Contribution.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:9e60bb45bfa633f107c72cc1f3049b58)
+ * (GenCodeChecksum:c612cd79d620e91f7498a3883c635293)
*/
/**
'table' => 'civicrm_contribution_page',
'keyColumn' => 'id',
'labelColumn' => 'title',
+ 'nameColumn' => 'name',
],
'add' => '1.5',
],
*
* Generated from xml/schema/CRM/Contribute/ContributionPage.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:075cce622b131127948be961f14fec2b)
+ * (GenCodeChecksum:fff705a45cbf2750018b57a05e5b1cb2)
*/
/**
/**
* Contribution Page title. For top of page display
*
- * @var string|null
+ * @var string
* (SQL type: varchar(255))
* Note that values will be retrieved from the database as a string.
*/
public $title;
+ /**
+ * Contribution Page Public title
+ *
+ * @var string
+ * (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.
*
*/
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.
*/
'title' => [
'name' => 'title',
'type' => CRM_Utils_Type::T_STRING,
- 'title' => ts('Contribution Page Title'),
+ 'title' => ts('Page Name'),
'description' => ts('Contribution Page title. For top of page display'),
+ 'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
'usage' => [
],
'add' => '1.3',
],
+ 'frontend_title' => [
+ 'name' => 'frontend_title',
+ 'type' => CRM_Utils_Type::T_STRING,
+ 'title' => ts('Public Title'),
+ 'description' => ts('Contribution Page Public title'),
+ 'required' => TRUE,
+ 'maxlength' => 255,
+ 'size' => CRM_Utils_Type::HUGE,
+ 'usage' => [
+ 'import' => FALSE,
+ 'export' => FALSE,
+ 'duplicate_matching' => FALSE,
+ 'token' => FALSE,
+ ],
+ 'where' => 'civicrm_contribution_page.frontend_title',
+ '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,
'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']);
}
* @return array
*/
public static function indices($localize = TRUE) {
- $indices = [];
+ $indices = [
+ 'UI_name' => [
+ 'name' => 'UI_name',
+ 'field' => [
+ 0 => 'name',
+ ],
+ 'localizable' => FALSE,
+ 'unique' => TRUE,
+ 'sig' => 'civicrm_contribution_page::1::name',
+ ],
+ ];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
$membershipSource = $form->_params['membership_source'];
}
elseif ((isset($form->_values['title']) && !empty($form->_values['title'])) || (isset($form->_values['frontend_title']) && !empty($form->_values['frontend_title']))) {
- $title = !empty($form->_values['frontend_title']) ? $form->_values['frontend_title'] : $form->_values['title'];
+ $title = $form->_values['frontend_title'];
$membershipSource = ts('Online Contribution:') . ' ' . $title;
}
$isPayLater = NULL;
}
}
// add a description field at the very beginning
- $title = !empty($this->_values['frontend_title']) ? $this->_values['frontend_title'] : $this->_values['title'];
+ $title = $this->_values['frontend_title'];
$this->_params['description'] = ts('Online Contribution') . ': ' . (!empty($this->_pcpInfo['title']) ? $this->_pcpInfo['title'] : $title);
$this->_params['accountingCode'] = $this->_values['accountingCode'] ?? NULL;
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 = [];
// 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));
if (empty($values[$idField]) && array_key_exists('name', $fields) && empty($values['name'])) {
$instance->makeNameFromLabel();
}
+ if (empty($values[$idField]) && array_key_exists('frontend_title', $fields) && empty($values['frontend_title'])) {
+ $instance->frontend_title = $instance->title;
+ }
+ if (empty($values[$idField]) && array_key_exists('title', $fields) && empty($values['title']) && !empty($values['frontend_title'])) {
+ $instance->title = $instance->frontend_title;
+ }
$instance->save();
if (!empty($record['custom']) && is_array($record['custom'])) {
$localizableFields = FALSE;
foreach ($fields as $name => $value) {
- if ($name == 'id' || $value['name'] == 'id') {
+ if ($name === 'id' || $value['name'] === 'id') {
// copy everything but the id!
continue;
}
$newObject->$dbName = $fieldsToReplace[$dbName];
}
- if ($type == 'Timestamp' || $type == 'Date') {
+ if ($type === 'Timestamp' || $type === 'Date') {
$newObject->$dbName = CRM_Utils_Date::isoToMysql($newObject->$dbName);
}
$newObject->copyValues($newData);
}
}
+ if (!empty($fields['name'])) {
+ $newObject->makeNameFromLabel();
+ }
$newObject->save();
// ensure we copy all localized fields as well
'frontend_description' => "text DEFAULT NULL COMMENT 'Alternative public description of the group.'",
],
'civicrm_contribution_page' => [
- 'title' => "varchar(255) COMMENT 'Contribution Page title. For top of page display'",
+ 'title' => "varchar(255) NOT NULL COMMENT 'Contribution Page title. For top of page display'",
+ 'frontend_title' => "varchar(255) NOT 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'",
'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'",
'civicrm_contribution_page' => [
'title' => [
'type' => "Text",
+ 'required' => "true",
+ ],
+ 'frontend_title' => [
+ 'type' => "Text",
+ 'required' => "true",
],
'intro_text' => [
'type' => "RichTextEditor",
'rows' => "6",
'cols' => "50",
],
- 'frontend_title' => [
- 'type' => "Text",
- ],
],
'civicrm_product' => [
'name' => [
+--------------------------------------------------------------------+
*/
+use Civi\Core\Exception\DBQueryException;
use Civi\Core\SettingsBag;
/**
$queries[] = "ALTER TABLE `$table` CHANGE `$column` `$column` $properties";
}
foreach ($queries as $query) {
- CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE);
+ try {
+ CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE);
+ }
+ catch (DBQueryException $e) {
+ throw new CRM_Core_Exception($e->getSQLErrorCode() . "\n" . $e->getDebugInfo());
+ }
}
$schema = new CRM_Logging_Schema();
if ($schema->isEnabled()) {
*
* @param string $rev
* The version number matching this function name
+ *
+ * @throws \Civi\Core\Exception\DBQueryException
*/
- public function upgrade_5_63_alpha1($rev): void {
+ public function upgrade_5_63_alpha1(string $rev): void {
+ $this->addTask('Add name column to civicrm_contribution_page', 'addColumn', 'civicrm_contribution_page',
+ 'name', "varchar(255) NULL COMMENT 'Unique name for identifying 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(255) NOT NULL COMMENT 'Unique name for identifying contribution page'");
+ $this->addTask('Make ContributionPage.title required', 'alterColumn', 'civicrm_contribution_page', 'title', "varchar(255) NOT NULL COMMENT 'Contribution Page title. For top of page display'", TRUE);
+ $this->addTask('Make ContributionPage.frontend_title required', 'alterColumn', 'civicrm_contribution_page', 'frontend_title', "varchar(255) NOT NULL COMMENT 'Contribution Page Public title'", TRUE);
}
}
( {$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';
+
+-- Ensure new name field is not null/unique. Setting to ID is a bit lazy - but sql localisation is painful.
+UPDATE civicrm_contribution_page SET `name` = `id`;
+
+-- Add name field, make frontend_title required (in conjunction with php function)
+{if $multilingual}
+ {foreach from=$locales item=locale}
+ UPDATE `civicrm_contribution_page`
+ SET `frontend_title_{$locale}` = `title_{$locale}`
+ WHERE `frontend_title_{$locale}` IS NULL OR `frontend_title_{$locale}` = '';
+ {/foreach}
+{else}
+ UPDATE `civicrm_contribution_page`
+ SET `frontend_title` = `title`
+ WHERE `frontend_title` IS NULL OR `frontend_title` = '';
+{/if}
* @inheritDoc
*/
public function modifySpec(RequestSpec $spec) {
- // Name is autogenerated from title if missing
- $spec->getFieldByName('name')->setRequired(FALSE)->setRequiredIf('empty($values.title)');
- // Title is supplied from name if missing
- $spec->getFieldByName('title')->setRequired(FALSE)->setRequiredIf('empty($values.name)');
- // Frontend_title is copied from title if missing
- $spec->getFieldByName('frontend_title')->setRequired(FALSE);
-
// Billing mode is copied across from the payment processor type field in the BAO::create function.
$spec->getFieldByName('billing_mode')->setRequired(FALSE);
--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+
+namespace Civi\Api4\Service\Spec\Provider;
+
+use Civi\Api4\Service\Spec\RequestSpec;
+use Civi\Core\Service\AutoService;
+
+/**
+ * @service
+ * @internal
+ */
+class TitleFieldSpecProvider extends AutoService implements Generic\SpecProviderInterface {
+
+ /**
+ * @param \Civi\Api4\Service\Spec\RequestSpec $spec
+ */
+ public function modifySpec(RequestSpec $spec): void {
+ // Name is autogenerated from title if missing
+ $spec->getFieldByName('name')->setRequired(FALSE)->setRequiredIf('empty($values.title)');
+ // Title is supplied from name if missing
+ $spec->getFieldByName('title')->setRequired(FALSE)->setRequiredIf('empty($values.name)');
+ // Frontend_title is copied from title if missing
+ $spec->getFieldByName('frontend_title')->setRequired(FALSE);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function applies($entity, $action): bool {
+ return in_array($entity, ['PaymentProcessor', 'ContributionPage']) && $action === 'create';
+ }
+
+}
LOCK TABLES `civicrm_contribution_page` WRITE;
/*!40000 ALTER TABLE `civicrm_contribution_page` DISABLE KEYS */;
-INSERT INTO `civicrm_contribution_page` (`id`, `title`, `intro_text`, `financial_type_id`, `payment_processor`, `is_credit_card_only`, `is_monetary`, `is_recur`, `is_confirm_enabled`, `recur_frequency_unit`, `is_recur_interval`, `is_recur_installments`, `adjust_recur_start_date`, `is_pay_later`, `pay_later_text`, `pay_later_receipt`, `is_partial_payment`, `initial_amount_label`, `initial_amount_help_text`, `min_initial_amount`, `is_allow_other_amount`, `default_amount_id`, `min_amount`, `max_amount`, `goal_amount`, `thankyou_title`, `thankyou_text`, `thankyou_footer`, `is_email_receipt`, `receipt_from_name`, `receipt_from_email`, `cc_receipt`, `bcc_receipt`, `receipt_text`, `is_active`, `footer_text`, `amount_block_is_active`, `start_date`, `end_date`, `created_id`, `created_date`, `currency`, `campaign_id`, `is_share`, `is_billing_required`, `frontend_title`) VALUES
- (1,'Help Support CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Contribute NOW by trying out our new online contribution features!',1,NULL,0,1,0,1,NULL,0,0,0,0,NULL,NULL,0,NULL,NULL,NULL,1,137,10.00,10000.00,100000.00,'Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about CiviCRM!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>',1,'CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1,NULL,1,NULL,NULL,NULL,NULL,'USD',NULL,1,0,NULL),
- (2,'Member Signup and Renewal','Members are the life-blood of our organization. If you\'re not already a member - please consider signing up today. You can select the membership level the fits your budget and needs below.',2,NULL,0,1,0,1,NULL,0,0,0,0,NULL,NULL,0,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,'Thanks for Your Support!','Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.',NULL,1,'Membership Department','memberships@civicrm.org',NULL,NULL,'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.\r\n\r\nKeep this receipt for your records.',1,NULL,0,NULL,NULL,NULL,NULL,'USD',NULL,1,0,NULL),
- (3,'Pledge for CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Pledge NOW by trying out our online contribution features!',1,NULL,0,1,0,1,NULL,0,0,0,0,NULL,NULL,0,NULL,NULL,NULL,1,NULL,10.00,10000.00,100000.00,'Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools like Pledge.</p><p>Please tell your friends and colleagues about CiviPledge!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>',1,'CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1,NULL,1,NULL,NULL,NULL,NULL,'USD',NULL,1,0,NULL);
+INSERT INTO `civicrm_contribution_page` (`id`, `title`, `name`, `intro_text`, `financial_type_id`, `payment_processor`, `is_credit_card_only`, `is_monetary`, `is_recur`, `is_confirm_enabled`, `recur_frequency_unit`, `is_recur_interval`, `is_recur_installments`, `adjust_recur_start_date`, `is_pay_later`, `pay_later_text`, `pay_later_receipt`, `is_partial_payment`, `initial_amount_label`, `initial_amount_help_text`, `min_initial_amount`, `is_allow_other_amount`, `default_amount_id`, `min_amount`, `max_amount`, `goal_amount`, `thankyou_title`, `thankyou_text`, `thankyou_footer`, `is_email_receipt`, `receipt_from_name`, `receipt_from_email`, `cc_receipt`, `bcc_receipt`, `receipt_text`, `is_active`, `footer_text`, `amount_block_is_active`, `start_date`, `end_date`, `created_id`, `created_date`, `currency`, `campaign_id`, `is_share`, `is_billing_required`, `frontend_title`) VALUES
+ (1,'Help Support CiviCRM!','donate','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Contribute NOW by trying out our new online contribution features!',1,NULL,0,1,0,1,NULL,0,0,0,0,NULL,NULL,0,NULL,NULL,NULL,1,137,10.00,10000.00,100000.00,'Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about CiviCRM!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>',1,'CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1,NULL,1,NULL,NULL,NULL,NULL,'USD',NULL,1,0,NULL),
+ (2,'Member Signup and Renewal','membership','Members are the life-blood of our organization. If you\'re not already a member - please consider signing up today. You can select the membership level the fits your budget and needs below.',2,NULL,0,1,0,1,NULL,0,0,0,0,NULL,NULL,0,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,'Thanks for Your Support!','Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.',NULL,1,'Membership Department','memberships@civicrm.org',NULL,NULL,'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.\r\n\r\nKeep this receipt for your records.',1,NULL,0,NULL,NULL,NULL,NULL,'USD',NULL,1,0,NULL),
+ (3,'Pledge for CiviCRM!','pledge','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Pledge NOW by trying out our online contribution features!',1,NULL,0,1,0,1,NULL,0,0,0,0,NULL,NULL,0,NULL,NULL,NULL,1,NULL,10.00,10000.00,100000.00,'Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools like Pledge.</p><p>Please tell your friends and colleagues about CiviPledge!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>',1,'CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1,NULL,1,NULL,NULL,NULL,NULL,'USD',NULL,1,0,NULL);
/*!40000 ALTER TABLE `civicrm_contribution_page` ENABLE KEYS */;
UNLOCK TABLES;
<div class="crm-block crm-form-block crm-contribution-contributionpage-settings-form-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class="form-layout-compressed">
- <tr class="crm-contribution-contributionpage-settings-form-block-title">
- <td class="label">{$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='title' id=$contributionPageID}{/if}</td>
- <td>{$form.title.html}</td>
- </tr>
- <tr class="crm-contribution-contributionpage-settings-form-block-frontend-title">
- <td class="label">{$form.contribution_page_frontend_title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='frontend_title' id=$contributionPageID}{/if}</td>
- <td>{$form.contribution_page_frontend_title.html}</td>
- </tr>
+ <tr class="crm-contribution-contributionpage-settings-form-block-frontend-title">
+ <td class="label">{$form.frontend_title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='frontend_title' id=$contributionPageID}{/if}</td>
+ <td>{$form.frontend_title.html}</td>
+ </tr>
+ <tr class="crm-contribution-contributionpage-settings-form-block-title">
+ <td class="label">{$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='title' id=$contributionPageID}{/if}</td>
+ <td>{$form.title.html}</td>
+ </tr>
<tr class="crm-contribution-contributionpage-settings-form-block-financial_type_id">
<td class="label">{$form.financial_type_id.label} {help id="id-financial_type"}</td>
<td>{$form.financial_type_id.html}</td>
*/
class CRM_Contribute_BAO_ContributionPageTest extends CiviUnitTestCase {
- const FINANCIAL_TYPE_ID = 1;
-
- public function setUp(): void {
- parent::setUp();
- }
-
/**
* Create() method (create Contribution Page)
*/
- public function testCreate() {
+ public function testCreate(): void {
$params = [
'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
'title' => 'Test Contribution Page',
- 'financial_type_id' => self::FINANCIAL_TYPE_ID,
+ 'financial_type_id' => 1,
'intro_text' => '',
'footer_text' => 'Thanks',
'is_for_organization' => 0,
'is_credit_card_only' => '',
];
- $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params);
-
- $this->assertNotNull($contributionpage->id);
- $this->assertIsInt($contributionpage->id);
- $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id]);
+ $contributionPageID = CRM_Contribute_BAO_ContributionPage::create($params)->id;
+ $this->assertIsInt($contributionPageID);
+ $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPageID]);
}
/**
* Test setValues() method
*/
- public function testSetValues() {
+ public function testSetValues(): void {
$params = [
'title' => 'Test Contribution Page',
- 'financial_type_id' => self::FINANCIAL_TYPE_ID,
+ 'financial_type_id' => 1,
'is_active' => 1,
];
CRM_Contribute_BAO_ContributionPage::setValues($id, $values);
$this->assertEquals($params['title'], $values['title'], 'Verify contribution title.');
- $this->assertEquals(self::FINANCIAL_TYPE_ID, $values['financial_type_id'], 'Verify financial types id.');
+ $this->assertEquals(1, $values['financial_type_id'], 'Verify financial types id.');
$this->assertEquals(1, $values['is_active'], 'Verify contribution is_active value.');
$this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id]);
}
/**
* Test copy() method
*/
- public function testcopy() {
+ public function testcopy(): void {
$params = [
'qfkey' => '9a3ef3c08879ad4c8c109b21c583400e',
'title' => 'Test Contribution Page',
- 'financial_type_id' => self::FINANCIAL_TYPE_ID,
+ 'financial_type_id' => 1,
'intro_text' => '',
'footer_text' => 'Thanks',
'is_for_organization' => 0,
$contributionPage = CRM_Contribute_BAO_ContributionPage::create($params);
$copyContributionPage = CRM_Contribute_BAO_ContributionPage::copy($contributionPage->id);
- $this->assertEquals($copyContributionPage->financial_type_id, self::FINANCIAL_TYPE_ID, 'Check for Financial type id.');
- $this->assertEquals($copyContributionPage->goal_amount, 400, 'Check for goal amount.');
+ $this->assertEquals(1, $copyContributionPage->financial_type_id, 'Check for Financial type id.');
+ $this->assertEquals(400, $copyContributionPage->goal_amount, 'Check for goal amount.');
$this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionPage->id]);
$this->callAPISuccess('ContributionPage', 'delete', ['id' => $copyContributionPage->id]);
}
*
* (these are denoted as 'quickConfig' in the code - but quickConfig is only supposed to refer to the
* configuration interface - there should be no different post process.
- *
- * @throws \CRM_Core_Exception
*/
- public function testGetAmountLevelTextAmount() {
+ public function testGetAmountLevelTextAmount(): void {
$priceSetID = $this->eventPriceSetCreate(9);
$priceSet = CRM_Price_BAO_PriceSet::getCachedPriceSetDetail($priceSetID);
$field = reset($priceSet['fields']);
}
/**
- * CRM-20237 Test that Copied price set does not generate long name and unneded information
- *
- * @throws \CRM_Core_Exception
+ * CRM-20237 Test that Copied price set does not generate long name and unnecessary information
*/
- public function testCopyPriceSet() {
+ public function testCopyPriceSet(): void {
$priceSetID = $this->eventPriceSetCreate(9);
$oldPriceSetInfo = $this->callAPISuccess('PriceSet', 'getsingle', ['id' => $priceSetID]);
$newPriceSet = CRM_Price_BAO_PriceSet::copy($priceSetID);
- $this->assertEquals(substr($oldPriceSetInfo['name'], 0, 20) . 'price_set_' . $newPriceSet->id, $newPriceSet->name);
+ $this->assertEquals('Price_Set_Copy_id_' . $newPriceSet->id . '_', $newPriceSet->name);
$this->assertEquals($oldPriceSetInfo['title'] . ' [Copy id ' . $newPriceSet->id . ']', $newPriceSet->title);
$new2PriceSet = CRM_Price_BAO_PriceSet::copy($newPriceSet->id);
- $this->assertEquals(substr($newPriceSet->name, 0, 20) . 'price_set_' . $new2PriceSet->id, $new2PriceSet->name);
+ $this->assertEquals('Price_Set_Copy_id_' . $new2PriceSet->id . '_', $new2PriceSet->name);
$this->assertEquals($oldPriceSetInfo['title'] . ' [Copy id ' . $new2PriceSet->id . ']', $new2PriceSet->title);
- $oldPriceField = $this->callAPISuccess('priceField', 'getsingle', ['price_set_id' => $priceSetID]);
- $oldPriceFieldValue = $this->callAPISuccess('priceFieldValue', 'getsingle', ['price_field_id' => $oldPriceField['id']]);
+ $oldPriceField = $this->callAPISuccess('PriceField', 'getsingle', ['price_set_id' => $priceSetID]);
+ $oldPriceFieldValue = $this->callAPISuccess('PriceFieldValue', 'getsingle', ['price_field_id' => $oldPriceField['id']]);
$this->callAPISuccess('PriceFieldValue', 'delete', ['id' => $oldPriceFieldValue['id']]);
$this->callAPISuccess('PriceField', 'delete', ['id' => $oldPriceField['id']]);
$this->callAPISuccess('PriceSet', 'delete', ['id' => $priceSetID]);
*
* @throws \CRM_Core_Exception
*/
- public function testGetMembershipCount() {
+ public function testGetMembershipCount(): void {
// create two organisations
$organization1 = $this->organizationCreate();
$organization2 = $this->organizationCreate();
'receipt_from_name' => 'Bob',
'receipt_from_email' => 'bob@example.org',
'financial_type_id' => 'Donation',
+ 'title' => 'page',
])['id'];
}
return $this->ids['ContributionPage'][0];
<pseudoconstant>
<table>civicrm_contribution_page</table>
<keyColumn>id</keyColumn>
+ <nameColumn>name</nameColumn>
<labelColumn>title</labelColumn>
</pseudoconstant>
<html>
</primaryKey>
<field>
<name>title</name>
- <title>Contribution Page Title</title>
+ <title>Page Name</title>
<type>varchar</type>
<length>255</length>
<localizable>true</localizable>
+ <required>true</required>
<comment>Contribution Page title. For top of page display</comment>
<add>1.3</add>
<html>
<type>Text</type>
</html>
</field>
+ <field>
+ <name>frontend_title</name>
+ <title>Public Title</title>
+ <type>varchar</type>
+ <length>255</length>
+ <localizable>true</localizable>
+ <required>true</required>
+ <comment>Contribution Page Public title</comment>
+ <html>
+ <type>Text</type>
+ </html>
+ <add>5.20</add>
+ </field>
+ <field>
+ <name>name</name>
+ <title>Unique Name</title>
+ <comment>Unique name for identifying contribution page</comment>
+ <required>true</required>
+ <type>varchar</type>
+ <length>255</length>
+ <html>
+ <type>Text</type>
+ </html>
+ <add>5.63</add>
+ </field>
<field>
<name>intro_text</name>
<title>Contribution Page Introduction Text</title>
<comment>if true - billing block is required for online contribution page</comment>
<add>4.6</add>
</field>
- <field>
- <name>frontend_title</name>
- <title>Public Title</title>
- <type>varchar</type>
- <length>255</length>
- <localizable>true</localizable>
- <default>NULL</default>
- <comment>Contribution Page Public title</comment>
- <html>
- <type>Text</type>
- </html>
- <add>5.20</add>
- <uniqueName>contribution_page_frontend_title</uniqueName>
- </field>
+ <index>
+ <name>UI_name</name>
+ <fieldName>name</fieldName>
+ <unique>true</unique>
+ <add>2.1</add>
+ </index>
</table>
(@priceFieldID, 'other_amount', 'Other Amount', 1, 3, 1, 0, 1);
INSERT INTO civicrm_contribution_page
- (title,intro_text,financial_type_id,is_monetary,is_allow_other_amount,default_amount_id,min_amount,max_amount,goal_amount,thankyou_title,thankyou_text,thankyou_footer,receipt_from_name,receipt_from_email,cc_receipt,bcc_receipt,receipt_text,is_active,footer_text,amount_block_is_active,currency,is_email_receipt)
+ (title,frontend_title, name,intro_text,financial_type_id,is_monetary,is_allow_other_amount,default_amount_id,min_amount,max_amount,goal_amount,thankyou_title,thankyou_text,thankyou_footer,receipt_from_name,receipt_from_email,cc_receipt,bcc_receipt,receipt_text,is_active,footer_text,amount_block_is_active,currency,is_email_receipt)
VALUES
- ('Help Support CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Contribute NOW by trying out our new online contribution features!',1,1,1,137,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about CiviCRM!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1, 'USD', 1),
- ('Member Signup and Renewal', 'Members are the life-blood of our organization. If you''re not already a member - please consider signing up today. You can select the membership level the fits your budget and needs below.', 2, 1, 0, NULL, NULL, NULL, NULL, 'Thanks for Your Support!', 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.', NULL, 'Membership Department', 'memberships@civicrm.org', NULL, NULL, 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.\r\n\r\nKeep this receipt for your records.', 1, NULL, 0, 'USD', 1),
- ('Pledge for CiviCRM!','Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Pledge NOW by trying out our online contribution features!',1,1,1,NULL,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools like Pledge.</p><p>Please tell your friends and colleagues about CiviPledge!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1, 'USD', 1);
+ ('Donate page', 'Help Support CiviCRM!','donate', 'Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Contribute NOW by trying out our new online contribution features!',1,1,1,137,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools.</p><p>Please tell your friends and colleagues about CiviCRM!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1, 'USD', 1),
+ ('Membership page','Member Signup and Renewal', 'membership','Members are the life-blood of our organization. If you''re not already a member - please consider signing up today. You can select the membership level the fits your budget and needs below.', 2, 1, 0, NULL, NULL, NULL, NULL, 'Thanks for Your Support!', 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.', NULL, 'Membership Department', 'memberships@civicrm.org', NULL, NULL, 'Thanks for supporting our organization with your membership. You can learn more about membership benefits from our members only page.\r\n\r\nKeep this receipt for your records.', 1, NULL, 0, 'USD', 1),
+ ('Pledge page', 'Pledge for CiviCRM!','pledge', 'Do you love CiviCRM? Do you use CiviCRM? Then please support CiviCRM and Pledge NOW by trying out our online contribution features!',1,1,1,NULL,'10.00','10000.00','100000.00','Thanks for Your Support!','<p>Thank you for your support. Your contribution will help us build even better tools like Pledge.</p><p>Please tell your friends and colleagues about CiviPledge!</p>','<p><a href=https://civicrm.org>Back to CiviCRM Home Page</a></p>','CiviCRM Fundraising Dept.','donationFake@civicrm.org','receipt@example.com','bcc@example.com','Your donation is tax deductible under IRS 501(c)(3) regulation. Our tax identification number is: 93-123-4567',1, NULL, 1, 'USD', 1);
INSERT INTO `civicrm_tell_friend`
(`entity_table`, `entity_id`, `title`, `intro`, `suggested_message`, `general_link`, `thankyou_title`, `thankyou_text`, `is_active`)