Пример #1
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     self::preProcessPaymentOptions($this);
     // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject));
     // Possible values for 'is_for_organization':
     // * 0 - org profile disabled
     // * 1 - org profile optional
     // * 2 - org profile required
     $this->_onbehalf = FALSE;
     if (!empty($this->_values['is_for_organization'])) {
         if ($this->_values['is_for_organization'] == 2) {
             $this->_onBehalfRequired = TRUE;
         }
         // Add organization profile if 1 of the following are true:
         // If the org profile is required
         if ($this->_onBehalfRequired || empty($_POST) || !empty($_POST['is_for_organization'])) {
             $this->_onbehalf = TRUE;
             CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         }
     }
     $this->assign('onBehalfRequired', $this->_onBehalfRequired);
     if ($this->_honor_block_is_active) {
         CRM_Contact_Form_ProfileContact::preprocess($this);
     }
     if ($this->_snippet) {
         $this->assign('isOnBehalfCallback', CRM_Utils_Array::value('onbehalf', $_GET, FALSE));
         return;
     }
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     //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', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
         $onBehalfProfileIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // getUFGroupIDs returns an array with the first item being the ID we need
         $onBehalfProfileID = $onBehalfProfileIDs[0];
         if ($onBehalfProfileID) {
             $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($onBehalfProfileID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $onBehalfProfile) && (in_array('Membership', $onBehalfProfile) || in_array('Contribution', $onBehalfProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_ppType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('ppType', FALSE);
     if ($this->_ppType) {
         $this->assign('ppType', TRUE);
         return CRM_Core_Payment_ProcessorForm::preProcess($this);
     }
     //get payPal express id and make it available to template
     $paymentProcessors = $this->get('paymentProcessors');
     if (!empty($paymentProcessors)) {
         foreach ($paymentProcessors as $ppId => $values) {
             $payPalExpressId = $values['payment_processor_type'] == 'PayPal_Express' ? $values['id'] : 0;
             $this->assign('payPalExpressId', $payPalExpressId);
             if ($payPalExpressId) {
                 break;
             }
         }
     }
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE, $this->_userID);
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($csContactID != $this->_userID) {
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     $this->_onbehalf = FALSE;
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}";
         $this->assign('urlParams', $urlParams);
         $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET);
         CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && (CRM_Utils_Array::value('is_for_organization', $_POST) || CRM_Utils_Array::value('is_for_organization', $this->_values) == 2)) {
             CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (CRM_Utils_Array::value('intro_text', $this->_values)) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('hidden_processor', $_POST)) {
         $this->set('type', CRM_Utils_Array::value('payment_processor', $_POST));
         $this->set('mode', $this->_mode);
         $this->set('paymentProcessor', $this->_paymentProcessor);
         CRM_Core_Payment_ProcessorForm::preProcess($this);
         CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     }
 }
Пример #3
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     self::preProcessPaymentOptions($this);
     // Make the contributionPageID avilable to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     // make sure we have right permission to edit this user
     $csContactID = $this->getContactID();
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     // Possible values for 'is_for_organization':
     // * 0 - org profile disabled
     // * 1 - org profile optional
     // * 2 - org profile required
     $this->_onbehalf = FALSE;
     if (!empty($this->_values['is_for_organization'])) {
         if ($this->_values['is_for_organization'] == 2) {
             $this->_onBehalfRequired = TRUE;
         }
         // Add organization profile if 1 of the following are true:
         // If the org profile is required
         if ($this->_onBehalfRequired || empty($_POST) || !empty($_POST['is_for_organization'])) {
             $this->_onbehalf = TRUE;
             CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         }
     }
     $this->assign('onBehalfRequired', $this->_onBehalfRequired);
     if (!empty($this->_values['honor_block_is_active'])) {
         CRM_Contact_Form_ProfileContact::preprocess($this);
     }
     if ($this->_snippet) {
         $this->assign('isOnBehalfCallback', CRM_Utils_Array::value('onbehalf', $_GET, FALSE));
         return;
     }
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if (!empty($this->_values['is_for_organization'])) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public 
  */
 public function preProcess()
 {
     parent::preProcess();
     // make sure we have right permission to edit this user
     $csContactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false, $this->_userID);
     $reset = CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject);
     $mainDisplay = CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject);
     require_once 'CRM/Contact/BAO/Contact.php';
     if ($csContactID != $this->_userID) {
         require_once 'CRM/Contact/BAO/Contact/Permission.php';
         if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactID, $this)) {
             $session = CRM_Core_Session::singleton();
             $session->set('userID', $csContactID);
             $this->_userID = $csContactID;
         }
     }
     if ($reset) {
         $this->assign('reset', $reset);
     }
     if ($mainDisplay) {
         $this->assign('mainDisplay', $mainDisplay);
     }
     $this->_onbehalf = false;
     if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
         $urlParams = "&id={$this->_id}&qfKey={$this->controller->_key}";
         $this->assign('urlParams', $urlParams);
         $this->_onbehalf = CRM_Utils_Array::value('onbehalf', $_GET);
         require_once 'CRM/Contribute/Form/Contribution/OnBehalfOf.php';
         CRM_Contribute_Form_Contribution_OnBehalfOf::preProcess($this);
         if (CRM_Utils_Array::value('hidden_onbehalf_profile', $_POST) && CRM_Utils_Array::value('is_for_organization', $_POST)) {
             CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
         }
     }
     if (CRM_Utils_Array::value('id', $this->_pcpInfo) && CRM_Utils_Array::value('intro_text', $this->_pcpInfo)) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } else {
         if (CRM_Utils_Array::value('intro_text', $this->_values)) {
             $this->assign('intro_text', $this->_values['intro_text']);
         }
     }
     if (CRM_Utils_Array::value('footer_text', $this->_values)) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
     //CRM-5001
     if ($this->_values['is_for_organization']) {
         $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.');
         require_once 'CRM/Core/BAO/UFGroup.php';
         if ($preID = CRM_Utils_Array::value('custom_pre_id', $this->_values)) {
             $preProfile = CRM_Core_BAO_UFGroup::profileGroups($preID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $preProfile) && (in_array('Membership', $preProfile) || in_array('Contribution', $preProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
         if ($postID = CRM_Utils_Array::value('custom_post_id', $this->_values)) {
             $postProfile = CRM_Core_BAO_UFGroup::profileGroups($postID);
             foreach (array('Individual', 'Organization', 'Household') as $contactType) {
                 if (in_array($contactType, $postProfile) && (in_array('Membership', $postProfile) || in_array('Contribution', $postProfile))) {
                     CRM_Core_Error::fatal($msg);
                 }
             }
         }
     }
 }