本文整理汇总了PHP中CRM_Member_BAO_Membership::getContactsCancelledMembership方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_Membership::getContactsCancelledMembership方法的具体用法?PHP CRM_Member_BAO_Membership::getContactsCancelledMembership怎么用?PHP CRM_Member_BAO_Membership::getContactsCancelledMembership使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_Membership
的用法示例。
在下文中一共展示了CRM_Member_BAO_Membership::getContactsCancelledMembership方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formRule
/**
* Global form rule.
*
* @param array $fields
* The input form values.
* @param array $files
* The uploaded files if any.
* @param CRM_Core_Form $self
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function formRule($fields, $files, $self)
{
$errors = array();
$amount = self::computeAmount($fields, $self->_values);
if (CRM_Utils_Array::value('auto_renew', $fields) && CRM_Utils_Array::value('payment_processor_id', $fields) == 0) {
$errors['auto_renew'] = ts('You cannot have auto-renewal on if you are paying later.');
}
if (!empty($fields['selectMembership']) && $fields['selectMembership'] != 'no_thanks' || !empty($fields['priceSetId']) && $self->_useForMember) {
$isTest = $self->_action & CRM_Core_Action::PREVIEW ? TRUE : FALSE;
$lifeMember = CRM_Member_BAO_Membership::getAllContactMembership($self->_membershipContactID, $isTest, TRUE);
$membershipOrgDetails = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization();
$unallowedOrgs = array();
foreach (array_keys($lifeMember) as $memTypeId) {
$unallowedOrgs[] = $membershipOrgDetails[$memTypeId];
}
}
//check for atleast one pricefields should be selected
if (!empty($fields['priceSetId']) && empty($self->_ccid)) {
$priceField = new CRM_Price_DAO_PriceField();
$priceField->price_set_id = $fields['priceSetId'];
$priceField->orderBy('weight');
$priceField->find();
$check = array();
$membershipIsActive = TRUE;
$previousId = $otherAmount = FALSE;
while ($priceField->fetch()) {
if ($self->_quickConfig && ($priceField->name == 'contribution_amount' || $priceField->name == 'membership_amount')) {
$previousId = $priceField->id;
if ($priceField->name == 'membership_amount' && !$priceField->is_active) {
$membershipIsActive = FALSE;
}
}
if ($priceField->name == 'other_amount') {
if ($self->_quickConfig && empty($fields["price_{$priceField->id}"]) && array_key_exists("price_{$previousId}", $fields) && isset($fields["price_{$previousId}"]) && $self->_values['fee'][$previousId]['name'] == 'contribution_amount' && empty($fields["price_{$previousId}"])) {
$otherAmount = $priceField->id;
} elseif (!empty($fields["price_{$priceField->id}"])) {
$otherAmountVal = CRM_Utils_Rule::cleanMoney($fields["price_{$priceField->id}"]);
$min = CRM_Utils_Array::value('min_amount', $self->_values);
$max = CRM_Utils_Array::value('max_amount', $self->_values);
if ($min && $otherAmountVal < $min) {
$errors["price_{$priceField->id}"] = ts('Contribution amount must be at least %1', array(1 => $min));
}
if ($max && $otherAmountVal > $max) {
$errors["price_{$priceField->id}"] = ts('Contribution amount cannot be more than %1.', array(1 => $max));
}
}
}
if (!empty($fields["price_{$priceField->id}"]) || $previousId == $priceField->id && isset($fields["price_{$previousId}"]) && empty($fields["price_{$previousId}"])) {
$check[] = $priceField->id;
}
}
$currentMemberships = NULL;
if ($membershipIsActive) {
$is_test = $self->_mode != 'live' ? 1 : 0;
$memContactID = $self->_membershipContactID;
// For anonymous user check using dedupe rule
// if user has Cancelled Membership
if (!$memContactID) {
$dedupeParams = CRM_Dedupe_Finder::formatParams($fields, 'Individual');
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
// if we find more than one contact, use the first one
$memContactID = CRM_Utils_Array::value(0, $ids);
}
$currentMemberships = CRM_Member_BAO_Membership::getContactsCancelledMembership($memContactID, $is_test);
$errorText = 'Your %1 membership was previously cancelled and can not be renewed online. Please contact the site administrator for assistance.';
foreach ($self->_values['fee'] as $fieldKey => $fieldValue) {
if ($fieldValue['html_type'] != 'Text' && CRM_Utils_Array::value('price_' . $fieldKey, $fields)) {
if (!is_array($fields['price_' . $fieldKey]) && isset($fieldValue['options'][$fields['price_' . $fieldKey]])) {
if (array_key_exists('membership_type_id', $fieldValue['options'][$fields['price_' . $fieldKey]]) && in_array($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id'], $currentMemberships)) {
$errors['price_' . $fieldKey] = ts($errorText, array(1 => CRM_Member_PseudoConstant::membershipType($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id'])));
}
} else {
if (is_array($fields['price_' . $fieldKey])) {
foreach (array_keys($fields['price_' . $fieldKey]) as $key) {
if (array_key_exists('membership_type_id', $fieldValue['options'][$key]) && in_array($fieldValue['options'][$key]['membership_type_id'], $currentMemberships)) {
$errors['price_' . $fieldKey] = ts($errorText, array(1 => CRM_Member_PseudoConstant::membershipType($fieldValue['options'][$key]['membership_type_id'])));
}
}
}
}
}
}
}
// CRM-12233
if ($membershipIsActive && !$self->_membershipBlock['is_required'] && $self->_values['amount_block_is_active']) {
$membershipFieldId = $contributionFieldId = $errorKey = $otherFieldId = NULL;
foreach ($self->_values['fee'] as $fieldKey => $fieldValue) {
//.........这里部分代码省略.........