public static function allForContact($contactId)
 {
     $statusNames = CRM_Core_OptionGroup::values("pcp_status", FALSE, FALSE, FALSE, NULL, 'name');
     $query = "SELECT\r\n           pcp.id,\r\n           pcp.title,\r\n           pcp.status_id,\r\n           pcp.page_id,\r\n           count(cc.total_amount) as contribution_count,\r\n           sum(cc.total_amount) as amount_raised,\r\n           pcp.goal_amount,\r\n           pcp.currency\r\n      FROM civicrm_pcp pcp\r\n      LEFT JOIN civicrm_contribution_soft cs ON ( pcp.id = cs.pcp_id )\r\n      LEFT JOIN civicrm_contribution cc ON ( cs.contribution_id = cc.id)\r\n      WHERE pcp.contact_id = %1\r\n      GROUP BY pcp.id";
     $cpages = CRM_Core_DAO::executeQuery($query, array(1 => array($contactId, 'Integer')));
     $pages = array();
     while ($cpages->fetch()) {
         $pages[] = array('id' => $cpages->id, 'title' => $cpages->title, 'status' => $statusNames[$cpages->status_id], 'page' => CRM_PCP_BAO_PCP::getPcpPageTitle($cpages->page_id, 'contribute'), 'contribution_count' => $cpages->contribution_count, 'amount_raised' => $cpages->amount_raised, 'goal_amount' => $cpages->goal_amount, 'currency' => $cpages->currency);
     }
     return $pages;
 }
Ejemplo n.º 2
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' => '         ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')));
     } else {
         $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '         ', 'isDefault' => TRUE);
     }
     $this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this);
     $this->addButtons($button);
 }
Ejemplo n.º 3
0
 /**
  * Function used to set defaults for soft credit block.
  *
  * @param $defaults
  * @param $form
  */
 public static function setDefaultValues(&$defaults, &$form)
 {
     //Used to hide/unhide PCP and/or Soft-credit Panes
     $noPCP = $noSoftCredit = TRUE;
     if (!empty($form->_softCreditInfo['soft_credit'])) {
         $noSoftCredit = FALSE;
         foreach ($form->_softCreditInfo['soft_credit'] as $key => $value) {
             $defaults["soft_credit_amount[{$key}]"] = CRM_Utils_Money::format($value['amount'], NULL, '%a');
             $defaults["soft_credit_contact_id[{$key}]"] = $value['contact_id'];
             $defaults["soft_credit_type[{$key}]"] = $value['soft_credit_type'];
         }
     }
     if (!empty($form->_softCreditInfo['pcp_id'])) {
         $noPCP = FALSE;
         $pcpInfo = $form->_softCreditInfo;
         $pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
         $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
         $contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
         $defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
         $defaults['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo);
         $defaults['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo);
         $defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
         $defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
     }
     $form->assign('noSoftCredit', $noSoftCredit);
     $form->assign('noPCP', $noPCP);
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     if ($this->_cdType) {
         $this->assign('cdType', TRUE);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_formType = CRM_Utils_Array::value('formType', $_GET);
     // get price set id.
     $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET);
     $this->set('priceSetId', $this->_priceSetId);
     $this->assign('priceSetId', $this->_priceSetId);
     //get the pledge payment id
     $this->_ppID = CRM_Utils_Request::retrieve('ppid', 'Positive', $this);
     //get the contact id
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //get the action.
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->assign('action', $this->_action);
     //get the contribution id if update
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $this->_context);
     $this->_compId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
     //set the contribution mode.
     $this->_mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
     $this->assign('contributionMode', $this->_mode);
     $this->_paymentProcessor = array('billing_mode' => 1);
     $this->assign('showCheckNumber', FALSE);
     $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
     //ensure that processor has a valid config
     //only valid processors get display to user
     if ($this->_mode) {
         $validProcessors = array();
         $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, "billing_mode IN ( 1, 3 )");
         foreach ($processors as $ppID => $label) {
             $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($ppID, $this->_mode);
             // at this stage only Authorize.net has been tested to support future start dates so if it's enabled let the template know
             // to show receive date
             $processorsSupportingFutureStartDate = array('AuthNet');
             if (in_array($paymentProcessor['payment_processor_type'], $processorsSupportingFutureStartDate)) {
                 $this->assign('processorSupportsFutureStartDate', TRUE);
             }
             if ($paymentProcessor['payment_processor_type'] == 'PayPal' && !$paymentProcessor['user_name']) {
                 continue;
             } elseif ($paymentProcessor['payment_processor_type'] == 'Dummy' && $this->_mode == 'live') {
                 continue;
             } else {
                 $paymentObject = CRM_Core_Payment::singleton($this->_mode, $paymentProcessor, $this);
                 $error = $paymentObject->checkConfig();
                 if (empty($error)) {
                     $validProcessors[$ppID] = $label;
                 }
                 $paymentObject = NULL;
             }
         }
         if (empty($validProcessors)) {
             CRM_Core_Error::fatal(ts('You will need to configure the %1 settings for your Payment Processor before you can submit credit card transactions.', array(1 => $this->_mode)));
         } else {
             $this->_processors = $validProcessors;
         }
         //get the valid recurring processors.
         $recurring = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1');
         $this->_recurPaymentProcessors = array_intersect_assoc($this->_processors, $recurring);
     }
     $this->assign('recurringPaymentProcessorIds', empty($this->_recurPaymentProcessors) ? '' : implode(',', array_keys($this->_recurPaymentProcessors)));
     // this required to show billing block
     $this->assign_by_ref('paymentProcessor', $paymentProcessor);
     $this->assign('hidePayPalExpress', TRUE);
     if ($this->_contactID) {
         list($this->userDisplayName, $this->userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID);
         $this->assign('displayName', $this->userDisplayName);
     }
     // also check for billing information
     // get the billing location type
     $locationTypes = CRM_Core_PseudoConstant::locationType();
     $this->_bltID = array_search('Billing', $locationTypes);
     if (!$this->_bltID) {
         CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
     }
     $this->set('bltID', $this->_bltID);
     $this->assign('bltID', $this->_bltID);
     $this->_fields = array();
     // payment fields are depending on payment type
     if (CRM_Utils_Array::value('payment_type', $this->_processors) & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
         CRM_Core_Payment_Form::setDirectDebitFields($this);
     } else {
         CRM_Core_Payment_Form::setCreditCardFields($this);
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviPledge', $config->enableComponents) && !$this->_formType) {
         //get the payment values associated with given pledge payment id OR check for payments due.
         $this->_pledgeValues = array();
         if ($this->_ppID) {
             $payParams = array('id' => $this->_ppID);
             CRM_Pledge_BAO_PledgePayment::retrieve($payParams, $this->_pledgeValues['pledgePayment']);
             $this->_pledgeID = CRM_Utils_Array::value('pledge_id', $this->_pledgeValues['pledgePayment']);
             $paymentStatusID = CRM_Utils_Array::value('status_id', $this->_pledgeValues['pledgePayment']);
             $this->_id = CRM_Utils_Array::value('contribution_id', $this->_pledgeValues['pledgePayment']);
             //get all status
             $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
             if (!($paymentStatusID == array_search('Pending', $allStatus) || $paymentStatusID == array_search('Overdue', $allStatus))) {
                 CRM_Core_Error::fatal(ts("Pledge payment status should be 'Pending' or  'Overdue'."));
             }
             //get the pledge values associated with given pledge payment.
             $ids = array();
             $pledgeParams = array('id' => $this->_pledgeID);
             CRM_Pledge_BAO_Pledge::getValues($pledgeParams, $this->_pledgeValues, $ids);
             $this->assign('ppID', $this->_ppID);
         } else {
             // Not making a pledge payment, so if adding a new contribution we should check if pledge payment(s) are due for this contact so we can alert the user. CRM-5206
             if (isset($this->_contactID)) {
                 $contactPledges = array();
                 $contactPledges = CRM_Pledge_BAO_Pledge::getContactPledges($this->_contactID);
                 if (!empty($contactPledges)) {
                     $payments = $paymentsDue = NULL;
                     $multipleDue = FALSE;
                     foreach ($contactPledges as $key => $pledgeId) {
                         $payments = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
                         if ($payments) {
                             if ($paymentsDue) {
                                 $multipleDue = TRUE;
                                 break;
                             } else {
                                 $paymentsDue = $payments;
                             }
                         }
                     }
                     if ($multipleDue) {
                         // Show link to pledge tab since more than one pledge has a payment due
                         $pledgeTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=pledge");
                         CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. <a href="%1">Click here to view their Pledges tab</a> and verify whether this contribution should be applied as a pledge payment.', array(1 => $pledgeTab)));
                     } elseif ($paymentsDue) {
                         // Show user link to oldest Pending or Overdue pledge payment
                         $ppAmountDue = CRM_Utils_Money::format($payments['amount'], $payments['currency']);
                         $ppSchedDate = CRM_Utils_Date::customFormat(CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $payments['id'], 'scheduled_date'));
                         if ($this->_mode) {
                             $ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge&mode=live");
                         } else {
                             $ppUrl = CRM_Utils_System::url('civicrm/contact/view/contribution', "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge");
                         }
                         CRM_Core_Session::setStatus(ts('This contact has a pending or overdue pledge payment of %2 which is scheduled for %3. <a href="%1">Click here to enter a pledge payment</a>.', array(1 => $ppUrl, 2 => $ppAmountDue, 3 => $ppSchedDate)));
                     }
                 }
             }
         }
     }
     $this->_values = array();
     // current contribution id
     if ($this->_id) {
         //to get Premium id
         $sql = "\nSELECT *\nFROM   civicrm_contribution_product\nWHERE  contribution_id = {$this->_id}\n";
         $dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
         if ($dao->fetch()) {
             $this->_premiumID = $dao->id;
             $this->_productDAO = $dao;
         }
         $dao->free();
         $ids = array();
         $params = array('id' => $this->_id);
         CRM_Contribute_BAO_Contribution::getValues($params, $this->_values, $ids);
         //do check for online / recurring contributions
         $fids = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnIds($this->_id, 'civicrm_contribution');
         $this->_online = CRM_Utils_Array::value('entityFinancialTrxnId', $fids);
         //don't allow to update all fields for recuring contribution.
         if (!$this->_online) {
             $this->_online = CRM_Utils_Array::value('contribution_recur_id', $this->_values);
         }
         $this->assign('isOnline', $this->_online ? TRUE : FALSE);
         //unset the honor type id:when delete the honor_contact_id
         //and edit the contribution, honoree infomation pane open
         //since honor_type_id is present
         if (!CRM_Utils_Array::value('honor_contact_id', $this->_values)) {
             unset($this->_values['honor_type_id']);
         }
         //to get note id
         $daoNote = new CRM_Core_BAO_Note();
         $daoNote->entity_table = 'civicrm_contribution';
         $daoNote->entity_id = $this->_id;
         if ($daoNote->find(TRUE)) {
             $this->_noteID = $daoNote->id;
             $this->_values['note'] = $daoNote->note;
         }
         $this->_contributionType = $this->_values['contribution_type_id'];
         $csParams = array('contribution_id' => $this->_id);
         $softCredit = CRM_Contribute_BAO_Contribution::getSoftContribution($csParams, TRUE);
         if (CRM_Utils_Array::value('soft_credit_to', $softCredit)) {
             $softCredit['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $softCredit['soft_credit_to'], 'sort_name');
         }
         $this->_values['soft_credit_to'] = CRM_Utils_Array::value('sort_name', $softCredit);
         $this->_values['softID'] = CRM_Utils_Array::value('soft_credit_id', $softCredit);
         $this->_values['soft_contact_id'] = CRM_Utils_Array::value('soft_credit_to', $softCredit);
         if (CRM_Utils_Array::value('pcp_id', $softCredit)) {
             $pcpId = CRM_Utils_Array::value('pcp_id', $softCredit);
             $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
             $contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
             $this->_values['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $softCredit) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
             $this->_values['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $softCredit);
             $this->_values['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $softCredit);
             $this->_values['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $softCredit);
             $this->_values['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $softCredit);
         }
         //display check number field only if its having value or its offline mode.
         if (CRM_Utils_Array::value('payment_instrument_id', $this->_values) == CRM_Core_OptionGroup::getValue('payment_instrument', 'Check', 'name') || CRM_Utils_Array::value('check_number', $this->_values)) {
             $this->assign('showCheckNumber', TRUE);
         }
     }
     // when custom data is included in this page
     if (CRM_Utils_Array::value('hidden_custom', $_POST)) {
         $this->set('type', 'Contribution');
         $this->set('subType', CRM_Utils_Array::value('contribution_type_id', $_POST));
         $this->set('entityId', $this->_id);
         CRM_Custom_Form_CustomData::preProcess($this);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     $this->_lineItems = array();
     if ($this->_id) {
         $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->_id, 'contribution', 1);
         empty($lineItem) ? null : ($this->_lineItems[] = $lineItem);
     }
     $this->assign('lineItem', empty($this->_lineItems) ? FALSE : $this->_lineItems);
 }
function civicrm_api3_pcpteams_delete($params)
{
    //check permission to delete
    $permParams = array('pcp_id' => $params['id']);
    if (!_civicrm_pcpteams_permission_check($permParams, CRM_Core_Permission::EDIT)) {
        return civicrm_api3_create_error('insufficient permission to delete this record');
    }
    $result = array();
    CRM_PCP_BAO_PCP::deleteById($params['id']);
    return civicrm_api3_create_success($result, $params);
}
Ejemplo n.º 6
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $formValues = $this->controller->exportValues($this->_name);
     $formValues['entity_id'] = $this->_entityId;
     $formValues['entity_table'] = $this->_entityTable;
     $formValues['source_contact_id'] = $this->_contactID;
     $formValues['is_test'] = $this->_action ? 1 : 0;
     $formValues['title'] = $this->_title;
     $formValues['campaign_id'] = $this->_campaignId;
     CRM_Friend_BAO_Friend::create($formValues);
     $this->assign('status', 'thankyou');
     $defaults = array();
     $defaults['entity_id'] = $this->_entityId;
     $defaults['entity_table'] = $this->_entityTable;
     CRM_Friend_BAO_Friend::getValues($defaults);
     if ($this->_entityTable == 'civicrm_pcp') {
         $defaults['thankyou_text'] = $defaults['thankyou_title'] = ts('Thank you for your support');
         $defaults['thankyou_text'] = ts('Thanks for supporting this campaign by spreading the word to your friends.');
     } elseif ($this->_entityTable == 'civicrm_contribution_page') {
         // If this is tell a friend after contributing, give donor link to create their own fundraising page
         if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) {
             $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$defaults['entity_id']}&component=contribute", FALSE, NULL, TRUE, TRUE);
             $this->assign('linkTextUrl', $linkTextUrl);
             $this->assign('linkText', $linkText);
         }
     } elseif ($this->_entityTable == 'civicrm_event') {
         // If this is tell a friend after registering for an event, give donor link to create their own fundraising page
         require_once 'CRM/PCP/BAO/PCP.php';
         if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($defaults['entity_id'], $defaults['entity_table'])) {
             $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$defaults['entity_id']}&component=event", FALSE, NULL, TRUE, TRUE);
             $this->assign('linkTextUrl', $linkTextUrl);
             $this->assign('linkText', $linkText);
         }
     }
     CRM_Utils_System::setTitle($defaults['thankyou_title']);
     $this->assign('thankYouText', $defaults['thankyou_text']);
 }
Ejemplo n.º 7
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, "&nbsp;");
     } 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);
 }
Ejemplo n.º 8
0
 /**
  * Browse all custom data groups.
  *
  *
  * @param null $action
  *
  * @return void
  * @access public
  * @static
  */
 function browse($action = NULL)
 {
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     if ($this->_sortByCharacter == 1 || !empty($_POST)) {
         $this->_sortByCharacter = '';
     }
     $status = CRM_PCP_BAO_PCP::buildOptions('status_id', 'create');
     $pcpSummary = $params = array();
     $whereClause = NULL;
     if (!empty($_POST) || !empty($_GET['page_type'])) {
         if (!empty($_POST['status_id'])) {
             $whereClause = ' AND cp.status_id = %1';
             $params['1'] = array($_POST['status_id'], 'Integer');
         }
         if (!empty($_POST['page_type'])) {
             $whereClause .= ' AND cp.page_type = %2';
             $params['2'] = array($_POST['page_type'], 'String');
         } elseif (!empty($_GET['page_type'])) {
             $whereClause .= ' AND cp.page_type = %2';
             $params['2'] = array($_GET['page_type'], 'String');
         }
         if (!empty($_POST['page_id'])) {
             $whereClause .= ' AND cp.page_id = %4 AND cp.page_type = "contribute"';
             $params['4'] = array($_POST['page_id'], 'Integer');
         }
         if (!empty($_POST['event_id'])) {
             $whereClause .= ' AND cp.page_id = %5 AND cp.page_type = "event"';
             $params['5'] = array($_POST['event_id'], 'Integer');
         }
         if ($whereClause) {
             $this->set('whereClause', $whereClause);
             $this->set('params', $params);
         } else {
             $this->set('whereClause', NULL);
             $this->set('params', NULL);
         }
     }
     $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
     //check for delete CRM-4418
     $allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
     // get all contribution pages
     $query = "SELECT id, title, start_date, end_date FROM civicrm_contribution_page WHERE (1)";
     $cpages = CRM_Core_DAO::executeQuery($query);
     while ($cpages->fetch()) {
         $pages['contribute'][$cpages->id]['id'] = $cpages->id;
         $pages['contribute'][$cpages->id]['title'] = $cpages->title;
         $pages['contribute'][$cpages->id]['start_date'] = $cpages->start_date;
         $pages['contribute'][$cpages->id]['end_date'] = $cpages->end_date;
     }
     // get all event pages. pcp campaign start and end dates for event related pcp's use the online registration start and end dates,
     // altho if target is contribution page this might not be correct. fixme? dgg
     $query = "SELECT id, title, start_date, end_date, registration_start_date, registration_end_date\n                  FROM civicrm_event\n                  WHERE is_template IS NULL OR is_template != 1";
     $epages = CRM_Core_DAO::executeQuery($query);
     while ($epages->fetch()) {
         $pages['event'][$epages->id]['id'] = $epages->id;
         $pages['event'][$epages->id]['title'] = $epages->title;
         $pages['event'][$epages->id]['start_date'] = $epages->registration_start_date;
         $pages['event'][$epages->id]['end_date'] = $epages->registration_end_date;
     }
     $params = $this->get('params') ? $this->get('params') : array();
     $title = '1';
     if ($this->_sortByCharacter !== NULL) {
         $clauses[] = "cp.title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
     }
     $query = "\n        SELECT cp.id, cp.contact_id , cp.status_id, cp.title, cp.is_active, cp.page_type, cp.page_id\n        FROM civicrm_pcp cp\n        WHERE {$title}" . $this->get('whereClause') . " ORDER BY cp.status_id";
     $pcp = CRM_Core_DAO::executeQuery($query, $params);
     while ($pcp->fetch()) {
         $action = array_sum(array_keys($this->links()));
         $contact = CRM_Contact_BAO_Contact::getDisplayAndImage($pcp->contact_id);
         $class = '';
         if ($pcp->status_id != $approvedId || $pcp->is_active != 1) {
             $class = 'disabled';
         }
         switch ($pcp->status_id) {
             case 2:
                 $action -= CRM_Core_Action::RENEW;
                 break;
             case 3:
                 $action -= CRM_Core_Action::REVERT;
                 break;
         }
         switch ($pcp->is_active) {
             case 1:
                 $action -= CRM_Core_Action::ENABLE;
                 break;
             case 0:
                 $action -= CRM_Core_Action::DISABLE;
                 break;
         }
         if (!$allowToDelete) {
             $action -= CRM_Core_Action::DELETE;
         }
         $page_type = $pcp->page_type;
         $page_id = (int) $pcp->page_id;
         if ($pages[$page_type][$page_id]['title'] == '' || $pages[$page_type][$page_id]['title'] == NULL) {
             $title = '(no title found for ' . $page_type . ' id ' . $page_id . ')';
         } else {
             $title = $pages[$page_type][$page_id]['title'];
         }
         if ($pcp->page_type == 'contribute') {
             $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/transact', 'reset=1&id=' . $pcp->page_id);
         } else {
             $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/register', 'reset=1&id=' . $pcp->page_id);
         }
         $pcpSummary[$pcp->id] = array('id' => $pcp->id, 'start_date' => $pages[$page_type][$page_id]['start_date'], 'end_date' => $pages[$page_type][$page_id]['end_date'], 'supporter' => $contact['0'], 'supporter_id' => $pcp->contact_id, 'status_id' => $status[$pcp->status_id], 'page_id' => $page_id, 'page_title' => $title, 'page_url' => $pageUrl, 'page_type' => $page_type, 'action' => CRM_Core_Action::formLink(self::links(), $action, array('id' => $pcp->id), ts('more'), FALSE, 'contributionpage.pcp.list', 'PCP', $pcp->id), 'title' => $pcp->title, 'class' => $class);
     }
     $this->search();
     $this->pagerAToZ($this->get('whereClause'), $params);
     $this->assign('rows', $pcpSummary);
     // Let template know if user has run a search or not
     if ($this->get('whereClause')) {
         $this->assign('isSearch', 1);
     } else {
         $this->assign('isSearch', 0);
     }
 }
Ejemplo n.º 9
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  * Finally it calls the parent's run method.
  *
  * @param
  *
  * @return void
  * @access public
  */
 function run()
 {
     // get the requested action
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     if ($action & CRM_Core_Action::REVERT) {
         $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
         CRM_PCP_BAO_PCP::setIsActive($id, 0);
         $session = CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
     } elseif ($action & CRM_Core_Action::RENEW) {
         $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
         CRM_PCP_BAO_PCP::setIsActive($id, 1);
         $session = CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
     } elseif ($action & CRM_Core_Action::DELETE) {
         $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
         $session = CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse'));
         $controller = new CRM_Core_Controller_Simple('CRM_PCP_Form_PCP', 'Personal Campaign Page', CRM_Core_Action::DELETE);
         //$this->setContext( $id, $action );
         $controller->set('id', $id);
         $controller->process();
         return $controller->run();
     }
     // finally browse
     $this->browse();
     // parent run
     parent::run();
 }
Ejemplo n.º 10
0
 /**
  * Validation.
  *
  * @param array $params
  *   (ref.) an assoc array of name/value pairs.
  *
  * @param $files
  * @param $self
  *
  * @return bool|array
  *   mixed true or array of errors
  */
 public static function formRule($params, $files, $self)
 {
     $errors = array();
     if (!empty($params['is_active'])) {
         if (!empty($params['is_tellfriend_enabled']) && CRM_Utils_Array::value('tellfriend_limit', $params) <= 0) {
             $errors['tellfriend_limit'] = ts('if Tell Friend is enabled, Maximum recipients limit should be greater than zero.');
         }
         if (empty($params['supporter_profile_id'])) {
             $errors['supporter_profile_id'] = ts('Supporter profile is a required field.');
         } else {
             if (CRM_PCP_BAO_PCP::checkEmailProfile($params['supporter_profile_id'])) {
                 $errors['supporter_profile_id'] = ts('Profile is not configured with Email address.');
             }
         }
         if ($emails = CRM_Utils_Array::value('notify_email', $params)) {
             $emailArray = explode(',', $emails);
             foreach ($emailArray as $email) {
                 if ($email && !CRM_Utils_Rule::email(trim($email))) {
                     $errors['notify_email'] = ts('A valid Notify Email address must be specified');
                 }
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
Ejemplo n.º 11
0
 /**
  * Process the form
  *
  * @param null
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_PCP_BAO_PCP::deleteById($this->_id);
         CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $this->_title)), ts('Page Deleted'), 'success');
     } else {
         $params = $this->controller->exportValues($this->_name);
         $parent = $this->controller->getParent();
         if (!empty($params)) {
             $fields = array('status_id', 'page_id');
             foreach ($fields as $field) {
                 if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field])) {
                     $parent->set($field, $params[$field]);
                 } else {
                     $parent->set($field, NULL);
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * 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);
 }
Ejemplo n.º 13
0
 /**
  * Function used to set defaults for soft credit block
  */
 static function setDefaultValues(&$defaults, &$form)
 {
     if (!empty($form->_softCreditInfo['soft_credit'])) {
         foreach ($form->_softCreditInfo['soft_credit'] as $key => $value) {
             $defaults["soft_credit_amount[{$key}]"] = CRM_Utils_Money::format($value['amount'], NULL, '%a');
             $defaults["soft_credit_contact_select_id[{$key}]"] = $value['contact_id'];
             $defaults["soft_credit_type[{$key}]"] = $value['soft_credit_type'];
         }
     } elseif (!empty($form->_softCreditInfo['pcp_id'])) {
         $pcpInfo = $form->_softCreditInfo;
         $pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo);
         $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title');
         $contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute');
         $defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle;
         $defaults['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo);
         $defaults['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo);
         $defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo);
         $defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo);
     }
 }
Ejemplo n.º 14
0
 /**
  * Function to build user dashboard
  *
  * @return void
  * @access public
  */
 function buildUserDashBoard()
 {
     //build component selectors
     $dashboardElements = array();
     $config = CRM_Core_Config::singleton();
     $this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'user_dashboard_options');
     $components = CRM_Core_Component::getEnabledComponents();
     $this->assign('contactId', $this->_contactId);
     foreach ($components as $name => $component) {
         $elem = $component->getUserDashboardElement();
         if (!$elem) {
             continue;
         }
         if (!empty($this->_userOptions[$name]) && (CRM_Core_Permission::access($component->name) || CRM_Core_Permission::check($elem['perm'][0]))) {
             $userDashboard = $component->getUserDashboardObject();
             $dashboardElements[] = array('class' => 'crm-dashboard-' . strtolower($component->name), 'sectionTitle' => $elem['title'], 'templatePath' => $userDashboard->getTemplateFileName(), 'weight' => $elem['weight']);
             $userDashboard->run();
         }
     }
     if (!empty($this->_userOptions['Permissioned Orgs'])) {
         $dashboardElements[] = array('class' => 'crm-dashboard-permissionedOrgs', 'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl', 'sectionTitle' => ts('Your Contacts / Organizations'), 'weight' => 40);
     }
     if (!empty($this->_userOptions['PCP'])) {
         $dashboardElements[] = array('class' => 'crm-dashboard-pcp', 'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl', 'sectionTitle' => ts('Personal Campaign Pages'), 'weight' => 40);
         list($pcpBlock, $pcpInfo) = CRM_PCP_BAO_PCP::getPcpDashboardInfo($this->_contactId);
         $this->assign('pcpBlock', $pcpBlock);
         $this->assign('pcpInfo', $pcpInfo);
     }
     if (!empty($this->_userOptions['Assigned Activities'])) {
         // Assigned Activities section
         $dashboardElements[] = array('class' => 'crm-dashboard-assignedActivities', 'templatePath' => 'CRM/Activity/Page/UserDashboard.tpl', 'sectionTitle' => ts('Your Assigned Activities'), 'weight' => 5);
         $userDashboard = new CRM_Activity_Page_UserDashboard();
         $userDashboard->run();
     }
     usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc'));
     $this->assign('dashboardElements', $dashboardElements);
     if (!empty($this->_userOptions['Groups'])) {
         $this->assign('showGroup', TRUE);
         //build group selector
         $gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
         $gContact->run();
     } else {
         $this->assign('showGroup', FALSE);
     }
 }
Ejemplo n.º 15
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     //CRM-4320
     $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     $this->_lineItem = $this->get('lineItem');
     $this->_isEventFull = $this->get('isEventFull');
     $this->_lineItemParticipantsCount = $this->get('lineItemParticipants');
     if (!is_array($this->_lineItem)) {
         $this->_lineItem = array();
     }
     if (!is_array($this->_lineItemParticipantsCount)) {
         $this->_lineItemParticipantsCount = array();
     }
     $this->_availableRegistrations = $this->get('availableRegistrations');
     $this->_participantIDS = $this->get('participantIDs');
     //check if participant allow to walk registration wizard.
     $this->_allowConfirmation = $this->get('allowConfirmation');
     // check for Approval
     $this->_requireApproval = $this->get('requireApproval');
     // check for waitlisting.
     $this->_allowWaitlist = $this->get('allowWaitlist');
     $this->_forcePayement = $this->get('forcePayement');
     //get the additional participant ids.
     $this->_additionalParticipantIds = $this->get('additionalParticipantIds');
     $config = CRM_Core_Config::singleton();
     if (!$this->_values) {
         // create redirect URL to send folks back to event info page is registration not available
         $infoUrl = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}", FALSE, NULL, FALSE, TRUE);
         // this is the first time we are hitting this, so check for permissions here
         if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId, 'register for events')) {
             CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
         }
         // get all the values from the dao object
         $this->_values = $this->_fields = array();
         $this->_forcePayement = FALSE;
         //retrieve event information
         $params = array('id' => $this->_eventId);
         CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
         $this->checkValidEvent($infoUrl);
         // get the participant values, CRM-4320
         $this->_allowConfirmation = FALSE;
         if ($this->_participantId) {
             $this->processFirstParticipant($this->_participantId);
         }
         //check for additional participants.
         if ($this->_allowConfirmation && $this->_values['event']['is_multiple_registrations']) {
             $additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
             $cnt = 1;
             foreach ($additionalParticipantIds as $additionalParticipantId) {
                 $this->_additionalParticipantIds[$cnt] = $additionalParticipantId;
                 $cnt++;
             }
             $this->set('additionalParticipantIds', $this->_additionalParticipantIds);
         }
         $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->_allowWaitlist = $this->_isEventFull = FALSE;
         if ($eventFull && !$this->_allowConfirmation) {
             $this->_isEventFull = TRUE;
             //lets redirecting to info only when to waiting list.
             $this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']);
             if (!$this->_allowWaitlist) {
                 CRM_Utils_System::redirect($infoUrl);
             }
         }
         $this->set('isEventFull', $this->_isEventFull);
         $this->set('allowWaitlist', $this->_allowWaitlist);
         //check for require requires approval.
         $this->_requireApproval = FALSE;
         if (!empty($this->_values['event']['requires_approval']) && !$this->_allowConfirmation) {
             $this->_requireApproval = TRUE;
         }
         $this->set('requireApproval', $this->_requireApproval);
         if (isset($this->_values['event']['default_role_id'])) {
             $participant_role = CRM_Core_OptionGroup::values('participant_role');
             $this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
         }
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']);
         $isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'is_pay_later');
         //check for variour combination for paylater, payment
         //process with paid event.
         if ($isMonetary && (!$isPayLater || !empty($this->_values['event']['payment_processor']))) {
             $ppID = CRM_Utils_Array::value('payment_processor', $this->_values['event']);
             if (!$ppID) {
                 CRM_Core_Error::statusBounce(ts('A payment processor must be selected for this event registration page, or the event must be configured to give users the option to pay later (contact the site administrator for assistance).'), $infoUrl);
             }
             $ppIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ppID);
             $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPayments($ppIds, $this->_mode);
             $this->set('paymentProcessors', $this->_paymentProcessors);
             //set default payment processor
             if (!empty($this->_paymentProcessors) && empty($this->_paymentProcessor)) {
                 foreach ($this->_paymentProcessors as $ppId => $values) {
                     if ($values['is_default'] == 1 || count($this->_paymentProcessors) == 1) {
                         $defaultProcessorId = $ppId;
                         break;
                     }
                 }
             }
             if (isset($defaultProcessorId)) {
                 $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode);
             }
             // make sure we have a valid payment class, else abort
             if ($this->_values['event']['is_monetary']) {
                 if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
                     foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
                         // check selected payment processor is active
                         if (!$eachPaymentProcessor) {
                             CRM_Core_Error::fatal(ts('The site administrator must set a Payment Processor for this event in order to use online registration.'));
                         }
                         // ensure that processor has a valid config
                         $payment = CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
                         $error = $payment->checkConfig();
                         if (!empty($error)) {
                             CRM_Core_Error::fatal($error);
                         }
                     }
                 }
             }
         }
         //init event fee.
         self::initEventFee($this, $this->_eventId);
         // get the profile ids
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
         list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // set profiles for additional participants
         if ($this->_values['event']['is_multiple_registrations']) {
             // CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
             $ufJoinParams['module'] = 'CiviEvent_Additional';
             list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
             // CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
             // set same profile for additional contacts.
             if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
                 $this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
             }
             if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
                 $this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
             }
             // now check for no profile condition, in that case is_active = 0
             if (isset($preActive) && !$preActive) {
                 unset($this->_values['additional_custom_pre_id']);
             }
             if (isset($postActive) && !$postActive) {
                 unset($this->_values['additional_custom_post_id']);
             }
         }
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts from Billing as the location type can not be translated in CiviCRM!
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         if ($this->_values['event']['is_monetary'] && $this->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
             CRM_Core_Payment_Form::setCreditCardFields($this);
         }
         $params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
         $this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
         $this->set('values', $this->_values);
         $this->set('fields', $this->_fields);
         $this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->set('availableRegistrations', $this->_availableRegistrations);
     }
     $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
     // check if this is a paypal auto return and redirect accordingly
     if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
         $url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
         CRM_Utils_System::redirect($url);
     }
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
     // setting CMS page title
     CRM_Utils_System::setTitle($this->_values['event']['title']);
     $this->assign('title', $this->_values['event']['title']);
     $this->assign('paidEvent', $this->_values['event']['is_monetary']);
     // we do not want to display recently viewed items on Registration pages
     $this->assign('displayRecent', FALSE);
     // Registration page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     // Handle PCP
     $pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
     if ($pcpId) {
         $pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
         $this->_pcpId = $pcp['pcpId'];
         $this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
     }
     // assign all event properties so wizard templates can display event info.
     $this->assign('event', $this->_values['event']);
     $this->assign('location', $this->_values['location']);
     $this->assign('bltID', $this->_bltID);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     //CRM-6907
     $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
     //lets allow user to override campaign.
     $campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
     if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
         $this->_values['event']['campaign_id'] = $campID;
     }
 }
Ejemplo n.º 16
0
 /**
  * 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);
     }
 }
Ejemplo n.º 17
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // Source
     $params['entity_table'] = 'civicrm_contribution_page';
     $params['entity_id'] = $this->_id;
     // Target
     $params['target_entity_type'] = CRM_Utils_Array::value('target_entity_type', $params, 'contribute');
     $params['target_entity_id'] = $this->_id;
     $dao = new CRM_PCP_DAO_PCPBlock();
     $dao->entity_table = $params['entity_table'];
     $dao->entity_id = $this->_id;
     $dao->find(TRUE);
     $params['id'] = $dao->id;
     $params['is_active'] = CRM_Utils_Array::value('pcp_active', $params, FALSE);
     $params['is_approval_needed'] = CRM_Utils_Array::value('is_approval_needed', $params, FALSE);
     $params['is_tellfriend_enabled'] = CRM_Utils_Array::value('is_tellfriend_enabled', $params, FALSE);
     $dao = CRM_PCP_BAO_PCP::add($params);
     parent::endPostProcess();
 }
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active', 'is_notify');
     foreach ($checkBoxes as $key) {
         if (!isset($params[$key])) {
             $params[$key] = 0;
         }
     }
     $session = CRM_Core_Session::singleton();
     $contactID = isset($this->_contactID) ? $this->_contactID : $session->get('userID');
     if (!$contactID) {
         $contactID = $this->get('contactID');
     }
     $params['title'] = $params['pcp_title'];
     $params['intro_text'] = $params['pcp_intro_text'];
     $params['contact_id'] = $contactID;
     $params['page_id'] = $this->get('component_page_id') ? $this->get('component_page_id') : $this->_contriPageId;
     $params['page_type'] = $this->_component;
     // since we are allowing html input from the user
     // we also need to purify it, so lets clean it up
     $htmlFields = array('intro_text', 'page_text', 'title');
     foreach ($htmlFields as $field) {
         if (!empty($params[$field])) {
             $params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
         }
     }
     $entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
     $pcpBlock = new CRM_PCP_DAO_PCPBlock();
     $pcpBlock->entity_table = $entity_table;
     $pcpBlock->entity_id = $params['page_id'];
     $pcpBlock->find(TRUE);
     $params['pcp_block_id'] = $pcpBlock->id;
     $params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
     $approval_needed = $pcpBlock->is_approval_needed;
     $approvalMessage = NULL;
     if ($this->get('action') & CRM_Core_Action::ADD) {
         $params['status_id'] = $approval_needed ? 1 : 2;
         $approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin promoting your campaign. You will receive an email confirmation shortly which includes a link to return to this page.') : ts('and is ready to use.');
     }
     $params['id'] = $this->_pageId;
     $pcp = CRM_PCP_BAO_PCP::add($params, FALSE);
     //create page in wordpress
     create_wp_campaign($pcp->title, $pcp->contact_id, $pcp->id);
     CRM_Core_Error::debug_log_message("Calling create_wp_campaign.... Params title: {$pcp->title}, contact_id: {$pcp->contact_id}, pcp_id: {$pcp->id} ");
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
     $pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
     $statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id');
     //send notification of PCP create/update.
     $pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id);
     $notifyParams = array();
     $notifyStatus = "";
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
     if ($emails = $pcpBlock->notify_email) {
         $this->assign('pcpTitle', $pcp->title);
         if ($this->_pageId) {
             $this->assign('mode', 'Update');
         } else {
             $this->assign('mode', 'Add');
         }
         $pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
         $this->assign('pcpStatus', $pcpStatus);
         $this->assign('pcpId', $pcp->id);
         $supporterUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$pcp->contact_id}", TRUE, NULL, FALSE, FALSE);
         $this->assign('supporterUrl', $supporterUrl);
         $supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
         $this->assign('supporterName', $supporterName);
         if ($this->_component == 'contribute') {
             $pageUrl = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
             $contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcpBlock->entity_id, 'title');
         } elseif ($this->_component == 'event') {
             $pageUrl = CRM_Utils_System::url('civicrm/event', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
             $contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpBlock->entity_id, 'title');
         }
         $this->assign('contribPageUrl', $pageUrl);
         $this->assign('contribPageTitle', $contribPageTitle);
         $managePCPUrl = CRM_Utils_System::url('civicrm/admin/pcp', "reset=1", TRUE, NULL, FALSE, FALSE);
         $this->assign('managePCPUrl', $managePCPUrl);
         //get the default domain email address.
         list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
         if (!$domainEmailAddress || $domainEmailAddress == '*****@*****.**') {
             $fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
             CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
         }
         //if more than one email present for PCP notification ,
         //first email take it as To and other as CC and First email
         //address should be sent in users email receipt for
         //support purpose.
         $emailArray = explode(',', $emails);
         $to = $emailArray[0];
         unset($emailArray[0]);
         $cc = implode(',', $emailArray);
         list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $to, 'cc' => $cc));
         if ($sent) {
             $notifyStatus = ts('A notification email has been sent to the site administrator.');
         }
     }
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_pcp', $pcp->id);
     // send email notification to supporter, if initial setup / add mode.
     if (!$this->_pageId) {
         CRM_PCP_BAO_PCP::sendStatusUpdate($pcp->id, $statusId, TRUE, $this->_component);
         if ($approvalMessage && CRM_Utils_Array::value('status_id', $params) == 1) {
             $notifyStatus .= ts(' You will receive a second email as soon as the review process is complete.');
         }
     }
     //check if pcp created by anonymous user
     $anonymousPCP = 0;
     if (!$session->get('userID')) {
         $anonymousPCP = 1;
     }
     CRM_Core_Session::setStatus(ts("Your Personal Campaign Page has been %1 %2 %3", array(1 => $pageStatus, 2 => $approvalMessage, 3 => $notifyStatus)), '', 'info');
     if (!$this->_pageId) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$pcp->id}&ap={$anonymousPCP}"));
     } elseif ($this->_context == 'dashboard') {
         $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/pcp', 'reset=1'));
     }
 }
Ejemplo n.º 19
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  * Finally it calls the parent's run method.
  *
  * @return void
  */
 public function run()
 {
     $session = CRM_Core_Session::singleton();
     $config = CRM_Core_Config::singleton();
     $permissionCheck = FALSE;
     $statusMessage = '';
     if ($config->userFramework != 'Joomla') {
         $permissionCheck = CRM_Core_Permission::check('administer CiviCRM');
     }
     //get the pcp id.
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     $prms = array('id' => $this->_id);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
     $this->_component = $pcpInfo['page_type'];
     if (empty($pcpInfo)) {
         $statusMessage = ts('The personal campaign page you requested is currently unavailable.');
         CRM_Core_Error::statusBounce($statusMessage, $config->userFrameworkBaseURL);
     }
     CRM_Utils_System::setTitle($pcpInfo['title']);
     $this->assign('pcp', $pcpInfo);
     $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
     $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
     // check if PCP is created by anonymous user
     $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this);
     if ($anonymousPCP) {
         $loginURL = $config->userSystem->getLoginURL();
         $anonMessage = ts('Once you\'ve received your new account welcome email, you can <a href=%1>click here</a> to login and promote your campaign page.', array(1 => $loginURL));
         CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success');
     } else {
         $statusMessage = ts('The personal campaign page you requested is currently unavailable. However you can still support the campaign by making a contribution here.');
     }
     $pcpBlock = new CRM_PCP_DAO_PCPBlock();
     $pcpBlock->entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($pcpInfo['page_type']);
     $pcpBlock->entity_id = $pcpInfo['page_id'];
     $pcpBlock->find(TRUE);
     // Redirect back to source page in case of error.
     if ($pcpInfo['page_type'] == 'contribute') {
         $urlBase = 'civicrm/contribute/transact';
     } elseif ($pcpInfo['page_type'] == 'event') {
         $urlBase = 'civicrm/event/register';
     }
     if ($pcpInfo['status_id'] != $approvedId || !$pcpInfo['is_active']) {
         if ($pcpInfo['contact_id'] != $session->get('userID') && !$permissionCheck) {
             CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, "reset=1&id=" . $pcpInfo['page_id'], FALSE, NULL, FALSE, TRUE));
         }
     } else {
         $getStatus = CRM_PCP_BAO_PCP::getStatus($this->_id, $this->_component);
         if (!$getStatus) {
             // PCP not enabled for this contribution page. Forward everyone to source page
             CRM_Core_Error::statusBounce($statusMessage, CRM_Utils_System::url($urlBase, "reset=1&id=" . $pcpInfo['page_id'], FALSE, NULL, FALSE, TRUE));
         }
     }
     $default = array();
     if ($pcpBlock->target_entity_type == 'contribute') {
         $urlBase = 'civicrm/contribute/transact';
     } elseif ($pcpBlock->target_entity_type == 'event') {
         $urlBase = 'civicrm/event/register';
     }
     if ($pcpBlock->entity_table == 'civicrm_event') {
         $page_class = 'CRM_Event_DAO_Event';
         $this->assign('pageName', CRM_Event_PseudoConstant::event($pcpInfo['page_id']));
         CRM_Core_DAO::commonRetrieveAll($page_class, 'id', $pcpInfo['page_id'], $default, array('start_date', 'end_date', 'registration_start_date', 'registration_end_date'));
     } elseif ($pcpBlock->entity_table == 'civicrm_contribution_page') {
         $page_class = 'CRM_Contribute_DAO_ContributionPage';
         $this->assign('pageName', CRM_Contribute_PseudoConstant::contributionPage($pcpInfo['page_id'], TRUE));
         CRM_Core_DAO::commonRetrieveAll($page_class, 'id', $pcpInfo['page_id'], $default, array('start_date', 'end_date'));
     }
     $pageInfo = $default[$pcpInfo['page_id']];
     if ($pcpInfo['contact_id'] == $session->get('userID')) {
         $owner = $pageInfo;
         $owner['status'] = CRM_Utils_Array::value($pcpInfo['status_id'], $pcpStatus);
         $this->assign('owner', $owner);
         $link = CRM_PCP_BAO_PCP::pcpLinks();
         $hints = array(CRM_Core_Action::UPDATE => ts('Change the content and appearance of your page'), CRM_Core_Action::DETACH => ts('Send emails inviting your friends to support your campaign!'), CRM_Core_Action::VIEW => ts('Copy this link to share directly with your network!'), CRM_Core_Action::BROWSE => ts('Update your personal contact information'), CRM_Core_Action::DISABLE => ts('De-activate the page (you can re-activate it later)'), CRM_Core_Action::ENABLE => ts('Activate the page (you can de-activate it later)'), CRM_Core_Action::DELETE => ts('Remove the page (this cannot be undone!)'));
         $replace = array('id' => $this->_id, 'block' => $pcpBlock->id, 'pageComponent' => $this->_component);
         if (!$pcpBlock->is_tellfriend_enabled || CRM_Utils_Array::value('status_id', $pcpInfo) != $approvedId) {
             unset($link['all'][CRM_Core_Action::DETACH]);
         }
         switch ($pcpInfo['is_active']) {
             case 1:
                 unset($link['all'][CRM_Core_Action::ENABLE]);
                 break;
             case 0:
                 unset($link['all'][CRM_Core_Action::DISABLE]);
                 break;
         }
         $this->assign('links', $link['all']);
         $this->assign('hints', $hints);
         $this->assign('replace', $replace);
     }
     $honor = CRM_PCP_BAO_PCP::honorRoll($this->_id);
     $entityFile = CRM_Core_BAO_File::getEntityFile('civicrm_pcp', $this->_id);
     if (!empty($entityFile)) {
         $fileInfo = reset($entityFile);
         $fileId = $fileInfo['fileID'];
         $image = '<img src="' . CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$this->_id}") . '" />';
         $this->assign('image', $image);
     }
     $totalAmount = CRM_PCP_BAO_PCP::thermoMeter($this->_id);
     $achieved = round($totalAmount / $pcpInfo['goal_amount'] * 100, 2);
     if ($pcpBlock->is_active == 1) {
         $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$pcpInfo['page_id']}&component={$pcpInfo['page_type']}", TRUE, NULL, TRUE, TRUE);
         $this->assign('linkTextUrl', $linkTextUrl);
         $this->assign('linkText', $pcpBlock->link_text);
     }
     $this->assign('honor', $honor);
     $this->assign('total', $totalAmount ? $totalAmount : '0.0');
     $this->assign('achieved', $achieved <= 100 ? $achieved : 100);
     if ($achieved <= 100) {
         $this->assign('remaining', 100 - $achieved);
     }
     // make sure that we are between contribution page start and end dates OR registration start date and end dates if they are set
     if ($pcpBlock->entity_table == 'civicrm_event') {
         $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $pageInfo));
         $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_end_date', $pageInfo));
     } else {
         $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('start_date', $pageInfo));
         $endDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('end_date', $pageInfo));
     }
     $now = time();
     $validDate = TRUE;
     if ($startDate && $startDate >= $now) {
         $validDate = FALSE;
     }
     if ($endDate && $endDate < $now) {
         $validDate = FALSE;
     }
     $this->assign('validDate', $validDate);
     // form parent page url
     if ($action == CRM_Core_Action::PREVIEW) {
         $parentUrl = CRM_Utils_System::url($urlBase, "id={$pcpInfo['page_id']}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
     } else {
         $parentUrl = CRM_Utils_System::url($urlBase, "id={$pcpInfo['page_id']}&reset=1", TRUE, NULL, TRUE, TRUE);
     }
     $this->assign('parentURL', $parentUrl);
     if ($validDate) {
         $contributionText = ts('Contribute Now');
         if (!empty($pcpInfo['donate_link_text'])) {
             $contributionText = $pcpInfo['donate_link_text'];
         }
         $this->assign('contributionText', $contributionText);
         // we always generate urls for the front end in joomla
         if ($action == CRM_Core_Action::PREVIEW) {
             $url = CRM_Utils_System::url($urlBase, "id=" . $pcpBlock->target_entity_id . "&pcpId={$this->_id}&reset=1&action=preview", TRUE, NULL, TRUE, TRUE);
         } else {
             $url = CRM_Utils_System::url($urlBase, "id=" . $pcpBlock->target_entity_id . "&pcpId={$this->_id}&reset=1", TRUE, NULL, TRUE, TRUE);
         }
         $this->assign('contributeURL', $url);
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', FALSE);
     $single = $permission = FALSE;
     switch ($action) {
         case CRM_Core_Action::BROWSE:
             $subForm = 'PCPAccount';
             $form = "CRM_PCP_Form_{$subForm}";
             $single = TRUE;
             break;
         case CRM_Core_Action::UPDATE:
             $subForm = 'Campaign';
             $form = "CRM_PCP_Form_{$subForm}";
             $single = TRUE;
             break;
     }
     $userID = $session->get('userID');
     //make sure the user has "administer CiviCRM" permission
     //OR has created the PCP
     if (CRM_Core_Permission::check('administer CiviCRM') || $userID && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $this->_id, 'contact_id') == $userID) {
         $permission = TRUE;
     }
     if ($single && $permission) {
         $controller = new CRM_Core_Controller_Simple($form, $subForm, $action);
         $controller->set('id', $this->_id);
         $controller->set('single', TRUE);
         $controller->process();
         return $controller->run();
     }
     $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&id=' . $this->_id));
     parent::run();
 }
Ejemplo n.º 20
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     // current contribution page id
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!$this->_id) {
         // seems like the session is corrupted and/or we lost the id trail
         // lets just bump this to a regular session error and redirect user to main page
         $this->controller->invalidKeyRedirect();
     }
     // this was used prior to the cleverer this_>getContactID - unsure now
     $this->_userID = $session->get('userID');
     $this->_contactID = $this->_membershipContactID = $this->getContactID();
     $this->_mid = NULL;
     if ($this->_contactID) {
         $this->_mid = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
         if ($this->_mid) {
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $this->_mid;
             if ($membership->find(TRUE)) {
                 $this->_defaultMemTypeId = $membership->membership_type_id;
                 if ($membership->contact_id != $this->_contactID) {
                     $validMembership = FALSE;
                     $employers = CRM_Contact_BAO_Relationship::getPermissionedEmployer($this->_userID);
                     if (!empty($employers) && array_key_exists($membership->contact_id, $employers)) {
                         $this->_membershipContactID = $membership->contact_id;
                         $this->assign('membershipContactID', $this->_membershipContactID);
                         $this->assign('membershipContactName', $employers[$this->_membershipContactID]['name']);
                         $validMembership = TRUE;
                     } else {
                         $membershipType = new CRM_Member_BAO_MembershipType();
                         $membershipType->id = $membership->membership_type_id;
                         if ($membershipType->find(TRUE)) {
                             // CRM-14051 - membership_type.relationship_type_id is a CTRL-A padded string w one or more ID values.
                             // Convert to commma separated list.
                             $inheritedRelTypes = implode(CRM_Utils_Array::explodePadded($membershipType->relationship_type_id), ',');
                             $permContacts = CRM_Contact_BAO_Relationship::getPermissionedContacts($this->_userID, $membershipType->relationship_type_id);
                             if (array_key_exists($membership->contact_id, $permContacts)) {
                                 $this->_membershipContactID = $membership->contact_id;
                                 $validMembership = TRUE;
                             }
                         }
                     }
                     if (!$validMembership) {
                         CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
                     }
                 }
             } else {
                 CRM_Core_Session::setStatus(ts("Oops. The membership you're trying to renew appears to be invalid. Contact your site administrator if you need assistance. If you continue, you will be issued a new membership."), ts('Membership Invalid'), 'alert');
             }
             unset($membership);
         }
     }
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', FALSE);
     // Contribution page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     // action
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->assign('action', $this->_action);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     if (!$this->_values) {
         // get all the values from the dao object
         $this->_values = array();
         $this->_fields = array();
         CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values);
         // check if form is active
         if (!CRM_Utils_Array::value('is_active', $this->_values)) {
             // form is inactive, die a fatal death
             CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
         }
         // also check for billing informatin
         // get the billing location type
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate');
         // CRM-8108 remove ts around Billing location type
         //$this->_bltID = array_search( ts('Billing'),  $locationTypes );
         $this->_bltID = array_search('Billing', $locationTypes);
         if (!$this->_bltID) {
             CRM_Core_Error::fatal(ts('Please set a location type of %1', array(1 => 'Billing')));
         }
         $this->set('bltID', $this->_bltID);
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values);
         $isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values);
         //FIXME: to support multiple payment processors
         if ($isMonetary && (!$isPayLater || CRM_Utils_Array::value('payment_processor', $this->_values))) {
             $ppID = CRM_Utils_Array::value('payment_processor', $this->_values);
             if (!$ppID) {
                 CRM_Core_Error::fatal(ts('A payment processor must be selected for this contribution page (contact the site administrator for assistance).'));
             }
             $ppIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ppID);
             $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPayments($ppIds, $this->_mode);
             $this->set('paymentProcessors', $this->_paymentProcessors);
             //set default payment processor
             if (!empty($this->_paymentProcessors) && empty($this->_paymentProcessor)) {
                 foreach ($this->_paymentProcessors as $ppId => $values) {
                     if ($values['is_default'] == 1 || count($this->_paymentProcessors) == 1) {
                         $defaultProcessorId = $ppId;
                         break;
                     }
                 }
             }
             if (isset($defaultProcessorId)) {
                 $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($defaultProcessorId, $this->_mode);
                 $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
             }
             if (!CRM_Utils_System::isNull($this->_paymentProcessors)) {
                 foreach ($this->_paymentProcessors as $eachPaymentProcessor) {
                     // check selected payment processor is active
                     if (empty($eachPaymentProcessor)) {
                         CRM_Core_Error::fatal(ts('A payment processor configured for this page might be disabled (contact the site administrator for assistance).'));
                     }
                     // ensure that processor has a valid config
                     $this->_paymentObject =& CRM_Core_Payment::singleton($this->_mode, $eachPaymentProcessor, $this);
                     $error = $this->_paymentObject->checkConfig();
                     if (!empty($error)) {
                         CRM_Core_Error::fatal($error);
                     }
                 }
             }
         }
         // get price info
         // CRM-5095
         CRM_Price_BAO_PriceSet::initSet($this, $this->_id, 'civicrm_contribution_page');
         // this avoids getting E_NOTICE errors in php
         $setNullFields = array('amount_block_is_active', 'honor_block_is_active', 'is_allow_other_amount', 'footer_text');
         foreach ($setNullFields as $f) {
             if (!isset($this->_values[$f])) {
                 $this->_values[$f] = NULL;
             }
         }
         //check if Membership Block is enabled, if Membership Fields are included in profile
         //get membership section for this contribution page
         $this->_membershipBlock = CRM_Member_BAO_Membership::getMembershipBlock($this->_id);
         $this->set('membershipBlock', $this->_membershipBlock);
         if ($this->_values['custom_pre_id']) {
             $preProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_pre_id']);
         }
         if ($this->_values['custom_post_id']) {
             $postProfileType = CRM_Core_BAO_UFField::getProfileType($this->_values['custom_post_id']);
         }
         if ((isset($postProfileType) && $postProfileType == 'Membership' || isset($preProfileType) && $preProfileType == 'Membership') && !$this->_membershipBlock['is_active']) {
             CRM_Core_Error::fatal(ts('This page includes a Profile with Membership fields - but the Membership Block is NOT enabled. Please notify the site administrator.'));
         }
         $pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id);
         if ($pledgeBlock) {
             $this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock);
             $this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock);
             $this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock);
             $this->_values['additional_reminder_day'] = CRM_Utils_Array::value('additional_reminder_day', $pledgeBlock);
             //set pledge id in values
             $pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this);
             //authenticate pledge user for pledge payment.
             if ($pledgeId) {
                 $this->_values['pledge_id'] = $pledgeId;
                 //lets override w/ pledge campaign.
                 $this->_values['campaign_id'] = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge', $pledgeId, 'campaign_id');
                 self::authenticatePledgeUser();
             }
         }
         $this->set('values', $this->_values);
         $this->set('fields', $this->_fields);
     }
     // Handle PCP
     $pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
     if ($pcpId) {
         $pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'contribute', $this->_values);
         $this->_pcpId = $pcp['pcpId'];
         $this->_pcpBlock = $pcp['pcpBlock'];
         $this->_pcpInfo = $pcp['pcpInfo'];
     }
     // Link (button) for users to create their own Personal Campaign page
     if ($linkText = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute')) {
         $linkTextUrl = CRM_Utils_System::url('civicrm/contribute/campaign', "action=add&reset=1&pageId={$this->_id}&component=contribute", FALSE, NULL, TRUE);
         $this->assign('linkTextUrl', $linkTextUrl);
         $this->assign('linkText', $linkText);
     }
     //set pledge block if block id is set
     if (CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
         $this->assign('pledgeBlock', TRUE);
     }
     // check if one of the (amount , membership)  bloks is active or not
     $this->_membershipBlock = $this->get('membershipBlock');
     if (!$this->_values['amount_block_is_active'] && !$this->_membershipBlock['is_active'] && !$this->_priceSetId) {
         CRM_Core_Error::fatal(ts('The requested online contribution page is missing a required Contribution Amount section or Membership section or Price Set. Please check with the site administrator for assistance.'));
     }
     if ($this->_values['amount_block_is_active']) {
         $this->set('amount_block_is_active', $this->_values['amount_block_is_active']);
     }
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
     //assigning is_monetary and is_email_receipt to template
     $this->assign('is_monetary', $this->_values['is_monetary']);
     $this->assign('is_email_receipt', $this->_values['is_email_receipt']);
     $this->assign('bltID', $this->_bltID);
     //assign cancelSubscription URL to templates
     $this->assign('cancelSubscriptionUrl', CRM_Utils_Array::value('cancelSubscriptionUrl', $this->_values));
     // assigning title to template in case someone wants to use it, also setting CMS page title
     if ($this->_pcpId) {
         $this->assign('title', $this->_pcpInfo['title']);
         CRM_Utils_System::setTitle($this->_pcpInfo['title']);
     } else {
         $this->assign('title', $this->_values['title']);
         CRM_Utils_System::setTitle($this->_values['title']);
     }
     $this->_defaults = array();
     $this->_amount = $this->get('amount');
     //CRM-6907
     $config = CRM_Core_Config::singleton();
     $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values, $config->defaultCurrency);
     //lets allow user to override campaign.
     $campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
     if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
         $this->_values['campaign_id'] = $campID;
     }
     //do check for cancel recurring and clean db, CRM-7696
     if (CRM_Utils_Request::retrieve('cancel', 'Boolean', CRM_Core_DAO::$_nullObject)) {
         self::cancelRecurring();
     }
 }
Ejemplo n.º 21
0
 function testDeletePCP()
 {
     $pcp = CRM_Core_DAO::createTestObject('CRM_PCP_DAO_PCP');
     $pcpId = $pcp->id;
     $del = CRM_PCP_BAO_PCP::deleteById($pcpId);
     $this->assertDBRowNotExist('CRM_PCP_DAO_PCP', $pcpId, 'Database check PCP deleted successfully.');
 }
Ejemplo n.º 22
0
Archivo: PCP.php Proyecto: kidaa30/yes
 /**
  * Add PCP form elements to a form.
  *
  * @param int $pcpId
  * @param CRM_Core_Page $page
  * @param null $elements
  */
 public static function buildPcp($pcpId, &$page, &$elements = NULL)
 {
     $prms = array('id' => $pcpId);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
     if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) {
         if ($pcpInfo['page_type'] == 'event') {
             $pcp_supporter_text = ts('This event registration is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event');
             if (!empty($text)) {
                 $pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!";
             }
         } else {
             $pcp_supporter_text = ts('This contribution is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute');
             if (!empty($text)) {
                 $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!";
             }
         }
         $page->assign('pcpSupporterText', $pcp_supporter_text);
     }
     $page->assign('pcp', TRUE);
     // build honor roll fields for registration form if supporter has honor roll enabled for their PCP
     if ($pcpInfo['is_honor_roll']) {
         $page->assign('is_honor_roll', TRUE);
         $page->add('checkbox', 'pcp_display_in_roll', ts('Show my support 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[] =& $page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption);
         $page->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
         $page->_defaults['pcp_is_anonymous'] = 0;
         $page->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $page->add('textarea', "pcp_personal_note", ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     } else {
         $page->assign('is_honor_roll', FALSE);
     }
 }
Ejemplo n.º 23
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // Source
     $params['entity_table'] = 'civicrm_event';
     $params['entity_id'] = $this->_id;
     // Target
     $params['target_entity_type'] = CRM_Utils_Array::value('target_entity_type', $params, 'event');
     if ($params['target_entity_type'] == 'event') {
         $params['target_entity_id'] = $this->_id;
     } else {
         $params['target_entity_id'] = CRM_Utils_Array::value('target_entity_id', $params, $this->_id);
     }
     $dao = new CRM_PCP_DAO_PCPBlock();
     $dao->entity_table = $params['entity_table'];
     $dao->entity_id = $this->_id;
     $dao->find(TRUE);
     $params['id'] = $dao->id;
     $params['is_active'] = CRM_Utils_Array::value('pcp_active', $params, FALSE);
     $params['is_approval_needed'] = CRM_Utils_Array::value('is_approval_needed', $params, FALSE);
     $params['is_tellfriend_enabled'] = CRM_Utils_Array::value('is_tellfriend_enabled', $params, FALSE);
     $dao = CRM_PCP_BAO_PCP::add($params);
     // Update tab "disabled" css class
     $this->ajaxResponse['tabValid'] = !empty($params['is_active']);
     parent::endPostProcess();
 }
Ejemplo n.º 24
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $this->_eventId = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     //CRM-4320
     $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
     // current mode
     $this->_mode = $this->_action == 1024 ? 'test' : 'live';
     $this->_values = $this->get('values');
     $this->_fields = $this->get('fields');
     $this->_bltID = $this->get('bltID');
     $this->_paymentProcessor = $this->get('paymentProcessor');
     $this->_priceSetId = $this->get('priceSetId');
     $this->_priceSet = $this->get('priceSet');
     $this->_lineItem = $this->get('lineItem');
     $this->_isEventFull = $this->get('isEventFull');
     $this->_lineItemParticipantsCount = $this->get('lineItemParticipants');
     if (!is_array($this->_lineItem)) {
         $this->_lineItem = array();
     }
     if (!is_array($this->_lineItemParticipantsCount)) {
         $this->_lineItemParticipantsCount = array();
     }
     $this->_availableRegistrations = $this->get('availableRegistrations');
     $this->_participantIDS = $this->get('participantIDs');
     //check if participant allow to walk registration wizard.
     $this->_allowConfirmation = $this->get('allowConfirmation');
     // check for Approval
     $this->_requireApproval = $this->get('requireApproval');
     // check for waitlisting.
     $this->_allowWaitlist = $this->get('allowWaitlist');
     $this->_forcePayement = $this->get('forcePayement');
     //get the additional participant ids.
     $this->_additionalParticipantIds = $this->get('additionalParticipantIds');
     $config = CRM_Core_Config::singleton();
     if (!$this->_values) {
         // create redirect URL to send folks back to event info page is registration not available
         $infoUrl = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_eventId}", FALSE, NULL, FALSE, TRUE);
         // this is the first time we are hitting this, so check for permissions here
         if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId, 'register for events')) {
             CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
         }
         // get all the values from the dao object
         $this->_values = $this->_fields = array();
         $this->_forcePayement = FALSE;
         //retrieve event information
         $params = array('id' => $this->_eventId);
         CRM_Event_BAO_Event::retrieve($params, $this->_values['event']);
         // check for is_monetary status
         $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']);
         // check for ability to add contributions of type
         if ($isMonetary && CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('add contributions of type ' . CRM_Contribute_PseudoConstant::financialType($this->_values['event']['financial_type_id']))) {
             CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
         }
         $this->checkValidEvent($infoUrl);
         // get the participant values, CRM-4320
         $this->_allowConfirmation = FALSE;
         if ($this->_participantId) {
             $this->processFirstParticipant($this->_participantId);
         }
         //check for additional participants.
         if ($this->_allowConfirmation && $this->_values['event']['is_multiple_registrations']) {
             $additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId);
             $cnt = 1;
             foreach ($additionalParticipantIds as $additionalParticipantId) {
                 $this->_additionalParticipantIds[$cnt] = $additionalParticipantId;
                 $cnt++;
             }
             $this->set('additionalParticipantIds', $this->_additionalParticipantIds);
         }
         $eventFull = CRM_Event_BAO_Participant::eventFull($this->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->_allowWaitlist = $this->_isEventFull = FALSE;
         if ($eventFull && !$this->_allowConfirmation) {
             $this->_isEventFull = TRUE;
             //lets redirecting to info only when to waiting list.
             $this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']);
             if (!$this->_allowWaitlist) {
                 CRM_Utils_System::redirect($infoUrl);
             }
         }
         $this->set('isEventFull', $this->_isEventFull);
         $this->set('allowWaitlist', $this->_allowWaitlist);
         //check for require requires approval.
         $this->_requireApproval = FALSE;
         if (!empty($this->_values['event']['requires_approval']) && !$this->_allowConfirmation) {
             $this->_requireApproval = TRUE;
         }
         $this->set('requireApproval', $this->_requireApproval);
         if (isset($this->_values['event']['default_role_id'])) {
             $participant_role = CRM_Core_OptionGroup::values('participant_role');
             $this->_values['event']['participant_role'] = $participant_role["{$this->_values['event']['default_role_id']}"];
         }
         $isPayLater = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'is_pay_later');
         //check for various combinations for paylater, payment
         //process with paid event.
         if ($isMonetary && (!$isPayLater || !empty($this->_values['event']['payment_processor']))) {
             $this->_paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values['event']));
             $this->assignPaymentProcessor($isPayLater);
         }
         //init event fee.
         self::initEventFee($this, $this->_eventId);
         // get the profile ids
         $ufJoinParams = array('entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $this->_eventId);
         list($this->_values['custom_pre_id'], $this->_values['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
         // set profiles for additional participants
         if ($this->_values['event']['is_multiple_registrations']) {
             // CRM-4377: CiviEvent for the main participant, CiviEvent_Additional for additional participants
             $ufJoinParams['module'] = 'CiviEvent_Additional';
             list($this->_values['additional_custom_pre_id'], $this->_values['additional_custom_post_id'], $preActive, $postActive) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
             // CRM-4377: we need to maintain backward compatibility, hence if there is profile for main contact
             // set same profile for additional contacts.
             if ($this->_values['custom_pre_id'] && !$this->_values['additional_custom_pre_id']) {
                 $this->_values['additional_custom_pre_id'] = $this->_values['custom_pre_id'];
             }
             if ($this->_values['custom_post_id'] && !$this->_values['additional_custom_post_id']) {
                 $this->_values['additional_custom_post_id'] = $this->_values['custom_post_id'];
             }
             // now check for no profile condition, in that case is_active = 0
             if (isset($preActive) && !$preActive) {
                 unset($this->_values['additional_custom_pre_id']);
             }
             if (isset($postActive) && !$postActive) {
                 unset($this->_values['additional_custom_post_id']);
             }
         }
         $this->assignBillingType();
         if ($this->_values['event']['is_monetary']) {
             CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
         }
         $params = array('entity_id' => $this->_eventId, 'entity_table' => 'civicrm_event');
         $this->_values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE);
         $this->set('values', $this->_values);
         $this->set('fields', $this->_fields);
         $this->_availableRegistrations = CRM_Event_BAO_Participant::eventFull($this->_values['event']['id'], TRUE, CRM_Utils_Array::value('has_waitlist', $this->_values['event']));
         $this->set('availableRegistrations', $this->_availableRegistrations);
     }
     $this->assign_by_ref('paymentProcessor', $this->_paymentProcessor);
     // check if this is a paypal auto return and redirect accordingly
     if (CRM_Core_Payment::paypalRedirect($this->_paymentProcessor)) {
         $url = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$this->controller->_key}");
         CRM_Utils_System::redirect($url);
     }
     // The concept of contributeMode is deprecated.
     $this->_contributeMode = $this->get('contributeMode');
     $this->assign('contributeMode', $this->_contributeMode);
     // setting CMS page title
     CRM_Utils_System::setTitle($this->_values['event']['title']);
     $this->assign('title', $this->_values['event']['title']);
     $this->assign('paidEvent', $this->_values['event']['is_monetary']);
     // we do not want to display recently viewed items on Registration pages
     $this->assign('displayRecent', FALSE);
     // Registration page values are cleared from session, so can't use normal Printer Friendly view.
     // Use Browser Print instead.
     $this->assign('browserPrint', TRUE);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     // Handle PCP
     $pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this);
     if ($pcpId) {
         $pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']);
         $this->_pcpId = $pcp['pcpId'];
         $this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']);
     }
     // assign all event properties so wizard templates can display event info.
     $this->assign('event', $this->_values['event']);
     $this->assign('location', $this->_values['location']);
     $this->assign('bltID', $this->_bltID);
     $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']);
     $this->assign('isShowLocation', $isShowLocation);
     //CRM-6907
     $config->defaultCurrency = CRM_Utils_Array::value('currency', $this->_values['event'], $config->defaultCurrency);
     //lets allow user to override campaign.
     $campID = CRM_Utils_Request::retrieve('campID', 'Positive', $this);
     if ($campID && CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Campaign', $campID)) {
         $this->_values['event']['campaign_id'] = $campID;
     }
     // Set the same value for is_billing_required as contribution page so code can be shared.
     $this->_values['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
     // check if billing block is required for pay later
     // note that I have started removing the use of isBillingAddressRequiredForPayLater in favour of letting
     // the CRM_Core_Payment_Manual class handle it - but there are ~300 references to it in the code base so only
     // removing in very limited cases.
     if (CRM_Utils_Array::value('is_pay_later', $this->_values['event'])) {
         $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']);
         $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater);
     }
 }
 static function getPcpBlockId($eventId, $component = 'event')
 {
     if (empty($eventId)) {
         return null;
     }
     $entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($component);
     $pcpBlock = new CRM_PCP_DAO_PCPBlock();
     $pcpBlock->entity_table = $entity_table;
     $pcpBlock->entity_id = $eventId;
     $pcpBlock->find(TRUE);
     return $pcpBlock->id;
 }