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

Fix CRM-20488: remove restrictions on soft credit contact type. #10419

Merged
merged 3 commits into from
Jun 19, 2017
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: 0 additions & 4 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,6 @@ public function preProcess() {
else {
$this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution'));
}

if ($this->_id) {
CRM_Contribute_Form_SoftCredit::preprocess($this);
}
}

/**
Expand Down
29 changes: 0 additions & 29 deletions CRM/Contribute/Form/SoftCredit.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,6 @@
*/
class CRM_Contribute_Form_SoftCredit {

/**
* Set variables up before form is built.
*
* @param CRM_Core_Form $form
*/
public static function preProcess(&$form) {
$contriDAO = new CRM_Contribute_DAO_Contribution();
$contriDAO->id = $form->_id;
$contriDAO->find(TRUE);
if ($contriDAO->contribution_page_id) {
$ufJoinParams = array(
'module' => 'soft_credit',
'entity_table' => 'civicrm_contribution_page',
'entity_id' => $contriDAO->contribution_page_id,
);
$profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);

//check if any honree profile is enabled if yes then assign its profile type to $_honoreeProfileType
// which will be used to constraint soft-credit contact type in formRule, CRM-13981
if (!empty($profileId[0]) && !empty($profileId[2])) {
$form->_honoreeProfileType = CRM_Core_BAO_UFGroup::getContactType($profileId[0]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove this part, I think we don't have any purpose to have preProcess() here as it seems this function was only used to set _honoreeProfileType in $form. Can we remove preProcess() from this file then ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point. Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further,

  1. I think we should also remove any reference to this preProcess() to avoid any fatal errors caused by this change - one I can see is here.

  2. Remove definition of _honoreeProfileType as it doesn't seem to be used elsewhere.

    jitendra$ grep -irn honoreeProfileType CRM
    CRM/Contribute/Form/Contribution.php:157:  public $_honoreeProfileType;
    

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I should have thought of that. Will get you something soon. Thanks!

}
}

/**
* Function used to build form element for soft credit block.
*
Expand Down Expand Up @@ -242,10 +217,6 @@ public static function formRule($fields, $errors, $self) {
if (empty($fields['soft_credit_amount'][$key])) {
$errors["soft_credit_amount[$key]"] = ts('Please enter the soft credit amount.');
}
$contactType = CRM_Contact_BAO_Contact::getContactType($fields['soft_credit_contact_id'][$key]);
if ($self->_honoreeProfileType && $self->_honoreeProfileType != $contactType) {
$errors["soft_credit_contact_id[$key]"] = ts('Please choose a contact of type %1', array(1 => $self->_honoreeProfileType));
}
}
}
}
Expand Down