From: atif-shaikh Date: Fri, 9 Jan 2015 08:04:45 +0000 (+0530) Subject: CRM-15787 - Not possible to add contribution field in profile for on behalf membership X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1da35d57d8d0905d18e771728d90f426d23d8f04;p=civicrm-core.git CRM-15787 - Not possible to add contribution field in profile for on behalf membership https://issues.civicrm.org/jira/browse/CRM-15787 --- diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 365009a078..2dada275a7 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -138,7 +138,9 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } //CRM-5001 - if (!empty($this->_values['is_for_organization'])) { + //CRM-15787 + $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); + if (!empty($this->_values['is_for_organization']) && empty($member['is_active'])) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); $ufJoinParams = array( 'module' => 'onBehalf', diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 0298e8bce3..8a8fa5f8f0 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -144,15 +144,25 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ // is on behalf of an organization ? $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);")); - $allowCoreTypes = array_merge(array('Contact', 'Organization'), CRM_Contact_BAO_ContactType::subTypes('Organization')); - $allowSubTypes = array(); - $entities = array( - array( - 'entity_name' => 'contact_1', - 'entity_type' => 'OrganizationModel', - ), + //CRM-15787 - If applicable, register 'membership_1' + $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); + $allowMemberCoreTypes = ''; + + $entities[] = array( + 'entity_name' => array ('contact_1'), + 'entity_type' => 'OrganizationModel', ); + if ($member && $member['is_active']) { + $allowMemberCoreTypes = 'Membership'; + $entities[] = array( + 'entity_name' => array ('membership_1'), + 'entity_type' => 'MembershipModel', + ); + } + $allowCoreTypes = array_merge(array('Contact', 'Organization', $allowMemberCoreTypes), CRM_Contact_BAO_ContactType::subTypes('Organization')); + $allowSubTypes = array(); + $this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities); $options = array();