Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.14 to master #14455

Merged
merged 11 commits into from
Jun 6, 2019
33 changes: 23 additions & 10 deletions CRM/Contact/BAO/Contact/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,34 @@ class CRM_Contact_BAO_Contact_Location {
* Array of display_name, email, location type and location id if found, or (null,null,null, null)
*/
public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID = NULL) {
$params = [
'location_type_id' => $locationTypeID,
$params = array(
'contact_id' => $id,
'return' => ['contact_id.display_name', 'email', 'location_type_id', 'id'],
];
'return' => array('display_name', 'email.email'),
'api.Email.get' => array(
'location_type_id' => $locationTypeID,
'sequential' => 0,
'return' => array('email', 'location_type_id', 'id'),
),
);
if ($isPrimary) {
$params['is_primary'] = 1;
$params['api.Email.get']['is_primary'] = 1;
}
$emails = civicrm_api3('Email', 'get', $params);

if ($emails['count'] > 0) {
$email = reset($emails['values']);
return [$email['contact_id.display_name'], $email['email'], $email['location_type_id'], $email['id']];
$contacts = civicrm_api3('Contact', 'get', $params);
if ($contacts['count'] > 0) {
$contact = reset($contacts['values']);
if ($contact['api.Email.get']['count'] > 0) {
$email = reset($contact['api.Email.get']['values']);
}
}
return [NULL, NULL, NULL, NULL];
$returnParams = array(
(isset($contact['display_name'])) ? $contact['display_name'] : NULL,
(isset($email['email'])) ? $email['email'] : NULL,
(isset($email['location_type_id'])) ? $email['location_type_id'] : NULL,
(isset($email['id'])) ? $email['id'] : NULL,
);

return $returnParams;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ protected static function getEntitySpecificJoins($name, $mode, $side, $primaryLo
case 'civicrm_worldregion':
// We can be sure from the calling function that country will already be joined in.
// we really don't need world_region - we could use a pseudoconstant for it.
return "$side JOIN civicrm_worldregion ON civicrm_country.region_id = civicrm_worldregion.id ";
return " $side JOIN civicrm_worldregion ON civicrm_country.region_id = civicrm_worldregion.id ";

case 'civicrm_location_type':
return " $side JOIN civicrm_location_type ON civicrm_address.location_type_id = civicrm_location_type.id ";
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/Form/CancelSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib

/**
* Set variables up before form is built.
*
* @throws \CRM_Core_Exception
*/
public function preProcess() {
parent::preProcess();
if ($this->_crid) {
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
Expand Down Expand Up @@ -79,7 +80,6 @@ public function preProcess() {
CRM_Core_Error::fatal(ts('The recurring contribution looks to have been cancelled already.'));
}
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');

$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
Expand Down
44 changes: 44 additions & 0 deletions CRM/Contribute/Form/ContributionRecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form {
*/
protected $entityFields = [];

/**
* Details of the subscription (recurring contribution) to be altered.
*
* @var array
*/
protected $subscriptionDetails = [];

/**
* Explicitly declare the entity api name.
*/
Expand All @@ -109,14 +116,20 @@ public function getDefaultContext() {

/**
* Set variables up before form is built.
*
* @throws \CRM_Core_Exception
*/
public function preProcess() {
$this->setAction(CRM_Core_Action::UPDATE);
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
$this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
$this->contributionRecurID = $this->_crid;
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
$this->setSubscriptionDetails();
$this->setPaymentProcessor();
if ($this->getSubscriptionContactID()) {
$this->set('cid', $this->getSubscriptionContactID());
}
}

/**
Expand All @@ -135,4 +148,35 @@ protected function setPaymentProcessor() {
}
}

/**
* Set the subscription details on the form.
*/
protected function setSubscriptionDetails() {
if ($this->contributionRecurID) {
$this->subscriptionDetails = $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
}
elseif ($this->_coid) {
$this->subscriptionDetails = $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
}
}

/**
* Get details for the recurring contribution being altered.
*
* @return array
*/
public function getSubscriptionDetails() {
return $this->subscriptionDetails;
}

/**
* Get the contact ID for the subscription.
*
* @return int|false
*/
protected function getSubscriptionContactID() {
$sub = $this->getSubscriptionDetails();
return isset($sub->contact_id) ? $sub->contact_id : FALSE;
}

}
5 changes: 2 additions & 3 deletions CRM/Contribute/Form/UpdateBilling.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_Contribution

/**
* Set variables up before form is built.
*
* @throws \CRM_Core_Exception
*/
public function preProcess() {
parent::preProcess();
if ($this->_crid) {
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);

// Are we cancelling a recurring contribution that is linked to an auto-renew membership?
if ($this->_subscriptionDetails->membership_id) {
$this->_mid = $this->_subscriptionDetails->membership_id;
Expand All @@ -60,7 +60,6 @@ public function preProcess() {
if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
$this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
}

if ($this->_mid) {
Expand Down
5 changes: 0 additions & 5 deletions CRM/Contribute/Form/UpdateSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,10 @@ public function preProcess() {
parent::preProcess();
$this->setAction(CRM_Core_Action::UPDATE);

if ($this->contributionRecurID) {
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID);
}

if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
// @todo test & replace with $this->_paymentProcessorObj = Civi\Payment\System::singleton()->getById($this->_paymentProcessor['id']);
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
$this->contributionRecurID = $this->_subscriptionDetails->recur_id;
}
elseif ($this->contributionRecurID) {
Expand Down
52 changes: 12 additions & 40 deletions CRM/Event/Form/Registration/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ public function postProcess() {
$preApprovalParams = $this->_paymentProcessor['object']->getPreApprovalDetails($this->get('pre_approval_parameters'));
$value = array_merge($value, $preApprovalParams);
}
$result = NULL;

if (!empty($value['is_pay_later']) ||
$value['amount'] == 0 ||
Expand All @@ -581,6 +582,16 @@ public function postProcess() {
if (empty($value['email'])) {
$value['email'] = CRM_Utils_Array::valueByRegexKey('/^email-/', $value);
}

if (is_object($payment)) {
// Not quite sure why we don't just user $value since it contains the data
// from result
// @todo ditch $result & retest.
list($result, $value) = $this->processPayment($payment, $value);
}
else {
CRM_Core_Error::fatal($paymentObjError);
}
}

$value['receive_date'] = $now;
Expand All @@ -607,44 +618,8 @@ public function postProcess() {
$isAdditionalAmount = TRUE;
}

CRM_Contribute_Form_AbstractEditPayment::formatCreditCardDetails($params[0]);
//passing contribution id is already registered.
$contribution = self::processContribution($this, $value, NULL, $contactID, TRUE, $isAdditionalAmount, $this->_paymentProcessor);

try {
// @todo this should really be if $amount > 0, for pay later we should just load the
// manual pseudo processor (0) so there *should* always be a defined processor
if (!empty($payment)) {
$result = $payment->doPayment($value, 'event');
if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')) {
try {
civicrm_api3('contribution', 'completetransaction', [
'id' => $contribution->id,
'trxn_id' => $result['trxn_id'],
'payment_processor_id' => $this->_paymentProcessor['id'],
'is_transactional' => FALSE,
'fee_amount' => CRM_Utils_Array::value('fee_amount', $result),
'is_email_receipt' => FALSE,
'card_type_id' => CRM_Utils_Array::value('card_type_id', $params[0]),
'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $params[0]),
]);
// This has now been set to 1 in the DB - declare it here also
$contribution->contribution_status_id = 1;
}
catch (CiviCRM_API3_Exception $e) {
if ($e->getErrorCode() != 'contribution_completed') {
throw new CRM_Core_Exception('Failed to update contribution in database');
}
}
}
}
}
catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
Civi::log()->error('Payment processor exception: ' . $e->getMessage());
CRM_Core_Session::singleton()->setStatus($e->getMessage());
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}"));
}

$contribution = self::processContribution($this, $value, $result, $contactID, $pending, $isAdditionalAmount, $this->_paymentProcessor);
$value['contributionID'] = $contribution->id;
$value['contributionTypeID'] = $contribution->financial_type_id;
$value['receive_date'] = $contribution->receive_date;
Expand Down Expand Up @@ -998,9 +973,6 @@ public static function processContribution(
}

// CRM-20264: fetch CC type ID and number (last 4 digit) and assign it back to $params
// @todo remove this once backoffice form is doing it - front end is doing it twice.
// (in general they are sharing much more code than they should - anything that truly should be shared
// should not be on this class).
CRM_Contribute_Form_AbstractEditPayment::formatCreditCardDetails($params);

$contribParams = [
Expand Down
3 changes: 3 additions & 0 deletions CRM/Upgrade/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class CRM_Upgrade_Form extends CRM_Core_Form {

/**
* Minimum php version required to run (equal to or lower than the minimum install version)
*
* Even though 5.6 is no longer supported, this value is left here for a while
* so as not to block stragglers from upgrading.
*/
const MINIMUM_PHP_VERSION = '5.6';

Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Incremental/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CRM_Upgrade_Incremental_General {
*
* @see install/index.php
*/
const MIN_INSTALL_PHP_VER = '5.6';
const MIN_INSTALL_PHP_VER = '7.0';

/**
* Compute any messages which should be displayed before upgrade.
Expand Down
7 changes: 7 additions & 0 deletions contributor-key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@
organization: Edinburgh College
jira : grahamsmith

- name : Guillaume Rischard
github : grischard

- github : guanhuan
name : Guanhuan Chen
organization: CompuCorp
Expand Down Expand Up @@ -1220,6 +1223,10 @@
name : Rubén Pineda
organization: iXiam

- github : scoobird
name : Morgan Robinson
organization: Palante

- name : Steve Binkowski
jira : s.bink

Expand Down
11 changes: 11 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ Other resources for identifying changes are:
* https://github.com/civicrm/civicrm-joomla
* https://github.com/civicrm/civicrm-wordpress

## CiviCRM 5.14.0

Released June 5, 2019

- **[Synopsis](release-notes/5.14.0.md#synopsis)**
- **[Features](release-notes/5.14.0.md#features)**
- **[Bugs resolved](release-notes/5.14.0.md#bugs)**
- **[Miscellany](release-notes/5.14.0.md#misc)**
- **[Credits](release-notes/5.14.0.md#credits)**
- **[Feedback](release-notes/5.14.0.md#feedback)**

## CiviCRM 5.13.5

Released May 29, 2019
Expand Down
Loading