From 518ef8375964464eb37420aa2daf766b26bf5a3a Mon Sep 17 00:00:00 2001 From: mzd Date: Sun, 27 Apr 2014 18:13:49 -0400 Subject: [PATCH] CRM-11864 replace selects with ProfileSelects; ---------------------------------------- * CRM-11864: Embed form-designer in event and contribution UIs https://issues.civicrm.org/jira/browse/CRM-11864 --- CRM/Event/Form/ManageEvent/Registration.php | 49 +++++++++------------ CRM/Event/Form/ManageEvent/TabHeader.php | 9 ++++ 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index 1060c78562..79285c4769 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -335,43 +335,36 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent // explicit height and width. $form->addWysiwyg('footer_text', ts('Footer Text'), array('rows' => 2, 'cols' => 40)); - $types = array_merge(array('Contact', 'Individual', 'Participant'), - CRM_Contact_BAO_ContactType::subTypes('Individual') - ); - - $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); - - $mainProfiles = array( - '' => ts('- select -')) + $profiles; - $addtProfiles = array( - '' => ts('- same as for main contact -')) + $profiles; + extract( $this->getProfileSelectorTypes() ); /*var_dump($profileEntities); var_dump($allowCoreTypes); var_dump($allowSubTypes); */ - $form->add('select', 'custom_pre_id', ts('Include Profile') . '
' . ts('(top of page)'), $mainProfiles); - $form->add('select', 'custom_post_id', ts('Include Profile') . '
' . ts('(bottom of page)'), $mainProfiles); + $form->addProfileSelector( 'custom_pre_id', ts('Include Profile') . '
' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities); + $form->addProfileSelector( 'custom_post_id', ts('Include Profile') . '
' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntities); - $form->add('select', 'additional_custom_pre_id', ts('Profile for Additional Participants') . '
' . ts('(top of page)'), $addtProfiles); - // Allow user to NOT provide a bottom profile for Additional Participant registration - $form->add('select', 'additional_custom_post_id', ts('Profile for Additional Participants') . '
' . ts('(bottom of page)'), array('none' => ts('- no profile -')) + $addtProfiles); + $form->addProfileSelector( 'additional_custom_pre_id', ts('Profile for Additional Participants') . '
' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntitites); + $form->addProfileSelector( 'additional_custom_post_id', ts('Profile for Additional Participants') . '
' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $profileEntitites); } function buildMultipleProfileBottom(&$form, $count, $prefix = '', $name = 'Include Profile') { - $types = array_merge(array('Contact', 'Individual', 'Participant'), - CRM_Contact_BAO_ContactType::subTypes('Individual') + extract( $this->getProfileSelectorTypes() ); + $element = $prefix . "custom_post_id_multiple[$count]"; + $form->addProfileSelector( $element, $name . '
' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $profileEntitites); + } + + function getProfileSelectorTypes() { + $configs = array( + 'allowCoreTypes' => array(), + 'allowSubTypes' => array(), + 'profileEntities' => array(), ); - $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); + $configs['allowCoreTypes'][] = 'Contact'; + $configs['allowCoreTypes'][] = 'Individual'; + $configs['allowCoreTypes'][] = 'Participant'; - if ($prefix == 'additional_') { - $mainProfiles = array( - '' => ts('- same as for main contact -'), 'none' => ts('- no profile -')) + $profiles; - } - else { - $mainProfiles = array( - '' => ts('- select -')) + $profiles; - } + $configs['profileEntities'][] = array('entity_name' => 'individual_entity', 'entity_type' => 'IndividualModel'); + $configs['profileEntities'][] = array('entity_name' => 'participant_entity', 'entity_type' => 'ParticipantModel'); - $element = $prefix . "custom_post_id_multiple[$count]"; - $form->add('select', $element, $name . '
' . ts('(bottom of page)'), $mainProfiles); + return $configs; } /** diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 32beceabb6..d5927f0ef2 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -50,6 +50,15 @@ class CRM_Event_Form_ManageEvent_TabHeader { ->addSetting(array('tabSettings' => array( 'active' => self::getCurrentTab($tabs), ))); + + // Preload libraries required by Online Registration Include Profiles + $schemas = array('IndividualModel', 'ParticipantModel'); + if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) { + $schemas[] = 'MembershipModel'; + } + CRM_UF_Page_ProfileEditor::registerProfileScripts(); + CRM_UF_Page_ProfileEditor::registerSchemas($schemas); + return $tabs; } -- 2.25.1