Skip to content

Commit

Permalink
Merge pull request #16050 from eileenmcnaughton/qf
Browse files Browse the repository at this point in the history
[NFC] code cleanup
  • Loading branch information
seamuslee001 authored Dec 9, 2019
2 parents 47becdb + 303007a commit 2d7ad76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,9 @@ public static function checkOnlinePendingContribution($componentId, $componentNa
* @param bool $processContributionObject
*
* @return array
* @throws \Exception
*
* @throws CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @deprecated
*
* Use api contribute.completetransaction
Expand Down
29 changes: 19 additions & 10 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ class CRM_Member_Form_Membership extends CRM_Member_Form {
protected $_contributorDisplayName = NULL;

/**
* email of the person paying for the membership (used for receipts)
* Email of the person paying for the membership (used for receipts).
*
* @var string
*/
protected $_contributorEmail = NULL;
protected $_contributorEmail;

/**
* email of the person paying for the membership (used for receipts)
Expand Down Expand Up @@ -114,9 +115,9 @@ protected function setEntityFields() {
*/
public function setDeleteMessage() {
$this->deleteMessage = '<span class="font-red bold">'
. ts("WARNING: Deleting this membership will also delete any related payment (contribution) records." . ts("This action cannot be undone.")
. ts('WARNING: Deleting this membership will also delete any related payment (contribution) records.' . ts('This action cannot be undone.')
. '</span><p>'
. ts("Consider modifying the membership status instead if you want to maintain an audit trail and avoid losing payment data. You can set the status to Cancelled by editing the membership and clicking the Status Override checkbox.")
. ts('Consider modifying the membership status instead if you want to maintain an audit trail and avoid losing payment data. You can set the status to Cancelled by editing the membership and clicking the Status Override checkbox.')
. '</p><p>'
. ts("Click 'Delete' if you want to continue.") . '</p>');
}
Expand All @@ -142,6 +143,7 @@ public function addFormButtons() {}
* @param array $params
*
* @return array
* @throws \CRM_Core_Exception
*/
public static function getSelectedMemberships($priceSet, $params) {
$memTypeSelected = [];
Expand Down Expand Up @@ -190,6 +192,8 @@ public static function getPriceFieldIDs($params, $priceSet) {

/**
* Form preProcess function.
*
* @throws \CRM_Core_Exception
*/
public function preProcess() {
// This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
Expand Down Expand Up @@ -324,7 +328,7 @@ public function setDefaultValues() {
}

//set Soft Credit Type to Gift by default
$scTypes = CRM_Core_OptionGroup::values("soft_credit_type");
$scTypes = CRM_Core_OptionGroup::values('soft_credit_type');
$defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes));

//CRM-13420
Expand Down Expand Up @@ -382,6 +386,8 @@ public function setDefaultValues() {

/**
* Build the form object.
*
* @throws \CRM_Core_Exception
*/
public function buildQuickForm() {

Expand Down Expand Up @@ -462,7 +468,7 @@ public function buildQuickForm() {
}

$contactField = $this->addEntityRef('contact_id', ts('Member'), ['create' => TRUE, 'api' => ['extra' => ['email']]], TRUE);
if ($this->_context != 'standalone') {
if ($this->_context !== 'standalone') {
$contactField->freeze();
}

Expand Down Expand Up @@ -766,14 +772,14 @@ public static function formRule($params, $files, $self) {

$membershipDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);

if ($startDate && CRM_Utils_Array::value('period_type', $membershipDetails) == 'rolling') {
if ($startDate && CRM_Utils_Array::value('period_type', $membershipDetails) === 'rolling') {
if ($startDate < $joinDate) {
$errors['start_date'] = ts('Start date must be the same or later than Member since.');
}
}

if ($endDate) {
if ($membershipDetails['duration_unit'] == 'lifetime') {
if ($membershipDetails['duration_unit'] === 'lifetime') {
// Check if status is NOT cancelled or similar. For lifetime memberships, there is no automated
// process to update status based on end-date. The user must change the status now.
$result = civicrm_api3('MembershipStatus', 'get', [
Expand Down Expand Up @@ -1054,9 +1060,12 @@ public static function emailReceipt(&$form, &$formValues, &$membership, $customV
* Submit function.
*
* This is also accessed by unit tests.
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function submit() {
$isTest = ($this->_mode == 'test') ? 1 : 0;
$isTest = ($this->_mode === 'test') ? 1 : 0;
$this->storeContactFields($this->_params);
$this->beginPostProcess();
$joinDate = $startDate = $endDate = NULL;
Expand Down Expand Up @@ -1448,7 +1457,7 @@ public function submit() {
);
$params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source'];
$params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result);
$params['is_test'] = ($this->_mode == 'live') ? 0 : 1;
$params['is_test'] = ($this->_mode === 'live') ? 0 : 1;
if (!empty($formValues['send_receipt'])) {
$params['receipt_date'] = $now;
}
Expand Down

0 comments on commit 2d7ad76

Please sign in to comment.