Beispiel #1
0
/**
 * Add an execute function for nsynch
 * http://booki.flossmanuals.net/civicrm-developer-guide/api/
 */
function civicrm_api3_nsynch_user($params)
{
    // execute function
    try {
        // execute
        CRM_Core_BAO_CMSUser::synchronize(FALSE);
        return civicrm_api3_create_success($values, $params);
    } catch (Exception $e) {
        // exception
        return civicrm_api3_create_error('Caught exception: ', $e->getMessage(), '\\n');
    }
}
 /**
  * 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
  * @access public
  *
  */
 function run()
 {
     //if javascript is enabled
     if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', $this, '', '', 'GET')) {
         CRM_Core_BAO_CMSUser::synchronize();
         return;
     }
     $controller = new CRM_Core_Controller_Simple('CRM_Admin_Form_CMSUser', 'Synchronize CMS Users');
     // set the userContext stack
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
     $controller->setEmbedded(TRUE);
     $controller->process();
     $controller->run();
     return parent::run();
 }
 /**
  * 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, " ");
         } 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' => '         ', 'isDefault' => TRUE, 'js' => $js)));
     }
     $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
     // add pcp fields
     if ($this->_pcpId) {
         CRM_PCP_BAO_PCP::buildPcp($this->_pcpId, $this);
     }
 }
Beispiel #4
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);
 }
Beispiel #5
0
 /**
  * update the uf_name in the user object
  *
  * @param int    $contactId id of the contact to update
  *
  * @return void
  * @access public
  * @static
  */
 static function updateUFName($contactId)
 {
     if (!$contactId) {
         return;
     }
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Standalone') {
         $ufName = CRM_Contact_BAO_Contact::getPrimaryOpenId($contactId);
     } else {
         $ufName = CRM_Contact_BAO_Contact::getPrimaryEmail($contactId);
     }
     if (!$ufName) {
         return;
     }
     $update = false;
     // 1.do check for contact Id.
     $ufmatch = new CRM_Core_DAO_UFMatch();
     $ufmatch->contact_id = $contactId;
     $ufmatch->domain_id = CRM_Core_Config::domainID();
     if (!$ufmatch->find(true)) {
         return;
     }
     if ($ufmatch->uf_name != $ufName) {
         $update = true;
     }
     // CRM-6928
     // 2.do check for duplicate ufName.
     $ufDupeName = new CRM_Core_DAO_UFMatch();
     $ufDupeName->uf_name = $ufName;
     $ufDupeName->domain_id = CRM_Core_Config::domainID();
     if ($ufDupeName->find(true) && $ufDupeName->contact_id != $contactId) {
         $update = false;
     }
     if (!$update) {
         return;
     }
     // save the updated ufmatch object
     $ufmatch->uf_name = $ufName;
     $ufmatch->save();
     require_once 'CRM/Core/BAO/CMSUser.php';
     CRM_Core_BAO_CMSUser::updateUFName($ufmatch->uf_id, $ufName);
 }
Beispiel #6
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     // build profiles first so that we can determine address fields etc
     // and then show copy address checkbox
     if (empty($this->_ccid)) {
         $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
         $this->buildCustom($this->_values['custom_post_id'], 'customPost');
         // CRM-18399: used by template to pass pre profile id as a url arg
         $this->assign('custom_pre_id', $this->_values['custom_pre_id']);
         $this->buildComponentForm($this->_id, $this);
     }
     // Build payment processor form
     CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     $config = CRM_Core_Config::singleton();
     $contactID = $this->getContactID();
     if ($contactID) {
         $this->assign('contact_id', $contactID);
         $this->assign('display_name', CRM_Contact_BAO_Contact::displayName($contactID));
     }
     $this->applyFilter('__ALL__', 'trim');
     if (empty($this->_ccid)) {
         $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60, 'class' => 'email'), TRUE);
         $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     } else {
         $this->addElement('hidden', "email-{$this->_bltID}", 1);
         $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE);
     }
     $pps = array();
     //@todo - this should be replaced by a check as to whether billing fields are set
     $onlinePaymentProcessorEnabled = FALSE;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $name) {
             if ($name['billing_mode'] == 1) {
                 $onlinePaymentProcessorEnabled = TRUE;
             }
             $pps[$key] = $name['name'];
         }
     }
     if (!empty($this->_values['is_pay_later'])) {
         $pps[0] = $this->_values['pay_later_text'];
     }
     if (count($pps) > 1) {
         $this->addRadio('payment_processor_id', ts('Payment Method'), $pps, NULL, " ");
     } elseif (!empty($pps)) {
         $key = array_keys($pps);
         $key = array_pop($key);
         $this->addElement('hidden', 'payment_processor_id', $key);
         if ($key === 0) {
             $this->assign('is_pay_later', $this->_values['is_pay_later']);
             $this->assign('pay_later_text', $this->_values['pay_later_text']);
         }
     }
     $contactID = $this->getContactID();
     if ($this->getContactID() === 0) {
         $this->addCidZeroOptions($onlinePaymentProcessorEnabled);
     }
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
         $this->_separateMembershipPayment = FALSE;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             $this->_separateMembershipPayment = $this->buildMembershipBlock($this->_membershipContactID, TRUE, NULL, FALSE, $isTest);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         if (empty($this->_ccid)) {
             CRM_Price_BAO_PriceSet::buildPriceSet($this);
         }
         if ($this->_values['is_monetary'] && $this->_values['is_recur'] && empty($this->_values['pledge_id'])) {
             self::buildRecur($this);
         }
     }
     if ($this->_priceSetId && empty($this->_ccid)) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $this->_useForMember = 0;
             $this->set('useForMember', $this->_useForMember);
         }
     }
     //we allow premium for pledge during pledge creation only.
     if (empty($this->_values['pledge_id']) && empty($this->_ccid)) {
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid && empty($this->_ccid)) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && !empty($this->_values['pledge_block_id'])) {
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     //to create an cms user
     if (!$this->_contactID && empty($this->_ccid)) {
         $createCMSUser = FALSE;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             if (!is_array($this->_values['custom_post_id'])) {
                 $profileIDs = array($this->_values['custom_post_id']);
             } else {
                 $profileIDs = $this->_values['custom_post_id'];
             }
             foreach ($profileIDs as $pid) {
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
                     $profileID = $pid;
                     $createCMSUser = TRUE;
                     break;
                 }
             }
         }
         if ($createCMSUser) {
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         }
     }
     if ($this->_pcpId && empty($this->_ccid)) {
         if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
             $pcp_supporter_text = ts('This contribution is being made thanks to the effort of <strong>%1</strong>, who supports our campaign.', array(1 => $pcpSupporter));
             // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field.
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute');
             if (!empty($text)) {
                 $pcp_supporter_text .= ts("You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!");
             }
             $this->assign('pcpSupporterText', $pcp_supporter_text);
         }
         $prms = array('id' => $this->_pcpId);
         CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
         if ($pcpInfo['is_honor_roll']) {
             $this->assign('isHonor', TRUE);
             $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
             $extraOption = array('onclick' => "return pcpAnonymous( );");
             $elements = array();
             $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
             $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
             $this->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
             $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
             $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
         }
     }
     if (empty($this->_values['fee']) && empty($this->_ccid)) {
         CRM_Core_Error::fatal(ts('This page does not have any price fields configured or you may not have permission for them. Please contact the site administrator for more details.'));
     }
     //we have to load confirm contribution button in template
     //when multiple payment processor as the user
     //can toggle with payment processor selection
     $billingModePaymentProcessors = 0;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $values) {
             if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
                 $billingModePaymentProcessors++;
             }
         }
     }
     if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
         $allAreBillingModeProcessors = TRUE;
     } else {
         $allAreBillingModeProcessors = FALSE;
     }
     if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
         $submitButton = array('type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
         // Add submit-once behavior when confirm page disabled
         if (empty($this->_values['is_confirm_enabled'])) {
             $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
         }
         //change button name for updating contribution
         if (!empty($this->_ccid)) {
             $submitButton['name'] = ts('Confirm Payment');
         }
         $this->addButtons(array($submitButton));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }
Beispiel #7
0
 /**
  * Post process function.
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->exportValues();
     CRM_Core_BAO_CMSUser::create($params, 'email');
     CRM_Core_Session::setStatus('', ts('User Added'), 'success');
 }
Beispiel #8
0
 /**
  * @param array $params
  * @param int $contactID
  * @param $mail
  */
 public static function createCMSUser(&$params, $contactID, $mail)
 {
     // lets ensure we only create one CMS user
     static $created = FALSE;
     if ($created) {
         return;
     }
     $created = TRUE;
     if (!empty($params['cms_create_account'])) {
         $params['contactID'] = $contactID;
         if (!CRM_Core_BAO_CMSUser::create($params, $mail)) {
             CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
         }
     }
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_ppType) {
         return CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
     }
     $config = CRM_Core_Config::singleton();
     if (CRM_Utils_Array::value('is_for_organization', $this->_values) == 2) {
         $this->assign('onBehalfRequired', TRUE);
         $this->_onBehalfRequired = 1;
     }
     if ($this->_onbehalf) {
         $this->assign('onbehalf', TRUE);
         return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), TRUE);
     $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     $this->_paymentProcessors = $this->get('paymentProcessors');
     $pps = array();
     if (!empty($this->_paymentProcessors)) {
         $pps = $this->_paymentProcessors;
         foreach ($pps as $key => &$name) {
             $pps[$key] = $name['name'];
         }
     }
     if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
         $pps[0] = $this->_values['pay_later_text'];
     }
     if (count($pps) > 1) {
         $this->addRadio('payment_processor', ts('Payment Method'), $pps, NULL, "&nbsp;", TRUE);
     } elseif (!empty($pps)) {
         $key = array_pop(array_keys($pps));
         $this->addElement('hidden', 'payment_processor', $key);
         if ($key === 0) {
             $this->assign('is_pay_later', $this->_values['is_pay_later']);
             $this->assign('pay_later_text', $this->_values['pay_later_text']);
         }
     }
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         $this->_separateMembershipPayment = FALSE;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, TRUE, NULL, FALSE, $isTest, $this->_membershipContactID);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         CRM_Price_BAO_Set::buildPriceSet($this);
         if ($this->_values['is_monetary'] && $this->_values['is_recur'] && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
             self::buildRecur($this);
         }
     } elseif (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
         $this->buildAmount($this->_separateMembershipPayment);
     }
     if ($this->_priceSetId) {
         $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_priceSetId, 'is_quick_config');
         if ($is_quick_config) {
             $this->_useForMember = 0;
             $this->set('useForMember', $this->_useForMember);
         }
     }
     if ($this->_values['is_for_organization']) {
         $this->buildOnBehalfOrganization();
     }
     //we allow premium for pledge during pledge creation only.
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, TRUE);
     }
     if ($this->_values['honor_block_is_active']) {
         $this->buildHonorBlock();
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     if (!empty($this->_fields)) {
         $profileAddressFields = array();
         foreach ($this->_fields as $key => $value) {
             CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields);
         }
         $this->set('profileAddressFields', $profileAddressFields);
     }
     //to create an cms user
     if (!$this->_userID) {
         $createCMSUser = FALSE;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             if (!is_array($this->_values['custom_post_id'])) {
                 $profileIDs = array($this->_values['custom_post_id']);
             } else {
                 $profileIDs = $this->_values['custom_post_id'];
             }
             foreach ($profileIDs as $pid) {
                 if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $pid, 'is_cms_user')) {
                     $profileID = $pid;
                     $createCMSUser = TRUE;
                     break;
                 }
             }
         }
         if ($createCMSUser) {
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         }
     }
     if ($this->_pcpId) {
         if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) {
             $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
         }
         $this->assign('pcp', TRUE);
         $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
         $extraOption = array('onclick' => "return pcpAnonymous( );");
         $elements = array();
         $elements[] =& $this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption);
         $this->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
         $this->_defaults['pcp_is_anonymous'] = 0;
         $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     }
     //we have to load confirm contribution button in template
     //when multiple payment processor as the user
     //can toggle with payment processor selection
     $billingModePaymentProcessors = 0;
     if (!empty($this->_paymentProcessors)) {
         foreach ($this->_paymentProcessors as $key => $values) {
             if ($values['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON) {
                 $billingModePaymentProcessors++;
             }
         }
     }
     if ($billingModePaymentProcessors && count($this->_paymentProcessors) == $billingModePaymentProcessors) {
         $allAreBillingModeProcessors = TRUE;
     } else {
         $allAreBillingModeProcessors = FALSE;
     }
     if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE)));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }
Beispiel #10
0
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     $contactID = parent::getContactID();
     if ($contactID) {
         require_once "CRM/Contact/BAO/Contact.php";
         $name = CRM_Contact_BAO_Contact::displayName($contactID);
         $this->assign('display_name', $name);
         $this->assign('contact_id', $contactID);
     }
     $config = CRM_Core_Config::singleton();
     $this->add('hidden', 'scriptFee', null);
     $this->add('hidden', 'scriptArray', null);
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true);
     $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     $bypassPayment = $allowGroupOnWaitlist = $isAdditionalParticipants = false;
     if ($this->_values['event']['is_multiple_registrations']) {
         // don't allow to add additional during confirmation if not preregistered.
         if (!$this->_allowConfirmation || $this->_additionalParticipantIds) {
             // Hardcode maximum number of additional participants here for now. May need to make this configurable per event.
             // Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self")
             $additionalOptions = array('' => ts('1'), 1 => ts('2'), 2 => ts('3'), 3 => ts('4'), 4 => ts('5'), 5 => ts('6'), 6 => ts('7'), 7 => ts('8'), 8 => ts('9'), 9 => ts('10'));
             $element = $this->add('select', 'additional_participants', ts('How many people are you registering?'), $additionalOptions, null, array('onChange' => "allowParticipant()"));
             $isAdditionalParticipants = true;
         }
     }
     //hack to allow group to register w/ waiting
     if ((CRM_Utils_Array::value('is_multiple_registrations', $this->_values['event']) || $this->_priceSetId) && !$this->_allowConfirmation && is_numeric($this->_availableRegistrations) && CRM_Utils_Array::value('has_waitlist', $this->_values['event'])) {
         $bypassPayment = true;
         //case might be group become as a part of waitlist.
         //If not waitlist then they require admin approve.
         $allowGroupOnWaitlist = true;
         $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations));
         if ($this->_requireApproval) {
             $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration(s) have been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
         }
     }
     //case where only approval needed - no waitlist.
     if ($this->_requireApproval && !$this->_allowWaitlist && !$bypassPayment) {
         $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], ts('Registration for this event requires approval. Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.'));
     }
     //lets display status to primary page only.
     $this->assign('waitlistMsg', $this->_waitlistMsg);
     $this->assign('requireApprovalMsg', $this->_requireApprovalMsg);
     $this->assign('allowGroupOnWaitlist', $allowGroupOnWaitlist);
     $this->assign('isAdditionalParticipants', $isAdditionalParticipants);
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     //lets get js on two different qf elements.
     $buildExpressPayBlock = false;
     $showHidePayfieldName = null;
     $showHidePaymentInformation = false;
     if ($this->_values['event']['is_monetary']) {
         self::buildAmount($this);
         $attributes = null;
         $freezePayLater = true;
         if (is_array($this->_paymentProcessor)) {
             $freezePayLater = false;
             if (!in_array($this->_paymentProcessor['billing_mode'], array(2, 4))) {
                 $showHidePayfieldName = 'payment_information';
                 $attributes = array('onclick' => "showHidePaymentInfo( );");
             }
             if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal_Express') {
                 $showHidePayfieldName = 'PayPalExpress';
                 $attributes = array('onclick' => "showHidePayPalExpressOption();");
             }
         }
         //lets build only when there is no waiting and no required approval.
         if ($this->_allowConfirmation || !$this->_requireApproval && !$this->_allowWaitlist) {
             if ($this->_values['event']['is_pay_later']) {
                 $element = $this->addElement('checkbox', 'is_pay_later', $this->_values['event']['pay_later_text'], null, $attributes);
                 //if payment processor is not available then freeze
                 //the paylater checkbox with default checked.
                 if ($freezePayLater) {
                     $element->freeze();
                 }
             }
             require_once 'CRM/Core/Payment/Form.php';
             CRM_Core_Payment_Form::buildCreditCard($this);
             if ($showHidePayfieldName == 'payment_information') {
                 $showHidePaymentInformation = true;
             }
             if ($showHidePayfieldName == 'PayPalExpress') {
                 $buildExpressPayBlock = true;
             }
         }
     }
     //lets add some qf element to bypass payment validations, CRM-4320
     if ($bypassPayment) {
         $attributes = null;
         if ($showHidePayfieldName == 'payment_information' && $showHidePaymentInformation) {
             $attributes = array('onclick' => "showHidePaymentInfo();");
         }
         if ($showHidePayfieldName == 'PayPalExpress') {
             $attributes = array('onclick' => "showHidePayPalExpressOption();");
         }
         $this->addElement('hidden', 'bypass_payment', null, array('id' => 'bypass_payment'));
     }
     $this->assign('bypassPayment', $bypassPayment);
     $this->assign('buildExpressPayBlock', $buildExpressPayBlock);
     $this->assign('showHidePaymentInformation', $showHidePaymentInformation);
     $userID = parent::getContactID();
     if (!$userID) {
         $createCMSUser = false;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             $profileID = $this->_values['custom_post_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if ($createCMSUser) {
             require_once 'CRM/Core/BAO/CMSUser.php';
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true);
         }
     }
     if ($this->_paymentProcessor['billing_mode'] != CRM_Core_Payment::BILLING_MODE_BUTTON || CRM_Utils_Array::value('is_pay_later', $this->_values['event']) || $bypassPayment || !$buildExpressPayBlock) {
         //freeze button to avoid multiple calls.
         $js = null;
         if (!CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
             $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');");
         }
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true, 'js' => $js)));
     }
     $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this);
 }
Beispiel #11
0
 /**  
  * Function to handle  process after the confirmation of payment by User
  *  
  * @return None  
  * @access public  
  */
 function confirmPostProcess($contactID = null, $contribution = null, $payment = null)
 {
     // add/update contact information
     $fields = array();
     unset($this->_params['note']);
     //to avoid conflict overwrite $this->_params
     $this->_params = $this->get('value');
     // create CMS user
     if (CRM_Utils_Array::value('cms_create_account', $this->_params)) {
         $this->_params['contactID'] = $contactID;
         $mail = 'email-5';
         // we should use primary email for
         // 1. free event registration.
         // 2. pay later participant.
         // 3. waiting list participant.
         // 4. require approval participant.
         if (CRM_Utils_Array::value('is_pay_later', $this->_params) || $this->_allowWaitlist || $this->_requireApproval || !CRM_Utils_Array::value('is_monetary', $this->_values['event'])) {
             $mail = 'email-Primary';
         }
         require_once "CRM/Core/BAO/CMSUser.php";
         if (!CRM_Core_BAO_CMSUser::create($this->_params, $mail)) {
             CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
         }
     }
     //get the amount of primary participant
     if (CRM_Utils_Array::value('is_primary', $this->_params)) {
         $this->_params['fee_amount'] = $this->get('primaryParticipantAmount');
     }
     // add participant record
     $participant = $this->addParticipant($this->_params, $contactID);
     $this->_participantIDS[] = $participant->id;
     //setting register_by_id field and primaryContactId
     if (CRM_Utils_Array::value('is_primary', $this->_params)) {
         $this->set('registerByID', $participant->id);
         $this->set('primaryContactId', $contactID);
     }
     require_once 'CRM/Core/BAO/CustomValueTable.php';
     CRM_Core_BAO_CustomValueTable::postProcess($this->_params, CRM_Core_DAO::$_nullArray, 'civicrm_participant', $participant->id, 'Participant');
     $createPayment = $this->_params['amount'] != 0 ? true : false;
     // force to create zero amount payment, CRM-5095
     if (!$createPayment && $contribution->id && $this->_params['amount'] == 0 && $this->_priceSetId && $this->_lineItem) {
         $createPayment = true;
     }
     if ($createPayment && $this->_values['event']['is_monetary'] && CRM_Utils_Array::value('contributionID', $this->_params)) {
         require_once 'CRM/Event/BAO/ParticipantPayment.php';
         $paymentParams = array('participant_id' => $participant->id, 'contribution_id' => $contribution->id);
         $ids = array();
         $paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams, $ids);
     }
     //set only primary participant's params for transfer checkout.
     if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && CRM_Utils_Array::value('is_primary', $this->_params)) {
         $this->_params['participantID'] = $participant->id;
         $this->set('primaryParticipant', $this->_params);
     }
     $this->assign('action', $this->_action);
 }
Beispiel #12
0
 /**
  * update the uf_name in the user object
  *
  * @param int    $contactId id of the contact to update
  *
  * @return void
  * @access public
  * @static
  */
 static function updateUFName($contactId)
 {
     $config =& CRM_Core_Config::singleton();
     if ($config->userFramework == 'Standalone') {
         $ufName = CRM_Contact_BAO_Contact::getPrimaryOpenId($contactId);
     } else {
         $ufName = CRM_Contact_BAO_Contact::getPrimaryEmail($contactId);
     }
     if (!$ufName) {
         return;
     }
     $ufmatch =& new CRM_Core_DAO_UFMatch();
     $ufmatch->contact_id = $contactId;
     $ufmatch->domain_id = CRM_Core_Config::domainID();
     if (!$ufmatch->find(true) || $ufmatch->uf_name == $ufName) {
         // if object does not exist or the OpenID has not changed
         return;
     }
     // save the updated ufmatch object
     $ufmatch->uf_name = $ufName;
     $ufmatch->save();
     require_once 'CRM/Core/BAO/CMSUser.php';
     CRM_Core_BAO_CMSUser::updateUFName($ufmatch->uf_id, $ufName);
 }
Beispiel #13
0
 public static function checkUserName()
 {
     $config = CRM_Core_Config::singleton();
     $username = trim(htmlentities($_POST['cms_name']));
     $isDrupal = ucfirst($config->userFramework) == 'Drupal' ? TRUE : FALSE;
     $isJoomla = ucfirst($config->userFramework) == 'Joomla' ? TRUE : FALSE;
     $params = array('name' => $username);
     $errors = array();
     require_once 'CRM/Core/BAO/CMSUser.php';
     CRM_Core_BAO_CMSUser::checkUserNameEmailExists($params, $errors);
     if (isset($errors['cms_name']) || isset($errors['name'])) {
         //user name is not availble
         $user = array('name' => 'no');
         echo json_encode($user);
     } else {
         //user name is available
         $user = array('name' => 'yes');
         echo json_encode($user);
     }
     CRM_Utils_System::civiExit();
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $config = CRM_Core_Config::singleton();
     if ($this->_values['is_for_organization'] == 2) {
         $this->assign('onBehalfRequired', true);
     }
     if ($this->_onbehalf) {
         $this->assign('onbehalf', true);
         return CRM_Contribute_Form_Contribution_OnBehalfOf::buildQuickForm($this);
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', "email-{$this->_bltID}", ts('Email Address'), array('size' => 30, 'maxlength' => 60), true);
     $this->addRule("email-{$this->_bltID}", ts('Email is not valid.'), 'email');
     //build pledge block.
     $this->_useForMember = 0;
     //don't build membership block when pledge_id is passed
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         $this->_separateMembershipPayment = false;
         if (in_array('CiviMember', $config->enableComponents)) {
             $isTest = 0;
             if ($this->_action & CRM_Core_Action::PREVIEW) {
                 $isTest = 1;
             }
             if ($this->_priceSetId && CRM_Core_Component::getComponentID('CiviMember') == CRM_Utils_Array::value('extends', $this->_priceSet)) {
                 $this->_useForMember = 1;
                 $this->set('useForMember', $this->_useForMember);
             }
             require_once 'CRM/Member/BAO/Membership.php';
             $this->_separateMembershipPayment = CRM_Member_BAO_Membership::buildMembershipBlock($this, $this->_id, true, null, false, $isTest, $this->_membershipContactID);
         }
         $this->set('separateMembershipPayment', $this->_separateMembershipPayment);
     }
     $this->assign('useForMember', $this->_useForMember);
     // If we configured price set for contribution page
     // we are not allow membership signup as well as any
     // other contribution amount field, CRM-5095
     if (isset($this->_priceSetId) && $this->_priceSetId) {
         $this->add('hidden', 'priceSetId', $this->_priceSetId);
         // build price set form.
         $this->set('priceSetId', $this->_priceSetId);
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::buildPriceSet($this);
     } else {
         if (CRM_Utils_Array::value('amount_block_is_active', $this->_values) && !CRM_Utils_Array::value('pledge_id', $this->_values)) {
             $this->buildAmount($this->_separateMembershipPayment);
             if ($this->_values['is_monetary'] && $this->_values['is_recur'] && $this->_paymentProcessor['is_recur']) {
                 self::buildRecur($this);
             }
         }
     }
     if (CRM_Utils_Array::value('is_pay_later', $this->_values)) {
         $this->buildPayLater();
     }
     if ($this->_values['is_for_organization']) {
         $this->buildOnBehalfOrganization();
     }
     //we allow premium for pledge during pledge creation only.
     if (!CRM_Utils_Array::value('pledge_id', $this->_values)) {
         require_once 'CRM/Contribute/BAO/Premium.php';
         CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, true);
     }
     if ($this->_values['honor_block_is_active']) {
         $this->buildHonorBlock();
     }
     //don't build pledge block when mid is passed
     if (!$this->_mid) {
         $config = CRM_Core_Config::singleton();
         if (in_array('CiviPledge', $config->enableComponents) && CRM_Utils_Array::value('pledge_block_id', $this->_values)) {
             require_once 'CRM/Pledge/BAO/PledgeBlock.php';
             CRM_Pledge_BAO_PledgeBlock::buildPledgeBlock($this);
         }
     }
     $this->buildCustom($this->_values['custom_pre_id'], 'customPre');
     $this->buildCustom($this->_values['custom_post_id'], 'customPost');
     // doing this later since the express button type depends if there is an upload or not
     if ($this->_values['is_monetary']) {
         require_once 'CRM/Core/Payment/Form.php';
         if ($this->_paymentProcessor['payment_type'] & CRM_Core_Payment::PAYMENT_TYPE_DIRECT_DEBIT) {
             CRM_Core_Payment_Form::buildDirectDebit($this);
         } else {
             CRM_Core_Payment_Form::buildCreditCard($this);
         }
     }
     //to create an cms user
     if (!$this->_userID) {
         $createCMSUser = false;
         if ($this->_values['custom_pre_id']) {
             $profileID = $this->_values['custom_pre_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if (!$createCMSUser && $this->_values['custom_post_id']) {
             $profileID = $this->_values['custom_post_id'];
             $createCMSUser = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileID, 'is_cms_user');
         }
         if ($createCMSUser) {
             require_once 'CRM/Core/BAO/CMSUser.php';
             CRM_Core_BAO_CMSUser::buildForm($this, $profileID, true);
         }
     }
     if ($this->_pcpId) {
         require_once 'CRM/Contribute/BAO/PCP.php';
         if ($pcpSupporter = CRM_Contribute_BAO_PCP::displayName($this->_pcpId)) {
             $this->assign('pcpSupporterText', ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!', array(1 => $pcpSupporter)));
         }
         $this->assign('pcp', true);
         $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), null, null, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
         $extraOption = array('onclick' => "return pcpAnonymous( );");
         $elements = array();
         $elements[] =& $this->createElement('radio', null, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $this->createElement('radio', null, '', ts('List my contribution anonymously'), 1, $extraOption);
         $this->addGroup($elements, 'pcp_is_anonymous', null, '&nbsp;&nbsp;&nbsp;');
         $this->_defaults['pcp_is_anonymous'] = 0;
         $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $this->add('textarea', 'pcp_personal_note', ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     }
     if (!($this->_paymentProcessor['billing_mode'] == CRM_Core_Payment::BILLING_MODE_BUTTON && !$this->_values['is_pay_later'])) {
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Confirm Contribution'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true)));
     }
     $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this);
 }
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     CRM_Core_BAO_CMSUser::synchronize();
 }
 /** 
  * Function to build the form 
  * 
  * @return None 
  * @access public 
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Contribute/BAO/PCP.php';
     $id = CRM_Contribute_BAO_PCP::getSupporterProfileId($this->_pageId);
     if (CRM_Contribute_BAO_PCP::checkEmailProfile($id)) {
         $this->assign('profileDisplay', true);
     }
     $fields = null;
     require_once "CRM/Core/BAO/UFGroup.php";
     if ($this->_contactID) {
         if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) {
             $fields = CRM_Core_BAO_UFGroup::getFields($id, false, CRM_Core_Action::ADD);
         }
         $this->addFormRule(array('CRM_Contribute_Form_PCP_PCPAccount', 'formRule'), $this);
     } else {
         require_once 'CRM/Core/BAO/CMSUser.php';
         CRM_Core_BAO_CMSUser::buildForm($this, $id, true);
         $fields = CRM_Core_BAO_UFGroup::getFields($id, false, CRM_Core_Action::ADD);
     }
     if ($fields) {
         $this->assign('fields', $fields);
         $addCaptcha = false;
         foreach ($fields as $key => $field) {
             if (isset($field['data_type']) && $field['data_type'] == 'File') {
                 // ignore file upload fields
                 continue;
             }
             require_once "CRM/Core/BAO/UFGroup.php";
             require_once "CRM/Profile/Form.php";
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
             $this->_fields[$key] = $field;
             if ($field['add_captcha']) {
                 $addCaptcha = true;
             }
         }
         if ($addCaptcha) {
             require_once 'CRM/Utils/ReCAPTCHA.php';
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign("isCaptcha", true);
         }
     }
     require_once "CRM/Contribute/PseudoConstant.php";
     $this->assign('campaignName', CRM_Contribute_PseudoConstant::contributionPage($this->_pageId));
     if ($this->_single) {
         $button = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     } else {
         $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => true);
     }
     $this->addFormRule(array('CRM_Contribute_Form_PCP_PCPAccount', 'formRule'), $this);
     $this->addButtons($button);
 }
Beispiel #17
0
 /**
  * Process the user submitted custom data values.
  *
  * @access public
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     if ($this->_mode == self::MODE_REGISTER) {
         require_once 'CRM/Core/BAO/Address.php';
         CRM_Core_BAO_Address::setOverwrite(false);
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     //used to send subcribe mail to the group which user want.
     //if the profile double option in is enabled
     $mailingType = array();
     $config =& CRM_Core_Config::singleton();
     if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
         $result = null;
         foreach ($params as $name => $values) {
             if (substr($name, 0, 6) == 'email-') {
                 $result['email'] = $values;
             }
         }
         $groupSubscribed = array();
         if (CRM_Utils_Array::value('email', $result)) {
             require_once 'CRM/Contact/DAO/Group.php';
             //array of group id, subscribed by contact
             $contactGroup = array();
             if ($this->_id) {
                 $contactGroups = new CRM_Contact_DAO_GroupContact();
                 $contactGroups->contact_id = $this->_id;
                 $contactGroups->status = 'Added';
                 $contactGroups->find();
                 $contactGroup = array();
                 while ($contactGroups->fetch()) {
                     $contactGroup[] = $contactGroups->group_id;
                     $groupSubscribed[$contactGroups->group_id] = 1;
                 }
             }
             foreach ($params['group'] as $key => $val) {
                 if (!$val) {
                     unset($params['group'][$key]);
                     continue;
                 }
                 $groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
                 $groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
                 //filter group of mailing type and unset it from params
                 if (in_array(2, $groupType)) {
                     //if group is already subscribed , ignore it
                     $groupExist = CRM_Utils_Array::key($key, $contactGroup);
                     if (!isset($groupExist)) {
                         $mailingType[] = $key;
                         unset($params['group'][$key]);
                     }
                 }
             }
         }
     }
     if ($this->_grid) {
         $params['group'] = $groupSubscribed;
     }
     // commenting below code, since we potentially
     // triggered maximum name field formatting cases during CRM-4430.
     // CRM-4343
     // $params['preserveDBName'] = true;
     $this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_id, $this->_addToGroupID, $this->_gid, $this->_ctype, true);
     //mailing type group
     if (!empty($mailingType)) {
         require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
         CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result);
     }
     require_once 'CRM/Core/BAO/UFGroup.php';
     $ufGroups = array();
     if ($this->_gid) {
         $ufGroups[$this->_gid] = 1;
     } else {
         if ($this->_mode == self::MODE_REGISTER) {
             $ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
         }
     }
     foreach ($ufGroups as $gId => $val) {
         if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
             $values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, null);
             CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
         }
     }
     //create CMS user (if CMS user option is selected in profile)
     if (CRM_Utils_Array::value('cms_create_account', $params) && $this->_mode == self::MODE_CREATE) {
         $params['contactID'] = $this->_id;
         require_once "CRM/Core/BAO/CMSUser.php";
         if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
             CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'));
             $transaction->rollback();
             return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
         }
     }
     $transaction->commit();
 }
Beispiel #18
0
 /**
  * Process the user submitted custom data values.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     //if the delete record button is clicked
     if ($this->_deleteButtonName) {
         if (!empty($_POST[$this->_deleteButtonName]) && $this->_recordId) {
             $filterParams['id'] = $this->_customGroupId;
             $returnProperties = array('is_multiple', 'table_name');
             CRM_Core_DAO::commonRetrieve("CRM_Core_DAO_CustomGroup", $filterParams, $returnValues, $returnProperties);
             if (!empty($returnValues['is_multiple'])) {
                 if ($tableName = CRM_Utils_Array::value('table_name', $returnValues)) {
                     $sql = "DELETE FROM {$tableName} WHERE id = %1 AND entity_id = %2";
                     $sqlParams = array(1 => array($this->_recordId, 'Integer'), 2 => array($this->_id, 'Integer'));
                     CRM_Core_DAO::executeQuery($sql, $sqlParams);
                     CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success');
                 }
             }
             return;
         }
     }
     CRM_Utils_Hook::processProfile($this->_ufGroup['name']);
     if (!empty($params['image_URL'])) {
         CRM_Contact_BAO_Contact::processImageParams($params);
     }
     $greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
     $details = array();
     if ($this->_id) {
         $contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes);
         $details = $contactDetails[0][$this->_id];
     }
     if (!(!empty($details['addressee_id']) || !empty($details['email_greeting_id']) || CRM_Utils_Array::value('postal_greeting_id', $details))) {
         $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
         //Though Profile type is contact we need
         //Individual/Household/Organization for setting Greetings.
         if ($profileType == 'Contact') {
             $profileType = 'Individual';
             //if we editing Household/Organization.
             if ($this->_id) {
                 $profileType = CRM_Contact_BAO_Contact::getContactType($this->_id);
             }
         }
         if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
             $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
         }
         foreach ($greetingTypes as $key => $value) {
             if (!array_key_exists($key, $params)) {
                 $params[$key] = CRM_Contact_BAO_Contact_Utils::defaultGreeting($profileType, $key);
             }
         }
     }
     $transaction = new CRM_Core_Transaction();
     //used to send subscribe mail to the group which user want.
     //if the profile double option in is enabled
     $mailingType = array();
     $result = NULL;
     foreach ($params as $name => $values) {
         if (substr($name, 0, 6) == 'email-') {
             $result['email'] = $values;
         }
     }
     //array of group id, subscribed by contact
     $contactGroup = array();
     if (!empty($params['group']) && CRM_Core_BAO_UFGroup::isProfileDoubleOptin()) {
         $groupSubscribed = array();
         if (!empty($result['email'])) {
             if ($this->_id) {
                 $contactGroups = new CRM_Contact_DAO_GroupContact();
                 $contactGroups->contact_id = $this->_id;
                 $contactGroups->status = 'Added';
                 $contactGroups->find();
                 $contactGroup = array();
                 while ($contactGroups->fetch()) {
                     $contactGroup[] = $contactGroups->group_id;
                     $groupSubscribed[$contactGroups->group_id] = 1;
                 }
             }
             foreach ($params['group'] as $key => $val) {
                 if (!$val) {
                     unset($params['group'][$key]);
                     continue;
                 }
                 $groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
                 $groupType = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($groupTypes, 1, -1));
                 //filter group of mailing type and unset it from params
                 if (in_array(2, $groupType)) {
                     //if group is already subscribed , ignore it
                     $groupExist = CRM_Utils_Array::key($key, $contactGroup);
                     if (!isset($groupExist)) {
                         $mailingType[] = $key;
                         unset($params['group'][$key]);
                     }
                 }
             }
         }
     }
     $addToGroupId = CRM_Utils_Array::value('add_to_group_id', $this->_ufGroup);
     if (!empty($addToGroupId)) {
         //run same check whether group is a mailing list
         $groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $addToGroupId, 'group_type', 'id');
         $groupType = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($groupTypes, 1, -1));
         //filter group of mailing type and unset it from params
         if (in_array(2, $groupType) && !empty($result['email']) && CRM_Core_BAO_UFGroup::isProfileAddToGroupDoubleOptin()) {
             if (!count($contactGroup)) {
                 //array of group id, subscribed by contact
                 $contactGroup = array();
                 if ($this->_id) {
                     $contactGroups = new CRM_Contact_DAO_GroupContact();
                     $contactGroups->contact_id = $this->_id;
                     $contactGroups->status = 'Added';
                     $contactGroups->find();
                     $contactGroup = array();
                     while ($contactGroups->fetch()) {
                         $contactGroup[] = $contactGroups->group_id;
                         $groupSubscribed[$contactGroups->group_id] = 1;
                     }
                 }
             }
             //if group is already subscribed , ignore it
             $groupExist = CRM_Utils_Array::key($addToGroupId, $contactGroup);
             if (!isset($groupExist)) {
                 $mailingType[] = $addToGroupId;
                 $addToGroupId = NULL;
             }
         } else {
             // since we are directly adding contact to group lets unset it from mailing
             if ($key = array_search($addToGroupId, $mailingType)) {
                 unset($mailingType[$key]);
             }
         }
     }
     if ($this->_grid) {
         $params['group'] = $groupSubscribed;
     }
     // commenting below code, since we potentially
     // triggered maximum name field formatting cases during CRM-4430.
     // CRM-4343
     // $params['preserveDBName'] = true;
     $profileFields = $this->_fields;
     if ($this->_mode & self::MODE_EDIT && $this->_activityId && $this->_isContactActivityProfile) {
         $profileFields = $activityParams = array();
         foreach ($this->_fields as $fieldName => $field) {
             if (CRM_Utils_Array::value('field_type', $field) == 'Activity') {
                 if (isset($params[$fieldName])) {
                     $activityParams[$fieldName] = $params[$fieldName];
                 }
                 if (isset($params['activity_date_time'])) {
                     $activityParams['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
                 }
                 if (!empty($params[$fieldName]) && isset($params["{$fieldName}_id"])) {
                     $activityParams[$fieldName] = $params["{$fieldName}_id"];
                 }
             } else {
                 $profileFields[$fieldName] = $field;
             }
         }
         if (!empty($activityParams)) {
             $activityParams['version'] = 3;
             $activityParams['id'] = $this->_activityId;
             $activityParams['skipRecentView'] = TRUE;
             civicrm_api('Activity', 'create', $activityParams);
         }
     }
     if ($this->_multiRecord && $this->_recordId && $this->_multiRecordFields && $this->_recordExists) {
         $params['customRecordValues'][$this->_recordId] = array_keys($this->_multiRecordFields);
     }
     $this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $profileFields, $this->_id, $addToGroupId, $this->_gid, $this->_ctype, TRUE);
     //mailing type group
     if (!empty($mailingType)) {
         // we send in the contactID so we match the same groups and are exact, rather than relying on email
         // CRM-8710
         CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result, $this->_id, 'profile');
     }
     $ufGroups = array();
     if ($this->_gid) {
         $ufGroups[$this->_gid] = 1;
     } elseif ($this->_mode == self::MODE_REGISTER) {
         $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
     }
     foreach ($ufGroups as $gId => $val) {
         if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
             $values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, NULL);
             CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
         }
     }
     //create CMS user (if CMS user option is selected in profile)
     if (!empty($params['cms_create_account']) && $this->_mode == self::MODE_CREATE) {
         $params['contactID'] = $this->_id;
         if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
             CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'), ts('Profile Error'), 'error');
             CRM_Core_Error::debug_log_message("Rolling back transaction as CMSUser Create failed in Profile_Form for contact " . $params['contactID']);
             $transaction->rollback();
             return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
         }
     }
     $transaction->commit();
 }
Beispiel #19
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     require_once 'CRM/Core/BAO/CMSUser.php';
     CRM_Core_BAO_CMSUser::synchronize();
 }
Beispiel #20
0
 public static function checkUserName()
 {
     $config =& CRM_Core_Config::singleton();
     $username = trim(htmlentities($_POST['cms_name']));
     $isDrupal = ucfirst($config->userFramework) == 'Drupal' ? TRUE : FALSE;
     $isJoomla = ucfirst($config->userFramework) == 'Joomla' ? TRUE : FALSE;
     $params = array('name' => $username);
     $errors = array();
     require_once 'CRM/Core/BAO/CMSUser.php';
     CRM_Core_BAO_CMSUser::checkUserNameEmailExists($params, $errors);
     if ($isDrupal) {
         //unset the drupal errors, related to email field is required.
         unset($errors['email']);
         unset($errors['mail']);
     }
     if (!empty($errors)) {
         //user name is not availble
         $user = array('name' => 'no');
         echo json_encode($user);
     } else {
         //user name is available
         $user = array('name' => 'yes');
         echo json_encode($user);
     }
     exit;
 }
<?php

civicrm_initialize();
// -----------------------------
// Get a list of users to update
if (!getenv('INSTALL_DASHBOARD_USERS')) {
    throw new RuntimeException('Missing environment variable: INSTALL_DASHBOARD_USERS');
}
$users = explode(';', getenv('INSTALL_DASHBOARD_USERS'));
CRM_Core_BAO_CMSUser::synchronize(FALSE);
// ------------------------------
// Get list of available dashlets
$reportInstanceResult = civicrm_api3('ReportInstance', 'get', array('option.limit' => 0));
$reportInstanceNames = CRM_Utils_Array::index(array('report_id'), $reportInstanceResult['values']);
$dashletTypeResult = civicrm_api3('Dashboard', 'get', array('domain_id' => CRM_Core_Config::domainID()));
$dashletTypes = CRM_Utils_Array::index(array('name'), $dashletTypeResult['values']);
// ---------------------------------------
// Build list of specific dashlets to add
$dashlets = array(array('dashboard_id' => $dashletTypes['report/' . $reportInstanceNames['event/summary']['id']]['id'], 'column_no' => 0, 'is_minimized' => 0, 'is_fullscreen' => 1, 'weight' => 1), array('dashboard_id' => $dashletTypes['report/' . $reportInstanceNames['contribute/topDonor']['id']]['id'], 'column_no' => 0, 'is_minimized' => 0, 'is_fullscreen' => 1, 'weight' => 3), array('dashboard_id' => $dashletTypes['report/' . $reportInstanceNames['contribute/summary']['id']]['id'], 'column_no' => 0, 'is_minimized' => 0, 'is_fullscreen' => 1, 'weight' => 4), array('dashboard_id' => $dashletTypes['activity']['id'], 'column_no' => 1, 'is_minimized' => 0, 'is_fullscreen' => 1, 'weight' => 10), array('dashboard_id' => $dashletTypes['myCases']['id'], 'column_no' => 1, 'is_minimized' => 0, 'is_fullscreen' => 1, 'weight' => 11), array('dashboard_id' => $dashletTypes['report/' . $reportInstanceNames['member/summary']['id']]['id'], 'column_no' => 1, 'is_minimized' => 0, 'is_fullscreen' => 1, 'weight' => 12));
// -------------------
// Insert the dashlets
$tx = new CRM_Core_Transaction();
try {
    foreach ($users as $user) {
        foreach ($dashlets as $dashlet) {
            $dashlet['contact_id'] = "@user:{$user}";
            $dashlet['is_active'] = 1;
            $dashlet['debug'] = 1;
            civicrm_api3('dashboard_contact', 'create', $dashlet);
        }
    }
Beispiel #22
0
 static function createCMSUser(&$params, $contactID, $mail)
 {
     // lets ensure we only create one CMS user
     static $created = false;
     if ($created) {
         return;
     }
     $created = true;
     if (CRM_Utils_Array::value('cms_create_account', $params)) {
         $params['contactID'] = $contactID;
         require_once 'CRM/Core/BAO/CMSUser.php';
         if (!CRM_Core_BAO_CMSUser::create($params, $mail)) {
             CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
         }
     }
 }
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     $profileID = CRM_Core_DAO::getFieldValue('CRM_Auction_DAO_Auction', $this->_aid, 'donor_profile_id');
     if (!$profileID) {
         CRM_Core_Error::fatal('Profile not configured for this auction.');
     }
     require_once 'CRM/Auction/BAO/Item.php';
     if (CRM_Auction_BAO_Item::isEmailInProfile($profileID)) {
         $this->assign('profileDisplay', TRUE);
     }
     $fields = NULL;
     require_once "CRM/Core/BAO/UFGroup.php";
     if ($this->_donorID) {
         if (CRM_Core_BAO_UFGroup::filterUFGroups($profileID, $this->_donorID)) {
             $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD);
         }
         $this->addFormRule(array('CRM_Auction_Form_ItemAccount', 'formRule'), $this);
     } else {
         require_once 'CRM/Core/BAO/CMSUser.php';
         CRM_Core_BAO_CMSUser::buildForm($this, $profileID, TRUE);
         $fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::ADD);
     }
     if ($fields) {
         $this->assign('fields', $fields);
         $addCaptcha = FALSE;
         foreach ($fields as $key => $field) {
             if (isset($field['data_type']) && $field['data_type'] == 'File') {
                 // ignore file upload fields
                 continue;
             }
             require_once "CRM/Core/BAO/UFGroup.php";
             require_once "CRM/Profile/Form.php";
             CRM_Core_BAO_UFGroup::buildProfile($this, $field, CRM_Profile_Form::MODE_CREATE);
             $this->_fields[$key] = $field;
             if ($field['add_captcha']) {
                 $addCaptcha = TRUE;
             }
         }
         if ($addCaptcha) {
             require_once 'CRM/Utils/ReCAPTCHA.php';
             $captcha =& CRM_Utils_ReCAPTCHA::singleton();
             $captcha->add($this);
             $this->assign("isCaptcha", TRUE);
         }
     }
     $button[] = array('type' => 'next', 'name' => ts('Continue >>'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
     $this->addButtons($button);
 }
Beispiel #24
0
 /**
  * Handle process after the confirmation of payment by User.
  *
  * @param int $contactID
  * @param null $contribution
  * @param null $payment
  */
 public function confirmPostProcess($contactID = NULL, $contribution = NULL, $payment = NULL)
 {
     // add/update contact information
     $fields = array();
     unset($this->_params['note']);
     //to avoid conflict overwrite $this->_params
     $this->_params = $this->get('value');
     //get the amount of primary participant
     if (!empty($this->_params['is_primary'])) {
         $this->_params['fee_amount'] = $this->get('primaryParticipantAmount');
     }
     // add participant record
     $participant = CRM_Event_Form_Registration::addParticipant($this, $contactID);
     $this->_participantIDS[] = $participant->id;
     //setting register_by_id field and primaryContactId
     if (!empty($this->_params['is_primary'])) {
         $this->set('registerByID', $participant->id);
         $this->set('primaryContactId', $contactID);
         // CRM-10032
         $this->processFirstParticipant($participant->id);
     }
     CRM_Core_BAO_CustomValueTable::postProcess($this->_params, 'civicrm_participant', $participant->id, 'Participant');
     $createPayment = CRM_Utils_Array::value('amount', $this->_params, 0) != 0 ? TRUE : FALSE;
     // force to create zero amount payment, CRM-5095
     // we know the amout is zero since createPayment is false
     if (!$createPayment && (isset($contribution) && $contribution->id) && $this->_priceSetId && $this->_lineItem) {
         $createPayment = TRUE;
     }
     if ($createPayment && $this->_values['event']['is_monetary'] && !empty($this->_params['contributionID'])) {
         $paymentParams = array('participant_id' => $participant->id, 'contribution_id' => $contribution->id);
         $ids = array();
         $paymentPartcipant = CRM_Event_BAO_ParticipantPayment::create($paymentParams, $ids);
     }
     //set only primary participant's params for transfer checkout.
     // The concept of contributeMode is deprecated.
     if (($this->_contributeMode == 'checkout' || $this->_contributeMode == 'notify') && !empty($this->_params['is_primary'])) {
         $this->_params['participantID'] = $participant->id;
         $this->set('primaryParticipant', $this->_params);
     }
     $this->assign('action', $this->_action);
     // create CMS user
     if (!empty($this->_params['cms_create_account'])) {
         $this->_params['contactID'] = $contactID;
         if (array_key_exists('email-5', $this->_params)) {
             $mail = 'email-5';
         } else {
             foreach ($this->_params as $name => $dontCare) {
                 if (substr($name, 0, 5) == 'email') {
                     $mail = $name;
                     break;
                 }
             }
         }
         // we should use primary email for
         // 1. free event registration.
         // 2. pay later participant.
         // 3. waiting list participant.
         // 4. require approval participant.
         if (!empty($this->_params['is_pay_later']) || $this->_allowWaitlist || $this->_requireApproval || empty($this->_values['event']['is_monetary'])) {
             $mail = 'email-Primary';
         }
         if (!CRM_Core_BAO_CMSUser::create($this->_params, $mail)) {
             CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
         }
     }
 }
Beispiel #25
0
 /**
  * Process the user submitted custom data values.
  *
  * @access public
  * @return void
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     if (CRM_Utils_Array::value('image_URL', $params)) {
         CRM_Contact_BAO_Contact::processImageParams($params);
     }
     $greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
     if ($this->_id) {
         $contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes);
         $details = $contactDetails[0][$this->_id];
     }
     if (!(CRM_Utils_Array::value('addressee_id', $details) || CRM_Utils_Array::value('email_greeting_id', $details) || CRM_Utils_Array::value('postal_greeting_id', $details))) {
         $profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
         //Though Profile type is contact we need
         //Individual/Household/Organization for setting Greetings.
         if ($profileType == 'Contact') {
             $profileType = 'Individual';
             //if we editing Household/Organization.
             if ($this->_id) {
                 $profileType = CRM_Contact_BAO_Contact::getContactType($this->_id);
             }
         }
         if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
             $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
         }
         $contactTypeFilters = array(1 => 'Individual', 2 => 'Household', 3 => 'Organization');
         $filter = CRM_Utils_Array::key($profileType, $contactTypeFilters);
         if ($filter) {
             foreach ($greetingTypes as $key => $value) {
                 if (!array_key_exists($key, $params)) {
                     $defaultGreetingTypeId = CRM_Core_OptionGroup::values($key, null, null, null, "AND is_default =1\n                                                                               AND (filter = \n                                                                               {$filter} OR \n                                                                               filter = 0 )", 'value');
                     $params[$key] = key($defaultGreetingTypeId);
                 }
             }
         }
         if ($profileType == 'Organization') {
             unset($params['email_greeting'], $params['postal_greeting']);
         }
     }
     if ($this->_mode == self::MODE_REGISTER) {
         require_once 'CRM/Core/BAO/Address.php';
         CRM_Core_BAO_Address::setOverwrite(false);
     }
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     //used to send subcribe mail to the group which user want.
     //if the profile double option in is enabled
     $mailingType = array();
     $config = CRM_Core_Config::singleton();
     if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
         $result = null;
         foreach ($params as $name => $values) {
             if (substr($name, 0, 6) == 'email-') {
                 $result['email'] = $values;
             }
         }
         $groupSubscribed = array();
         if (CRM_Utils_Array::value('email', $result)) {
             require_once 'CRM/Contact/DAO/Group.php';
             //array of group id, subscribed by contact
             $contactGroup = array();
             if ($this->_id) {
                 $contactGroups = new CRM_Contact_DAO_GroupContact();
                 $contactGroups->contact_id = $this->_id;
                 $contactGroups->status = 'Added';
                 $contactGroups->find();
                 $contactGroup = array();
                 while ($contactGroups->fetch()) {
                     $contactGroup[] = $contactGroups->group_id;
                     $groupSubscribed[$contactGroups->group_id] = 1;
                 }
             }
             foreach ($params['group'] as $key => $val) {
                 if (!$val) {
                     unset($params['group'][$key]);
                     continue;
                 }
                 $groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
                 $groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
                 //filter group of mailing type and unset it from params
                 if (in_array(2, $groupType)) {
                     //if group is already subscribed , ignore it
                     $groupExist = CRM_Utils_Array::key($key, $contactGroup);
                     if (!isset($groupExist)) {
                         $mailingType[] = $key;
                         unset($params['group'][$key]);
                     }
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('add_to_group', $params)) {
         $addToGroupId = $params['add_to_group'];
         // since we are directly adding contact to group lets unset it from mailing
         if ($key = array_search($addToGroupId, $mailingType)) {
             unset($mailingType[$key]);
         }
     }
     if ($this->_grid) {
         $params['group'] = $groupSubscribed;
     }
     // commenting below code, since we potentially
     // triggered maximum name field formatting cases during CRM-4430.
     // CRM-4343
     // $params['preserveDBName'] = true;
     $this->_id = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_id, $this->_addToGroupID, $this->_gid, $this->_ctype, true);
     //mailing type group
     if (!empty($mailingType)) {
         require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
         CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result);
     }
     require_once 'CRM/Core/BAO/UFGroup.php';
     $ufGroups = array();
     if ($this->_gid) {
         $ufGroups[$this->_gid] = 1;
     } else {
         if ($this->_mode == self::MODE_REGISTER) {
             $ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('User Registration');
         }
     }
     foreach ($ufGroups as $gId => $val) {
         if ($notify = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gId, 'notify')) {
             $values = CRM_Core_BAO_UFGroup::checkFieldsEmptyValues($gId, $this->_id, null);
             CRM_Core_BAO_UFGroup::commonSendMail($this->_id, $values);
         }
     }
     //create CMS user (if CMS user option is selected in profile)
     if (CRM_Utils_Array::value('cms_create_account', $params) && $this->_mode == self::MODE_CREATE) {
         $params['contactID'] = $this->_id;
         require_once "CRM/Core/BAO/CMSUser.php";
         if (!CRM_Core_BAO_CMSUser::create($params, $this->_mail)) {
             CRM_Core_Session::setStatus(ts('Your profile is not saved and Account is not created.'));
             $transaction->rollback();
             return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $this->_gid));
         }
     }
     $transaction->commit();
 }