Beispiel #1
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // build profiles first so that we can determine address fields etc
     // and then show copy address checkbox
     if (empty($this->_ccid)) {
         $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
         $this->buildCustom($this->_values['custom_post_id'], 'customPost');
         // CRM-18399: used by template to pass pre profile id as a url arg
         $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
         $this->buildComponentForm($this->_id, $this);
     }
     // Build payment processor form
     CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     $config = CRM_Core_Config::singleton();
     $contactID = $this->getContactID();
     if ($contactID) {
         $this->assign('contact_id', $contactID);
         $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
     }
     $this->applyFilter('__ALL__', 'trim');
     if (empty($this->_ccid)) {
         $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60, 'class' => 'email'), TRUE);
         $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     } else {
         $this->addElement('hidden', "email-{$this->_bltID}", 1);
         $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE);
     }
     $pps = array();
     //@todo - this should be replaced by a check as to whether billing fields are set
     $onlinePaymentProcessorEnabled = FALSE;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $name) {
             if ($name['billing_mode'] == 1) {
                 $onlinePaymentProcessorEnabled = TRUE;
             }
             $pps[$key] = $name['name'];
         }
     }
     if (!empty($this->_values['is_pay_later'])) {
         $pps[0] = $this->_values['pay_later_text'];
     }
     if (count($pps) > 1) {
         $this->addRadio('payment_processor_id', ts('Payment Method'), $pps, NULL, " ");
     } elseif (!empty($pps)) {
         $key = array_keys($pps);
         $key = array_pop($key);
         $this->addElement('hidden', 'payment_processor_id', $key);
         if ($key === 0) {
             $this->assign('is_pay_later', $this->_values['is_pay_later']);
             $this->assign('pay_later_text', $this->_values['pay_later_text']);
         }
     }
     $contactID = $this->getContactID();
     if ($this->getContactID() === 0) {
         $this->addCidZeroOptions($onlinePaymentProcessorEnabled);
     }
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
         $this->_separateMembershipPayment = FALSE;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             $this->_separateMembershipPayment = $this->buildMembershipBlock($this->_membershipContactID, TRUE, NULL, FALSE, $isTest);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         if (empty($this->_ccid)) {
             CRM_Price_BAO_PriceSet::buildPriceSet($this);
         }
         if ($this->_values['is_monetary'] && $this->_values['is_recur'] && empty($this->_values['pledge_id'])) {
             self::buildRecur($this);
         }
     }
     if ($this->_priceSetId && empty($this->_ccid)) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $this->_useForMember = 0;
             $this->set('useForMember', $this->_useForMember);
         }
     }
     //we allow premium for pledge during pledge creation only.
     if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid && empty($this->_ccid)) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     //to create an cms user
     if (!$this->_contactID && empty($this->_ccid)) {
         $createCMSUser = FALSE;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             if (!is_array($this->_values['custom_post_id'])) {
                 $profileIDs = array($this->_values['custom_post_id']);
             } else {
                 $profileIDs = $this->_values['custom_post_id'];
             }
             foreach ($profileIDs as $pid) {
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
                     $profileID = $pid;
                     $createCMSUser = TRUE;
                     break;
                 }
             }
         }
         if ($createCMSUser) {
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         }
     }
     if ($this->_pcpId && empty($this->_ccid)) {
         if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
             $pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
             // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute');
             if (!empty($text)) {
                 $pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
             }
             $this->assign('pcpSupporterText', $pcp_supporter_text);
         }
         $prms = array('id' => $this->_pcpId);
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
         if ($pcpInfo['is_honor_roll']) {
             $this->assign('isHonor', TRUE);
             $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
             $extraOption = array('onclick' => "return pcpAnonymous( );");
             $elements = array();
             $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
             $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
             $this->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
             $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
             $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
         }
     }
     if (empty($this->_values['fee']) && empty($this->_ccid)) {
         CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
     }
     //we have to load confirm contribution button in template
     //when multiple payment processor as the user
     //can toggle with payment processor selection
     $billingModePaymentProcessors = 0;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $values) {
             if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
                 $billingModePaymentProcessors++;
             }
         }
     }
     if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
         $allAreBillingModeProcessors = TRUE;
     } else {
         $allAreBillingModeProcessors = FALSE;
     }
     if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
         $submitButton = array('type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
         // Add submit-once behavior when confirm page disabled
         if (empty($this->_values['is_confirm_enabled'])) {
             $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
         }
         //change button name for updating contribution
         if (!empty($this->_ccid)) {
             $submitButton['name'] = ts('Confirm Payment');
         }
         $this->addButtons(array($submitButton));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     // build profiles first so that we can determine address fields etc
     // and then show copy address checkbox
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     if (!empty($this->_fields) && !empty($this->_values['custom_pre_id'])) {
         $profileAddressFields = array();
         foreach ($this->_fields as $key => $value) {
             CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $this->_values['custom_pre_id']));
         }
         $this->set('profileAddressFields', $profileAddressFields);
     }
     // Build payment processor form
     if ($this->_ppType) {
         CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
         // Return if we are in an ajax callback
         if ($this->_snippet) {
             return;
         }
     }
     $contactID = $this->getContactID();
     $this->assign('contact_id', $contactID);
     $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
     $this->add('hidden', 'scriptFee', NULL);
     $this->add('hidden', 'scriptArray', NULL);
     $bypassPayment = $allowGroupOnWaitlist = $isAdditionalParticipants = FALSE;
     if ($this->_values['event']['is_multiple_registrations']) {
         // don't allow to add additional during confirmation if not preregistered.
         if (!$this->_allowConfirmation || $this->_additionalParticipantIds) {
             // Hardcode maximum number of additional participants here for now. May need to make this configurable per event.
             // Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self")
             $additionalOptions = array('' => '1', 1 => '2', 2 => '3', 3 => '4', 4 => '5', 5 => '6', 6 => '7', 7 => '8', 8 => '9', 9 => '10');
             $element = $this->add('select', 'additional_participants', ts('How many people are you registering?'), $additionalOptions, NULL, array('onChange' => "allowParticipant()"));
             $isAdditionalParticipants = TRUE;
         }
     }
     //hack to allow group to register w/ waiting
     if ((CRM_Utils_Array::value('is_multiple_registrations', $this->_values['event']) || $this->_priceSetId) && !$this->_allowConfirmation && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $bypassPayment = TRUE;
         //case might be group become as a part of waitlist.
         //If not waitlist then they require admin approve.
         $allowGroupOnWaitlist = TRUE;
         $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations));
         if ($this->_requireApproval) {
             $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration(s) have been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
         }
     }
     //case where only approval needed - no waitlist.
     if ($this->_requireApproval && !$this->_allowWaitlist && !$bypassPayment) {
         $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
     }
     //lets display status to primary page only.
     $this->assign('waitlistMsg', $this->_waitlistMsg);
     $this->assign('requireApprovalMsg', $this->_requireApprovalMsg);
     $this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
     $this->assign('isAdditionalParticipants', $isAdditionalParticipants);
     //lets get js on two different qf elements.
     $showHidePayfieldName = NULL;
     $showHidePaymentInformation = FALSE;
     if ($this->_values['event']['is_monetary']) {
         self::buildAmount($this);
     }
     $pps = array();
     //@todo this processor adding fn is another one duplicated on contribute - a shared
     // common class would make this sort of thing extractable
     $onlinePaymentProcessorEnabled = FALSE;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $name) {
             if ($name['billing_mode'] == 1) {
                 $onlinePaymentProcessorEnabled = TRUE;
             }
             $pps[$key] = $name['name'];
         }
     }
     if ($this->getContactID() === '0' && !$this->_values['event']['is_multiple_registrations']) {
         //@todo we are blocking for multiple registrations because we haven't tested
         $this->addCidZeroOptions($onlinePaymentProcessorEnabled);
     }
     if (CRM_Utils_Array::value('is_pay_later', $this->_values['event']) && ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist)) {
         $pps[0] = $this->_values['event']['pay_later_text'];
     }
     if ($this->_values['event']['is_monetary']) {
         if (count($pps) > 1) {
             $this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, "&nbsp;");
         } elseif (!empty($pps)) {
             $ppKeys = array_keys($pps);
             $currentPP = array_pop($ppKeys);
             $this->addElement('hidden', 'payment_processor', $currentPP);
         }
     }
     //lets add some qf element to bypass payment validations, CRM-4320
     if ($bypassPayment) {
         $this->addElement('hidden', 'bypass_payment', NULL, array('id' => 'bypass_payment'));
     }
     $this->assign('bypassPayment', $bypassPayment);
     $this->assign('showHidePaymentInformation', $showHidePaymentInformation);
     $userID = $this->getContactID();
     if (!$userID) {
         $createCMSUser = FALSE;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             if (!is_array($this->_values['custom_post_id'])) {
                 $profileIDs = array($this->_values['custom_post_id']);
             } else {
                 $profileIDs = $this->_values['custom_post_id'];
             }
             foreach ($profileIDs as $pid) {
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
                     $profileID = $pid;
                     $createCMSUser = TRUE;
                     break;
                 }
             }
         }
         if ($createCMSUser) {
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         }
     }
     //we have to load confirm contribution button in template
     //when multiple payment processor as the user
     //can toggle with payment processor selection
     $billingModePaymentProcessors = 0;
     if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $values) {
             if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
                 $billingModePaymentProcessors++;
             }
         }
     }
     if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
         $allAreBillingModeProcessors = TRUE;
     } else {
         $allAreBillingModeProcessors = FALSE;
     }
     if (!$allAreBillingModeProcessors || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment) {
         //freeze button to avoid multiple calls.
         $js = NULL;
         if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
             $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
         }
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE, 'js' => $js)));
     }
     $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
     // add pcp fields
     if ($this->_pcpId) {
         CRM_PCP_BAO_PCP::buildPcp($this->_pcpId, $this);
     }
 }
Beispiel #3
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->add('hidden', 'gid', $this->_gid);
     switch ($this->_mode) {
         case self::MODE_CREATE:
         case self::MODE_EDIT:
         case self::MODE_REGISTER:
             CRM_Utils_Hook::buildProfile($this->_ufGroup['name']);
             break;
         case self::MODE_SEARCH:
             CRM_Utils_Hook::searchProfile($this->_ufGroup['name']);
             break;
         default:
     }
     //lets have single status message, CRM-4363
     $return = FALSE;
     $statusMessage = NULL;
     if ($this->_multiRecord & CRM_Core_Action::ADD && $this->_maxRecordLimit) {
         return;
     }
     if ($this->_multiRecord & CRM_Core_Action::DELETE) {
         if (!$this->_recordExists) {
             CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', array(1 => $this->_recordId)), ts('Record doesnot exists'), 'alert');
         } else {
             $this->assign('deleteRecord', TRUE);
         }
         return;
     }
     CRM_Core_BAO_Address::checkContactSharedAddressFields($this->_fields, $this->_id);
     // we should not allow component and mix profiles in search mode
     if ($this->_mode != self::MODE_REGISTER) {
         //check for mix profile fields (eg:  individual + other contact type)
         if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
             if ($this->_mode & self::MODE_EDIT && $this->_isContactActivityProfile) {
                 $errors = self::validateContactActivityProfile($this->_activityId, $this->_id, $this->_gid);
                 if (!empty($errors)) {
                     $statusMessage = array_pop($errors);
                     $return = TRUE;
                 }
             } else {
                 $statusMessage = ts('Profile search, view and edit are not supported for Profiles which include fields for more than one record type.');
                 $return = TRUE;
             }
         }
         $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
         if ($this->_id) {
             $contactTypes = CRM_Contact_BAO_Contact::getContactTypes($this->_id);
             $contactType = $contactTypes[0];
             array_shift($contactTypes);
             $contactSubtypes = $contactTypes;
             $profileSubType = FALSE;
             if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                 $profileSubType = $profileType;
                 $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
             }
             if ($profileType != 'Contact' && !$this->_isContactActivityProfile && ($profileSubType && !empty($contactSubtypes) && !in_array($profileSubType, $contactSubtypes) || $profileType != $contactType)) {
                 $return = TRUE;
                 if (!$statusMessage) {
                     $statusMessage = ts("This profile is configured for contact type '%1'. It cannot be used to edit contacts of other types.", array(1 => $profileSubType ? $profileSubType : $profileType));
                 }
             }
         }
         if (in_array($profileType, array("Membership", "Participant", "Contribution"))) {
             $return = TRUE;
             if (!$statusMessage) {
                 $statusMessage = ts('Profile is not configured for the selected action.');
             }
         }
     }
     //lets have single status message,
     $this->assign('statusMessage', $statusMessage);
     if ($return) {
         return FALSE;
     }
     $this->assign('id', $this->_id);
     $this->assign('mode', $this->_mode);
     $this->assign('action', $this->_action);
     $this->assign('fields', $this->_fields);
     $this->assign('fieldset', isset($this->_fieldset) ? $this->_fieldset : "");
     // should we restrict what we display
     $admin = TRUE;
     if ($this->_mode == self::MODE_EDIT) {
         $admin = FALSE;
         // show all fields that are visibile:
         // if we are a admin OR the same user OR acl-user with access to the profile
         // or we have checksum access to this contact (i.e. the user without a login) - CRM-5909
         if (CRM_Core_Permission::check('administer users') || $this->_id == $this->_currentUserID || $this->_isPermissionedChecksum || in_array($this->_gid, CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id')))) {
             $admin = TRUE;
         }
     }
     // if false, user is not logged-in.
     $anonUser = FALSE;
     if (!$this->_currentUserID) {
         $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
         $primaryLocationType = $defaultLocationType->id;
         $anonUser = TRUE;
     }
     $this->assign('anonUser', $anonUser);
     $addCaptcha = array();
     $emailPresent = FALSE;
     // add the form elements
     foreach ($this->_fields as $name => $field) {
         // make sure that there is enough permission to expose this field
         if (!$admin && $field['visibility'] == 'User and User Admin Only') {
             unset($this->_fields[$name]);
             continue;
         }
         // since the CMS manages the email field, suppress the email display if in
         // register mode which occur within the CMS form
         if ($this->_mode == self::MODE_REGISTER && substr($name, 0, 5) == 'email') {
             unset($this->_fields[$name]);
             continue;
         }
         list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
         CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
         if ($field['add_to_group_id']) {
             $addToGroupId = $field['add_to_group_id'];
         }
         //build array for captcha
         if ($field['add_captcha']) {
             $addCaptcha[$field['group_id']] = $field['add_captcha'];
         }
         if ($name == 'email-Primary' || ($name == 'email-' . isset($primaryLocationType) ? $primaryLocationType : "")) {
             $emailPresent = TRUE;
             $this->_mail = $name;
         }
     }
     // add captcha only for create mode.
     if ($this->_mode == self::MODE_CREATE) {
         // suppress captcha for logged in users only
         if ($this->_currentUserID) {
             $this->_isAddCaptcha = FALSE;
         } elseif (!$this->_isAddCaptcha && !empty($addCaptcha)) {
             $this->_isAddCaptcha = TRUE;
         }
         if ($this->_gid) {
             $dao = new CRM_Core_DAO_UFGroup();
             $dao->id = $this->_gid;
             $dao->addSelect();
             $dao->addSelect('is_update_dupe');
             if ($dao->find(TRUE)) {
                 if ($dao->is_update_dupe) {
                     $this->_isUpdateDupe = $dao->is_update_dupe;
                 }
             }
         }
     } else {
         $this->_isAddCaptcha = FALSE;
     }
     //finally add captcha to form.
     if ($this->_isAddCaptcha) {
         $captcha = CRM_Utils_ReCAPTCHA::singleton();
         $captcha->add($this);
     }
     $this->assign("isCaptcha", $this->_isAddCaptcha);
     if ($this->_mode != self::MODE_SEARCH) {
         if (isset($addToGroupId)) {
             $this->_ufGroup['add_to_group_id'] = $addToGroupId;
         }
     }
     //let's do set defaults for the profile
     $this->setDefaultsValues();
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL);
     if ($this->_mode == self::MODE_CREATE) {
         CRM_Core_BAO_CMSUser::buildForm($this, $this->_gid, $emailPresent, $action);
     } else {
         $this->assign('showCMS', FALSE);
     }
     $this->assign('groupId', $this->_gid);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
     if ($this->_context == 'dialog') {
         $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
     }
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $profileID = CRM_Core_DAO::getFieldValue('CRM_Auction_DAO_Auction', $this->_aid, 'donor_profile_id');
     if (!$profileID) {
         CRM_Core_Error::fatal('Profile not configured for this auction.');
     }
     require_once 'CRM/Auction/BAO/Item.php';
     if (CRM_Auction_BAO_Item::isEmailInProfile($profileID)) {
         $this->assign('profileDisplay', TRUE);
     }
     $fields = NULL;
     require_once "CRM/Core/BAO/UFGroup.php";
     if ($this->_donorID) {
         if (CRM_Core_BAO_UFGroup::filterUFGroups($profileID, $this->_donorID)) {
             $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD);
         }
         $this->addFormRule(array('CRM_Auction_Form_ItemAccount', 'formRule'), $this);
     } else {
         require_once 'CRM/Core/BAO/CMSUser.php';
         CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD);
     }
     if ($fields) {
         $this->assign('fields', $fields);
         $addCaptcha = FALSE;
         foreach ($fields as $key => $field) {
             if (isset($field['data_type']) && $field['data_type'] == 'File') {
                 // ignore file upload fields
                 continue;
             }
             require_once "CRM/Core/BAO/UFGroup.php";
             require_once "CRM/Profile/Form.php";
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
             $this->_fields[$key] = $field;
             if ($field['add_captcha']) {
                 $addCaptcha = TRUE;
             }
         }
         if ($addCaptcha) {
             require_once 'CRM/Utils/ReCAPTCHA.php';
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign("isCaptcha", TRUE);
         }
     }
     $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
     $this->addButtons($button);
 }
Beispiel #5
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $id = CRM_PCP_BAO_PCP::getSupporterProfileId($this->_pageId, $this->_component);
     if (CRM_PCP_BAO_PCP::checkEmailProfile($id)) {
         $this->assign('profileDisplay', TRUE);
     }
     $fields = NULL;
     if ($this->_contactID) {
         if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
             $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
         }
         $this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
     } else {
         CRM_Core_BAO_CMSUser::buildForm($this, $id, TRUE);
         $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD);
     }
     if ($fields) {
         $this->assign('fields', $fields);
         $addCaptcha = FALSE;
         foreach ($fields as $key => $field) {
             if (isset($field['data_type']) && $field['data_type'] == 'File') {
                 // ignore file upload fields
                 continue;
             }
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
             $this->_fields[$key] = $field;
             // CRM-11316 Is ReCAPTCHA enabled for this profile AND is this an anonymous visitor
             if ($field['add_captcha'] && !$this->_contactID) {
                 $addCaptcha = TRUE;
             }
         }
         if ($addCaptcha) {
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign('isCaptcha', TRUE);
         }
     }
     if ($this->_component == 'contribute') {
         $this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
     } elseif ($this->_component == 'event') {
         $this->assign('campaignName', CRM_Event_PseudoConstant::event($this->_pageId));
     }
     if ($this->_single) {
         $button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
     } else {
         $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
     }
     $this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
     $this->addButtons($button);
 }
Beispiel #6
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     //lets have single status message, CRM-4363
     $return = false;
     $statusMessage = null;
     //we should not allow component and mix profiles in search mode
     if ($this->_mode != self::MODE_REGISTER) {
         //check for mix profile fields (eg:  individual + other contact type)
         if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
             $statusMessage = ts('Profile search, view and edit are not supported for Profiles which include fields for more than one record type.');
         }
         $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
         if ($this->_id) {
             list($contactType, $contactSubType) = CRM_Contact_BAO_Contact::getContactTypes($this->_id);
             if ($profileType != 'Contact' && $contactType != $profileType && !CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                 $return = true;
                 if (!$statusMessage) {
                     $statusMessage = ts('This profile is not configured for "%1" contact type.', array(1 => $contactType));
                 }
             }
             if ($contactSubType && CRM_Contact_BAO_ContactType::isaSubType($profileType) && $profileType != $contactSubType) {
                 $return = true;
                 if (!$statusMessage) {
                     $statusMessage = ts('This profile is not configured for "%1" contact subtype.', array(1 => $contactSubType));
                 }
             }
         }
         if (in_array($profileType, array("Membership", "Participant", "Contribution"))) {
             $return = true;
             if (!$statusMessage) {
                 $statusMessage = ts('Profile is not configured for the selected action.');
             }
         }
     }
     //lets have sigle status message,
     $this->assign('statusMessage', $statusMessage);
     if ($return) {
         return false;
     }
     $sBlocks = array();
     $hBlocks = array();
     $config =& CRM_Core_Config::singleton();
     $this->assign('id', $this->_id);
     $this->assign('mode', $this->_mode);
     $this->assign('action', $this->_action);
     $this->assign_by_ref('fields', $this->_fields);
     $this->assign('fieldset', isset($this->_fieldset) ? $this->_fieldset : "");
     // do we need inactive options ?
     if ($this->_action & CRM_Core_Action::VIEW) {
         $inactiveNeeded = true;
     } else {
         $inactiveNeeded = false;
     }
     $session =& CRM_Core_Session::singleton();
     // should we restrict what we display
     $admin = true;
     if ($this->_mode == self::MODE_EDIT) {
         $admin = false;
         // show all fields that are visibile: if we are a admin or the same user or in registration mode
         if (CRM_Core_Permission::check('administer users') || $this->_id == $session->get('userID')) {
             $admin = true;
         }
     }
     $userID = $session->get('userID');
     $anonUser = false;
     // if false, user is not logged-in.
     if (!$userID) {
         require_once 'CRM/Core/BAO/LocationType.php';
         $defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
         $primaryLocationType = $defaultLocationType->id;
         $anonUser = true;
         $this->assign('anonUser', true);
     }
     $addCaptcha = array();
     $emailPresent = false;
     // cache the state country fields. based on the results, we could use our javascript solution
     // in create or register mode
     $stateCountryMap = array();
     // add the form elements
     foreach ($this->_fields as $name => $field) {
         // make sure that there is enough permission to expose this field
         if (!$admin && $field['visibility'] == 'User and User Admin Only' || CRM_Utils_Array::value('is_view', $field)) {
             unset($this->_fields[$name]);
             continue;
         }
         // since the CMS manages the email field, suppress the email display if in
         // register mode which occur within the CMS form
         if ($this->_mode == self::MODE_REGISTER && substr($name, 0, 5) == 'email') {
             unset($this->_fields[$name]);
             continue;
         }
         list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2);
         if ($prefixName == 'state_province' || $prefixName == 'country') {
             if (!array_key_exists($index, $stateCountryMap)) {
                 $stateCountryMap[$index] = array();
             }
             $stateCountryMap[$index][$prefixName] = $name;
         }
         CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
         if ($field['add_to_group_id']) {
             $addToGroupId = $field['add_to_group_id'];
         }
         //build array for captcha
         if ($field['add_captcha']) {
             $addCaptcha[$field['group_id']] = $field['add_captcha'];
         }
         if ($name == 'email-Primary' || ($name == 'email-' . isset($primaryLocationType) ? $primaryLocationType : "")) {
             $emailPresent = true;
             $this->_mail = $name;
         }
     }
     $setCaptcha = false;
     // do this only for CiviCRM created forms
     if ($this->_mode == self::MODE_CREATE) {
         if (!empty($addCaptcha)) {
             $setCaptcha = true;
         }
         if ($this->_gid) {
             $dao = new CRM_Core_DAO_UFGroup();
             $dao->id = $this->_gid;
             $dao->addSelect();
             $dao->addSelect('add_captcha', 'is_update_dupe');
             if ($dao->find(true)) {
                 if ($dao->add_captcha) {
                     $setCaptcha = true;
                 }
                 if ($dao->is_update_dupe) {
                     $this->_isUpdateDupe = true;
                 }
             }
         }
         if ($setCaptcha) {
             require_once 'CRM/Utils/ReCAPTCHA.php';
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign("isCaptcha", true);
         }
     }
     if ($this->_mode != self::MODE_SEARCH) {
         if (isset($addToGroupId)) {
             $this->add('hidden', "group[{$addToGroupId}]", 1);
             $this->_addToGroupID = $addToGroupId;
         }
     }
     // also do state country js
     require_once 'CRM/Core/BAO/Address.php';
     CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap, $this->_defaults);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, null);
     if ($this->_mode == self::MODE_CREATE) {
         require_once 'CRM/Core/BAO/CMSUser.php';
         CRM_Core_BAO_CMSUser::buildForm($this, $this->_gid, $emailPresent, $action);
     } else {
         $this->assign('showCMS', false);
     }
     $this->assign('groupId', $this->_gid);
     // now fix all state country selectors
     require_once 'CRM/Core/BAO/Address.php';
     CRM_Core_BAO_Address::fixAllStateSelects($this, $this->_defaults);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
     }
     if ($this->_context == 'dialog') {
         $this->addElement('submit', $this->_duplicateButtonName, ts('Save Matching Contact'));
     }
 }
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Contribute/BAO/PCP.php';
     $id = CRM_Contribute_BAO_PCP::getSupporterProfileId($this->_pageId);
     if (CRM_Contribute_BAO_PCP::checkEmailProfile($id)) {
         $this->assign('profileDisplay', true);
     }
     $fields = null;
     require_once "CRM/Core/BAO/UFGroup.php";
     if ($this->_contactID) {
         if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
             $fields = CRM_Core_BAO_UFGroup::getFields($id, false, CRM_Core_Action::ADD);
         }
         $this->addFormRule(array('CRM_Contribute_Form_PCP_PCPAccount', 'formRule'), $this);
     } else {
         require_once 'CRM/Core/BAO/CMSUser.php';
         CRM_Core_BAO_CMSUser::buildForm($this, $id, true);
         $fields = CRM_Core_BAO_UFGroup::getFields($id, false, CRM_Core_Action::ADD);
     }
     if ($fields) {
         $this->assign('fields', $fields);
         $addCaptcha = false;
         foreach ($fields as $key => $field) {
             if (isset($field['data_type']) && $field['data_type'] == 'File') {
                 // ignore file upload fields
                 continue;
             }
             require_once "CRM/Core/BAO/UFGroup.php";
             require_once "CRM/Profile/Form.php";
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
             $this->_fields[$key] = $field;
             if ($field['add_captcha']) {
                 $addCaptcha = true;
             }
         }
         if ($addCaptcha) {
             require_once 'CRM/Utils/ReCAPTCHA.php';
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign("isCaptcha", true);
         }
     }
     require_once "CRM/Contribute/PseudoConstant.php";
     $this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
     if ($this->_single) {
         $button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     } else {
         $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true);
     }
     $this->addFormRule(array('CRM_Contribute_Form_PCP_PCPAccount', 'formRule'), $this);
     $this->addButtons($button);
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_ppType) {
         return CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     }
     $config = CRM_Core_Config::singleton();
     if (CRM_Utils_Array::value('is_for_organization', $this->_values) == 2) {
         $this->assign('onBehalfRequired', TRUE);
         $this->_onBehalfRequired = 1;
     }
     if ($this->_onbehalf) {
         $this->assign('onbehalf', TRUE);
         return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), TRUE);
     $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     $this->_paymentProcessors = $this->get('paymentProcessors');
     $pps = array();
     if (!empty($this->_paymentProcessors)) {
         $pps = $this->_paymentProcessors;
         foreach ($pps as $key => &$name) {
             $pps[$key] = $name['name'];
         }
     }
     if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
         $pps[0] = $this->_values['pay_later_text'];
     }
     if (count($pps) > 1) {
         $this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, "&nbsp;", TRUE);
     } elseif (!empty($pps)) {
         $key = array_pop(array_keys($pps));
         $this->addElement('hidden', 'payment_processor', $key);
         if ($key === 0) {
             $this->assign('is_pay_later', $this->_values['is_pay_later']);
             $this->assign('pay_later_text', $this->_values['pay_later_text']);
         }
     }
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         $this->_separateMembershipPayment = FALSE;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, TRUE, NULL, FALSE, $isTest, $this->_membershipContactID);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         CRM_Price_BAO_Set::buildPriceSet($this);
         if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
             self::buildRecur($this);
         }
     } elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
         $this->buildAmount($this->_separateMembershipPayment);
     }
     if ($this->_priceSetId) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $this->_useForMember = 0;
             $this->set('useForMember', $this->_useForMember);
         }
     }
     if ($this->_values['is_for_organization']) {
         $this->buildOnBehalfOrganization();
     }
     //we allow premium for pledge during pledge creation only.
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
     }
     if ($this->_values['honor_block_is_active']) {
         $this->buildHonorBlock();
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     if (!empty($this->_fields)) {
         $profileAddressFields = array();
         foreach ($this->_fields as $key => $value) {
             CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
         }
         $this->set('profileAddressFields', $profileAddressFields);
     }
     //to create an cms user
     if (!$this->_userID) {
         $createCMSUser = FALSE;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             if (!is_array($this->_values['custom_post_id'])) {
                 $profileIDs = array($this->_values['custom_post_id']);
             } else {
                 $profileIDs = $this->_values['custom_post_id'];
             }
             foreach ($profileIDs as $pid) {
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
                     $profileID = $pid;
                     $createCMSUser = TRUE;
                     break;
                 }
             }
         }
         if ($createCMSUser) {
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         }
     }
     if ($this->_pcpId) {
         if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
             $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
         }
         $this->assign('pcp', TRUE);
         $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
         $extraOption = array('onclick' => "return pcpAnonymous( );");
         $elements = array();
         $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
         $this->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
         $this->_defaults['pcp_is_anonymous'] = 0;
         $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     }
     //we have to load confirm contribution button in template
     //when multiple payment processor as the user
     //can toggle with payment processor selection
     $billingModePaymentProcessors = 0;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $values) {
             if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
                 $billingModePaymentProcessors++;
             }
         }
     }
     if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
         $allAreBillingModeProcessors = TRUE;
     } else {
         $allAreBillingModeProcessors = FALSE;
     }
     if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }
Beispiel #9
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     $contactID = parent::getContactID();
     if ($contactID) {
         require_once "CRM/Contact/BAO/Contact.php";
         $name = CRM_Contact_BAO_Contact::displayName($contactID);
         $this->assign('display_name', $name);
         $this->assign('contact_id', $contactID);
     }
     $config = CRM_Core_Config::singleton();
     $this->add('hidden', 'scriptFee', null);
     $this->add('hidden', 'scriptArray', null);
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true);
     $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     $bypassPayment = $allowGroupOnWaitlist = $isAdditionalParticipants = false;
     if ($this->_values['event']['is_multiple_registrations']) {
         // don't allow to add additional during confirmation if not preregistered.
         if (!$this->_allowConfirmation || $this->_additionalParticipantIds) {
             // Hardcode maximum number of additional participants here for now. May need to make this configurable per event.
             // Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self")
             $additionalOptions = array('' => ts('1'), 1 => ts('2'), 2 => ts('3'), 3 => ts('4'), 4 => ts('5'), 5 => ts('6'), 6 => ts('7'), 7 => ts('8'), 8 => ts('9'), 9 => ts('10'));
             $element = $this->add('select', 'additional_participants', ts('How many people are you registering?'), $additionalOptions, null, array('onChange' => "allowParticipant()"));
             $isAdditionalParticipants = true;
         }
     }
     //hack to allow group to register w/ waiting
     if ((CRM_Utils_Array::value('is_multiple_registrations', $this->_values['event']) || $this->_priceSetId) && !$this->_allowConfirmation && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $bypassPayment = true;
         //case might be group become as a part of waitlist.
         //If not waitlist then they require admin approve.
         $allowGroupOnWaitlist = true;
         $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations));
         if ($this->_requireApproval) {
             $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration(s) have been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
         }
     }
     //case where only approval needed - no waitlist.
     if ($this->_requireApproval && !$this->_allowWaitlist && !$bypassPayment) {
         $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
     }
     //lets display status to primary page only.
     $this->assign('waitlistMsg', $this->_waitlistMsg);
     $this->assign('requireApprovalMsg', $this->_requireApprovalMsg);
     $this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
     $this->assign('isAdditionalParticipants', $isAdditionalParticipants);
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     //lets get js on two different qf elements.
     $buildExpressPayBlock = false;
     $showHidePayfieldName = null;
     $showHidePaymentInformation = false;
     if ($this->_values['event']['is_monetary']) {
         self::buildAmount($this);
         $attributes = null;
         $freezePayLater = true;
         if (is_array($this->_paymentProcessor)) {
             $freezePayLater = false;
             if (!in_array($this->_paymentProcessor['billing_mode'], array(2, 4))) {
                 $showHidePayfieldName = 'payment_information';
                 $attributes = array('onclick' => "showHidePaymentInfo( );");
             }
             if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal_Express') {
                 $showHidePayfieldName = 'PayPalExpress';
                 $attributes = array('onclick' => "showHidePayPalExpressOption();");
             }
         }
         //lets build only when there is no waiting and no required approval.
         if ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist) {
             if ($this->_values['event']['is_pay_later']) {
                 $element = $this->addElement('checkbox', 'is_pay_later', $this->_values['event']['pay_later_text'], null, $attributes);
                 //if payment processor is not available then freeze
                 //the paylater checkbox with default checked.
                 if ($freezePayLater) {
                     $element->freeze();
                 }
             }
             require_once 'CRM/Core/Payment/Form.php';
             CRM_Core_Payment_Form::buildCreditCard($this);
             if ($showHidePayfieldName == 'payment_information') {
                 $showHidePaymentInformation = true;
             }
             if ($showHidePayfieldName == 'PayPalExpress') {
                 $buildExpressPayBlock = true;
             }
         }
     }
     //lets add some qf element to bypass payment validations, CRM-4320
     if ($bypassPayment) {
         $attributes = null;
         if ($showHidePayfieldName == 'payment_information' && $showHidePaymentInformation) {
             $attributes = array('onclick' => "showHidePaymentInfo();");
         }
         if ($showHidePayfieldName == 'PayPalExpress') {
             $attributes = array('onclick' => "showHidePayPalExpressOption();");
         }
         $this->addElement('hidden', 'bypass_payment', null, array('id' => 'bypass_payment'));
     }
     $this->assign('bypassPayment', $bypassPayment);
     $this->assign('buildExpressPayBlock', $buildExpressPayBlock);
     $this->assign('showHidePaymentInformation', $showHidePaymentInformation);
     $userID = parent::getContactID();
     if (!$userID) {
         $createCMSUser = false;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             $profileID = $this->_values['custom_post_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if ($createCMSUser) {
             require_once 'CRM/Core/BAO/CMSUser.php';
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true);
         }
     }
     if ($this->_paymentProcessor['billing_mode'] != CRM_Core_Payment::BILLING_MODE_BUTTON || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment || !$buildExpressPayBlock) {
         //freeze button to avoid multiple calls.
         $js = null;
         if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
             $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
         }
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true, 'js' => $js)));
     }
     $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     if ($this->_values['is_for_organization'] == 2) {
         $this->assign('onBehalfRequired', true);
     }
     if ($this->_onbehalf) {
         $this->assign('onbehalf', true);
         return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true);
     $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         $this->_separateMembershipPayment = false;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             require_once 'CRM/Member/BAO/Membership.php';
             $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, true, null, false, $isTest, $this->_membershipContactID);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::buildPriceSet($this);
     } else {
         if (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
             $this->buildAmount($this->_separateMembershipPayment);
             if ($this->_values['is_monetary'] && $this->_values['is_recur'] && $this->_paymentProcessor['is_recur']) {
                 self::buildRecur($this);
             }
         }
     }
     if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
         $this->buildPayLater();
     }
     if ($this->_values['is_for_organization']) {
         $this->buildOnBehalfOrganization();
     }
     //we allow premium for pledge during pledge creation only.
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         require_once 'CRM/Contribute/BAO/Premium.php';
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, true);
     }
     if ($this->_values['honor_block_is_active']) {
         $this->buildHonorBlock();
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
             require_once 'CRM/Pledge/BAO/PledgeBlock.php';
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     // doing this later since the express button type depends if there is an upload or not
     if ($this->_values['is_monetary']) {
         require_once 'CRM/Core/Payment/Form.php';
         if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
             CRM_Core_Payment_Form::buildDirectDebit($this);
         } else {
             CRM_Core_Payment_Form::buildCreditCard($this);
         }
     }
     //to create an cms user
     if (!$this->_userID) {
         $createCMSUser = false;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             $profileID = $this->_values['custom_post_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if ($createCMSUser) {
             require_once 'CRM/Core/BAO/CMSUser.php';
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true);
         }
     }
     if ($this->_pcpId) {
         require_once 'CRM/Contribute/BAO/PCP.php';
         if ($pcpSupporter = CRM_Contribute_BAO_PCP::displayName($this->_pcpId)) {
             $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
         }
         $this->assign('pcp', true);
         $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), null, null, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
         $extraOption = array('onclick' => "return pcpAnonymous( );");
         $elements = array();
         $elements[] =& $this->createElement('radio', null, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $this->createElement('radio', null, '', ts('List my contribution anonymously'), 1, $extraOption);
         $this->addGroup($elements, 'pcp_is_anonymous', null, '&nbsp;&nbsp;&nbsp;');
         $this->_defaults['pcp_is_anonymous'] = 0;
         $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     }
     if (!($this->_paymentProcessor['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON && !$this->_values['is_pay_later'])) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true)));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }