Skip to content

Commit

Permalink
Merge pull request #21274 from mattwire/contributionviewid
Browse files Browse the repository at this point in the history
REF Don't check if id is set in ContributionView form - it's required
  • Loading branch information
seamuslee001 authored Aug 27, 2021
2 parents e47f64b + b2095b9 commit 75f7801
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions CRM/Contribute/Form/ContributionView.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
*/
public function preProcess() {
$id = $this->get('id');
if (empty($id)) {
throw new CRM_Core_Exception('Contribution ID is required');
}
$params = ['id' => $id];
$context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
$this->assign('context', $context);
Expand Down Expand Up @@ -96,13 +99,11 @@ public function preProcess() {
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $id);

$premiumId = NULL;
if ($id) {
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}
$dao = new CRM_Contribute_DAO_ContributionProduct();
$dao->contribution_id = $id;
if ($dao->find(TRUE)) {
$premiumId = $dao->id;
$productID = $dao->product_id;
}

if ($premiumId) {
Expand Down Expand Up @@ -139,27 +140,23 @@ public function preProcess() {
$this->assign($name, $value);
}

$lineItems = [];
$displayLineItems = FALSE;
if ($id) {
$lineItems = [CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id))];
$firstLineItem = reset($lineItems[0]);
if (empty($firstLineItem['price_set_id'])) {
// CRM-20297 All we care is that it's not QuickConfig, so no price set
// is no problem.
$displayLineItems = TRUE;
$lineItems = [CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id))];
$firstLineItem = reset($lineItems[0]);
if (empty($firstLineItem['price_set_id'])) {
// CRM-20297 All we care is that it's not QuickConfig, so no price set
// is no problem.
$displayLineItems = TRUE;
}
else {
try {
$priceSet = civicrm_api3('PriceSet', 'getsingle', [
'id' => $firstLineItem['price_set_id'],
'return' => 'is_quick_config, id',
]);
$displayLineItems = !$priceSet['is_quick_config'];
}
else {
try {
$priceSet = civicrm_api3('PriceSet', 'getsingle', [
'id' => $firstLineItem['price_set_id'],
'return' => 'is_quick_config, id',
]);
$displayLineItems = !$priceSet['is_quick_config'];
}
catch (CiviCRM_API3_Exception $e) {
throw new CRM_Core_Exception('Cannot find price set by ID');
}
catch (CiviCRM_API3_Exception $e) {
throw new CRM_Core_Exception('Cannot find price set by ID');
}
}
$this->assign('lineItem', $lineItems);
Expand All @@ -177,7 +174,7 @@ public function preProcess() {
}

// assign values to the template
$this->assign($values);
$this->assignVariables($values, array_keys($values));
$invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
$this->assign('invoicing', $invoicing);
$this->assign('isDeferred', Civi::settings()->get('deferred_revenue_enabled'));
Expand Down

0 comments on commit 75f7801

Please sign in to comment.