X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContribute%2FForm%2FContributionPage%2FSettings.php;h=3046183d005a75faddd11884feccb62434142b54;hb=a969ba2b3fc64eebf12a98e3bfc69212d832ee19;hp=528d9066e84a7f379910e1cf52c9a4509c4fe5bf;hpb=cc9b655cc2686260be3931d5b8ceba0df61abe8b;p=civicrm-core.git diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 528d9066e8..3046183d00 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -61,9 +61,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $this->_id, 'title' ); - CRM_Utils_System::setTitle(ts('Title and Settings (%1)', - array(1 => $title) - )); + CRM_Utils_System::setTitle(ts('Title and Settings') . " ($title)"); $ufJoinParams = array( 'module' => 'OnBehalf', @@ -138,44 +136,23 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $this->addWysiwyg('footer_text', ts('Footer Message'), $attributes['footer_text']); + //Register schema which will be used for OnBehalOf and HonorOf profile Selector + CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel', 'HouseholdModel')); + // 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);")); - $required = array('Contact', 'Organization'); - $optional = array('Contribution', 'Membership'); - - $profiles = CRM_Core_BAO_UFGroup::getValidProfiles($required, $optional); - //Check profiles for Organization subtypes - $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); - foreach ($contactSubType as $type) { - $required = array('Contact', $type); - $subTypeProfiles = CRM_Core_BAO_UFGroup::getValidProfiles($required, $optional); - foreach ($subTypeProfiles as $profileId => $profileName) { - $profiles[$profileId] = $profileName; - } - } - - $requiredProfileFields = array('organization_name', 'email'); - - if (!empty($profiles)) { - foreach ($profiles as $id => $dontCare) { - $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($id, $requiredProfileFields); - if (!$validProfile) { - unset($profiles[$id]); - } - } - } - - if (empty($profiles)) { - $invalidProfiles = TRUE; - $this->assign('invalidProfiles', $invalidProfiles); - } - - $this->add('select', 'onbehalf_profile_id', ts('Organization Profile'), + $allowCoreTypes = array_merge(array('Contact', 'Organization'), CRM_Contact_BAO_ContactType::subTypes('Organization')); + $allowSubTypes = array(); + $entities = array( array( - '' => ts('- select -')) + $profiles + 'entity_name' => 'contact_1', + 'entity_type' => 'OrganizationModel', + ), ); + $this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities); + $options = array(); $options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1); $options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2); @@ -221,7 +198,6 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $allowSubTypes = array(); $this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities); - CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel','HouseholdModel')); if (!empty($this->_submitValues['honor_block_is_active'])) { $this->addRule('soft_credit_types', ts('At least one value must be selected if Honor Section is active'), 'required'); @@ -242,6 +218,9 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ * * @param array $values posted values of the form * + * @param $files + * @param $self + * * @return array list of errors to be posted back to the form * @static * @access public @@ -254,8 +233,17 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $errors['title'] = ts("Please do not use '/' in Title"); } - if (!empty($values['is_organization']) && empty($values['onbehalf_profile_id'])) { - $errors['onbehalf_profile_id'] = ts('Please select a profile to collect organization information on this contribution page.'); + // ensure on-behalf-of profile meets minimum requirements + if (!empty($values['is_organization'])) { + if (empty($values['onbehalf_profile_id']) ) { + $errors['onbehalf_profile_id'] = ts('Please select a profile to collect organization information on this contribution page.'); + } + else { + $requiredProfileFields = array('organization_name', 'email'); + if (!CRM_Core_BAO_UFGroup::checkValidProfile($values['onbehalf_profile_id'], $requiredProfileFields)) { + $errors['onbehalf_profile_id'] = ts('Profile does not contain the minimum required fields for an On Behalf Of Organization'); + } + } } //CRM-11494