當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Member_DAO_MembershipBlock::find方法代碼示例

本文整理匯總了PHP中CRM_Member_DAO_MembershipBlock::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Member_DAO_MembershipBlock::find方法的具體用法?PHP CRM_Member_DAO_MembershipBlock::find怎麽用?PHP CRM_Member_DAO_MembershipBlock::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Member_DAO_MembershipBlock的用法示例。


在下文中一共展示了CRM_Member_DAO_MembershipBlock::find方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteMembershipBlock

 /**
  * Helper function to delete the membership block.
  * @param $blcokId
  */
 public function deleteMembershipBlock($blcokId)
 {
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->id = $blcokId;
     if ($dao->find(TRUE)) {
         $dao->delete();
     }
 }
開發者ID:konadave,項目名稱:civicrm-core,代碼行數:12,代碼來源:Membership.php

示例2: del

 /**
  * Function to delete membership Blocks
  *
  * @param int $id
  * @static
  */
 static function del($id)
 {
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->id = $id;
     $result = FALSE;
     if ($dao->find(TRUE)) {
         $dao->delete();
         $result = TRUE;
     }
     return $result;
 }
開發者ID:hguru,項目名稱:224Civi,代碼行數:17,代碼來源:MembershipBlock.php

示例3: getMembershipBlock

 /**
  * Return Membership Block info in Contribution Pages.
  *
  * @param int $pageID
  *   Contribution page id.
  *
  * @return array|null
  */
 public static function getMembershipBlock($pageID)
 {
     $membershipBlock = array();
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $pageID;
     $dao->is_active = 1;
     if ($dao->find(TRUE)) {
         CRM_Core_DAO::storeValues($dao, $membershipBlock);
         if (!empty($membershipBlock['membership_types'])) {
             $membershipTypes = unserialize($membershipBlock['membership_types']);
             if (!is_array($membershipTypes)) {
                 return $membershipBlock;
             }
             $memTypes = array();
             foreach ($membershipTypes as $key => $value) {
                 $membershipBlock['auto_renew'][$key] = $value;
                 $memTypes[$key] = $key;
             }
             $membershipBlock['membership_types'] = implode(',', $memTypes);
         }
     } else {
         return NULL;
     }
     return $membershipBlock;
 }
開發者ID:konadave,項目名稱:civicrm-core,代碼行數:34,代碼來源:Membership.php

示例4: formRule

 /**  
  * global form rule  
  *  
  * @param array $fields  the input form values  
  * @param array $files   the uploaded files if any  
  * @param array $options additional user data  
  *  
  * @return true if no errors, else array of errors  
  * @access public  
  * @static  
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     $minAmount = CRM_Utils_Array::value('min_amount', $fields);
     $maxAmount = CRM_Utils_Array::value('max_amount', $fields);
     if (!empty($minAmount) && !empty($maxAmount)) {
         $minAmount = CRM_Utils_Rule::cleanMoney($minAmount);
         $maxAmount = CRM_Utils_Rule::cleanMoney($maxAmount);
         if ((double) $minAmount > (double) $maxAmount) {
             $errors['min_amount'] = ts('Minimum Amount should be less than Maximum Amount');
         }
     }
     if (isset($fields['is_pay_later'])) {
         if (empty($fields['pay_later_text'])) {
             $errors['pay_later_text'] = ts('Please enter the text for the \'pay later\' checkbox displayed on the contribution form.');
         }
         if (empty($fields['pay_later_receipt'])) {
             $errors['pay_later_receipt'] = ts('Please enter the instructions to be sent to the contributor when they choose to \'pay later\'.');
         }
     }
     //as for separate membership payment we has to have
     //contribution amount section enabled, hence to disable it need to
     //check if separate membership payment enabled,
     //if so disable first separate membership payment option
     //then disable contribution amount section. CRM-3801,
     require_once 'CRM/Member/DAO/MembershipBlock.php';
     $membershipBlock = new CRM_Member_DAO_MembershipBlock();
     $membershipBlock->entity_table = 'civicrm_contribution_page';
     $membershipBlock->entity_id = $self->_id;
     $membershipBlock->is_active = 1;
     $hasMembershipBlk = false;
     if ($membershipBlock->find(true)) {
         $hasMembershipBlk = true;
         if ($membershipBlock->is_separate_payment && !$fields['amount_block_is_active']) {
             $errors['amount_block_is_active'] = ts('To disable Contribution Amounts section you need to first disable Separate Membership Payment option from Membership Settings.');
         }
     }
     // don't allow price set w/ membership signup, CRM-5095
     if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
         // don't allow price set w/ membership.
         if ($hasMembershipBlk) {
             $errors['price_set_id'] = ts('You cannot enable both Price Set and Membership Signup on the same online contribution page.');
         }
     } else {
         if (isset($fields['is_recur'])) {
             if (empty($fields['recur_frequency_unit'])) {
                 $errors['recur_frequency_unit'] = ts('At least one recurring frequency option needs to be checked.');
             }
         }
         // validation for pledge fields.
         if (CRM_Utils_array::value('is_pledge_active', $fields)) {
             if (empty($fields['pledge_frequency_unit'])) {
                 $errors['pledge_frequency_unit'] = ts('At least one pledge frequency option needs to be checked.');
             }
             if (CRM_Utils_array::value('is_recur', $fields)) {
                 $errors['is_recur'] = ts('You cannot enable both Recurring Contributions AND Pledges on the same online contribution page.');
             }
         }
         // If Contribution amount section is enabled, then
         // Allow other amounts must be enabeld OR the Fixed Contribution
         // Contribution options must contain at least one set of values.
         if (CRM_Utils_Array::value('amount_block_is_active', $fields)) {
             if (!CRM_Utils_Array::value('is_allow_other_amount', $fields) && !$priceSetId) {
                 //get the values of amount block
                 $values = CRM_Utils_Array::value('value', $fields);
                 $isSetRow = false;
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (isset($values[$i]) && strlen(trim($values[$i])) > 0) {
                         $isSetRow = true;
                     }
                 }
                 if (!$isSetRow) {
                     $errors['amount_block_is_active'] = ts('If you want to enable the \'Contribution Amounts section\', you need to either \'Allow Other Amounts\' and/or enter at least one row in the \'Fixed Contribution Amounts\' table.');
                 }
             }
         }
     }
     return $errors;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:90,代碼來源:Amount.php

示例5: formRule

 /**
  * global form rule
  *
  * @param array $fields  the input form values
  * @param array $files   the uploaded files if any
  * @param array $options additional user data
  *
  * @return true if no errors, else array of errors
  * @access public
  * @static
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     //as for separate membership payment we has to have
     //contribution amount section enabled, hence to disable it need to
     //check if separate membership payment enabled,
     //if so disable first separate membership payment option
     //then disable contribution amount section. CRM-3801,
     $membershipBlock = new CRM_Member_DAO_MembershipBlock();
     $membershipBlock->entity_table = 'civicrm_contribution_page';
     $membershipBlock->entity_id = $self->_id;
     $membershipBlock->is_active = 1;
     $hasMembershipBlk = FALSE;
     if ($membershipBlock->find(TRUE)) {
         if (CRM_Utils_Array::value('amount_block_is_active', $fields) && ($setID = CRM_Price_BAO_Set::getFor('civicrm_contribution_page', $self->_id, NULL, 1))) {
             $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $setID, 'extends');
             if ($extends && $extends == CRM_Core_Component::getComponentID('CiviMember')) {
                 $errors['amount_block_is_active'] = ts('You cannot use a Membership Price Set when the Contribution Amounts section is enabled. Click the Memberships tab above, and select your Membership Price Set on that form. Membership Price Sets may include additional fields for non-membership options that require an additional fee (e.g. magazine subscription) or an additional voluntary contribution.');
                 return $errors;
             }
         }
         $hasMembershipBlk = TRUE;
         if ($membershipBlock->is_separate_payment && !$fields['amount_block_is_active']) {
             $errors['amount_block_is_active'] = ts('To disable Contribution Amounts section you need to first disable Separate Membership Payment option from Membership Settings.');
         }
     }
     $minAmount = CRM_Utils_Array::value('min_amount', $fields);
     $maxAmount = CRM_Utils_Array::value('max_amount', $fields);
     if (!empty($minAmount) && !empty($maxAmount)) {
         $minAmount = CRM_Utils_Rule::cleanMoney($minAmount);
         $maxAmount = CRM_Utils_Rule::cleanMoney($maxAmount);
         if ((double) $minAmount > (double) $maxAmount) {
             $errors['min_amount'] = ts('Minimum Amount should be less than Maximum Amount');
         }
     }
     if (isset($fields['is_pay_later'])) {
         if (empty($fields['pay_later_text'])) {
             $errors['pay_later_text'] = ts('Please enter the text for the \'pay later\' checkbox displayed on the contribution form.');
         }
         if (empty($fields['pay_later_receipt'])) {
             $errors['pay_later_receipt'] = ts('Please enter the instructions to be sent to the contributor when they choose to \'pay later\'.');
         }
     }
     // don't allow price set w/ membership signup, CRM-5095
     if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
         // don't allow price set w/ membership.
         if ($hasMembershipBlk) {
             $errors['price_set_id'] = ts('You cannot enable both a Contribution Price Set and Membership Signup on the same online contribution page.');
         }
     } else {
         if (isset($fields['is_recur'])) {
             if (empty($fields['recur_frequency_unit'])) {
                 $errors['recur_frequency_unit'] = ts('At least one recurring frequency option needs to be checked.');
             }
         }
         // validation for pledge fields.
         if (CRM_Utils_array::value('is_pledge_active', $fields)) {
             if (empty($fields['pledge_frequency_unit'])) {
                 $errors['pledge_frequency_unit'] = ts('At least one pledge frequency option needs to be checked.');
             }
             if (CRM_Utils_array::value('is_recur', $fields)) {
                 $errors['is_recur'] = ts('You cannot enable both Recurring Contributions AND Pledges on the same online contribution page.');
             }
         }
         // If Contribution amount section is enabled, then
         // Allow other amounts must be enabeld OR the Fixed Contribution
         // Contribution options must contain at least one set of values.
         if (CRM_Utils_Array::value('amount_block_is_active', $fields)) {
             if (!CRM_Utils_Array::value('is_allow_other_amount', $fields) && !$priceSetId) {
                 //get the values of amount block
                 $values = CRM_Utils_Array::value('value', $fields);
                 $isSetRow = FALSE;
                 for ($i = 1; $i < self::NUM_OPTION; $i++) {
                     if (isset($values[$i]) && strlen(trim($values[$i])) > 0) {
                         $isSetRow = TRUE;
                     }
                 }
                 if (!$isSetRow) {
                     $errors['amount_block_is_active'] = ts('If you want to enable the \'Contribution Amounts section\', you need to either \'Allow Other Amounts\' and/or enter at least one row in the \'Fixed Contribution Amounts\' table.');
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('is_recur_interval', $fields)) {
         foreach (array_keys($fields['payment_processor']) as $paymentProcessorID) {
             $paymentProcessorType = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PaymentProcessor', $paymentProcessorID, 'payment_processor_type');
             if ($paymentProcessorType == 'Google_Checkout') {
                 $errors['is_recur_interval'] = ts('Google Checkout does not support recurring intervals');
                 break;
//.........這裏部分代碼省略.........
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:101,代碼來源:Amount.php

示例6: getMembershipBlock

 /**
  * Function to return Membership  Block info in Contribution Pages 
  * 
  * @param int $pageId contribution page id
  *
  * @static
  */
 static function getMembershipBlock($pageID)
 {
     $membershipBlock = array();
     require_once 'CRM/Member/DAO/MembershipBlock.php';
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $pageID;
     $dao->is_active = 1;
     if ($dao->find(true)) {
         CRM_Core_DAO::storeValues($dao, $membershipBlock);
         $membershipTypes = unserialize($membershipBlock['membership_types']);
         if (!is_array($membershipTypes)) {
             return $membershipBlock;
         }
         foreach ($membershipTypes as $key => $value) {
             $membershipBlock["auto_renew"][$key] = $value;
             $memTypes[$key] = $key;
         }
         $membershipBlock['membership_types'] = implode(',', $memTypes);
     } else {
         return null;
     }
     return $membershipBlock;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:31,代碼來源:Membership.php

示例7: postProcess

 /**
  * 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++;
//.........這裏部分代碼省略.........
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:101,代碼來源:MembershipBlock.php

示例8: formRule

 /**
  * Global form rule.
  *
  * @param array $fields
  *   The input form values.
  *
  * @param $files
  * @param int $contributionPageId
  *
  * @return bool|array
  *   true if no errors, else array of errors
  */
 public static function formRule($fields, $files, $contributionPageId)
 {
     $errors = array();
     $preProfileType = $postProfileType = NULL;
     // for membership profile make sure Membership section is enabled
     // get membership section for this contribution page
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $contributionPageId;
     $membershipEnable = FALSE;
     if ($dao->find(TRUE) && $dao->is_active) {
         $membershipEnable = TRUE;
     }
     if ($fields['custom_pre_id']) {
         $preProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_pre_id']);
     }
     if ($fields['custom_post_id']) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_post_id']);
     }
     $errorMsg = ts('You must enable the Membership Block for this Contribution Page if you want to include a Profile with Membership fields.');
     if ($preProfileType == 'Membership' && !$membershipEnable) {
         $errors['custom_pre_id'] = $errorMsg;
     }
     if ($postProfileType == 'Membership' && !$membershipEnable) {
         $errors['custom_post_id'] = $errorMsg;
     }
     $behalf = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageId, 'is_for_organization');
     if ($fields['custom_pre_id']) {
         $errorMsg = ts('You should move the membership related fields in the "On Behalf" profile for this Contribution Page');
         if ($preProfileType == 'Membership' && $behalf) {
             $errors['custom_pre_id'] = isset($errors['custom_pre_id']) ? $errors['custom_pre_id'] . $errorMsg : $errorMsg;
         }
     }
     if ($fields['custom_post_id']) {
         $errorMsg = ts('You should move the membership related fields in the "On Behalf" profile for this Contribution Page');
         if ($postProfileType == 'Membership' && $behalf) {
             $errors['custom_post_id'] = isset($errors['custom_post_id']) ? $errors['custom_post_id'] . $errorMsg : $errorMsg;
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
開發者ID:vakeesan26,項目名稱:civicrm-core,代碼行數:53,代碼來源:Custom.php

示例9: buildQuickForm

 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     $this->applyFilter('__ALL__', 'trim');
     $session = CRM_Core_Session::singleton();
     $this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST);
     if (!$this->_cancelURL) {
         $this->_cancelURL = CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1');
     }
     if ($this->_cancelURL) {
         $this->addElement('hidden', 'cancelURL', $this->_cancelURL);
     }
     if ($this->_single) {
         $buttons = array(array('type' => 'next', 'name' => ts('Save'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and Done'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'subName' => 'done'));
         if (!$this->_last) {
             $buttons[] = array('type' => 'submit', 'name' => ts('Save and Next'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'subName' => 'savenext');
         }
         $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
         $this->addButtons($buttons);
     } else {
         $buttons = array();
         if (!$this->_first) {
             $buttons[] = array('type' => 'back', 'name' => ts('Previous'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
         }
         $buttons[] = array('type' => 'next', 'name' => ts('Continue'), 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 'isDefault' => TRUE);
         $buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'));
         $this->addButtons($buttons);
     }
     $session->replaceUserContext($this->_cancelURL);
     // views are implemented as frozen form
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"));
     }
     // don't show option for contribution amounts section if membership price set
     // this flag is sent to template
     $membershipBlock = new CRM_Member_DAO_MembershipBlock();
     $membershipBlock->entity_table = 'civicrm_contribution_page';
     $membershipBlock->entity_id = $this->_id;
     $membershipBlock->is_active = 1;
     $hasMembershipBlk = FALSE;
     if ($membershipBlock->find(TRUE) && ($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, NULL, 1))) {
         $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends');
         if ($extends && $extends == CRM_Core_Component::getComponentID('CiviMember')) {
             $hasMembershipBlk = TRUE;
         }
     }
     // set value in DOM that membership price set exists
     CRM_Core_Resources::singleton()->addSetting(array('memberPriceset' => $hasMembershipBlk));
 }
開發者ID:kidaa30,項目名稱:yes,代碼行數:54,代碼來源:ContributionPage.php

示例10: createPriceSet

 /**
  *
  * create price sets
  */
 public static function createPriceSet($daoName, $addTo, $options = array())
 {
     $query = "SELECT title FROM {$addTo[0]} where id =%1";
     $setParams['title'] = CRM_Core_DAO::singleValueQuery($query, array(1 => array($addTo[2], 'Integer')));
     $pageTitle = strtolower(CRM_Utils_String::munge($setParams['title'], '_', 245));
     // an event or contrib page has been deleted but left the option group behind - (this may be fixed in later versions?)
     // we should probably delete the option group - but at least early exit here as the code following it does not fatal
     // CRM-10298
     if (empty($pageTitle)) {
         return;
     }
     $optionValue = array();
     if (!empty($options['optionGroup'])) {
         CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
         if (empty($optionValue)) {
             return;
         }
     } elseif (empty($options['otherAmount']) && empty($options['membership'])) {
         //CRM-12273
         //if options group, otherAmount, membersip is empty then return, contribution should be default price set
         return;
     }
     if (!CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
         $setParams['name'] = $pageTitle;
     } else {
         $timeSec = explode(".", microtime(TRUE));
         $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
     }
     $setParams['extends'] = $daoName[$addTo[0]][1];
     $setParams['is_quick_config'] = 1;
     $priceSet = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
     CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo($addTo[0], $addTo[2], $priceSet->id, 1);
     $fieldParams['price_set_id'] = $priceSet->id;
     if (!empty($options['optionGroup'])) {
         $fieldParams['html_type'] = 'Radio';
         $fieldParams['is_required'] = 1;
         if ($addTo[0] == 'civicrm_event') {
             $query = "SELECT fee_label FROM civicrm_event where id =%1";
             $fieldParams['name'] = $fieldParams['label'] = CRM_Core_DAO::singleValueQuery($query, array(1 => array($addTo[2], 'Integer')));
             $defaultAmountColumn = 'default_fee_id';
         } else {
             $options['membership'] = 1;
             $fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245));
             $fieldParams['label'] = "Contribution Amount";
             $defaultAmountColumn = 'default_amount_id';
             $options['otherAmount'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $addTo[2], 'is_allow_other_amount');
             if (!empty($options['otherAmount'])) {
                 $fieldParams['is_required'] = 0;
             }
         }
         $fieldParams['option_label'] = $optionValue['label'];
         $fieldParams['option_amount'] = $optionValue['value'];
         $fieldParams['option_weight'] = $optionValue['weight'];
         $fieldParams['is_quick_config'] = $setParams['is_quick_config'];
         if ($defaultAmount = CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], $defaultAmountColumn)) {
             $fieldParams['default_option'] = array_search($defaultAmount, $optionValue['amount_id']);
         }
         $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
     }
     if (!empty($options['membership'])) {
         $dao = new CRM_Member_DAO_MembershipBlock();
         $dao->entity_table = 'civicrm_contribution_page';
         $dao->entity_id = $addTo[2];
         if ($dao->find(TRUE)) {
             if ($dao->membership_types) {
                 $fieldParams = array('name' => strtolower(CRM_Utils_String::munge("Membership Amount", '_', 245)), 'label' => "Membership Amount", 'is_required' => $dao->is_required, 'is_display_amounts' => $dao->display_min_fee, 'is_active' => $dao->is_active, 'price_set_id' => $priceSet->id, 'html_type' => 'Radio', 'weight' => 1);
                 $membershipTypes = unserialize($dao->membership_types);
                 $rowcount = 0;
                 foreach ($membershipTypes as $membershipType => $autoRenew) {
                     $membershipTypeDetail = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipType);
                     $rowcount++;
                     $fieldParams['option_label'][$rowcount] = $membershipTypeDetail['name'];
                     $fieldParams['option_amount'][$rowcount] = $membershipTypeDetail['minimum_fee'];
                     $fieldParams['option_weight'][$rowcount] = $rowcount;
                     $fieldParams['membership_type_id'][$rowcount] = $membershipType;
                     if ($membershipType == $dao->membership_type_default) {
                         $fieldParams['default_option'] = $rowcount;
                     }
                 }
                 $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
                 $setParams = array('id' => $priceSet->id, 'extends' => CRM_Core_Component::getComponentID('CiviMember'), 'contribution_type_id' => CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], 'contribution_type_id'));
                 CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
             }
         }
     }
     if (!empty($options['otherAmount'])) {
         $fieldParams = array('name' => strtolower(CRM_Utils_String::munge("Other Amount", '_', 245)), 'label' => "Other Amount", 'is_required' => 0, 'is_display_amounts' => 0, 'is_active' => 1, 'price_set_id' => $priceSet->id, 'html_type' => 'Text', 'weight' => 3);
         $fieldParams['option_label'][1] = "Other Amount";
         $fieldParams['option_amount'][1] = 1;
         $fieldParams['option_weight'][1] = 1;
         $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
     }
 }
開發者ID:JSProffitt,項目名稱:civicrm-website-org,代碼行數:97,代碼來源:FourTwo.php

示例11: formRule

 /**
  * Global form rule.
  *
  * @param array $fields
  *   The input form values.
  * @param array $files
  *   The uploaded files if any.
  * @param $self
  *
  *
  * @return bool|array
  *   true if no errors, else array of errors
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     //as for separate membership payment we has to have
     //contribution amount section enabled, hence to disable it need to
     //check if separate membership payment enabled,
     //if so disable first separate membership payment option
     //then disable contribution amount section. CRM-3801,
     $membershipBlock = new CRM_Member_DAO_MembershipBlock();
     $membershipBlock->entity_table = 'civicrm_contribution_page';
     $membershipBlock->entity_id = $self->_id;
     $membershipBlock->is_active = 1;
     $hasMembershipBlk = FALSE;
     if ($membershipBlock->find(TRUE)) {
         if (!empty($fields['amount_block_is_active']) && ($setID = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $self->_id, NULL, 1))) {
             $extends = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $setID, 'extends');
             if ($extends && $extends == CRM_Core_Component::getComponentID('CiviMember')) {
                 $errors['amount_block_is_active'] = ts('You cannot use a Membership Price Set when the Contribution Amounts section is enabled. Click the Memberships tab above, and select your Membership Price Set on that form. Membership Price Sets may include additional fields for non-membership options that require an additional fee (e.g. magazine subscription) or an additional voluntary contribution.');
                 return $errors;
             }
         }
         $hasMembershipBlk = TRUE;
         if ($membershipBlock->is_separate_payment && empty($fields['amount_block_is_active'])) {
             $errors['amount_block_is_active'] = ts('To disable Contribution Amounts section you need to first disable Separate Membership Payment option from Membership Settings.');
         }
         //CRM-16165, Don't allow reccuring contribution if membership block contain any renewable membership option
         $membershipTypes = unserialize($membershipBlock->membership_types);
         if (!empty($fields['is_recur']) && !empty($membershipTypes)) {
             if (!$membershipBlock->is_separate_payment) {
                 $errors['is_recur'] = ts('You need to enable Separate Membership Payment when online contribution page is configured for both Membership and Recurring Contribution.');
             } elseif (count(array_filter($membershipTypes)) != 0) {
                 $errors['is_recur'] = ts('You cannot enable both Recurring Contributions and Auto-renew memberships on the same online contribution page.');
             }
         }
     }
     // CRM-18854 Check if recurring start date is in the future.
     if (CRM_Utils_Array::value('pledge_calendar_date', $fields)) {
         if (date('Ymd') > date('Ymd', strtotime($fields['pledge_calendar_date']))) {
             $errors['pledge_calendar_date'] = ts('The recurring start date cannot be prior to the current date.');
         }
     }
     //check for the amount label (mandatory)
     if (!empty($fields['amount_block_is_active']) && empty($fields['amount_label'])) {
         $errors['amount_label'] = ts('Please enter the contribution amount label.');
     }
     $minAmount = CRM_Utils_Array::value('min_amount', $fields);
     $maxAmount = CRM_Utils_Array::value('max_amount', $fields);
     if (!empty($minAmount) && !empty($maxAmount)) {
         $minAmount = CRM_Utils_Rule::cleanMoney($minAmount);
         $maxAmount = CRM_Utils_Rule::cleanMoney($maxAmount);
         if ((double) $minAmount > (double) $maxAmount) {
             $errors['min_amount'] = ts('Minimum Amount should be less than Maximum Amount');
         }
     }
     if (isset($fields['is_pay_later'])) {
         if (empty($fields['pay_later_text'])) {
             $errors['pay_later_text'] = ts('Please enter the text for the \'pay later\' checkbox displayed on the contribution form.');
         }
         if (empty($fields['pay_later_receipt'])) {
             $errors['pay_later_receipt'] = ts('Please enter the instructions to be sent to the contributor when they choose to \'pay later\'.');
         }
     }
     // don't allow price set w/ membership signup, CRM-5095
     if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
         // don't allow price set w/ membership.
         if ($hasMembershipBlk) {
             $errors['price_set_id'] = ts('You cannot enable both a Contribution Price Set and Membership Signup on the same online contribution page.');
         }
     } else {
         if (isset($fields['is_recur'])) {
             if (empty($fields['recur_frequency_unit'])) {
                 $errors['recur_frequency_unit'] = ts('At least one recurring frequency option needs to be checked.');
             }
         }
         // validation for pledge fields.
         if (!empty($fields['is_pledge_active'])) {
             if (empty($fields['pledge_frequency_unit'])) {
                 $errors['pledge_frequency_unit'] = ts('At least one pledge frequency option needs to be checked.');
             }
             if (!empty($fields['is_recur'])) {
                 $errors['is_recur'] = ts('You cannot enable both Recurring Contributions AND Pledges on the same online contribution page.');
             }
         }
         // If Contribution amount section is enabled, then
         // Allow other amounts must be enabled OR the Fixed Contribution
         // Contribution options must contain at least one set of values.
         if (!empty($fields['amount_block_is_active'])) {
//.........這裏部分代碼省略.........
開發者ID:nielosz,項目名稱:civicrm-core,代碼行數:101,代碼來源:Amount.php

示例12: formRule

 /**  
  * global form rule  
  *  
  * @param array $fields  the input form values  
  *  
  * @return true if no errors, else array of errors  
  * @access public  
  * @static  
  */
 static function formRule($fields, $files, $contributionPageId)
 {
     $errors = array();
     $preProfileType = $postProfileType = null;
     // for membership profile make sure Membership section is enabled
     // get membership section for this contribution page
     require_once 'CRM/Member/DAO/MembershipBlock.php';
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $contributionPageId;
     $membershipEnable = false;
     if ($dao->find(true) && $dao->is_active) {
         $membershipEnable = true;
     }
     require_once "CRM/Core/BAO/UFField.php";
     if ($fields['custom_pre_id']) {
         $preProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_pre_id']);
     }
     if ($fields['custom_post_id']) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_post_id']);
     }
     $errorMsg = ts('You must enable the Membership Block for this Contribution Page if you want to include a Profile with Membership fields.');
     if ($preProfileType == 'Membership' && !$membershipEnable) {
         $errors['custom_pre_id'] = $errorMsg;
     }
     if ($postProfileType == 'Membership' && !$membershipEnable) {
         $errors['custom_post_id'] = $errorMsg;
     }
     return empty($errors) ? true : $errors;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:39,代碼來源:Custom.php

示例13: postProcess

 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     if ($params['membership_type']) {
         // we do this in case the user has hit the forward/back button
         require_once 'CRM/Member/DAO/MembershipBlock.php';
         $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] = $params["auto_renew_{$k}"];
                 }
             }
         }
         $params['membership_type_default'] = CRM_Utils_Array::value('membership_type_default', $params, 'null');
         $params['membership_types'] = serialize($membershipTypes);
         $params['is_required'] = CRM_Utils_Array::value('is_required', $params, false);
         $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false);
         $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();
     }
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:42,代碼來源:MembershipBlock.php

示例14: formRule

 /**
  * global form rule
  *
  * @param array $fields  the input form values
  *
  * @return true if no errors, else array of errors
  * @access public
  * @static
  */
 static function formRule($fields, $files, $contributionPageId)
 {
     $errors = array();
     $preProfileType = $postProfileType = NULL;
     // for membership profile make sure Membership section is enabled
     // get membership section for this contribution page
     $dao = new CRM_Member_DAO_MembershipBlock();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $contributionPageId;
     $membershipEnable = FALSE;
     if ($dao->find(TRUE) && $dao->is_active) {
         $membershipEnable = TRUE;
     }
     if ($fields['custom_pre_id']) {
         $preProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_pre_id']);
     }
     if ($fields['custom_post_id']) {
         $postProfileType = CRM_Core_BAO_UFField::getProfileType($fields['custom_post_id']);
     }
     $errorMsg = ts('You must enable the Membership Block for this Contribution Page if you want to include a Profile with Membership fields.');
     if ($preProfileType == 'Membership' && !$membershipEnable) {
         $errors['custom_pre_id'] = $errorMsg;
     }
     if ($postProfileType == 'Membership' && !$membershipEnable) {
         $errors['custom_post_id'] = $errorMsg;
     }
     return empty($errors) ? TRUE : $errors;
 }
開發者ID:peteainsworth,項目名稱:civicrm-4.2.9-drupal,代碼行數:37,代碼來源:Custom.php


注:本文中的CRM_Member_DAO_MembershipBlock::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。