コード例 #1
0
ファイル: Custom.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /** 
  * This function sets the default values for the form. Note that in edit/view mode 
  * the default values are retrieved from the database 
  * 
  * @access public 
  * @return void 
  */
 function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id, 'weight' => 1);
     $defaults['custom_pre_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     $ufJoinParams['weight'] = 2;
     $defaults['custom_post_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     return $defaults;
 }
コード例 #2
0
ファイル: Custom.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /** 
  * This function sets the default values for the form. Note that in edit/view mode 
  * the default values are retrieved from the database 
  * 
  * @access public 
  * @return void 
  */
 function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     if ($this->_id) {
         $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
         CRM_Utils_System::setTitle(ts('Include Profiles (%1)', array(1 => $title)));
     }
     require_once 'CRM/Core/BAO/UFJoin.php';
     $ufJoinParams = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
     list($defaults['custom_pre_id'], $defaults['custom_post_id']) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
     return $defaults;
 }
コード例 #3
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 function buildQuickForm()
 {
     $this->_first = true;
     // name
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'title'), true);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), CRM_Contribute_PseudoConstant::contributionType());
     // intro_text and footer_text
     $this->add('textarea', 'intro_text', ts('Introductory Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'intro_text'), true);
     $this->add('textarea', 'footer_text', ts('Footer Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'footer_text'), false);
     // is this group active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?'));
     parent::buildQuickForm();
 }
コード例 #4
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     //Check if there are contributions related to Contribution Page
     parent::preProcess();
     //check for delete
     if (!CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     $dao = new CRM_Contribute_DAO_Contribution();
     $dao->contribution_page_id = $this->_id;
     if ($dao->find(TRUE)) {
         $this->_relatedContributions = TRUE;
         $this->assign('relatedContributions', TRUE);
     }
 }
コード例 #5
0
ファイル: Amount.php プロジェクト: bhirsch/voipdrupal-4.7-1.0
 /** 
  * This function sets the default values for the form. Note that in edit/view mode 
  * the default values are retrieved from the database 
  * 
  * @access public 
  * @return void 
  */
 function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     require_once 'CRM/Core/BAO/CustomOption.php';
     CRM_Core_BAO_CustomOption::getAssoc('civicrm_contribution_page', $this->_id, $defaults);
     if (CRM_Utils_Array::value('value', $defaults)) {
         foreach ($defaults['value'] as $i => $v) {
             if ($v == $defaults['default_amount']) {
                 $defaults['default'] = $i;
                 break;
             }
         }
     }
     return $defaults;
 }
コード例 #6
0
ファイル: ThankYou.php プロジェクト: bhirsch/voipdev
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $this->registerRule('emailList', 'callback', 'emailList', 'CRM_Utils_Rule');
     // thank you title and text (html allowed in text)
     $this->add('text', 'thankyou_title', ts('Thank-you Page Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'thankyou_title'), true);
     $this->addWysiwyg('thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'thankyou_text'));
     $this->addWysiwyg('thankyou_footer', ts('Thank-you Page Footer'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'thankyou_footer'));
     $this->addElement('checkbox', 'is_email_receipt', ts('Email Receipt to Contributor?'), null, array('onclick' => "showReceipt()"));
     $this->add('text', 'receipt_from_name', ts('Receipt From Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'receipt_from_name'));
     $this->add('text', 'receipt_from_email', ts('Receipt From Email'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'receipt_from_email'));
     $this->add('textarea', 'receipt_text', ts('Receipt Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'receipt_text'));
     $this->add('text', 'cc_receipt', ts('CC Receipt To'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'cc_receipt'));
     $this->addRule('cc_receipt', ts('Please enter a valid list of comma delimited email addresses'), 'emailList');
     $this->add('text', 'bcc_receipt', ts('BCC Receipt To'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'bcc_receipt'));
     $this->addRule('bcc_receipt', ts('Please enter a valid list of comma delimited email addresses'), 'emailList');
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_ThankYou', 'formRule'));
     parent::buildQuickForm();
 }
コード例 #7
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $formValues = $this->controller->exportValues($this->_name);
     $formValues['entity_table'] = 'civicrm_contribution_page';
     $formValues['entity_id'] = $this->_id;
     $formValues['title'] = $formValues['tf_title'];
     $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, FALSE);
     $formValues['thankyou_title'] = CRM_Utils_Array::value('tf_thankyou_title', $formValues);
     $formValues['thankyou_text'] = CRM_Utils_Array::value('tf_thankyou_text', $formValues);
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_friendId) {
         $formValues['id'] = $this->_friendId;
     }
     CRM_Friend_BAO_Friend::addTellAFriend($formValues);
     parent::endPostProcess();
 }
コード例 #8
0
ファイル: Custom.php プロジェクト: vakeesan26/civicrm-core
 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     $transaction = new CRM_Core_Transaction();
     // also update uf join table
     $ufJoinParams = array('is_active' => 1, 'module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
     if (!empty($params['custom_pre_id'])) {
         $ufJoinParams['weight'] = 1;
         $ufJoinParams['uf_group_id'] = $params['custom_pre_id'];
         CRM_Core_BAO_UFJoin::create($ufJoinParams);
     }
     unset($ufJoinParams['id']);
     if (!empty($params['custom_post_id'])) {
         $ufJoinParams['weight'] = 2;
         $ufJoinParams['uf_group_id'] = $params['custom_post_id'];
         CRM_Core_BAO_UFJoin::create($ufJoinParams);
     }
     $transaction->commit();
     parent::endPostProcess();
 }
コード例 #9
0
ファイル: MembershipBlock.php プロジェクト: ksecor/civicrm
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Member/BAO/MembershipType.php';
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes();
     if (!empty($membershipTypes)) {
         $this->addElement('checkbox', 'is_active', ts('Membership Section Enabled?'), null, array('onclick' => "memberBlock(this);"));
         $this->addElement('text', 'new_title', ts('Title - New Membership'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_title'));
         $this->addWysiwyg('new_text', ts('Introductory Message - New Memberships'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_text'));
         $this->addElement('text', 'renewal_title', ts('Title - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_title'));
         $this->addWysiwyg('renewal_text', ts('Introductory Message - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_text'));
         $this->addElement('checkbox', 'is_required', ts('Require Membership Signup'));
         $this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee'));
         $this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment'));
         $membership = array();
         $membershipDefault = array();
         foreach ($membershipTypes as $k => $v) {
             $membership[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
             $membershipDefault[] = HTML_QuickForm::createElement('radio', null, null, null, $k);
         }
         $this->addGroup($membership, 'membership_type', ts('Membership Types'));
         $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'));
         $this->addFormRule(array('CRM_Member_Form_MembershipBlock', 'formRule'), $this->_id);
     }
     $session =& CRM_Core_Session::singleton();
     $single = $session->get('singleForm');
     if ($single) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         parent::buildQuickForm();
     }
     //$session->set('single', false );
 }
コード例 #10
0
ファイル: Widget.php プロジェクト: bhirsch/voipdev
 function buildQuickForm()
 {
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Widget');
     $this->addElement('checkbox', 'is_active', ts('Enable Widget?'), null, array('onclick' => "widgetBlock(this)"));
     $this->addWysiwyg('about', ts('About'), $attributes['about']);
     foreach ($this->_fields as $name => $val) {
         $this->add($val[1], $name, $val[0], $attributes[$name], $val[2]);
     }
     foreach ($this->_colorFields as $name => $val) {
         $this->add($val[1], $name, $val[0], $attributes[$name], $val[2]);
     }
     $this->assign_by_ref('fields', $this->_fields);
     $this->assign_by_ref('colorFields', $this->_colorFields);
     $this->_refreshButtonName = $this->getButtonName('refresh');
     $this->addElement('submit', $this->_refreshButtonName, ts('Save and Preview'));
     parent::buildQuickForm();
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Widget', 'formRule'), $this);
 }
コード例 #11
0
ファイル: Settings.php プロジェクト: bhirsch/voipdev
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Utils/Money.php';
     $this->_first = true;
     $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage');
     // name
     $this->add('text', 'title', ts('Title'), $attributes['title'], true);
     $this->add('select', 'contribution_type_id', ts('Contribution Type'), CRM_Contribute_PseudoConstant::contributionType(), true);
     $this->addWysiwyg('intro_text', ts('Introductory Message'), $attributes['intro_text']);
     $this->addWysiwyg('footer_text', ts('Footer Message'), $attributes['footer_text']);
     // is on behalf of an organization ?
     $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), null, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);"));
     $options = array();
     $options[] = HTML_QuickForm::createElement('radio', null, null, ts('Optional'), 1);
     $options[] = HTML_QuickForm::createElement('radio', null, null, ts('Required'), 2);
     $this->addGroup($options, 'is_for_organization', ts(''));
     $this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization']);
     // collect goal amount
     $this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12));
     $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
     // is this page active ?
     $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?'));
     // should the honor be enabled
     $this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), null, array('onclick' => "showHonor()"));
     $this->add('text', 'honor_block_title', ts('Honoree Section Title'), $attributes['honor_block_title']);
     $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), $attributes['honor_block_text']);
     // add optional start and end dates
     $this->addDateTime('start_date', ts('Start Date'));
     $this->addDateTime('end_date', ts('End Date'));
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'));
     parent::buildQuickForm();
 }
コード例 #12
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // we do this in case the user has hit the forward/back button
     $dao = new CRM_Contribute_DAO_Premium();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $this->_id;
     $dao->find(TRUE);
     $premiumID = $dao->id;
     if ($premiumID) {
         $params['id'] = $premiumID;
     }
     $params['premiums_active'] = CRM_Utils_Array::value('premiums_active', $params, FALSE);
     $params['premiums_display_min_contribution'] = CRM_Utils_Array::value('premiums_display_min_contribution', $params, FALSE);
     $params['entity_table'] = 'civicrm_contribution_page';
     $params['entity_id'] = $this->_id;
     $dao = new CRM_Contribute_DAO_Premium();
     $dao->copyValues($params);
     $dao->save();
     parent::endPostProcess();
 }
コード例 #13
0
 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $deletePriceSet = 0;
     if ($params['membership_type']) {
         // we do this in case the user has hit the forward/back button
         $dao = new CRM_Member_DAO_MembershipBlock();
         $dao->entity_table = 'civicrm_contribution_page';
         $dao->entity_id = $this->_id;
         $dao->find(TRUE);
         $membershipID = $dao->id;
         if ($membershipID) {
             $params['id'] = $membershipID;
         }
         $membershipTypes = array();
         if (is_array($params['membership_type'])) {
             foreach ($params['membership_type'] as $k => $v) {
                 if ($v) {
                     $membershipTypes[$k] = CRM_Utils_Array::value("auto_renew_{$k}", $params);
                 }
             }
         }
         if ($this->_id && !empty($params['member_price_set_id'])) {
             CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'amount_block_is_active', 0);
         }
         // check for price set.
         $priceSetID = CRM_Utils_Array::value('member_price_set_id', $params);
         if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) {
             $usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2);
             if (empty($params['mem_price_field_id']) && !$usedPriceSetId) {
                 $pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
                 $setParams['title'] = $this->_values['title'];
                 if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle, 'id', 'name')) {
                     $setParams['name'] = $pageTitle;
                 } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceSet', $pageTitle . '_' . $this->_id, 'id', 'name')) {
                     $setParams['name'] = $pageTitle . '_' . $this->_id;
                 } else {
                     $timeSec = explode(".", microtime(TRUE));
                     $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
                 }
                 $setParams['is_quick_config'] = 1;
                 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
                 $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
                 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
                 $priceSetID = $priceSet->id;
                 $fieldParams['price_set_id'] = $priceSet->id;
             } elseif ($usedPriceSetId) {
                 $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember');
                 $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values);
                 $setParams['id'] = $usedPriceSetId;
                 $priceSet = CRM_Price_BAO_PriceSet::create($setParams);
                 $priceSetID = $priceSet->id;
                 $fieldParams['price_set_id'] = $priceSet->id;
             } else {
                 $fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params);
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id');
             }
             $editedFieldParams = array('price_set_id' => $priceSetID, 'name' => 'membership_amount');
             $editedResults = array();
             CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
             if (empty($editedResults['id'])) {
                 $fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245));
                 if (empty($params['mem_price_field_id'])) {
                     CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID));
                 }
                 $fieldParams['weight'] = 1;
             } else {
                 $fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults);
             }
             $fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership');
             $fieldParams['is_active'] = 1;
             $fieldParams['html_type'] = 'Radio';
             $fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0;
             $fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0;
             $rowCount = 1;
             $options = array();
             if (!empty($fieldParams['id'])) {
                 CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} ");
             }
             foreach ($membershipTypes as $memType => $memAutoRenew) {
                 if ($priceFieldID = CRM_Utils_Array::key($memType, $options)) {
                     $fieldParams['option_id'][$rowCount] = $priceFieldID;
                     unset($options[$priceFieldID]);
                 }
                 $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
                 $fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype);
                 $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0);
                 $fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype);
                 $fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype);
                 $fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params);
                 $fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype);
                 $fieldParams['membership_type_id'][$rowCount] = $memType;
                 // [$rowCount] = $membetype[''];
                 $rowCount++;
             }
             foreach ($options as $priceFieldID => $memType) {
                 CRM_Price_BAO_PriceFieldValue::setIsActive($priceFieldID, '0');
             }
             $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
         } elseif (!$priceSetID) {
             $deletePriceSet = 1;
         }
         $params['is_required'] = CRM_Utils_Array::value('is_required', $params, FALSE);
         $params['is_active'] = CRM_Utils_Array::value('member_is_active', $params, FALSE);
         if ($priceSetID) {
             $params['membership_types'] = 'null';
             $params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
             $params['membership_types'] = serialize($membershipTypes);
             $params['display_min_fee'] = CRM_Utils_Array::value('display_min_fee', $params, FALSE);
             $params['is_separate_payment'] = CRM_Utils_Array::value('is_separate_payment', $params, FALSE);
         }
         $params['entity_table'] = 'civicrm_contribution_page';
         $params['entity_id'] = $this->_id;
         $dao = new CRM_Member_DAO_MembershipBlock();
         $dao->copyValues($params);
         $dao->save();
         if ($priceSetID && $params['is_active']) {
             CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetID);
         }
         if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) {
             if ($this->_memPriceSetId) {
                 $pFIDs = array();
                 $conditionParams = array('price_set_id' => $this->_memPriceSetId, 'html_type' => 'radio', 'name' => 'contribution_amount');
                 CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs);
                 if (empty($pFIDs['id'])) {
                     CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id);
                     CRM_Price_BAO_PriceSet::setIsQuickConfig($this->_memPriceSetId, '0');
                 } else {
                     CRM_Price_BAO_PriceField::setIsActive($params['mem_price_field_id'], '0');
                 }
             }
         }
     }
     parent::endPostProcess();
 }
コード例 #14
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     require_once 'CRM/Member/BAO/MembershipType.php';
     $membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes();
     if (!empty($membershipTypes)) {
         $this->addElement('checkbox', 'is_active', ts('Membership Section Enabled?'), null, array('onclick' => "memberBlock(this);"));
         $this->addElement('text', 'new_title', ts('Title - New Membership'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_title'));
         $this->addWysiwyg('new_text', ts('Introductory Message - New Memberships'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'new_text'));
         $this->addElement('text', 'renewal_title', ts('Title - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_title'));
         $this->addWysiwyg('renewal_text', ts('Introductory Message - Renewals'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipBlock', 'renewal_text'));
         $this->addElement('checkbox', 'is_required', ts('Require Membership Signup'));
         $this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee'));
         $this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment'));
         $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(false, false, 'is_recur = 1');
         $paymentProcessorId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'payment_processor_id');
         $isRecur = false;
         $membership = array();
         $membershipDefault = array();
         foreach ($membershipTypes as $k => $v) {
             $membership[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
             $membershipDefault[] = HTML_QuickForm::createElement('radio', null, null, null, $k);
             if (is_array($paymentProcessor) && CRM_Utils_Array::value($paymentProcessorId, $paymentProcessor)) {
                 $isRecur = true;
                 $autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew');
                 $autoRenewOptions = array();
                 if ($autoRenew) {
                     $autoRenewOptions = array(ts('Not offered'), ts('Give option'), ts('Required'));
                     $this->addElement('select', "auto_renew_{$k}", ts('Auto-renew'), $autoRenewOptions);
                     $this->_renewOption[$k] = $autoRenew;
                 }
             } else {
                 $isRecur = false;
             }
         }
         $this->assign('is_recur', $isRecur);
         $this->assign('auto_renew', $this->_renewOption);
         $this->addGroup($membership, 'membership_type', ts('Membership Types'));
         $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default'));
         $this->addFormRule(array('CRM_Member_Form_MembershipBlock', 'formRule'), $this->_id);
     }
     $session = CRM_Core_Session::singleton();
     $single = $session->get('singleForm');
     if ($single) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         parent::buildQuickForm();
     }
     //$session->set('single', false );
 }
コード例 #15
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 function buildQuickForm()
 {
     if ($this->_action & CRM_CORE_ACTION_DELETE) {
         $session =& CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url('/civicrm/admin/contribute', 'reset=1&action=update&id=' . $this->_id . '&subPage=Premium');
         $session->pushUserContext($url);
         if (CRM_Utils_Request::retrieve('confirmed', $form, '', '', 'GET')) {
             require_once 'CRM/Contribute/DAO/PremiumsProduct.php';
             $dao =& new CRM_Contribute_DAO_PremiumsProduct();
             $dao->id = $this->_pid;
             $dao->delete();
             CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'));
             CRM_Utils_System::redirect($url);
         }
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '    ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if ($this->_action & CRM_CORE_ACTION_PREVIEW) {
         require_once 'CRM/Contribute/BAO/Premium.php';
         CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, null, $this->_pid);
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Done With Preview'), 'isDefault' => true)));
         return;
     }
     $session =& CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('/civicrm/admin/contribute', 'reset=1&action=update&id=' . $this->_id . '&subPage=Premium');
     $session->pushUserContext($url);
     $this->addElement('select', 'product_id', ts('Select the Product') . ' ', $this->_products);
     $this->addRule('product_id', ts('Select the Product') . ' ', 'required');
     $this->addElement('text', 'sort_position', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PremiumsProduct', 'sort_position'));
     $this->addRule('sort_position', ts('Please enter integer value for weight'), 'integer');
     $session =& CRM_Core_Session::singleton();
     $single = $session->get('singleForm');
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/contribute', 'action=update&reset=1&id=' . $this->_id . '&subPage=Premium'));
     if ($single) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '    ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         parent::buildQuickForm();
     }
 }
コード例 #16
0
 function postProcess()
 {
     //to reset quickform elements of next (pcp) page.
     if ($this->controller->getNextName('Widget') == 'PCP') {
         $this->controller->resetPage('PCP');
     }
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if ($this->_widget) {
         $params['id'] = $this->_widget->id;
     }
     $params['contribution_page_id'] = $this->_id;
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['url_homepage'] = 'null';
     $widget = new CRM_Contribute_DAO_Widget();
     $widget->copyValues($params);
     $widget->save();
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->_refreshButtonName) {
         return;
     }
     parent::endPostProcess();
 }
コード例 #17
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // we do this in case the user has hit the forward/back button
     if ($this->_id) {
         $params['id'] = $this->_id;
     } else {
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
         $config = CRM_Core_Config::singleton();
         $params['currency'] = $config->defaultCurrency;
     }
     $params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
     $params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_credit_card_only'] = CRM_Utils_Array::value('is_credit_card_only', $params, FALSE);
     $params['honor_block_is_active'] = CRM_Utils_Array::value('honor_block_is_active', $params, FALSE);
     $params['is_for_organization'] = CRM_Utils_Array::value('is_organization', $params) ? CRM_Utils_Array::value('is_for_organization', $params, FALSE) : 0;
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time'], TRUE);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE);
     $params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
     if (!$params['honor_block_is_active']) {
         $params['honor_block_title'] = NULL;
         $params['honor_block_text'] = NULL;
     }
     $dao = CRM_Contribute_BAO_ContributionPage::create($params);
     // make entry in UF join table for onbehalf of org profile
     $ufJoinParams = array('is_active' => 1, 'module' => 'OnBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id);
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
     if (CRM_Utils_Array::value('onbehalf_profile_id', $params)) {
         $ufJoinParams['weight'] = 1;
         $ufJoinParams['uf_group_id'] = $params['onbehalf_profile_id'];
         CRM_Core_BAO_UFJoin::create($ufJoinParams);
     }
     $this->set('id', $dao->id);
     if ($this->_action & CRM_Core_Action::ADD) {
         $url = 'civicrm/admin/contribute/amount';
         $urlParams = "action=update&reset=1&id={$dao->id}";
         // special case for 'Save and Done' consistency.
         if ($this->controller->getButtonName('submit') == '_qf_Amount_upload_done') {
             $url = 'civicrm/admin/contribute';
             $urlParams = 'reset=1';
             CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())));
         }
         CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
     }
     parent::endPostProcess();
 }
コード例 #18
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 function buildQuickForm()
 {
     $this->assign('showForm', false);
     $this->addElement('checkbox', 'premiums_active', ts('Premiums Section Enabled?'));
     $this->addElement('text', 'premiums_intro_title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_intro_title'));
     //$this->addRule('premiums_intro_title',ts('Plese Eneter the Title'),'required');
     // intro_text
     $this->add('textarea', 'premiums_intro_text', ts('Introductory Message'), 'rows=5, cols=50');
     $this->add('text', 'premiums_contact_email', ts('Contact Email') . ' ', CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_contact_email'));
     $this->addRule('premiums_contact_email', ts('Please enter valid email address for Contact Email') . ' ', 'email');
     $this->add('text', 'premiums_contact_phone', ts('Contact Phone'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_contact_phone'));
     $this->addRule('premiums_contact_phone', ts('Please enter valid phone'), 'phone');
     $this->addElement('checkbox', 'premiums_display_min_contribution', ts('Display Minimum Contribution Amount?'));
     $session =& CRM_Core_Session::singleton();
     $single = $session->get('singleForm');
     if ($single) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         $this->assign('showForm', true);
         parent::buildQuickForm();
     }
     //$session->set('single', false );
 }
コード例 #19
0
ファイル: Settings.php プロジェクト: rollox/civicrm-core
 /**
  * Process the form.
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // we do this in case the user has hit the forward/back button
     if ($this->_id) {
         $params['id'] = $this->_id;
     } else {
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
         $config = CRM_Core_Config::singleton();
         $params['currency'] = $config->defaultCurrency;
     }
     $params['is_confirm_enabled'] = CRM_Utils_Array::value('is_confirm_enabled', $params, FALSE);
     $params['is_share'] = CRM_Utils_Array::value('is_share', $params, FALSE);
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_credit_card_only'] = CRM_Utils_Array::value('is_credit_card_only', $params, FALSE);
     $params['honor_block_is_active'] = CRM_Utils_Array::value('honor_block_is_active', $params, FALSE);
     $params['is_for_organization'] = !empty($params['is_organization']) ? CRM_Utils_Array::value('is_for_organization', $params, FALSE) : 0;
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time'], TRUE);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], TRUE);
     $params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
     if (!$params['honor_block_is_active']) {
         $params['honor_block_title'] = NULL;
         $params['honor_block_text'] = NULL;
     }
     $dao = CRM_Contribute_BAO_ContributionPage::create($params);
     $ufJoinParams = array('is_organization' => array('module' => 'on_behalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id), 'honor_block_is_active' => array('module' => 'soft_credit', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id));
     foreach ($ufJoinParams as $index => $ufJoinParam) {
         if (!empty($params[$index])) {
             // first delete all past entries
             CRM_Core_BAO_UFJoin::deleteAll($ufJoinParam);
             $ufJoinParam['uf_group_id'] = $params[$index];
             $ufJoinParam['weight'] = 1;
             $ufJoinParam['is_active'] = 1;
             if ($index == 'honor_block_is_active') {
                 $ufJoinParam['uf_group_id'] = $params['honoree_profile'];
                 $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'soft_credit');
             } else {
                 $ufJoinParam['uf_group_id'] = $params['onbehalf_profile_id'];
                 $ufJoinParam['module_data'] = CRM_Contribute_BAO_ContributionPage::formatModuleData($params, FALSE, 'on_behalf');
             }
             CRM_Core_BAO_UFJoin::create($ufJoinParam);
         } else {
             if ($index == 'honor_block_is_active') {
                 $params['honor_block_title'] = NULL;
                 $params['honor_block_text'] = NULL;
             } else {
                 $params['for_organization'] = NULL;
             }
             //On subsequent honor_block_is_active uncheck, disable(don't delete)
             //that particular honoree profile entry in UFjoin table, CRM-13981
             $ufId = CRM_Core_BAO_UFJoin::findJoinEntryId($ufJoinParam);
             if ($ufId) {
                 $ufJoinParam['uf_group_id'] = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParam);
                 $ufJoinParam['is_active'] = 0;
                 CRM_Core_BAO_UFJoin::create($ufJoinParam);
             }
         }
     }
     $this->set('id', $dao->id);
     if ($this->_action & CRM_Core_Action::ADD) {
         $url = 'civicrm/admin/contribute/amount';
         $urlParams = "action=update&reset=1&id={$dao->id}";
         // special case for 'Save and Done' consistency.
         if ($this->controller->getButtonName('submit') == '_qf_Amount_upload_done') {
             $url = 'civicrm/admin/contribute';
             $urlParams = 'reset=1';
             CRM_Core_Session::setStatus(ts("'%1' information has been saved.", array(1 => $this->getTitle())), ts('Saved'), 'success');
         }
         CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
     }
     parent::endPostProcess();
 }
コード例 #20
0
ファイル: AddProduct.php プロジェクト: kidaa30/yes
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $urlParams = 'civicrm/admin/contribute/premium';
     if ($this->_action & CRM_Core_Action::DELETE) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $session->pushUserContext($url);
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject, '', '', 'GET')) {
             $dao = new CRM_Contribute_DAO_PremiumsProduct();
             $dao->id = $this->_pid;
             $dao->delete();
             CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'), ts('Saved'), 'success');
             CRM_Utils_System::redirect($url);
         }
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '    ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, NULL, $this->_pid);
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Done with Preview'), 'isDefault' => TRUE)));
         return;
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
     $session->pushUserContext($url);
     $this->add('select', 'product_id', ts('Select the Product') . ' ', $this->_products, TRUE);
     $this->addElement('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PremiumsProduct', 'weight'));
     $financialType = CRM_Contribute_PseudoConstant::financialType();
     $premiumFinancialType = array();
     CRM_Core_PseudoConstant::populate($premiumFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 8');
     $costFinancialType = array();
     CRM_Core_PseudoConstant::populate($costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', $all = TRUE, $retrieve = 'entity_id', $filter = NULL, 'account_relationship = 7');
     $productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
     foreach ($financialType as $key => $financialTypeName) {
         if (!in_array($key, $productFinancialType)) {
             unset($financialType[$key]);
         }
     }
     if (count($financialType)) {
         $this->assign('financialType', $financialType);
     }
     $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + $financialType);
     $this->addRule('weight', ts('Please enter integer value for weight'), 'integer');
     $session->pushUserContext(CRM_Utils_System::url($urlParams, 'action=update&reset=1&id=' . $this->_id));
     if ($this->_single) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '    ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         parent::buildQuickForm();
     }
 }
コード例 #21
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     CRM_Friend_BAO_Friend::buildFriendForm($this);
     parent::buildQuickForm();
 }
コード例 #22
0
ファイル: PCP.php プロジェクト: ksecor/civicrm
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 function buildQuickForm()
 {
     $this->addElement('checkbox', 'is_active', ts('Enable Personal Campaign Pages (for this contribution page)?'), null, array('onclick' => "return showHideByValue('is_active',true,'pcpFields','table-row','radio',false);"));
     $this->addElement('checkbox', 'is_approval_needed', ts('Approval required'));
     $profile = array();
     $isUserRequired = null;
     $config =& CRM_Core_Config::singleton();
     if ($config->userFramework != 'Standalone') {
         $isUserRequired = 2;
     }
     CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, array('title', 'is_active'));
     if (!empty($profiles)) {
         foreach ($profiles as $key => $value) {
             if ($value['is_active']) {
                 $profile[$key] = $value['title'];
             }
         }
         $this->assign('profile', $profile);
     }
     $this->add('select', 'supporter_profile_id', ts('Supporter profile'), array('' => ts('- select -')) + $profile);
     $this->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), null, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);"));
     $this->add('text', 'tellfriend_limit', ts("'Tell a friend' maximum recipients limit"), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'pcp_tellfriend_limit'));
     $this->addRule('tellfriend_limit', ts('Please enter a valid limit.'), 'integer');
     $this->add('text', 'link_text', ts("'Create Personal Campaign Page' link text"), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PCPBlock', 'pcp_link_text'));
     $this->add('text', 'notify_email', ts('Notify Email'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PCPBlock', 'notify_email'));
     parent::buildQuickForm();
     $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_PCP', 'formRule'), $this);
 }
コード例 #23
0
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $urlParams = 'civicrm/admin/contribute/premium';
     if ($this->_action & CRM_Core_Action::DELETE) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $session->pushUserContext($url);
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject, '', '', 'GET')) {
             $dao = new CRM_Contribute_DAO_PremiumsProduct();
             $dao->id = $this->_pid;
             $dao->delete();
             CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'));
             CRM_Utils_System::redirect($url);
         }
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '    ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, NULL, $this->_pid);
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Done with Preview'), 'isDefault' => TRUE)));
         return;
     }
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
     $session->pushUserContext($url);
     $this->add('select', 'product_id', ts('Select the Product') . ' ', $this->_products, TRUE);
     $this->addElement('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PremiumsProduct', 'weight'));
     $this->addRule('weight', ts('Please enter integer value for weight'), 'integer');
     $session->pushUserContext(CRM_Utils_System::url($urlParams, 'action=update&reset=1&id=' . $this->_id));
     if ($this->_single) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '    ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     } else {
         parent::buildQuickForm();
     }
 }
コード例 #24
0
 /**
  * Process the form submission.
  *
  * @return void
  */
 public function postProcess()
 {
     // TODO:: is this required?
     $params = $this->controller->exportValues($this->_name);
     $existParams['page_id'] = $this->_id;
     $existParams['page_category'] = "civicrm_contribution";
     $existingEnrty = array();
     CRM_WebTracking_BAO_WebTracking::retrieve($existParams, $existingEnrty);
     // Setting up the params array with the values obtained from the form
     if (!empty($existingEnrty)) {
         $params['id'] = $existingEnrty['id'];
     }
     $params['page_id'] = $this->_id;
     $params['page_category'] = "civicrm_contribution";
     $params['enable_tracking'] = CRM_Utils_Array::value('enable_tracking', $params, FALSE);
     $params['tracking_id'] = CRM_Utils_Array::value('tracking_id', $params, NULL);
     $params['ga_event_tracking'] = CRM_Utils_Array::value('ga_event_tracking', $params, FALSE);
     $params['track_register'] = CRM_Utils_Array::value('track_register', $params, FALSE);
     $params['track_confirm_register'] = CRM_Utils_Array::value('track_confirm_register', $params, FALSE);
     $params['track_thank_you'] = CRM_Utils_Array::value('track_thank_you', $params, FALSE);
     $params['track_price_change'] = CRM_Utils_Array::value('track_price_change', $params, FALSE);
     $params['track_ecommerce'] = CRM_Utils_Array::value('track_ecommerce', $params, FALSE);
     $params['is_experiment'] = CRM_Utils_Array::value('is_experiment', $params, FALSE);
     $params['experiment_id'] = CRM_Utils_Array::value('experiment_id', $params, NULL);
     // Updating the database with the new entry
     $event = CRM_WebTracking_BAO_WebTracking::add($params);
     $subPage = 'webtracking';
     $nextPage = 'webtracking';
     $subPageName = 'WebTracking';
     parent::endPostProcess();
 }
コード例 #25
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if (array_key_exists('payment_processor', $params)) {
         if (array_key_exists(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PaymentProcessor', 'AuthNet', 'id', 'payment_processor_type'), CRM_Utils_Array::value('payment_processor', $params))) {
             CRM_Core_Session::setStatus(ts(' Please note that the Authorize.net payment processor only allows recurring contributions and auto-renew memberships with payment intervals from 7-365 days or 1-12 months (i.e. not greater than 1 year).'));
         }
     }
     // check for price set.
     $priceSetID = CRM_Utils_Array::value('price_set_id', $params);
     // get required fields.
     $fields = array('id' => $this->_id, 'is_recur' => FALSE, 'min_amount' => "null", 'max_amount' => "null", 'is_monetary' => FALSE, 'is_pay_later' => FALSE, 'is_recur_interval' => FALSE, 'recur_frequency_unit' => "null", 'default_amount_id' => "null", 'is_allow_other_amount' => FALSE, 'amount_block_is_active' => FALSE);
     $resetFields = array();
     if ($priceSetID) {
         $resetFields = array('min_amount', 'max_amount', 'is_allow_other_amount');
     }
     if (!CRM_Utils_Array::value('is_recur', $params)) {
         $resetFields = array_merge($resetFields, array('is_recur_interval', 'recur_frequency_unit'));
     }
     foreach ($fields as $field => $defaultVal) {
         $val = CRM_Utils_Array::value($field, $params, $defaultVal);
         if (in_array($field, $resetFields)) {
             $val = $defaultVal;
         }
         if (in_array($field, array('min_amount', 'max_amount'))) {
             $val = CRM_Utils_Rule::cleanMoney($val);
         }
         $params[$field] = $val;
     }
     if ($params['is_recur']) {
         $params['recur_frequency_unit'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['recur_frequency_unit']));
         $params['is_recur_interval'] = CRM_Utils_Array::value('is_recur_interval', $params, FALSE);
     }
     if (array_key_exists('payment_processor', $params) && !CRM_Utils_System::isNull($params['payment_processor'])) {
         $params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['payment_processor']));
     } else {
         $params['payment_processor'] = 'null';
     }
     $contributionPage = CRM_Contribute_BAO_ContributionPage::create($params);
     $contributionPageID = $contributionPage->id;
     // prepare for data cleanup.
     $deleteAmountBlk = $deletePledgeBlk = $deletePriceSet = FALSE;
     if ($this->_priceSetID) {
         $deletePriceSet = TRUE;
     }
     if ($this->_pledgeBlockID) {
         $deletePledgeBlk = TRUE;
     }
     if (!empty($this->_amountBlock)) {
         $deleteAmountBlk = TRUE;
     }
     if ($contributionPageID) {
         if (CRM_Utils_Array::value('amount_block_is_active', $params)) {
             // handle price set.
             if ($priceSetID) {
                 // add/update price set.
                 $deletePriceSet = FALSE;
                 if (CRM_Utils_Array::value('price_field_id', $params) || CRM_Utils_Array::value('price_field_other', $params)) {
                     $deleteAmountBlk = TRUE;
                 }
                 CRM_Price_BAO_Set::addTo('civicrm_contribution_page', $contributionPageID, $priceSetID);
             } else {
                 $deletePriceSet = FALSE;
                 // process contribution amount block
                 $deleteAmountBlk = FALSE;
                 $labels = CRM_Utils_Array::value('label', $params);
                 $values = CRM_Utils_Array::value('value', $params);
                 $default = CRM_Utils_Array::value('default', $params);
                 $options = array();
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (isset($values[$i]) && strlen(trim($values[$i])) > 0) {
                         $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i);
                     }
                 }
                 /* || CRM_Utils_Array::value( 'price_field_value', $params )|| CRM_Utils_Array::value( 'price_field_other', $params )*/
                 if (!empty($options) || CRM_Utils_Array::value('is_allow_other_amount', $params)) {
                     $fieldParams['is_quick_config'] = 1;
                     $noContriAmount = NULL;
                     $usedPriceSetId = CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $this->_id, 3);
                     if (!(CRM_Utils_Array::value('price_field_id', $params) || CRM_Utils_Array::value('price_field_other', $params)) && !$usedPriceSetId) {
                         $pageTitle = strtolower(CRM_Utils_String::munge($this->_values['title'], '_', 245));
                         $setParams['title'] = $this->_values['title'];
                         if (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $pageTitle, 'id', 'name')) {
                             $setParams['name'] = $pageTitle;
                         } elseif (!CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Set', $pageTitle . '_' . $this->_id, 'id', 'name')) {
                             $setParams['name'] = $pageTitle . '_' . $this->_id;
                         } else {
                             $timeSec = explode(".", microtime(true));
                             $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
                         }
                         $setParams['is_quick_config'] = 1;
                         $setParams['extends'] = CRM_Core_Component::getComponentID('CiviContribute');
                         $priceSet = CRM_Price_BAO_Set::create($setParams);
                         $priceSetId = $priceSet->id;
                     } elseif ($usedPriceSetId && !CRM_Utils_Array::value('price_field_id', $params)) {
                         $priceSetId = $usedPriceSetId;
                     } else {
                         if ($priceFieldId = CRM_Utils_Array::value('price_field_id', $params)) {
                             foreach ($params['price_field_value'] as $arrayID => $fieldValueID) {
                                 if (empty($params['label'][$arrayID]) && empty($params['value'][$arrayID]) && !empty($fieldValueID)) {
                                     CRM_Price_BAO_FieldValue::setIsActive($fieldValueID, '0');
                                     unset($params['price_field_value'][$arrayID]);
                                 }
                             }
                             if (implode('', $params['price_field_value'])) {
                                 $fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params);
                                 $fieldParams['option_id'] = $params['price_field_value'];
                             } else {
                                 $noContriAmount = 0;
                                 CRM_Price_BAO_Field::setIsActive($priceFieldId, '0');
                             }
                         } else {
                             $priceFieldId = CRM_Utils_Array::value('price_field_other', $params);
                         }
                         $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $priceFieldId, 'price_set_id');
                     }
                     CRM_Price_BAO_Set::addTo('civicrm_contribution_page', $this->_id, $priceSetId);
                     if (!empty($options)) {
                         $editedFieldParams = array('price_set_id' => $priceSetId, 'name' => 'contribution_amount');
                         $editedResults = array();
                         $noContriAmount = 1;
                         CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
                         if (!CRM_Utils_Array::value('id', $editedResults)) {
                             $fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245));
                             $fieldParams['label'] = "Contribution Amount";
                         } else {
                             $fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults);
                         }
                         $fieldParams['price_set_id'] = $priceSetId;
                         $fieldParams['is_active'] = 1;
                         $fieldParams['weight'] = 2;
                         if (CRM_Utils_Array::value('is_allow_other_amount', $params)) {
                             $fieldParams['is_required'] = 0;
                         } else {
                             $fieldParams['is_required'] = 1;
                         }
                         $fieldParams['html_type'] = 'Radio';
                         $fieldParams['option_label'] = $params['label'];
                         $fieldParams['option_amount'] = $params['value'];
                         foreach ($options as $value) {
                             $fieldParams['option_weight'][$value['weight']] = $value['weight'];
                         }
                         $fieldParams['default_option'] = $params['default'];
                         $priceField = CRM_Price_BAO_Field::create($fieldParams);
                     }
                     if (CRM_Utils_Array::value('is_allow_other_amount', $params) && !CRM_Utils_Array::value('price_field_other', $params)) {
                         $editedFieldParams = array('price_set_id' => $priceSetId, 'name' => 'other_amount');
                         $editedResults = array();
                         CRM_Price_BAO_Field::retrieve($editedFieldParams, $editedResults);
                         if (!($priceFieldID = CRM_Utils_Array::value('id', $editedResults))) {
                             $fieldParams = array('name' => 'other_amount', 'label' => 'Other Amount', 'price_set_id' => $priceSetId, 'html_type' => 'Text', 'is_display_amounts' => 0, 'weight' => 3);
                             $fieldParams['option_weight'][1] = 1;
                             $fieldParams['option_amount'][1] = 1;
                             if (!$noContriAmount) {
                                 $fieldParams['is_required'] = 1;
                                 $fieldParams['option_label'][1] = 'Contribution Amount';
                             } else {
                                 $fieldParams['is_required'] = 0;
                                 $fieldParams['option_label'][1] = 'Other Amount';
                             }
                             $priceField = CRM_Price_BAO_Field::create($fieldParams);
                         } else {
                             if (!CRM_Utils_Array::value('is_active', $editedResults)) {
                                 CRM_Price_BAO_Field::setIsActive($priceFieldID, '1');
                             }
                         }
                     } elseif (!CRM_Utils_Array::value('is_allow_other_amount', $params) && CRM_Utils_Array::value('price_field_other', $params)) {
                         CRM_Price_BAO_Field::setIsActive($params['price_field_other'], '0');
                     } elseif ($priceFieldID = CRM_Utils_Array::value('price_field_other', $params)) {
                         $priceFieldValueID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $priceFieldID, 'id', 'price_field_id');
                         if (!$noContriAmount) {
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_Field', $priceFieldID, 'is_required', 1);
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_FieldValue', $priceFieldValueID, 'label', 'Contribution Amount');
                         } else {
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_Field', $priceFieldID, 'is_required', 0);
                             CRM_Core_DAO::setFieldValue('CRM_Price_DAO_FieldValue', $priceFieldValueID, 'label', 'Other Amount');
                         }
                     }
                 }
                 if (CRM_Utils_Array::value('is_pledge_active', $params)) {
                     $deletePledgeBlk = FALSE;
                     $pledgeBlockParams = array('entity_id' => $contributionPageID, 'entity_table' => ts('civicrm_contribution_page'));
                     if ($this->_pledgeBlockID) {
                         $pledgeBlockParams['id'] = $this->_pledgeBlockID;
                     }
                     $pledgeBlock = array('pledge_frequency_unit', 'max_reminders', 'initial_reminder_day', 'additional_reminder_day');
                     foreach ($pledgeBlock as $key) {
                         $pledgeBlockParams[$key] = CRM_Utils_Array::value($key, $params);
                     }
                     $pledgeBlockParams['is_pledge_interval'] = CRM_Utils_Array::value('is_pledge_interval', $params, FALSE);
                     // create pledge block.
                     CRM_Pledge_BAO_PledgeBlock::create($pledgeBlockParams);
                 }
             }
         } else {
             if (CRM_Utils_Array::value('price_field_id', $params) || CRM_Utils_Array::value('price_field_other', $params)) {
                 $usedPriceSetId = CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $this->_id, 3);
                 if ($usedPriceSetId) {
                     if (CRM_Utils_Array::value('price_field_id', $params)) {
                         CRM_Price_BAO_Field::setIsActive($params['price_field_id'], '0');
                     }
                     if (CRM_Utils_Array::value('price_field_other', $params)) {
                         CRM_Price_BAO_Field::setIsActive($params['price_field_other'], '0');
                     }
                 } else {
                     $deleteAmountBlk = TRUE;
                     $deletePriceSet = TRUE;
                 }
             }
         }
         // delete pledge block.
         if ($deletePledgeBlk) {
             CRM_Pledge_BAO_PledgeBlock::deletePledgeBlock($this->_pledgeBlockID);
         }
         // delete previous price set.
         if ($deletePriceSet) {
             CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $contributionPageID);
         }
         if ($deleteAmountBlk) {
             $priceField = CRM_Utils_Array::value('price_field_id', $params) ? $params['price_field_id'] : CRM_Utils_Array::value('price_field_other', $params);
             if ($priceField) {
                 $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $priceField, 'price_set_id');
                 CRM_Price_BAO_Set::setIsQuickConfig($priceSetID, 0);
             }
         }
     }
     parent::endPostProcess();
 }
コード例 #26
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // we do this in case the user has hit the forward/back button
     if ($this->_id) {
         $params['id'] = $this->_id;
     } else {
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = date('YmdHis');
         $config = CRM_Core_Config::singleton();
         $params['currency'] = $config->defaultCurrency;
     }
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
     $params['is_credit_card_only'] = CRM_Utils_Array::value('is_credit_card_only', $params, false);
     $params['honor_block_is_active'] = CRM_Utils_Array::value('honor_block_is_active', $params, false);
     $params['is_for_organization'] = CRM_Utils_Array::value('is_organization', $params) ? CRM_Utils_Array::value('is_for_organization', $params, false) : 0;
     $params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], $params['start_date_time'], true);
     $params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], $params['end_date_time'], true);
     $params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
     if (!$params['honor_block_is_active']) {
         $params['honor_block_title'] = null;
         $params['honor_block_text'] = null;
     }
     require_once 'CRM/Contribute/BAO/ContributionPage.php';
     $dao =& CRM_Contribute_BAO_ContributionPage::create($params);
     $this->set('id', $dao->id);
     parent::postProcess();
 }
コード例 #27
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $params['id'] = $this->_id;
     $params['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $params, FALSE);
     if (!$params['is_email_receipt']) {
         $params['receipt_from_name'] = NULL;
         $params['receipt_from_email'] = NULL;
         $params['receipt_text'] = NULL;
         $params['cc_receipt'] = NULL;
         $params['bcc_receipt'] = NULL;
     }
     $dao = CRM_Contribute_BAO_ContributionPage::create($params);
     parent::endPostProcess();
 }
コード例 #28
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();
 }
コード例 #29
0
ファイル: Amount.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /** 
  * This function sets the default values for the form. Note that in edit/view mode 
  * the default values are retrieved from the database 
  * 
  * @access public 
  * @return void 
  */
 function setDefaultValues()
 {
     $defaults = parent::setDefaultValues();
     $title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
     CRM_Utils_System::setTitle(ts('Contribution Amounts (%1)', array(1 => $title)));
     if (!CRM_Utils_Array::value('pay_later_text', $defaults)) {
         $defaults['pay_later_text'] = ts('I will send payment by check');
     }
     if (CRM_Utils_Array::value('amount_block_is_active', $defaults)) {
         // don't allow other amount option when price set present.
         $this->assign('priceSetID', $this->_priceSetID);
         if ($this->_priceSetID) {
             return $defaults;
         }
         require_once 'CRM/Core/OptionGroup.php';
         CRM_Core_OptionGroup::getAssoc("civicrm_contribution_page.amount.{$this->_id}", $this->_amountBlock);
         $hasAmountBlock = false;
         if (!empty($this->_amountBlock)) {
             $hasAmountBlock = true;
             $defaults = array_merge($defaults, $this->_amountBlock);
         }
         if (CRM_Utils_Array::value('value', $defaults) && is_array($defaults['value'])) {
             if (CRM_Utils_Array::value('default_amount_id', $defaults) && CRM_Utils_Array::value('amount_id', $defaults) && is_array($defaults['amount_id'])) {
                 foreach ($defaults['value'] as $i => $v) {
                     if ($defaults['amount_id'][$i] == $defaults['default_amount_id']) {
                         $defaults['default'] = $i;
                         break;
                     }
                 }
             }
             // CRM-4038: fix value display
             foreach ($defaults['value'] as &$amount) {
                 $amount = trim(CRM_Utils_Money::format($amount, ' '));
             }
         }
     }
     // fix the display of the monetary value, CRM-4038
     require_once 'CRM/Utils/Money.php';
     if (isset($defaults['min_amount'])) {
         $defaults['min_amount'] = CRM_Utils_Money::format($defaults['min_amount'], null, '%a');
     }
     if (isset($defaults['max_amount'])) {
         $defaults['max_amount'] = CRM_Utils_Money::format($defaults['max_amount'], null, '%a');
     }
     return $defaults;
 }
コード例 #30
0
ファイル: Premium.php プロジェクト: ksecor/civicrm
 /**
  * Function to actually build the form
  *
  * @return void
  * @access public
  */
 public function buildQuickForm()
 {
     $this->addElement('checkbox', 'premiums_active', ts('Premiums Section Enabled?'), null, array('onclick' => "premiumBlock(this);"));
     $this->addElement('text', 'premiums_intro_title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_intro_title'));
     $this->add('textarea', 'premiums_intro_text', ts('Introductory Message'), 'rows=5, cols=50');
     $this->add('text', 'premiums_contact_email', ts('Contact Email') . ' ', CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_contact_email'));
     $this->addRule('premiums_contact_email', ts('Please enter a valid email address for Contact Email') . ' ', 'email');
     $this->add('text', 'premiums_contact_phone', ts('Contact Phone'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Premium', 'premiums_contact_phone'));
     $this->addRule('premiums_contact_phone', ts('Please enter a valid phone number.'), 'phone');
     $this->addElement('checkbox', 'premiums_display_min_contribution', ts('Display Minimum Contribution Amount?'));
     $showForm = true;
     if ($this->_single) {
         if ($this->_id) {
             $daoPremium =& new CRM_Contribute_DAO_Premium();
             $daoPremium->entity_id = $this->_id;
             $daoPremium->entity_table = 'civicrm_contribution_page';
             if ($daoPremium->find(true)) {
                 $showForm = false;
             }
         }
     }
     $this->assign('showForm', $showForm);
     parent::buildQuickForm();
 }