本文整理汇总了PHP中CRM_Member_DAO_MembershipBlock类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_DAO_MembershipBlock类的具体用法?PHP CRM_Member_DAO_MembershipBlock怎么用?PHP CRM_Member_DAO_MembershipBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Member_DAO_MembershipBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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;
}
示例3: postProcess
/**
* Process the form when submitted
*
* @return void
* @access public
*/
public function postProcess()
{
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
// first delete the join entries associated with this contribution page
require_once 'CRM/Core/DAO/UFJoin.php';
$dao = new CRM_Core_DAO_UFJoin();
$params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
$dao->copyValues($params);
$dao->delete();
require_once 'CRM/Core/OptionGroup.php';
$groupName = "civicrm_contribution_page.amount.{$this->_id}";
CRM_Core_OptionGroup::deleteAssoc($groupName);
//next delete the membership block fields
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->delete();
//next delete the pcp block fields
require_once 'CRM/Contribute/DAO/PCPBlock.php';
$dao = new CRM_Contribute_DAO_PCPBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $this->_id;
$dao->delete();
// need to delete premiums. CRM-4586
require_once 'CRM/Contribute/BAO/Premium.php';
CRM_Contribute_BAO_Premium::deletePremium($this->_id);
// price set cleanup, CRM-5527
require_once 'CRM/Price/BAO/Set.php';
CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $this->_id);
// finally delete the contribution page
require_once 'CRM/Contribute/DAO/ContributionPage.php';
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->id = $this->_id;
$dao->delete();
$transaction->commit();
CRM_Core_Session::setStatus(ts('The contribution page \'%1\' has been deleted.', array(1 => $this->_title)));
}
示例4: 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++;
//.........这里部分代码省略.........
示例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;
//.........这里部分代码省略.........
示例6: 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();
}
}
示例7: 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;
}
示例8: upgrade_3_3_2
function upgrade_3_3_2($rev)
{
$dropMailingIndex = FALSE;
$indexes = CRM_Core_DAO::executeQuery('SHOW INDEXES FROM civicrm_mailing_job');
while ($indexes->fetch()) {
if ($indexes->Key_name == 'parent_id') {
$dropMailingIndex = TRUE;
break;
}
}
//CRM-7137
// get membership type for each membership block.
$sql = "SELECT id, membership_types FROM civicrm_membership_block ";
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$memType = explode(',', $dao->membership_types);
$memTypeSerialize = array();
foreach ($memType as $k => $v) {
$memTypeSerialize[$v] = 0;
}
// save membership type as an serialized array along w/ auto_renew defalt value zero.
$memBlock = new CRM_Member_DAO_MembershipBlock();
$memBlock->id = $dao->id;
$memBlock->membership_types = serialize($memTypeSerialize);
$memBlock->save();
}
//CRM-7172
if (CRM_Mailing_Info::workflowEnabled()) {
$config = CRM_Core_Config::singleton();
if (is_callable(array($config->userSystem, 'replacePermission'))) {
$config->userSystem->replacePermission('access CiviMail', array('access CiviMail', 'create mailings', 'approve mailings', 'schedule mailings'));
}
}
$upgrade = new CRM_Upgrade_Form();
$upgrade->assign('dropMailingIndex', $dropMailingIndex);
$upgrade->processSQL($rev);
}
示例9: 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);
}
}
示例10: 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;
}
示例11: postProcess
/**
* Process the form when submitted
*
* @return void
* @access public
*/
public function postProcess()
{
$transaction = new CRM_Core_Transaction();
// first delete the join entries associated with this contribution page
$dao = new CRM_Core_DAO_UFJoin();
$params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
$dao->copyValues($params);
$dao->delete();
//next delete the membership block fields
$dao = new CRM_Member_DAO_MembershipBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $this->_id;
$dao->delete();
//next delete the pcp block fields
$dao = new CRM_PCP_DAO_PCPBlock();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $this->_id;
$dao->delete();
// need to delete premiums. CRM-4586
CRM_Contribute_BAO_Premium::deletePremium($this->_id);
// price set cleanup, CRM-5527
CRM_Price_BAO_PriceSet::removeFrom('civicrm_contribution_page', $this->_id);
// finally delete the contribution page
$dao = new CRM_Contribute_DAO_ContributionPage();
$dao->id = $this->_id;
$dao->delete();
$transaction->commit();
CRM_Core_Session::setStatus(ts("The contribution page '%1' has been deleted.", array(1 => $this->_title)), ts('Deleted'), 'success');
}
示例12: 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'])) {
//.........这里部分代码省略.........
示例13: 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;
}
示例14: 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;
}
示例15: 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' => ' ', 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and Done'), 'spacing' => ' ', 'subName' => 'done'));
if (!$this->_last) {
$buttons[] = array('type' => 'submit', 'name' => ts('Save and Next'), 'spacing' => ' ', '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' => ' ');
}
$buttons[] = array('type' => 'next', 'name' => ts('Continue'), 'spacing' => ' ', '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));
}