// CRM-12675
$activityClause = NULL;
- $components = CRM_Core_Component::getNames();
- $componentClause = [];
- foreach ($components as $componentID => $componentName) {
- if ($componentName != 'CiviCase' && !CRM_Core_Permission::check("access $componentName")) {
- $componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) ";
- }
- }
- if (!empty($componentClause)) {
- $activityClause = implode(' AND ', $componentClause);
- }
$result = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $activityClause);
while ($result->fetch()) {
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled());
- $this->addElement(
- 'xbutton',
- 'ckeditor_config',
- CRM_Core_Page::crmIcon('fa-wrench') . ' ' . ts('Configure CKEditor'),
- [
- 'type' => 'submit',
- 'class' => 'crm-button',
- 'style' => 'display:inline-block;vertical-align:middle;float:none!important;',
- 'value' => 1,
- ]
- );
+ $this->addElement('submit', 'ckeditor_config', ts('Configure CKEditor'));
$editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
$this->assign('editOptions', $editOptions);
$this->addFormRule(['CRM_Admin_Form_Setting_Smtp', 'formRule']);
parent::buildQuickForm();
$buttons = $this->getElement('buttons')->getElements();
- $buttons[] = $this->createElement(
- 'xbutton',
- $this->_testButtonName,
- CRM_Core_Page::crmIcon('fa-envelope-o') . ' ' . ts('Save & Send Test Email'),
- ['type' => 'submit']
- );
+ $buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), ['crm-icon' => 'fa-envelope-o']);
$this->getElement('buttons')->setElements($buttons);
if (!empty($setStatus)) {
// add the force save button
$forceSave = $this->getButtonName('upload', 'force');
- $this->addElement('xbutton',
+ $this->addElement('submit',
$forceSave,
- ts('Ignore Mismatch & Process the Batch?'),
- [
- 'type' => 'submit',
- 'value' => 1,
- 'class' => 'crm-button crm-button_qf_Entry_upload_force-save',
- ]
+ ts('Ignore Mismatch & Process the Batch?')
);
$this->addButtons([
$this->add('wysiwyg', 'goal_general', ts('Campaign Goals'), ['rows' => 2, 'cols' => 40]);
$this->add('text', 'goal_revenue', ts('Revenue Goal'), ['size' => 8, 'maxlength' => 12]);
$this->addRule('goal_revenue', ts('Please enter a valid money value (e.g. %1).',
- [1 => CRM_Utils_Money::format('99.99', ' ')]
+ [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency(99.99)]
), 'money');
// is this Campaign active
// This button is hidden but gets clicked by javascript at
// https://github.com/civicrm/civicrm-core/blob/bd28ecf8121a85bc069cad3ab912a0c3dff8fdc5/templates/CRM/Case/Form/CaseView.js#L194
// by the onChange handler for the above timeline_id select.
- $this->addElement('xbutton', $this->getButtonName('next'), ' ', [
- 'class' => 'hiddenElement',
- 'type' => 'submit',
- ]);
+ $this->addElement('submit', $this->getButtonName('next'), ' ', ['class' => 'hiddenElement']);
$this->buildMergeCaseForm();
// This button is hidden but gets clicked by javascript at
// https://github.com/civicrm/civicrm-core/blob/bd28ecf8121a85bc069cad3ab912a0c3dff8fdc5/templates/CRM/Case/Form/CaseView.js#L55
// when the mergeCasesDialog is saved.
- $this->addElement('xbutton',
+ $this->addElement('submit',
$this->getButtonName('next', 'merge_case'),
ts('Merge'),
[
'class' => 'hiddenElement',
- 'type' => 'submit',
]
);
}
$this->addField('image_URL', ['maxlength' => '255', 'label' => ts('Browse/Upload Image')]);
// add the dedupe button
- $this->addElement('xbutton',
+ $this->addElement('submit',
$this->_dedupeButtonName,
- ts('Check for Matching Contact(s)'),
- [
- 'type' => 'submit',
- 'value' => 1,
- 'class' => "crm-button crm-button{$this->_dedupeButtonName}",
- ]
+ ts('Check for Matching Contact(s)')
);
- $this->addElement('xbutton',
+ $this->addElement('submit',
$this->_duplicateButtonName,
- ts('Save Matching Contact'),
- [
- 'type' => 'submit',
- 'value' => 1,
- 'class' => "crm-button crm-button{$this->_duplicateButtonName}",
- ]
+ ts('Save Matching Contact')
);
- $this->addElement('xbutton',
+ $this->addElement('submit',
$this->getButtonName('next', 'sharedHouseholdDuplicate'),
- ts('Save With Duplicate Household'),
- [
- 'type' => 'submit',
- 'value' => 1,
- ]
+ ts('Save With Duplicate Household')
);
$buttons = [
// also set the group title and freeze the action task with Add Members to Group
$groupValues = ['id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]];
$this->assign_by_ref('group', $groupValues);
- $this->add('xbutton', $this->_actionButtonName, ts('Add Contacts to %1', [1 => $this->_group[$this->_amtgID]]),
+ $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', [1 => $this->_group[$this->_amtgID]]),
[
- 'type' => 'submit',
'class' => 'crm-form-submit',
]
);
$this->assign('searchCount', $searchCount);
$this->assign('searchDone', $this->get('searchDone'));
$this->assign('contact_type_display', $contactType);
- $buttonAttrs = [
- 'type' => 'submit',
- 'class' => 'crm-form-submit',
- 'value' => 1,
- ];
- $this->addElement('xbutton', $this->getButtonName('refresh'), ts('Search'), $buttonAttrs);
- $this->addElement('xbutton', $this->getButtonName('cancel'), ts('Cancel'), $buttonAttrs);
+ $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), ['class' => 'crm-form-submit']);
+ $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), ['class' => 'crm-form-submit']);
$this->addButtons([
[
'type' => 'next',
$form->addFormFieldsFromMetadata();
$form->add('text', 'contribution_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]);
- $form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money');
+ $form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('9.99')]), 'money');
$form->add('text', 'contribution_amount_high', ts('To'), ['size' => 8, 'maxlength' => 8]);
- $form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
// Adding select option for curreny type -- CRM-4711
$form->add('select', 'contribution_currency_type',
*
* Generated from xml/schema/CRM/Contribute/ContributionPage.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:f12a7fabc2ed417166aeeefbdd596fb2)
+ * (GenCodeChecksum:902bfa164280b9ba21a7cb5a38aceba8)
*/
/**
$pledgeParams['create_date'] = $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date("Ymd");
if (!empty($params['start_date'])) {
$pledgeParams['frequency_day'] = intval(date("d", strtotime($params['start_date'])));
- $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date('Ymd', strtotime(CRM_Utils_Array::value('start_date', $params)));
+ $pledgeParams['start_date'] = $pledgeParams['scheduled_date'] = date('Ymd', strtotime($params['start_date']));
}
$pledgeParams['status_id'] = $contribution->contribution_status_id;
$pledgeParams['max_reminders'] = $form->_values['max_reminders'];
$paymentProcessorOutcome, $receiptDate, $recurringContributionID) {
$contributionParams = [
'financial_type_id' => $financialTypeID,
- 'receive_date' => (CRM_Utils_Array::value('receive_date', $params)) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
+ 'receive_date' => !empty($params['receive_date']) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'),
'tax_amount' => $params['tax_amount'] ?? NULL,
'amount_level' => $params['amount_level'] ?? NULL,
'invoice_id' => $params['invoiceID'],
'currency' => $params['currencyID'],
- 'is_pay_later' => CRM_Utils_Array::value('is_pay_later', $params, 0),
+ 'is_pay_later' => $params['is_pay_later'] ?? 0,
//configure cancel reason, cancel date and thankyou date
//from 'contribution' type profile if included
- 'cancel_reason' => CRM_Utils_Array::value('cancel_reason', $params, 0),
+ 'cancel_reason' => $params['cancel_reason'] ?? 0,
'cancel_date' => isset($params['cancel_date']) ? CRM_Utils_Date::format($params['cancel_date']) : NULL,
'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL,
//setting to make available to hook - although seems wrong to set on form for BAO hook availability
- 'skipLineItem' => CRM_Utils_Array::value('skipLineItem', $params, 0),
+ 'skipLineItem' => $params['skipLineItem'] ?? 0,
];
if ($paymentProcessorOutcome) {
$this->_params['is_pay_later'] = $this->get('is_pay_later');
$this->assign('is_pay_later', $this->_params['is_pay_later']);
if ($this->_params['is_pay_later']) {
- $this->assign('pay_later_receipt', CRM_Utils_Array::value('pay_later_receipt', $this->_values));
+ $this->assign('pay_later_receipt', $this->_values['pay_later_receipt'] ?? NULL);
}
// if onbehalf-of-organization
if (!empty($this->_values['onbehalf_profile_id']) && !empty($this->_params['onbehalf']['organization_name'])) {
// assign contribution page id to the template so we can add css class for it
$this->assign('contributionPageID', $this->_id);
- $this->assign('is_for_organization', CRM_Utils_Array::value('is_for_organization', $this->_params));
+ $this->assign('is_for_organization', $this->_params['is_for_organization'] ?? NULL);
$this->set('params', $this->_params);
}
$fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($this->_values['honoree_profile_id']);
$this->buildCustom($this->_values['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes);
}
- $this->assign('receiptFromEmail', CRM_Utils_Array::value('receipt_from_email', $this->_values));
+ $this->assign('receiptFromEmail', $this->_values['receipt_from_email']);
$amount_block_is_active = $this->get('amount_block_is_active');
$this->assign('amount_block_is_active', $amount_block_is_active);
$this->assign('product_name', $productDAO->name);
$this->assign('price', $productDAO->price);
$this->assign('sku', $productDAO->sku);
- $this->assign('option', CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams));
+ $this->assign('option', $premiumParams['options_' . $premiumParams['selectProduct']] ?? NULL);
$periodType = $productDAO->period_type;
$isEmailReceipt = !empty($form->_values['is_email_receipt']);
$isSeparateMembershipPayment = !empty($params['separate_membership_payment']);
- $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values);
+ $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : $form->_values['pledge_id'] ?? NULL;
if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) &&
(!empty($params['is_pledge']) || $pledgeID)) {
$isPledge = TRUE;
$recurParams['is_email_receipt'] = $params['is_email_receipt'] ?? NULL;
// we need to add a unique trxn_id to avoid a unique key error
// in paypal IPN we reset this when paypal sends us the real trxn id, CRM-2991
- $recurParams['trxn_id'] = CRM_Utils_Array::value('trxn_id', $params, $params['invoiceID']);
+ $recurParams['trxn_id'] = $params['trxn_id'] ?? $params['invoiceID'];
$recurParams['financial_type_id'] = $contributionType->id;
- $campaignId = CRM_Utils_Array::value('campaign_id', $params, CRM_Utils_Array::value('campaign_id', $form->_values));
+ $campaignId = $params['campaign_id'] ?? $form->_values['campaign_id'] ?? NULL;
$recurParams['campaign_id'] = $campaignId;
$recurring = CRM_Contribute_BAO_ContributionRecur::add($recurParams);
if (is_a($recurring, 'CRM_Core_Error')) {
$membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
$membershipType = empty($membershipTypes) ? [] : reset($membershipTypes);
- $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
+ $this->assign('membership_name', $membershipType['name']);
$this->_values['membership_name'] = $membershipType['name'] ?? NULL;
$isPaidMembership = FALSE;
$financialTypeID = $this->_values['financial_type_id'];
}
else {
- $financialTypeID = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
+ $financialTypeID = $membershipType['financial_type_id'] ?? $membershipParams['financial_type_id'] ?? NULL;
}
if (!empty($this->_params['membership_source'])) {
$isProcessSeparateMembershipTransaction, $financialTypeID, $unprocessedLineItems) {
$membershipContribution = NULL;
- $isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE);
+ $isTest = $membershipParams['is_test'] ?? FALSE;
$errors = $paymentResults = [];
$form->_values['isMembership'] = TRUE;
- $isRecurForFirstTransaction = CRM_Utils_Array::value('is_recur', $form->_params, CRM_Utils_Array::value('is_recur', $membershipParams));
+ $isRecurForFirstTransaction = $form->_params['is_recur'] ?? $membershipParams['is_recur'] ?? NULL;
$totalAmount = $membershipParams['amount'];
unset($membershipParams['is_recur']);
}
list($membershipContribution, $secondPaymentResult) = $this->processSecondaryFinancialTransaction($contactID, $form, array_merge($membershipParams, ['skipLineItem' => 1]),
- $isTest, $unprocessedLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails));
+ $isTest, $unprocessedLineItems, $membershipDetails['minimum_fee'] ?? 0, $membershipDetails['financial_type_id'] ?? NULL);
$paymentResults[] = ['contribution_id' => $membershipContribution->id, 'result' => $secondPaymentResult];
$totalAmount = $membershipContribution->total_amount;
}
}
//@todo it should no longer be possible for it to get to this point & membership to not be an array
if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) {
- $typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, []);
+ $typesTerms = $membershipParams['types_terms'] ?? [];
$membershipLines = $nonMembershipLines = [];
foreach ($unprocessedLineItems as $priceSetID => $lines) {
$membershipLineItems = $unprocessedLineItems;
}
$i++;
- $numTerms = CRM_Utils_Array::value($memType, $typesTerms, 1);
+ $numTerms = $typesTerms[$memType] ?? 1;
$contributionRecurID = $form->_params['contributionRecurID'] ?? NULL;
$membershipSource = NULL;
$pending = $membershipContribution->contribution_status_id == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
}
else {
- $pending = $this->getIsPending();
+ // The concept of contributeMode is deprecated.
+ // the is_monetary concept probably should be too as it can be calculated from
+ // the existence of 'amount' & seems fragile.
+ if (((isset($this->_contributeMode)) || !empty($this->_params['is_pay_later'])
+ ) &&
+ (($this->_values['is_monetary'] && $this->_amount > 0.0))
+ ) {
+ $pending = TRUE;
+ }
+ $pending = FALSE;
}
+
list($membership, $renewalMode, $dates) = CRM_Member_BAO_Membership::processMembership(
$contactID, $memType, $isTest,
- date('YmdHis'), CRM_Utils_Array::value('cms_contactID', $membershipParams),
+ date('YmdHis'), $membershipParams['cms_contactID'] ?? NULL,
$customFieldsFormatted,
$numTerms, $membershipID, $pending,
$contributionRecurID, $membershipSource, $isPayLater, $campaignId, [], $membershipContribution,
if (!empty($membershipContribution) && !is_a($membershipContribution, 'CRM_Core_Error')) {
if (empty($form->_paymentProcessor)) {
// @todo this can maybe go now we are setting payment_processor_id = 0 more reliably.
- $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values));
+ $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_values['payment_processor'] ?? NULL);
$this->_paymentProcessor['id'] = $paymentProcessorIDs[0];
}
$result = ['payment_status_id' => 1, 'contribution' => $membershipContribution];
'contact_id' => $contactID,
'line_item' => $lineItems,
'is_test' => $isTest,
- 'campaign_id' => CRM_Utils_Array::value('campaign_id', $tempParams, CRM_Utils_Array::value('campaign_id',
- $form->_values)),
+ 'campaign_id' => $tempParams['campaign_id'] ?? $form->_values['campaign_id'] ?? NULL,
'contribution_page_id' => $form->_id,
- 'source' => CRM_Utils_Array::value('source', $tempParams, CRM_Utils_Array::value('description', $tempParams)),
+ 'source' => $tempParams['source'] ?? $tempParams['description'] ?? NULL,
];
$isMonetary = !empty($form->_values['is_monetary']);
if ($isMonetary) {
return [$membershipContribution, $result];
}
- /**
- * Is the payment a pending payment.
- *
- * We are moving towards always creating as pending and updating at the end (based on payment), so this should be
- * an interim refactoring. It was shared with another unrelated form & some parameters may not apply to this form.
- *
- * @return bool
- */
- protected function getIsPending() {
- // The concept of contributeMode is deprecated.
- // the is_monetary concept probably should be too as it can be calculated from
- // the existence of 'amount' & seems fragile.
- if (((isset($this->_contributeMode)) || !empty($this->_params['is_pay_later'])
- ) &&
- (($this->_values['is_monetary'] && $this->_amount > 0.0))
- ) {
- return TRUE;
- }
- return FALSE;
- }
-
/**
* Are we going to do 2 financial transactions.
*
!empty($this->_membershipBlock['is_separate_payment'])
&& !empty($this->_values['fee'][$priceField->id])
&& ($this->_values['fee'][$priceField->id]['name'] == "other_amount")
- && CRM_Utils_Array::value("price_{$paramWeDoNotUnderstand}", $this->_params) < 1
+ && ($this->_params["price_{$paramWeDoNotUnderstand}"] ?? NULL) < 1
&& empty($this->_params["price_{$priceField->id}"])
) {
$this->_params['amount'] = NULL;
//@todo - merge with section above
if (!empty($this->_membershipBlock['is_separate_payment'])
&& !empty($this->_values['fee'][$priceField->id])
- && CRM_Utils_Array::value('name', $this->_values['fee'][$priceField->id]) == 'contribution_amount'
- && CRM_Utils_Array::value("price_{$priceField->id}", $this->_params) == '-1'
+ && ($this->_values['fee'][$priceField->id]['name'] ?? NULL) == 'contribution_amount'
+ && ($this->_params["price_{$priceField->id}"] ?? NULL) == '-1'
) {
$this->_params['amount'] = NULL;
}
}
$form->set('memberPriceFieldIDS', $membershipPriceFieldIDs);
$form->setRecurringMembershipParams();
- $form->processFormSubmission(CRM_Utils_Array::value('contact_id', $params));
+ $form->processFormSubmission($params['contact_id'] ?? NULL);
}
/**
$this->_contactID = $contactID;
//get email primary first if exist
- $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)];
+ $subscriptionEmail = ['email' => $params['email-Primary'] ?? NULL];
if (!$subscriptionEmail['email']) {
$subscriptionEmail['email'] = $params["email-{$this->_bltID}"] ?? NULL;
}
$contactID,
$this->wrangleFinancialTypeID($this->_values['financial_type_id']),
($this->_mode == 'test') ? 1 : 0,
- CRM_Utils_Array::value('is_recur', $paymentParams)
+ $paymentParams['is_recur'] ?? NULL
);
if (empty($result['is_payment_failure'])) {
* @throws \Exception
*/
protected function completeTransaction($result, $contributionID) {
- if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
+ if (($result['payment_status_id'] ?? NULL) == 1) {
try {
civicrm_api3('contribution', 'completetransaction', [
'id' => $contributionID,
'trxn_id' => $result['trxn_id'] ?? NULL,
- 'payment_processor_id' => CRM_Utils_Array::value('payment_processor_id', $result, $this->_paymentProcessor['id']),
+ 'payment_processor_id' => $result['payment_processor_id'] ?? $this->_paymentProcessor['id'],
'is_transactional' => FALSE,
'fee_amount' => $result['fee_amount'] ?? NULL,
'receive_date' => $result['receive_date'] ?? NULL,
// views are implemented as frozen form
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
- $this->addElement('xbutton', 'done', ts('Done'), [
- 'type' => 'button',
- 'onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'",
- ]);
+ $this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"]);
}
// don't show option for contribution amounts section if membership price set
// do u want to allow a free form text field for amount
$this->addElement('checkbox', 'is_allow_other_amount', ts('Allow other amounts'), NULL, ['onclick' => "minMax(this);showHideAmountBlock( this, 'is_allow_other_amount' );"]);
$this->add('text', 'min_amount', ts('Minimum Amount'), ['size' => 8, 'maxlength' => 8]);
- $this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money');
+ $this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('9.99')]), 'money');
$this->add('text', 'max_amount', ts('Maximum Amount'), ['size' => 8, 'maxlength' => 8]);
- $this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
//CRM-12055
$this->add('text', 'amount_label', ts('Contribution Amounts Label'));
// value
$this->add('text', "value[$i]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'));
- $this->addRule("value[$i]", ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $this->addRule("value[$i]", ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
// default
$default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
// CRM-4038: fix value display
foreach ($defaults['value'] as & $amount) {
- $amount = trim(CRM_Utils_Money::format($amount, ' '));
+ $amount = trim(CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($amount));
}
}
}
// collect goal amount
$this->add('text', 'goal_amount', ts('Goal Amount'), ['size' => 8, 'maxlength' => 12]);
- $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
// is confirmation page enabled?
$this->addElement('checkbox', 'is_confirm_enabled', ts('Use a confirmation page?'));
$this->assign('cpageId', $this->_id);
- $this->assign('widgetExternUrl', CRM_Utils_System::externUrl('extern/widget', "cpageId={$this->_id}&widgetId={$this->_widget->id}&format=3"));
+ $this->assign('widgetExternUrl', CRM_Utils_System::externUrl('extern/widget', "cpageId={$this->_id}&widgetId=" . ($this->_widget->id ?? '') . "&format=3"));
$config = CRM_Core_Config::singleton();
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage',
$this->assign_by_ref('colorFields', $this->_colorFields);
$this->_refreshButtonName = $this->getButtonName('refresh');
- $this->addElement('xbutton',
+ $this->addElement('submit',
$this->_refreshButtonName,
- ts('Save and Preview'),
- ['type' => 'submit']
+ ts('Save and Preview')
);
parent::buildQuickForm();
$this->addFormRule(['CRM_Contribute_Form_ContributionPage_Widget', 'formRule'], $this);
*/
protected function getSubscriptionContactID() {
$sub = $this->getSubscriptionDetails();
- return $sub->contact_id ?? FALSE;
+ return $sub->contact_id ? (int) $sub->contact_id : FALSE;
}
/**
* Is this being used by a front end user to update their own recurring.
*
* @return bool
+ * @throws \CRM_Core_Exception
*/
protected function isSelfService() {
- if (!is_null($this->selfService)) {
+ if ($this->selfService !== NULL) {
return $this->selfService;
}
$this->selfService = FALSE;
if (!CRM_Core_Permission::check('edit contributions')) {
- if ($this->_subscriptionDetails->contact_id != $this->getContactID()) {
+ if ($this->getSubscriptionContactID() !== $this->getContactIDIfAccessingOwnRecord()) {
CRM_Core_Error::statusBounce(ts('You do not have permission to cancel this recurring contribution.'));
}
$this->selfService = TRUE;
$this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
- $this->addElement('xbutton', 'loadMapping', ts('Load Mapping'), [
- 'type' => 'submit',
- 'onclick' => 'checkSelect()',
- ]);
+ $this->addElement('submit', 'loadMapping', ts('Load Mapping'), NULL, ['onclick' => 'checkSelect()']);
$this->addContactTypeSelector();
}
];
}
- if (!$paymentProcessorObj->supports('ChangeSubscriptionAmount') && !$paymentProcessorObj->supports('EditRecurringContribution')) {
+ if (
+ (!CRM_Core_Permission::check('edit contributions') && $context === 'contribution') ||
+ (!$paymentProcessorObj->supports('ChangeSubscriptionAmount')
+ && !$paymentProcessorObj->supports('EditRecurringContribution')
+ )) {
unset($links[CRM_Core_Action::UPDATE]);
}
}
$hasRelationTypes = [];
$columnCount = $columnNo;
- $form->addElement('xbutton', 'addBlock', ts('Also include contacts where'),
- [
- 'type' => 'submit',
- 'class' => 'submit-link',
- 'value' => 1,
- ]
+ $form->addElement('submit', 'addBlock', ts('Also include contacts where'),
+ ['class' => 'submit-link']
);
$contactTypes = CRM_Contact_BAO_ContactType::basicTypes();
$form->add('text', "value[$x][$i]", '');
}
- $form->addElement('xbutton', "addMore[$x]", ts('Another search field'), [
- 'type' => 'submit',
- 'class' => 'submit-link',
- 'value' => 1,
- ]);
+ $form->addElement('submit', "addMore[$x]", ts('Another search field'), ['class' => 'submit-link']);
}
//end of block for
return CRM_Core_DAO::singleValueQuery('SELECT @@collation_database');
}
+ /**
+ * Get the collation actually being used by the tables in the database.
+ *
+ * The db collation may not match the collation used by the tables, get what is
+ * set on the tables (represented by civicrm_contact).
+ *
+ * @return string
+ */
+ public static function getInUseCollation() {
+ if (!isset(\Civi::$statics[__CLASS__][__FUNCTION__])) {
+ $dao = CRM_Core_DAO::executeQuery('SHOW TABLE STATUS LIKE \'civicrm_contact\'');
+ $dao->fetch();
+ \Civi::$statics[__CLASS__][__FUNCTION__] = $dao->Collation;
+ }
+ return \Civi::$statics[__CLASS__][__FUNCTION__];
+ }
+
/**
* Get the database collation.
*
*
* Generated from xml/schema/CRM/Core/Phone.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:49f2d961afab0fe5b18a91bd1371cf35)
+ * (GenCodeChecksum:b10c818f0a807eacffe604063455467f)
*/
/**
$attrs = ['class' => 'crm-form-submit'] + (array) CRM_Utils_Array::value('js', $button);
- // A lot of forms use the hacky method of looking at
- // `$params['button name']` (dating back to them being inputs with a
- // "value" of the button label) rather than looking at
- // `$this->controller->getButtonName()`. It makes sense to give buttons a
- // value by default as a precaution.
- $attrs['value'] = 1;
-
if (!empty($button['class'])) {
$attrs['class'] .= ' ' . $button['class'];
}
}
if ($button['type'] === 'reset') {
- $attrs['type'] = 'reset';
- $prevnext[] = $this->createElement('xbutton', 'reset', $button['name'], $attrs);
+ $prevnext[] = $this->createElement($button['type'], 'reset', $button['name'], $attrs);
}
else {
if (!empty($button['subName'])) {
if (in_array($button['type'], ['next', 'upload', 'done']) && $button['name'] === ts('Save')) {
$attrs['accesskey'] = 'S';
}
- $buttonContents = CRM_Core_Page::crmIcon($button['icon'] ?? $defaultIcon) . ' ' . $button['name'];
+ $icon = CRM_Utils_Array::value('icon', $button, $defaultIcon);
+ if ($icon) {
+ $attrs['crm-icon'] = $icon;
+ }
$buttonName = $this->getButtonName($button['type'], CRM_Utils_Array::value('subName', $button));
- $attrs['class'] .= " crm-button crm-button-type-{$button['type']} crm-button{$buttonName}";
- $attrs['type'] = 'submit';
- $prevnext[] = $this->createElement('xbutton', $buttonName, $buttonContents, $attrs);
+ $prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs);
}
if (!empty($button['isDefault'])) {
$this->setDefaultAction($button['type']);
/**
* Get the contact id of the logged in user.
+ *
+ * @return int|false
*/
public function getLoggedInUserContactID() {
// check if the user is logged in and has a contact ID
$session = CRM_Core_Session::singleton();
- return $session->get('userID');
+ return $session->get('userID') ? (int) $session->get('userID') : FALSE;
}
/**
* - id_field
* - url (for ajax lookup)
*
+ * @throws \CRM_Core_Exception
* @todo add data attributes so we can deal with multiple instances on a form
*/
public function addAutoSelector($profiles = [], $autoCompleteField = []) {
$this->_actionButtonName = $this->getButtonName('next', 'action');
}
$this->assign('actionButtonName', $this->_actionButtonName);
- $this->add('xbutton', $this->_actionButtonName, ts('Go'), [
- 'type' => 'submit',
- 'class' => 'hiddenElement crm-search-go-button',
- ]);
+ $this->add('submit', $this->_actionButtonName, ts('Go'), ['class' => 'hiddenElement crm-search-go-button']);
// Radio to choose "All items" or "Selected items only"
$selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', ['checked' => 'checked']);
}
}
+ /**
+ * Get the contact if from the url, using the checksum or the cid if it is the logged in user.
+ *
+ * This function returns the user being validated. It is not intended to get another user
+ * they have permission to (setContactID does do that) and can be used to check if the user is
+ * accessing their own record.
+ *
+ * @return int|false
+ * @throws \CRM_Core_Exception
+ */
+ protected function getContactIDIfAccessingOwnRecord() {
+ $contactID = (int) CRM_Utils_Request::retrieve('cid', 'Positive', $this);
+ if (!$contactID) {
+ return FALSE;
+ }
+ if ($contactID === $this->getLoggedInUserContactID()) {
+ return $contactID;
+ }
+ $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this);
+ return CRM_Contact_BAO_Contact_Utils::validChecksum($contactID, $userChecksum) ? $contactID : FALSE;
+ }
+
}
'size' => 20,
'maxlength' => 20,
'autocomplete' => 'off',
- 'class' => 'creditcard',
+ 'class' => 'creditcard required',
],
'is_required' => TRUE,
// 'description' => '16 digit card number', // If you enable a description field it will be shown below the field on the form
'size' => 5,
'maxlength' => 10,
'autocomplete' => 'off',
+ 'class' => ($isCVVRequired ? 'required' : ''),
],
'is_required' => $isCVVRequired,
'rules' => [
'rule_parameters' => TRUE,
],
],
- 'extra' => ['class' => 'crm-form-select'],
+ 'extra' => ['class' => 'crm-form-select required'],
],
'credit_card_type' => [
'htmlType' => 'select',
'size' => 20,
'maxlength' => 34,
'autocomplete' => 'on',
+ 'class' => 'required',
],
'is_required' => TRUE,
],
'size' => 20,
'maxlength' => 34,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'rules' => [
[
'size' => 20,
'maxlength' => 11,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
'rules' => [
'size' => 20,
'maxlength' => 64,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
];
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
];
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
];
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
];
'name' => "billing_state_province_id-{$billingLocationID}",
'cc_field' => TRUE,
'is_required' => TRUE,
+ 'extra' => ['class' => 'required'],
];
$metadata["billing_postal_code-{$billingLocationID}"] = [
'size' => 30,
'maxlength' => 60,
'autocomplete' => 'off',
+ 'class' => 'required',
],
'is_required' => TRUE,
];
'' => ts('- select -'),
] + CRM_Core_PseudoConstant::country(),
'is_required' => TRUE,
+ 'extra' => ['class' => 'required'],
];
return $metadata;
}
default:
// Success
$params['trxn_id'] = !empty($response_fields[6]) ? $response_fields[6] : $this->getTestTrxnID();
- $params['gross_amount'] = $response_fields[9];
break;
}
$params['trxn_id'] = $this->getTrxnID();;
- $params['gross_amount'] = $propertyBag->getAmount();
// Add a fee_amount so we can make sure fees are handled properly in underlying classes.
$params['fee_amount'] = 1.50;
$params['description'] = $this->getPaymentDescription($params);
$field['name'],
$field['title'],
$field['attributes'],
- $field['is_required'],
+ FALSE,
$field['extra']
);
}
// Success
$params['trxn_result_code'] = $pjpgResponse['dc_response_code'];
$params['trxn_id'] = $pjpgResponse['dc_transaction_id'];
- $params['gross_amount'] = $params['amount'];
return $params;
}
/* Success */
$params['trxn_id'] = $result['transactionid'];
- $params['gross_amount'] = $result['amt'];
$params['fee_amount'] = $result['feeamt'];
$params['net_amount'] = $result['settleamt'] ?? NULL;
if ($params['net_amount'] == 0 && $params['fee_amount'] != 0) {
$params['trxn_id'] = $response['PASREF'];
$params['trxn_result_code'] = serialize($extras);
$params['currencyID'] = $this->_getParam('currency');
- $params['gross_amount'] = $this->_getParam('amount');
$params['fee_amount'] = 0;
return $params;
$beaglestatus = ': ' . $beaglestatus;
}
$params['trxn_result_code'] = $eWAYResponse->Status() . $beaglestatus;
- $params['gross_amount'] = $eWAYResponse->Amount();
$params['trxn_id'] = $eWAYResponse->TransactionNumber();
return $params;
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$url = CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid);
- $this->addElement('xbutton',
+ $this->addElement('button',
'done',
ts('Done'),
- [
- 'type' => 'button',
- 'onclick' => "location.href='$url'",
- ]
+ ['onclick' => "location.href='$url'"]
);
}
}
// TODO: Is this condition ever true? Can this code be removed?
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
- $this->addElement('xbutton', 'done', ts('Done'), [
- 'type' => 'button',
- 'onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'",
- ]);
+ $this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"]);
}
}
'reset=1&action=browse&fid=' . $this->_fid . '&gid=' . $this->_gid,
TRUE, NULL, FALSE
);
- $this->addElement('xbutton',
+ $this->addElement('button',
'done',
- CRM_Core_Page::crmIcon('fa-times') . ' ' . ts('Done'),
- [
- 'type' => 'button',
- 'onclick' => "location.href='$url'",
- 'class' => 'crm-form-submit cancel',
- ]
+ ts('Done'),
+ ['onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times']
);
}
}
*
* Generated from xml/schema/CRM/Event/Event.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:ad8debb948e4646b04fb46991c0867db)
+ * (GenCodeChecksum:164ee1a507b9244536114d1569ccff1e)
*/
/**
// value
$this->add('text', "value[$i]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'));
- $this->addRule("value[$i]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $this->addRule("value[$i]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
// default
$default[] = $this->createElement('radio', NULL, NULL, NULL, $i);
$this->add('datepicker', 'discount_end_date[' . $i . ']', ts('Discount End Date'), [], FALSE, ['time' => FALSE]);
}
$_showHide->addToTemplate();
- $this->addElement('xbutton', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'),
- [
- 'type' => 'submit',
- 'class' => 'crm-form-submit cancel',
- 'value' => 1,
- ]
+ $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'),
+ ['class' => 'crm-form-submit cancel']
);
if (Civi::settings()->get('deferred_revenue_enabled')) {
$deferredFinancialType = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType();
// value
for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) {
$this->add('text', "discounted_value[$i][$j]", ts('Value'), ['size' => 10]);
- $this->addRule("discounted_value[$i][$j]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $this->addRule("discounted_value[$i][$j]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
}
// default
$params['value'][$index] = CRM_Utils_Rule::cleanMoney(trim($value));
}
}
- foreach ($params['discounted_value'] as $index => $discountedValueSet) {
+ foreach ($params['discounted_value'] ?? [] as $index => $discountedValueSet) {
foreach ($discountedValueSet as $innerIndex => $value) {
if (CRM_Utils_System::isNull($value)) {
unset($params['discounted_value'][$index][$innerIndex]);
*/
public function buildQuickForm() {
if ($this->_batchStatus == 'Closed') {
- $this->add('xbutton', 'export_batch', ts('Export Batch'), ['type' => 'submit']);
+ $this->add('submit', 'export_batch', ts('Export Batch'));
}
// do not build rest of form unless it is open/reopened batch
parent::buildQuickForm();
if (CRM_Batch_BAO_Batch::checkBatchPermission('close', $this->_values['created_id'])) {
- $this->add('xbutton', 'close_batch', ts('Close Batch'), ['type' => 'submit']);
+ $this->add('submit', 'close_batch', ts('Close Batch'));
if (CRM_Batch_BAO_Batch::checkBatchPermission('export', $this->_values['created_id'])) {
- $this->add('xbutton', 'export_batch', ts('Close & Export Batch'), ['type' => 'submit']);
+ $this->add('submit', 'export_batch', ts('Close & Export Batch'));
}
}
ts('Task'),
['' => ts('- actions -')] + ['Remove' => ts('Remove from Batch')]);
- $this->add('xbutton', 'rSubmit', ts('Go'),
+ $this->add('submit', 'rSubmit', ts('Go'),
[
- 'type' => 'submit',
'class' => 'crm-form-submit',
'id' => 'GoRemove',
]);
ts('Task'),
['' => ts('- actions -')] + ['Assign' => ts('Assign to Batch')]);
- $this->add('xbutton', 'submit', ts('Go'),
+ $this->add('submit', 'submit', ts('Go'),
[
- 'type' => 'submit',
'class' => 'crm-form-submit',
'id' => 'Go',
]);
ts('Task'),
['' => ts('- actions -')] + $batchAction);
- $this->add('xbutton', 'submit', ts('Go'),
+ $this->add('submit', 'submit', ts('Go'),
[
- 'type' => 'submit',
'class' => 'crm-form-submit',
'id' => 'Go',
]);
$form->addElement('checkbox', 'grant_decision_date_notset', ts('Date is not set'), NULL);
$form->add('text', 'grant_amount_low', ts('Minimum Amount'), ['size' => 8, 'maxlength' => 8]);
- $form->addRule('grant_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money');
+ $form->addRule('grant_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('9.99')]), 'money');
$form->add('text', 'grant_amount_high', ts('Maximum Amount'), ['size' => 8, 'maxlength' => 8]);
- $form->addRule('grant_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $form->addRule('grant_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
self::addCustomFormFields($form, ['Grant']);
$allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get');
$activityParams = [
- 'status_id' => CRM_Utils_Array::value('membership_activity_status', $params, 'Completed'),
+ 'status_id' => $params['membership_activity_status'] ?? 'Completed',
];
if (in_array($allStatus[$membership->status_id], ['Pending', 'Grace'])) {
$activityParams['status_id'] = 'Scheduled';
}
foreach (['Membership Signup', 'Membership Renewal'] as $activityType) {
- $activityParams['id'] = CRM_Utils_Array::value('id',
- civicrm_api3('Activity', 'Get',
- [
- 'source_record_id' => $membership->id,
- 'activity_type_id' => $activityType,
- 'status_id' => 'Scheduled',
- ]
- )
- );
+ $activityParams['id'] = civicrm_api3('Activity', 'Get', [
+ 'source_record_id' => $membership->id,
+ 'activity_type_id' => $activityType,
+ 'status_id' => 'Scheduled',
+ ])['id'] ?? NULL;
// 1. Update Schedule Membership Signup/Renwal activity to completed on successful payment of pending membership
// 2. OR Create renewal activity scheduled if its membership renewal will be paid later
if (!empty($params['membership_activity_status']) && (!empty($activityParams['id']) || $activityType == 'Membership Renewal')) {
$params['join_date'] = trim($params['join_date']) ? date('Ymd', strtotime(trim($params['join_date']))) : 'null';
//fix for CRM-3570, during import exclude the statuses those having is_admin = 1
- $excludeIsAdmin = CRM_Utils_Array::value('exclude_is_admin', $params, FALSE);
+ $excludeIsAdmin = $params['exclude_is_admin'] ?? FALSE;
//CRM-3724 always skip is_admin if is_override != true.
if (!$excludeIsAdmin && empty($params['is_override'])) {
}
$calcStatus = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate($params['start_date'], $params['end_date'], $params['join_date'],
- 'today', $excludeIsAdmin, CRM_Utils_Array::value('membership_type_id', $params), $params
+ 'today', $excludeIsAdmin, $params['membership_type_id'] ?? NULL, $params
);
if (empty($calcStatus)) {
throw new CRM_Core_Exception(ts("The membership cannot be saved because the status cannot be calculated for start_date: {$params['start_date']} end_date {$params['end_date']} join_date {$params['join_date']} as at " . date('Y-m-d H:i:s')));
$transaction = new CRM_Core_Transaction();
- // @todo remove $ids from here $ids['userId'] is still used
- $params['id'] = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membership', $ids));
- if (empty($params['modified_id']) && !empty($ids['userID'])) {
- CRM_Core_Error::deprecatedFunctionWarning('$ids["userID"] no longer supported - use $params["modified_id"]');
- $params['modified_id'] = $ids['userID'];
- }
+ $params['id'] = $params['id'] ?? $ids['membership'] ?? NULL;
$membership = self::add($params);
if (is_a($membership, 'CRM_Core_Error')) {
if (!empty($params['contribution'])) {
$params['line_item'][$priceSetId][$lineIndex]['contribution_id'] = $params['contribution']->id;
}
- if ($lineMembershipType && $lineMembershipType == CRM_Utils_Array::value('membership_type_id', $params)) {
+ if ($lineMembershipType && $lineMembershipType == ($params['membership_type_id'] ?? NULL)) {
$params['line_item'][$priceSetId][$lineIndex]['entity_id'] = $membership->id;
$params['line_item'][$priceSetId][$lineIndex]['entity_table'] = 'civicrm_membership';
}
CRM_Price_BAO_LineItem::processPriceSet(
$membership->id,
$params['line_item'],
- CRM_Utils_Array::value('contribution', $params)
+ $params['contribution'] ?? NULL
);
}
'limit' => 0,
],
]);
- $memberTypesSameParentOrgList = implode(',', array_keys(CRM_Utils_Array::value('values', $memberTypesSameParentOrg, [])));
+ $memberTypesSameParentOrgList = implode(',', array_keys($memberTypesSameParentOrg['values'] ?? []));
$dao->whereAdd('membership_type_id IN (' . $memberTypesSameParentOrgList . ')');
}
}
}
$status = CRM_Member_BAO_MembershipStatus::getMembershipStatusByDate(
- CRM_Utils_Array::value('start_date', $currentMembership),
- CRM_Utils_Array::value('end_date', $currentMembership),
- CRM_Utils_Array::value('join_date', $currentMembership),
+ $currentMembership['start_date'] ?? NULL,
+ $currentMembership['end_date'] ?? NULL,
+ $currentMembership['join_date'] ?? NULL,
$today,
TRUE,
$currentMembership['membership_type_id'],
$format
),
'membership_type_id' => $currentMembership['membership_type_id'],
- 'max_related' => CRM_Utils_Array::value('max_related', $currentMembership, 0),
+ 'max_related' => $currentMembership['max_related'] ?? 0,
];
$session = CRM_Core_Session::singleton();
$relatedContacts = [];
$allRelatedContacts = CRM_Member_BAO_Membership::checkMembershipRelationship($membership->membership_type_id,
$membership->contact_id,
- CRM_Utils_Array::value('action', $params)
+ $params['action'] ?? NULL
);
// CRM-4213, CRM-19735 check for loops, using static variable to record contacts already processed.
) {
$params['status_id'] = $deceasedStatusId;
}
- elseif ((CRM_Utils_Array::value('action', $params) & CRM_Core_Action::UPDATE) &&
+ elseif ((($params['action'] ?? NULL) & CRM_Core_Action::UPDATE) &&
($relationshipStatus == CRM_Contact_BAO_Relationship::PAST)
) {
$params['status_id'] = $expiredStatusId;
// Insert renewed dates for CURRENT membership
$memParams = [];
$memParams['join_date'] = CRM_Utils_Date::isoToMysql($membership->join_date);
- $memParams['start_date'] = CRM_Utils_Array::value('start_date', $formDates, CRM_Utils_Date::isoToMysql($membership->start_date));
+ $memParams['start_date'] = $formDates['start_date'] ?? CRM_Utils_Date::isoToMysql($membership->start_date);
$memParams['end_date'] = $formDates['end_date'] ?? NULL;
if (empty($memParams['end_date'])) {
$memParams['end_date'] = $dates['end_date'] ?? NULL;
$contributionParams = [];
$config = CRM_Core_Config::singleton();
$contributionParams['currency'] = $config->defaultCurrency;
- $contributionParams['receipt_date'] = (CRM_Utils_Array::value('receipt_date', $params)) ? $params['receipt_date'] : 'null';
+ $contributionParams['receipt_date'] = !empty($params['receipt_date']) ? $params['receipt_date'] : 'null';
$contributionParams['source'] = $params['contribution_source'] ?? NULL;
$contributionParams['non_deductible_amount'] = 'null';
$contributionParams['skipCleanMoney'] = TRUE;
$form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE);
$form->add('text', 'pledge_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]);
- $form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money');
+ $form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('9.99')]), 'money');
$form->add('text', 'pledge_amount_high', ts('To'), ['size' => 8, 'maxlength' => 8]);
- $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money');
+ $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency('99.99')]), 'money');
$form->addYesNo('pledge_acknowledge_date_is_not_null', ts('Acknowledgement sent?'), TRUE);
}
if (!empty($contributionDetails->id)) {
$line['contribution_id'] = $contributionDetails->id;
- if ($line['entity_table'] == 'civicrm_contribution') {
+ if ($line['entity_table'] === 'civicrm_contribution') {
$line['entity_id'] = $contributionDetails->id;
}
- // CRM-19094: entity_table is set to civicrm_membership then ensure
- // the entityId is set to membership ID not contribution by default
- elseif ($line['entity_table'] == 'civicrm_membership' && !empty($line['entity_id']) && $line['entity_id'] == $contributionDetails->id) {
- $membershipId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $contributionDetails->id, 'membership_id', 'contribution_id');
- if ($membershipId && (int) $membershipId !== (int) $line['entity_id']) {
- $line['entity_id'] = $membershipId;
- Civi::log()->warning('Per https://lab.civicrm.org/dev/core/issues/15 this data fix should not be required. Please log a ticket at https://lab.civicrm.org/dev/core with steps to get this.', ['civi.tag' => 'deprecated']);
- }
- }
}
// if financial type is not set and if price field value is NOT NULL
*
* Generated from xml/schema/CRM/Price/PriceFieldValue.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:4ce556d152a07393048aa1bc0a0e3ed0)
+ * (GenCodeChecksum:a1acc613daec86c6049e545af5fc7fd1)
*/
/**
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid);
- $this->addElement('xbutton',
+ $this->addElement('button',
'done',
ts('Done'),
- [
- 'type' => 'button',
- 'onclick' => "location.href='$url'",
- ]
+ ['onclick' => "location.href='$url'"]
);
}
}
if ($this->_context == 'dialog') {
$this->addElement(
- 'xbutton',
+ 'submit',
$this->_duplicateButtonName,
- ts('Save Matching Contact'),
- [
- 'type' => 'submit',
- 'class' => 'crm-button',
- ]
+ ts('Save Matching Contact')
);
}
}
if (($this->_multiRecord & CRM_Core_Action::DELETE) && $this->_recordExists) {
$this->_deleteButtonName = $this->getButtonName('upload', 'delete');
- $this->addElement('xbutton', $this->_deleteButtonName, ts('Delete'), [
- 'type' => 'submit',
- 'value' => 1,
- 'class' => 'crm-button',
- ]);
+ $this->addElement('submit', $this->_deleteButtonName, ts('Delete'));
return;
}
if (!empty($this->_charts)) {
$this->addElement('select', "charts", ts('Chart'), $this->_charts);
$this->assign('charts', $this->_charts);
- $this->addElement('xbutton', $this->_chartButtonName, ts('View'), ['type' => 'submit']);
+ $this->addElement('submit', $this->_chartButtonName, ts('View'));
}
}
$this->assign('group', TRUE);
}
- $this->addElement('xbutton', $this->_groupButtonName, '', [
- 'type' => 'submit',
- 'style' => 'display: none;',
- ]);
+ $this->addElement('submit', $this->_groupButtonName, '', ['style' => 'display: none;']);
$this->addChartOptions();
$showResultsLabel = $this->getResultsLabel();
}
if ($last_primary && ($rowNum == "{$last_primary}_total")) {
- $value = CRM_Utils_Money::format($value, ' ');
+ $value = CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($value);
}
$row[$key] = '<strong>' . $value . '</strong>';
}
);
// Get the mailing groups.
- $groups = CRM_Core_PseudoConstant::nestedGroup('Mailing');
+ $groups = CRM_Core_PseudoConstant::nestedGroup(TRUE, 'Mailing');
// Get the sms mailing list.
$mailings = CRM_Mailing_PseudoConstant::completed('sms');
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
- $this->addElement('xbutton', 'done', ts('Done'),
- [
- 'type' => 'button',
- 'onclick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'",
- ]
+ $this->addElement('button', 'done', ts('Done'),
+ ['onclick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'"]
);
}
// views are implemented as frozen form
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
- $this->addElement('xbutton', 'done', ts('Done'), [
- 'type' => 'button',
- 'onclick' => "location.href='civicrm/admin/uf/group?reset=1&action=browse'",
- ]);
+ $this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/uf/group?reset=1&action=browse'"]);
}
$this->addFormRule(['CRM_UF_Form_Group', 'formRule'], $this);
* @param null $currentVer
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
- // Example: Generate a pre-upgrade message.
- // if ($rev == '5.12.34') {
- // $preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '</p>';
- // }
+ if ($rev == '5.29.beta1') {
+ if (CIVICRM_UF === 'Drupal8') {
+ $preUpgradeMessage .= '<p>' . ts('<em>Pre-announcement for upcoming version 5.30</em>: If your composer configuration or composer.json does not enable patching, you MUST do that BEFORE running composer to update your files to version 5.30. Either by using `composer config \'extra.enable-patching\' true`, or updating the top level composer.json\'s extra section with `"enable-patching": true`. See %1 for details.', [1 => '<a href="' . CRM_Utils_System::docURL2('installation/drupal8', TRUE) . '">Drupal 8 installation guide</a>']) . '</p>';
+ }
+ }
}
/**
$template = CRM_Core_Smarty::singleton();
list($currentVer, $latestVer) = $upgrade->getUpgradeVersions();
- if ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
+ // Show success msg if db already upgraded
+ if (version_compare($currentVer, $latestVer) == 0) {
+ $template->assign('upgraded', TRUE);
+ $template->assign('newVersion', $latestVer);
+ CRM_Utils_System::setTitle(ts('Your database has already been upgraded to CiviCRM %1',
+ [1 => $latestVer]
+ ));
+ $template->assign('pageTitle', ts('Your database has already been upgraded to CiviCRM %1',
+ [1 => $latestVer]
+ ));
+ }
+
+ // Throw error if db in unexpected condition
+ elseif ($error = $upgrade->checkUpgradeableVersion($currentVer, $latestVer)) {
throw new CRM_Core_Exception($error);
}
- $config = CRM_Core_Config::singleton();
+ else {
+ $config = CRM_Core_Config::singleton();
- // All cached content needs to be cleared because the civi codebase was just replaced
- CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
+ // All cached content needs to be cleared because the civi codebase was just replaced
+ CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode();
- // cleanup only the templates_c directory
- $config->cleanup(1, FALSE);
+ // cleanup only the templates_c directory
+ $config->cleanup(1, FALSE);
- $preUpgradeMessage = NULL;
- $upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
+ $preUpgradeMessage = NULL;
+ $upgrade->setPreUpgradeMessage($preUpgradeMessage, $currentVer, $latestVer);
- $template->assign('currentVersion', $currentVer);
- $template->assign('newVersion', $latestVer);
- $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2',
- [1 => $currentVer, 2 => $latestVer]
- ));
- $template->assign('upgraded', FALSE);
+ $template->assign('preUpgradeMessage', $preUpgradeMessage);
+ $template->assign('currentVersion', $currentVer);
+ $template->assign('newVersion', $latestVer);
+ $template->assign('upgradeTitle', ts('Upgrade CiviCRM from v %1 To v %2',
+ [1 => $currentVer, 2 => $latestVer]
+ ));
+ $template->assign('upgraded', FALSE);
+ }
// Render page header
if (!defined('CIVICRM_UF_HEAD') && $region = CRM_Core_Region::instance('html-header', FALSE)) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
- $template->assign('preUpgradeMessage', $preUpgradeMessage);
-
$content = $template->fetch('CRM/common/success.tpl');
echo CRM_Utils_System::theme($content, $this->_print, TRUE);
}
/**
* Checks if new versions are available
+ * @param bool $force
* @return CRM_Utils_Check_Message[]
+ * @throws CRM_Core_Exception
*/
- public function checkVersion() {
+ public function checkVersion($force = FALSE) {
$messages = [];
try {
$vc = new CRM_Utils_VersionCheck();
- $vc->initialize();
+ $vc->initialize($force);
}
catch (Exception $e) {
$messages[] = new CRM_Utils_Check_Message(
}
// Show a notice if the version_check job is disabled
- if (empty($vc->cronJob['is_active'])) {
+ if (!$force && empty($vc->cronJob['is_active'])) {
$args = empty($vc->cronJob['id']) ? ['reset' => 1] : ['reset' => 1, 'action' => 'update', 'id' => $vc->cronJob['id']];
$messages[] = new CRM_Utils_Check_Message(
'checkVersionDisabled',
*/
class CRM_Utils_SQL_TempTable {
+ /**
+ * @deprecated
+ * The system will attempt to use the same as your other tables, and
+ * if you really need something else then use createWithColumns and
+ * specify it per-column there.
+ */
const UTF8 = 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci';
+
const CATEGORY_LENGTH = 12;
const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;';
// MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37
/**
* Get the utf8 string for the table.
*
- * If the db collation is already utf8 by default (either
- * utf8 or utf84mb) then rely on that. Otherwise set to utf8.
- *
- * Respecting the DB collation supports utf8mb4 adopters, which is currently
- * not the norm in civi installs.
+ * Our tables are either utf8_unicode_ci OR utf8mb4_unicode_ci - check the contact table
+ * to see which & use the matching one. Or early adopters may have switched
+ * switched to other collations e.g. utf8mb4_0900_ai_ci (the default in mysql
+ * 8).
*
* @return string
*/
public function getUtf8String() {
- if (!$this->utf8) {
- return '';
- }
- $dbUTF = CRM_Core_BAO_SchemaHandler::getDBCollation();
- if (strpos($dbUTF, 'utf8') !== FALSE) {
- return '';
- }
- return self::UTF8;
+ return $this->utf8 ? ('COLLATE ' . CRM_Core_BAO_SchemaHandler::getInUseCollation()) : '';
}
/**
}
/**
+ * @deprecated
* @return bool
*/
public function isUtf8() {
+ CRM_Core_Error::deprecatedFunctionWarning('your own charset/collation per column with createWithColumns if you really need latin1');
return $this->utf8;
}
* @return $this
*/
public function setUtf8($value = TRUE) {
+ CRM_Core_Error::deprecatedFunctionWarning('your own charset/collation per column with createWithColumns if you really need latin1');
$this->utf8 = $value;
return $this;
}
* @return mixed
*/
public static function formatDocUrl($url) {
- return preg_replace('#^(user|sysadmin|dev)/#', '\1/en/latest/', $url);
+ return preg_replace('#^(installation|user|sysadmin|dev)/#', '\1/en/latest/', $url);
}
/**
if ($config->userFrameworkFrontend) {
global $post;
if (get_option('permalink_structure') != '') {
- $script = get_permalink($post->ID);
+ $script = $post ? get_permalink($post->ID) : "";
}
- if ($config->wpBasePage == $post->post_name) {
+ if ($post && $config->wpBasePage == $post->post_name) {
$basepage = TRUE;
}
// when shortcode is included in page
break;
case 'receive_date':
+ case 'receipt_date':
$value = CRM_Utils_Array::retrieveValueRecursive($contribution, $token);
- $value = CRM_Utils_Date::customFormat($value, NULL, ['j', 'm', 'Y']);
+ $config = CRM_Core_Config::singleton();
+ $value = CRM_Utils_Date::customFormat($value, $config->dateformatDatetime);
break;
default:
/**
* Self-populates version info
*
- * @throws \Exception
+ * @param bool $force
+ * @throws Exception
*/
- public function initialize() {
+ public function initialize($force = FALSE) {
$this->getJob();
// Populate remote $versionInfo from cache file
// Fallback if scheduled job is enabled but has failed to run.
$expiryTime = time() - self::CACHEFILE_EXPIRE;
- if (!empty($this->cronJob['is_active']) &&
+ if ($force || (!empty($this->cronJob['is_active']) &&
(!$this->isInfoAvailable || filemtime($this->cacheFile) < $expiryTime)
- ) {
+ )) {
// First try updating the files modification time, for 2 reasons:
// - if the file is not writeable, this saves the trouble of pinging back
// - if the remote server is down, this will prevent an immediate retry
cursor: pointer;
}
-#crm-container button.submit-link {
+#crm-container input.submit-link {
color: #285286;
background: none transparent;
border: none;
margin-left: .5em;
}
+.crm-container .crm-button input {
+ background: none;
+ border: medium none;
+ color: #FFF;
+ cursor: pointer;
+ font-size: 13px;
+ font-weight: normal;
+ margin: 0;
+ padding: 1px 8px 2px 4px;
+}
+
.crm-container .crm-button-type-cancel,
.crm-container .crm-button-type-back {
margin-left: 20px;
.crm-container a.button,
.crm-container a.button:link,
.crm-container a.button:visited,
+.crm-container input.crm-form-submit,
.crm-container .ui-dialog-buttonset .ui-button,
+.crm-container input[type=button],
.crm-container .crm-button {
text-shadow: 0 1px 0 black;
background: #696969;
text-decoration: none;
cursor: pointer;
border: 1px solid #3e3e3e;
+}
+
+.crm-container a.button,
+.crm-container a.button:link,
+.crm-container a.button:visited,
+.crm-container span.crm-button {
display: block;
float: left;
overflow: hidden;
line-height: 135%;
- border-radius: 3px;
+}
+
+/* Preserving the important but not sure why */
+.crm-container span.crm-button {
+ float: left !important;
+}
+
+.crm-container button.crm-button {
+ padding: 3px 6px;
+}
+
+.crm-container button.crm-button .icon {
+ margin-bottom: -4px;
+}
+
+.crm-container input.crm-form-submit,
+.crm-container input[type=button] {
+ padding: 2px 6px;
+}
+
+.crm-container .crm-button input[type=button],
+.crm-container .crm-button input.crm-form-submit {
+ padding: 0;
+ margin: 0;
+ background: none;
+ border: none;
}
.crm-container .crm-button:hover,
.crm-container .crm-button:focus,
+.crm-container input[type=submit]:hover,
+.crm-container input[type=button]:hover,
.crm-container .ui-dialog-buttonset .ui-button:hover,
.crm-container .ui-dialog-buttonset .ui-button:focus,
.crm-container a.button:hover,
.crm-container .crm-button-disabled,
.crm-container .crm-button.crm-button-disabled,
.crm-container .ui-dialog-buttonset .ui-button[disabled],
+.crm-container input.crm-form-submit[disabled],
+.crm-container input[type=button][disabled],
.crm-container .crm-button[disabled] {
opacity: .6;
cursor: default;
}
+.crm-container .crm-button-disabled input[disabled] {
+ opacity: 1;
+}
+
.crm-container .ui-dialog-buttonpane {
background: linear-gradient(to bottom, #f2f2f2 0%,#ffffff 35%);
}
+.crm-container .ui-dialog-buttonset .ui-button {
+ padding: 0;
+}
.crm-container .ui-dialog-buttonset .ui-button .ui-icon {
background-image: url("../i/icons/jquery-ui-FFFFFF.png");
}
-/* Override of a line in crm-i.css that may not be important anymore */
-.crm-container .ui-dialog-buttonset .ui-button .ui-icon[class*=" fa-"] {
- margin-top: 0;
-}
-
/* No crm-button styling for PayPal Express buttons */
.crm-container input#_qf_Register_upload_express,
.crm-container input#_qf_Payment_upload_express,
}
/* rounded corners */
+.crm-container .crm-button,
+.crm-container a.button,
+.crm-container a.button:link,
+.crm-container input.crm-form-submit,
+.crm-container input[type=button] {
+ border-radius: 3px;
+}
+
+
.crm-container div.status,
.crm-container #help,
.crm-container .help,
.crm-container input {
height: auto;
}
-.crm-container button[type=submit] {
+.crm-container input[type=submit] {
height: auto;
}
}
/* Remove Joomla subhead toolbar & whitespace border */
-
+
body.admin.com_civicrm .subhead-collapse {
display:none;
}
<?php } ?>
<p>
- <button id="install_button" type="submit" name="go" onclick="document.getElementById('saving_top').style.display = ''; this.innerHTML = '<?php echo ts('Installing CiviCRM...', ['escape' => 'js']); ?>'"><?php echo ts('Check Requirements and Install CiviCRM', ['escape' => 'js']); ?></button>
+ <input id="install_button" type="submit" name="go" value="<?php echo ts('Check Requirements and Install CiviCRM', array('escape' => 'js')); ?>" onclick="document.getElementById('saving_top').style.display = ''; this.value = '<?php echo ts('Installing CiviCRM...', array('escape' => 'js')); ?>'" />
<span id="saving_top" style="display: none">
?>
</select>
<noscript>
- <button type="submit" name="setlanguage"><?php echo ts('Change language', ['escape' => 'js']); ?></button>
+ <input type="submit" name="setlanguage" value="<?php echo ts('Change language', array('escape' => 'js')); ?>" />
</noscript>
<span class="testResults">
<?php
<span class="testResults">Check this box to pre-populate CiviCRM with sample English contact records, online contribution pages, profile forms, etc. These examples can help you learn about CiviCRM features.</span><br />
</p>
-<p style="margin-left: 2em"><button type="submit"><?php echo ts('Re-check requirements', ['escape' => 'js']); ?></button></p>
+<p style="margin-left: 2em"><input type="submit" value="<?php echo ts('Re-check requirements', array('escape' => 'js')); ?>" /></p>
<a name="dbDetails">
}
var submitcount = 0;
+/**
+ * Old submit-once function. Will be removed soon.
+ * @deprecated
+ */
+function submitOnce(obj, formId, procText) {
+ // if named button clicked, change text
+ if (obj.value != null) {
+ cj('input[name=' + obj.name + ']').val(procText + " ...");
+ }
+ cj(obj).closest('form').attr('data-warn-changes', 'false');
+ if (document.getElementById) { // disable submit button for newer browsers
+ cj('input[name=' + obj.name + ']').attr("disabled", true);
+ document.getElementById(formId).submit();
+ return true;
+ }
+ else { // for older browsers
+ if (submitcount == 0) {
+ submitcount++;
+ return true;
+ }
+ else {
+ alert("Your request is currently being processed ... Please wait.");
+ return false;
+ }
+ }
+}
/**
* Function to show / hide the row in optionFields
$.propHooks.disabled = {
set: function (el, value, name) {
// Sync button enabled status with wrapper css
- if ($(el).is('.crm-button.crm-form-submit')) {
+ if ($(el).is('span.crm-button > input.crm-form-submit')) {
$(el).parent().toggleClass('crm-button-disabled', !!value);
}
// Sync button enabled status with dialog button
$('form[data-submit-once]', e.target)
.submit(submitOnceForm)
.on('invalid-form', submitFormInvalid);
- $('form[data-submit-once] button[type=submit]', e.target).click(function(e) {
+ $('form[data-submit-once] input[type=submit]', e.target).click(function(e) {
submitButton = e.target;
});
})
var buttonContainers = '.crm-submit-buttons, .action-link',
buttons = [],
added = [];
- $(buttonContainers, $el).find('.crm-form-submit, .crm-form-xbutton, a.button, button').each(function() {
+ $(buttonContainers, $el).find('input.crm-form-submit, a.button, button').each(function() {
var $el = $(this),
label = $el.is('input') ? $el.attr('value') : $el.text(),
identifier = $el.attr('name') || $el.attr('href');
$el.dialog('option', 'buttons', buttons);
}
// Allow a button to prevent ajax submit
- $('input[data-no-ajax-submit=true], button[data-no-ajax-submit=true]').click(function() {
+ $('input[data-no-ajax-submit=true]').click(function() {
$(this).closest('form').ajaxFormUnbind();
});
// For convenience, focus the first field
// When selecting a task
.on('change', 'select#task', function(e) {
var $form = $(this).closest('form'),
- $go = $('button.crm-search-go-button', $form);
+ $go = $('input.crm-search-go-button', $form);
var $selectedOption = $(this).find(':selected');
if (!$selectedOption.val()) {
// do not blank refresh the empty option.
html += '<form class="widget-settings">';
html += ' <div class="widget-settings-inner"></div>';
html += ' <div class="widget-settings-buttons">';
- html += ' <button id="' + widget.id + '-settings-save" class="widget-settings-save" type="submit">Save</button>';
- html += ' <button id="' + widget.id + '-settings-cancel" class="widget-settings-cancel" type="submit">Cancel</button>';
+ html += ' <input id="' + widget.id + '-settings-save" class="widget-settings-save" value="Save" type="submit" />';
+ html += ' <input id="' + widget.id + '-settings-cancel" class="widget-settings-cancel" value="Cancel" type="submit" />';
html += ' </div>';
html += '</form>';
return html;
<div>
<input type="text" name="civisetup[advanced][db]" value="<?php echo htmlentities($model->extras['advanced']['db']); ?>" data-original="<?php echo htmlentities($model->extras['advanced']['db']); ?>">
- <button id="db_apply_button" type="submit" name="civisetup[action][Start]"><?php echo htmlentities(ts('Apply')); ?></button>
+ <input id="db_apply_button" type="submit" name="civisetup[action][Start]" value="<?php echo htmlentities(ts('Apply')); ?>" />
<a href="" onclick="civisetupAdvancedDbCancel(); return false;" title="<?php echo htmlentities(ts('Cancel')) ?>"><i class="fa fa-close"></i></a>
<script type="text/javascript">
function civisetupAdvancedDbCancel() {
<?php if (!defined('CIVI_SETUP')): exit("Installation plugins must only be loaded by the installer.\n");
endif; ?>
<div class="action-box">
- <button id="install_button" type="submit" name="civisetup[action][Install]"
- onclick="document.getElementById('saving_top').style.display = ''; this.innerHTML = '<?php echo ts('Installing CiviCRM...', array('escape' => 'js')); ?>'"><?php echo htmlentities(ts('Install CiviCRM')); ?></button>
+ <input id="install_button" type="submit" name="civisetup[action][Install]"
+ value="<?php echo htmlentities(ts('Install CiviCRM')); ?>"
+ onclick="document.getElementById('saving_top').style.display = ''; this.value = '<?php echo ts('Installing CiviCRM...', array('escape' => 'js')); ?>'"/>
<div id="saving_top" style="display: none;">
<img src="<?php echo htmlentities($installURLPath . "network-save.gif") ?>"/>
<?php echo ts('(this will take a few minutes)'); ?>
</table>
<div class="action-box">
- <button id="recheck_button" type="submit" name="civisetup[action][Start]"><?php echo htmlentities(ts('Refresh')); ?></button>
+ <input id="recheck_button" type="submit" name="civisetup[action][Start]" value="<?php echo htmlentities(ts('Refresh')); ?>" />
<div class="advancedTip">
<?php echo ts('After updating your system, refresh to test the requirements again.'); ?>
</div>
float: left;
margin-left: 10%;
margin-top: 50px;
- margin-right: 20%;
+ margin-right: 20%;
display: inline-flex;
}
100% { left: 0; color: #555;}
}
-
+
.civicrm-setup-header hr{
border-bottom: 2px solid #fff;
border-top: 2px solid #ddd;
text-align: center;
margin: 2em 0.5em;
}
-.civicrm-setup-body button[type=submit] {
+.civicrm-setup-body input[type=submit] {
padding:15px 25px;
background:#82C459;
color: white;
border-radius: 5px;
font-size: 20px;
}
-.civicrm-setup-body button[type=submit]:hover {
+.civicrm-setup-body input[type=submit]:hover {
background: #60A237;
}
-.civicrm-setup-body button[type=submit]:disabled {
+.civicrm-setup-body input[type=submit]:disabled {
background: #888;
cursor: not-allowed;
}
width: 95%;
}
}
+
*
* @param array $fields
* HTTP inputs -- e.g. with a form element like this:
- * `<button type="submit" name="civisetup[action][Foo]">Do the foo</button>`
+ * `<input type="submit" name="civisetup[action][Foo]" value="Do the foo">`
* @param string $default
* The action-name to return if no other action is identified.
* @return string
<td>
{$form.editor_id.html}
- {$form.ckeditor_config.html}
+ <span class="crm-button" style="display:inline-block;vertical-align:middle;float:none!important;">
+ <i class="crm-i fa-wrench" aria-hidden="true"></i>
+ {$form.ckeditor_config.html}
+ </span>
</td>
</tr>
<tr class="crm-preferences-display-form-block-ajaxPopupsEnabled">
</table>
</div>
<div class="crm-submit-buttons">
- <button type="submit" class="crm-button crm-form-submit" accesskey="S" title="{ts}Execute API call and display results{/ts}">
- <i class="crm-i fa-bolt" aria-hidden="true"></i> {ts}Execute{/ts}
- </button>
+ <span class="crm-button">
+ <i class="crm-i fa-bolt" aria-hidden="true"></i> <input type="submit" value="{ts}Execute{/ts}" class="crm-form-submit" accesskey="S" title="{ts}Execute API call and display results{/ts}"/>
+ </span>
</div>
<pre id="api-result" class="linenums">
</div>
<div class="crm-submit-buttons">
- <button type="submit" name="save" class="crm-form-submit crm-button" accesskey="S">
- <i class="crm-i fa-wrench" aria-hidden="true"></i> {ts}Save{/ts}
- </button>
- <button type="submit" name="revert" class="crm-form-submit crm-button" onclick="return confirm('{$revertConfirm}');">
- <i class="crm-i fa-times" aria-hidden="true"></i> {ts}Revert to Default{/ts}
- </button>
+ <span class="crm-button">
+ <i class="crm-i fa-wrench" aria-hidden="true"></i> <input type="submit" value="{ts}Save{/ts}" name="save" class="crm-form-submit" accesskey="S"/>
+ </span>
+ <span class="crm-button">
+ <i class="crm-i fa-times" aria-hidden="true"></i> <input type="submit" value="{ts}Revert to Default{/ts}" name="revert" class="crm-form-submit" onclick="return confirm('{$revertConfirm}');"/>
+ </span>
</div>
<input type="hidden" value="{$preset}" name="preset" />
</fieldset>
<div class="status message status-warning">
<i class="crm-i fa-exclamation-triangle" aria-hidden="true"></i> {ts}Total for amounts entered below does not match the expected batch total.{/ts}
</div>
- {$form._qf_Entry_upload_force.html}
+ <span class="crm-button crm-button_qf_Entry_upload_force-save">
+ {$form._qf_Entry_upload_force.html}
+ </span>
<div class="clear"></div>
{/if}
<table class="form-layout-compressed batch-totals">
<input type="hidden" name="qfKey" value="{crmKey name='CRM_Contact_Form_Contact' addSequence=1}" />
</div>
-<div class="form-item"><button type="submit" name="_qf_Contact_next" class="crm-button crm-form-submit">{ts}Save{/ts}</button></div>
+<div class="form-item"><input type="submit" name="_qf_Contact_next" value="{ts}Save{/ts}" class="crm-form-submit" /></div>
</form>
</div>
<div class="block-crm crm-container">
<form method="post" id="id_fulltext_search">
<div style="margin-bottom: 8px;">
- <input type="text" name="text" id='text' value="" class="crm-form-text" style="width: 10em;" /> <button type="submit" name="submit" id="fulltext_submit" class="crm-button crm-form-submit" onclick='submitForm();'>{ts}Go{/ts}</button>
+ <input type="text" name="text" id='text' value="" class="crm-form-text" style="width: 10em;" /> <input type="submit" name="submit" id="fulltext_submit" value="{ts}Go{/ts}" class="crm-form-submit"/ onclick='submitForm();'>
<input type="hidden" name="qfKey" value="{crmKey name='CRM_Contact_Controller_Search' addSequence=1}" />
</div>
<select class="form-select" id="fulltext_table" name="fulltext_table">
</table>
{*add dupe buttons *}
- {$form._qf_Contact_refresh_dedupe.html}
+ <span class="crm-button crm-button_qf_Contact_refresh_dedupe">
+ {$form._qf_Contact_refresh_dedupe.html}
+ </span>
{if $isDuplicate}
- {$form._qf_Contact_upload_duplicate.html}
+ <span class="crm-button crm-button_qf_Contact_upload_duplicate">
+ {$form._qf_Contact_upload_duplicate.html}
+ </span>
{/if}
<div class="spacer"></div>
</div>
loadMultiRecordFields();
{/literal}{if $oldSubtypes}{literal}
- $('button[name=_qf_Contact_upload_view], button[name=_qf_Contact_upload_new]').click(function() {
+ $('input[name=_qf_Contact_upload_view], input[name=_qf_Contact_upload_new]').click(function() {
var submittedSubtypes = $('#contact_sub_type').val();
var oldSubtypes = {/literal}{$oldSubtypes}{literal};
})
// Add new field - if there's a hidden one, show it
// Otherwise allow form to submit and fetch more from the server
- .on('click', 'button[name^=addMore]', function() {
+ .on('click', 'input[name^=addMore]', function() {
var table = $(this).closest('table');
if ($('tr:hidden', table).length) {
$('tr:hidden', table).first().show();
{/literal}
<form action="{crmURL p='civicrm/contact/view' q="cid=`$contactId`&reset=1"}" method="post" id="Print1" >
<div class="form-item">
- <span class="element-right"><button onclick="window.print(); return false" class="crm-button crm-form-submit default" name="_qf_Print_next" type="submit">{ts}Print{/ts}</button> <button class="crm-button crm-form-submit" name="_qf_Print_back" type="submit">{ts}Done{/ts}</button></span>
+ <span class="element-right"><input onclick="window.print(); return false" class="crm-form-submit default" name="_qf_Print_next" value="{ts}Print{/ts}" type="submit" /> <input class="crm-form-submit" name="_qf_Print_back" value="{ts}Done{/ts}" type="submit" /></span>
</div>
</form>
<br />
<div class="premium-full-title">{$row.name}</div>
<div class="premium-full-disabled">
{ts 1=$row.min_contribution|crmMoney}You must contribute at least %1 to get this item{/ts}<br/>
- <button type="button" value="{ts 1=$row.min_contribution|crmMoney}Contribute %1 Instead{/ts}" amount="{$row.min_contribution}" />
+ <input type="button" value="{ts 1=$row.min_contribution|crmMoney}Contribute %1 Instead{/ts}" amount="{$row.min_contribution}" />
</div>
<div class="premium-full-description">
{$row.description}
amounts.sort(function(a,b){return a - b});
// make contribution instead buttons work
- $('.premium-full-disabled button').click(function(){
+ $('.premium-full-disabled input').click(function(){
var amount = Number($(this).attr('amount'));
if (price_sets[amount]) {
if (!$(price_sets[amount]).length) {
{/literal}
{/if}
{/if}
+
{foreach from=$paymentFields item=paymentField}
{assign var='name' value=$form.$paymentField.name}
<div class="crm-section {$form.$paymentField.name}-section">
- <div class="label">{$form.$paymentField.label}</div>
+ <div class="label">{$form.$paymentField.label}
+ {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
+ </div>
<div class="content">
{$form.$paymentField.html}
{if $paymentFieldsMetadata.$name.description}
{foreach from=$billingDetailsFields item=billingField}
{assign var='name' value=$form.$billingField.name}
<div class="crm-section {$form.$billingField.name}-section">
- <div class="label">{$form.$billingField.label}</div>
+ <div class="label">{$form.$billingField.label}
+ {if $requiredPaymentFields.$name}<span class="crm-marker" title="{ts}This field is required.{/ts}">*</span>{/if}
+ </div>
{if $form.$billingField.type == 'text'}
<div class="content">{$form.$billingField.html}</div>
{else}
<script type="text/javascript">
{literal} (function($, _) { // Generic Closure
- $(".crm-submit-buttons button").click( function() {
+ $(".crm-submit-buttons input").click( function() {
$(".dedupenotify .ui-notify-close").click();
});
<script type="text/javascript">
var totalPages = {/literal}{$pager->_totalPages}{literal};
CRM.$(function($) {
- $("#crm-container .crm-pager button.crm-form-submit").click(function () {
+ $("#crm-container .crm-pager input.crm-form-submit").click(function () {
submitPagerData(this);
});
});
{ts 1=$display_name 2=$email}Are you sure you want to resubscribe: %1 (%2){/ts}
<br/>
<center>
-<button type="submit" name="_qf_resubscribe_next" class="crm-button crm-form-submit">{ts}Resubscribe{/ts}</button>
+<input type="submit" name="_qf_resubscribe_next" value="{ts}Resubscribe{/ts}" class="crm-form-submit" />
-<button type="submit" name="_qf_resubscribe_cancel" class="crm-button crm-form-submit">{ts}Cancel{/ts}</button>
+<input type="submit" name="_qf_resubscribe_cancel" value="{ts}Cancel{/ts}" class="crm-form-submit" />
</center>
</form>
</div>
</div>
<div class="crm-submit-buttons">
- {$form._qf_Edit_upload_delete.html}
+ <span class="crm-button">{$form._qf_Edit_upload_delete.html}</span>
{if $includeCancelButton}
<a class="button cancel" href="{$cancelURL}">{$cancelButtonText}</a>
{/if}
{if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) }
<div class="crm-submit-buttons">
- {$form._qf_Edit_upload_duplicate.html}
+ <span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>
</div>
{/if}
{if $mode eq 1 || $activeComponent neq "CiviCRM"}
{if $action eq 2 and $multiRecordFieldListing}
<h1>{ts}Edit Details{/ts}</h1>
<div class="crm-submit-buttons" style='float:right'>
- {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}{$form._qf_Edit_upload_duplicate.html}{/if}
+ {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
</div>
{/if}
</div>
{/if}
<div class="crm-submit-buttons" style='{$floatStyle}'>
- {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}{$form._qf_Edit_upload_duplicate.html}{/if}
+ {include file="CRM/common/formButtons.tpl"}{if $isDuplicate}<span class="crm-button">{$form._qf_Edit_upload_duplicate.html}</span>{/if}
{if $includeCancelButton}
<a class="button cancel" href="{$cancelURL}">
<span>
createChart( chartID, divName, chartValues.size.xSize, chartValues.size.ySize, allData[chartID].object );
});
- // FIXME
$("input[id$='submit_print'],input[id$='submit_pdf']").bind('click', function(e){
// image creator php file path and append image name
var url = CRM.url('civicrm/report/chart', 'name=' + '{/literal}{$chartId}{literal}' + '.png');
params.autoClose = params.openInline = params.cancelButton = params.refreshAction = false;
ui.panel.on('crmFormLoad', function() {
// Hack: "Save and done" and "Cancel" buttons submit without ajax
- $('.cancel.crm-form-submit, button[name$=upload_done]', this).on('click', function(e) {
+ $('.cancel.crm-form-submit, input[name$=upload_done]', this).on('click', function(e) {
$(this).closest('form').ajaxFormUnbind();
});
});
* If any of these contain a single quote or backslash, escape those characters with a backslash: \' and \\, respectively.
*
* Datasource (DSN) format:
- * define( 'CIVICRM_UF_DSN', 'mysqli://cms_db_username:cms_db_password@db_server/cms_database?new_link=true');
+ * define( 'CIVICRM_UF_DSN', 'mysql://cms_db_username:cms_db_password@db_server/cms_database?new_link=true');
*/
if (!defined('CIVICRM_UF_DSN') && CIVICRM_UF !== 'UnitTests') {
- define( 'CIVICRM_UF_DSN' , 'mysqli://%%CMSdbUser%%:%%CMSdbPass%%@%%CMSdbHost%%/%%CMSdbName%%?new_link=true');
+ define( 'CIVICRM_UF_DSN' , 'mysql://%%CMSdbUser%%:%%CMSdbPass%%@%%CMSdbHost%%/%%CMSdbName%%?new_link=true');
}
// %%extraSettings%%
*
* Database URL (CIVICRM_DSN) for CiviCRM Data:
* Database URL format:
- * define( 'CIVICRM_DSN', 'mysqli://crm_db_username:crm_db_password@db_server/crm_database?new_link=true');
+ * define( 'CIVICRM_DSN', 'mysql://crm_db_username:crm_db_password@db_server/crm_database?new_link=true');
*
* Drupal and CiviCRM can share the same database, or can be installed into separate databases.
* Backdrop CMS and CiviCRM can also share the same database, or can be installed into separate databases.
*
* EXAMPLE: Drupal/Backdrop and CiviCRM running in the same database...
* DB Name = cms, DB User = cms
- * define( 'CIVICRM_DSN' , 'mysqli://cms:YOUR_PASSWORD@localhost/cms?new_link=true');
+ * define( 'CIVICRM_DSN' , 'mysql://cms:YOUR_PASSWORD@localhost/cms?new_link=true');
*
* EXAMPLE: Drupal/Backdrop and CiviCRM running in separate databases...
* CMS DB Name = cms, DB User = cms
* CiviCRM DB Name = civicrm, CiviCRM DB User = civicrm
- * define( 'CIVICRM_DSN' , 'mysqli://civicrm:YOUR_PASSWORD@localhost/civicrm?new_link=true');
+ * define( 'CIVICRM_DSN' , 'mysql://civicrm:YOUR_PASSWORD@localhost/civicrm?new_link=true');
*
* If your username, password, server or DB name contain a single quote or backslash, escape those characters
* with a backslash: \' and \\, respectively.
define('CIVICRM_DSN', $GLOBALS['_CV']['TEST_DB_DSN']);
}
else {
- define('CIVICRM_DSN', 'mysqli://%%dbUser%%:%%dbPass%%@%%dbHost%%/%%dbName%%?new_link=true');
+ define('CIVICRM_DSN', 'mysql://%%dbUser%%:%%dbPass%%@%%dbHost%%/%%dbName%%?new_link=true');
}
}
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var more = $('.crm-button.validate').click(function(e) {
+ var more = $('.crm-button input.validate').click(function(e) {
var message = "{/literal} {if $context eq 'Event'}
{ts escape='js'}Note: Revenue for this event registration will not be deferred as the financial type does not have a deferred revenue account setup for it. If you want the revenue to be deferred, please select a different Financial Type with a Deferred Revenue account setup for it, or setup a Deferred Revenue account for this Financial Type.{/ts}
{else if $context eq 'MembershipType'}
{/foreach}
{/if}
+{* Loops through $form.buttons.html array and assigns separate spans with classes to allow theming by button and name.
+ * crmBtnType grabs type keyword from button name (e.g. 'upload', 'next', 'back', 'cancel') so types of buttons can be styled differently via css.
+ *}
{foreach from=$form.buttons item=button key=key name=btns}
{if $key|substring:0:4 EQ '_qf_'}
{if $location}
- {$form.buttons.$key.html|crmReplace:id:"$key-$location"}
+ {assign var='html' value=$form.buttons.$key.html|crmReplace:id:"$key-$location"}
{else}
- {$form.buttons.$key.html}
+ {assign var='html' value=$form.buttons.$key.html}
{/if}
+ {crmGetAttribute html=$html attr='crm-icon' assign='icon'}
+ {capture assign=iconPrefix}{$icon|truncate:3:"":true}{/capture}
+ {if $icon && $iconPrefix eq 'fa-'}
+ {capture assign=iconDisp}<i class="crm-i {$icon}" aria-hidden="true"></i>{/capture}
+ {/if}
+ {crmGetAttribute html=$html attr='disabled' assign='disabled'}
+ <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}{if $disabled} crm-button-disabled{/if}"{if $buttonStyle} style="{$buttonStyle}"{/if}>
+ {$iconDisp}
+ {$html}
+ </span>
{/if}
{/foreach}
{/crmRegion}
<input type="hidden" name="hidden_location" value="1" />
<input type="hidden" name="hidden_custom" value="1" />
<input type="hidden" name="qfKey" value="" />
- <div style="height:1px; overflow:hidden;"><button type="submit" name="_qf_Advanced_refresh" class="crm-button crm-form-submit default">{ts}Go{/ts}</button></div>
+ <div style="height:1px; overflow:hidden;"><input type="submit" value="{ts}Go{/ts}" name="_qf_Advanced_refresh" class="crm-form-submit default" /></div>
</div>
</form>
<ul>
$this->assertEquals("Contribution Amount: $ 100.00", $contributionDetails[$contactId1]['text'], "The text does not match");
$this->assertEquals("<p>Contribution Source: ABC</p></br>
<p>Contribution Invoice ID: 12345</p></br>
- <p>Contribution Receive Date: May 11th, 2015</p></br>
+ <p>Contribution Receive Date: May 11th, 2015 12:00 AM</p></br>
<p>Contribution Custom Field: Label2</p></br>", $contributionDetails[$contactId2]['html'], "The html does not match");
}
unset($_REQUEST['id']);
}
+ /**
+ * Mostly just check there's no errors opening the Widget tab on contribution
+ * pages.
+ */
+ public function testOpeningWidgetAdminPage() {
+ $page_id = $this->callAPISuccess('ContributionPage', 'create', [
+ 'title' => 'my page',
+ 'financial_type_id' => $this->_financialTypeId,
+ 'payment_processor' => $this->paymentProcessorID,
+ ])['id'];
+
+ $form = new CRM_Contribute_Form_ContributionPage_Widget();
+ $form->controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_ContributionPage_Widget', 'Widget');
+
+ $form->set('reset', '1');
+ $form->set('action', 'update');
+ $form->set('id', $page_id);
+
+ ob_start();
+ $form->controller->_actions['display']->perform($form, 'display');
+ $contents = ob_get_contents();
+ ob_end_clean();
+
+ // The page contents load later by ajax, so there's just the surrounding
+ // html available now, but we can check at least one thing while we're here.
+ $this->assertStringContainsString("selectedTab = 'widget';", $contents);
+ }
+
}
$orderID = $this->callAPISuccess('Order', 'create', [
'total_amount' => '200',
'financial_type_id' => 'Donation',
- 'contribution_status_id' => 'Pending',
'contact_id' => $this->_contactID,
'contribution_page_id' => $this->_contributionPageID,
'payment_processor_id' => $this->_paymentProcessorID,
$this->ids['Contribution'][0] = $orderID;
}
+ /**
+ * Create an order with more than one membership.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function createMultipleMembershipOrder() {
+ $this->createExtraneousContribution();
+ $this->ids['contact'][0] = $this->individualCreate();
+ $this->ids['contact'][1] = $this->individualCreate();
+ $this->ids['membership_type'][0] = $this->membershipTypeCreate();
+ $this->ids['membership_type'][1] = $this->membershipTypeCreate(['name' => 'Type 2']);
+ $priceFieldID = $this->callAPISuccessGetValue('price_field', [
+ 'return' => 'id',
+ 'label' => 'Membership Amount',
+ 'options' => ['limit' => 1, 'sort' => 'id DESC'],
+ ]);
+ $generalPriceFieldValueID = $this->callAPISuccessGetValue('price_field_value', [
+ 'return' => 'id',
+ 'label' => 'General',
+ 'options' => ['limit' => 1, 'sort' => 'id DESC'],
+ ]);
+
+ $orderID = $this->callAPISuccess('Order', 'create', [
+ 'total_amount' => 400,
+ 'financial_type_id' => 'Member Dues',
+ 'contact_id' => $this->_contactID,
+ 'is_test' => 0,
+ 'payment_instrument_id' => 'Check',
+ 'receive_date' => '2019-07-25 07:34:23',
+ 'line_items' => [
+ [
+ 'params' => [
+ 'contact_id' => $this->ids['contact'][0],
+ 'membership_type_id' => $this->ids['membership_type'][0],
+ 'source' => 'Payment',
+ ],
+ 'line_item' => [
+ [
+ 'label' => 'General',
+ 'qty' => 1,
+ 'unit_price' => 200,
+ 'line_total' => 200,
+ 'financial_type_id' => 1,
+ 'entity_table' => 'civicrm_membership',
+ 'price_field_id' => $priceFieldID,
+ 'price_field_value_id' => $generalPriceFieldValueID,
+ ],
+ ],
+ ],
+ [
+ 'params' => [
+ 'contact_id' => $this->ids['contact'][1],
+ 'membership_type_id' => $this->ids['membership_type'][0],
+ 'source' => 'Payment',
+ ],
+ 'line_item' => [
+ [
+ 'label' => 'General',
+ 'qty' => 1,
+ 'unit_price' => 200,
+ 'line_total' => 200,
+ 'financial_type_id' => 1,
+ 'entity_table' => 'civicrm_membership',
+ 'price_field_id' => $priceFieldID,
+ 'price_field_value_id' => $generalPriceFieldValueID,
+ ],
+ ],
+ ],
+ ],
+ ])['id'];
+
+ $this->ids['Contribution'][0] = $orderID;
+ }
+
/**
* Create an extraneous contribution to throw off any 'number one bugs'.
*
* @group headless
*/
class api_v3_MembershipTest extends CiviUnitTestCase {
- protected $_apiversion;
+
+ use CRMTraits_Financial_OrderTrait;
+
protected $_contactID;
protected $_membershipID;
protected $_membershipID2;
*/
public function setUp() {
parent::setUp();
- $this->_apiversion = 3;
$this->_contactID = $this->individualCreate();
$this->_membershipTypeID = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID]);
$this->_membershipTypeID2 = $this->membershipTypeCreate([
* @throws \Exception
*/
public function hook_civicrm_pre_update_create_membership($op, $objectName, $id, &$params) {
- if ($objectName == 'Membership' && $op == 'edit') {
+ if ($objectName === 'Membership' && $op === 'edit') {
$existingMembership = $this->callAPISuccessGetSingle('membership', ['id' => $params['id']]);
unset($params['id'], $params['membership_id']);
$params['join_date'] = $params['membership_start_date'] = $params['start_date'] = date('Ymd000000', strtotime($existingMembership['start_date']));
}
+ /**
+ * Test that a contribution linked to multiple memberships results in all being updated.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testMultipleMembershipContribution() {
+ $this->createMultipleMembershipOrder();
+ $this->callAPISuccess('Payment', 'create', [
+ 'contribution_id' => $this->ids['Contribution'][0],
+ 'payment_instrument_id' => 'Check',
+ 'total_amount' => 400,
+ ]);
+ $memberships = $this->callAPISuccess('membership', 'get')['values'];
+ $this->assertCount(2, $memberships);
+ }
+
/**
* Test that all membership types are returned when getoptions is called.
*
*/
class api_v3_MembershipTypeTest extends CiviUnitTestCase {
protected $_contactID;
- protected $_contributionTypeID;
protected $_entity = 'MembershipType';
/**
* Get the membership without providing an ID.
*
* This should return an empty array but not an error.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetWithoutId($version) {
$this->_apiversion = $version;
/**
* Test get works.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
*/
public function testGet($version) {
$this->_apiversion = $version;
$id = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID]);
-
- $params = [
- 'id' => $id,
- ];
+ $params = ['id' => $id];
$membershipType = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__);
$this->assertEquals($membershipType['values'][$id]['name'], 'General');
$this->assertEquals($membershipType['values'][$id]['member_of_contact_id'], $this->_contactID);
/**
* Test create with missing mandatory field.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
*/
public function testCreateWithoutMemberOfContactId($version) {
$this->_apiversion = $version;
/**
* Test successful create.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
*/
public function testCreate($version) {
$this->_apiversion = $version;
/**
* Domain ID can be intuited..
* DomainID is now optional on API, check that it gets set correctly and that the domain_id is not overwritten when not specified in create.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCreateWithoutDomainId($version) {
$this->_apiversion = $version;
/**
* CRM-20010 Tests period_type is required for MemberType create
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
*/
public function testMemberTypePeriodiTypeRequired($version) {
$this->_apiversion = $version;
$this->callAPIFailure('MembershipType', 'create', [
- 'domain_id' => "Default Domain Name",
+ 'domain_id' => 'Default Domain Name',
'member_of_contact_id' => 1,
- 'financial_type_id' => "Member Dues",
- 'duration_unit' => "month",
+ 'financial_type_id' => 'Member Dues',
+ 'duration_unit' => 'month',
'duration_interval' => 1,
- 'name' => "Standard Member",
+ 'name' => 'Standard Member',
'minimum_fee' => 100,
]);
}
/**
* Test update.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
+ *
+ * @throws \CRM_Core_Exception
*/
public function testUpdate($version) {
$this->_apiversion = $version;
/**
* Test successful delete.
+ *
* @dataProvider versionThreeAndFour
+ *
+ * @param bool $version
*/
public function testDelete($version) {
$this->_apiversion = $version;
$membershipTypeID = $this->membershipTypeCreate(['member_of_contact_id' => $this->organizationCreate()]);
- $params = [
- 'id' => $membershipTypeID,
- ];
-
+ $params = ['id' => $membershipTypeID];
$this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
}
$memType = [];
$memType[1] = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID, 'minimum_fee' => 100]);
$priceSet = $this->callAPISuccess('price_set', 'create', [
- 'title' => "test priceset",
- 'name' => "test_priceset",
- 'extends' => "CiviMember",
+ 'title' => 'test priceset',
+ 'name' => 'test_priceset',
+ 'extends' => 'CiviMember',
'is_quick_config' => 1,
- 'financial_type_id' => "Member Dues",
+ 'financial_type_id' => 'Member Dues',
]);
$priceSet = $priceSet['id'];
$field = $this->callAPISuccess('price_field', 'create', [
]);
//Verify if membership type updates are copied to pricefield value.
foreach ($priceFieldValue['values'] as $key => $value) {
- $setId = $this->callAPISuccessGetValue('PriceField', ['return' => "price_set_id", 'id' => $value['price_field_id']]);
+ $setId = $this->callAPISuccessGetValue('PriceField', ['return' => 'price_set_id', 'id' => $value['price_field_id']]);
if ($setId == $priceSet) {
$this->assertEquals($value['label'], $updateParams['name']);
$this->assertEquals($value['description'], $updateParams['description']);
$this->assertEquals(2, $rows['count'], 'Report failed - the sql used to generate the results was ' . print_r($rows['metadata']['sql'], TRUE));
- $expected = preg_replace('/\s+/', ' ', 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
+ $expected = preg_replace('/\s+/', ' ', 'COLLATE utf8_unicode_ci AS
SELECT SQL_CALC_FOUND_ROWS contact_civireport.id as cid FROM civicrm_contact contact_civireport INNER JOIN civicrm_contribution contribution_civireport USE index (received_date) ON contribution_civireport.contact_id = contact_civireport.id
AND contribution_civireport.is_test = 0
AND contribution_civireport.receive_date BETWEEN \'20140701000000\' AND \'20150630235959\'