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

[NFC] code cleanup #16050

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));

if (!empty($defaults['record_contribution']) && !$this->_mode) {
Expand Down Expand Up @@ -399,6 +403,8 @@ public function setDefaultValues() {

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

Expand Down Expand Up @@ -479,7 +485,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 @@ -783,14 +789,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 @@ -1071,9 +1077,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 @@ -1465,7 +1474,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