本文整理汇总了PHP中CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes方法的具体用法?PHP CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes怎么用?PHP CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Member_BAO_MembershipType
的用法示例。
在下文中一共展示了CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formRule
/**
* Validation.
*
* @param array $params
* (ref.) an assoc array of name/value pairs.
*
* @param $files
* @param $self
*
* @throws CiviCRM_API3_Exception
* @return bool|array
* mixed true or array of errors
*/
public static function formRule($params, $files, $self)
{
$errors = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $params);
if ($priceSetId) {
CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $params, $errors);
$priceFieldIDS = array();
foreach ($self->_priceSet['fields'] as $priceIds => $field) {
if (!empty($params['price_' . $priceIds])) {
if (is_array($params['price_' . $priceIds])) {
foreach ($params['price_' . $priceIds] as $priceFldVal => $isSet) {
if ($isSet) {
$priceFieldIDS[] = $priceFldVal;
}
}
} elseif (!$field['is_enter_qty']) {
$priceFieldIDS[] = $params['price_' . $priceIds];
}
}
}
if (!empty($priceFieldIDS)) {
$ids = implode(',', $priceFieldIDS);
$count = CRM_Price_BAO_PriceSet::getMembershipCount($ids);
foreach ($count as $id => $occurance) {
if ($occurance > 1) {
$errors['_qf_default'] = ts('Select at most one option associated with the same membership type.');
}
}
foreach ($priceFieldIDS as $priceFieldId) {
if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id')) {
$self->_memTypeSelected[$id] = $id;
}
}
}
} elseif (empty($params['membership_type_id'][1])) {
$errors['membership_type_id'] = ts('Please select a membership type.');
} else {
$self->_memTypeSelected[] = $params['membership_type_id'][1];
}
if (!$priceSetId) {
$numterms = CRM_Utils_Array::value('num_terms', $params);
if ($numterms && intval($numterms) != $numterms) {
$errors['num_terms'] = ts('Please enter an integer for the number of terms.');
}
}
// Return error if empty $self->_memTypeSelected
if ($priceSetId && empty($errors) && empty($self->_memTypeSelected)) {
$errors['_qf_default'] = ts('Select at least one membership option.');
}
if (!empty($errors) && count($self->_memTypeSelected) > 1) {
$memberOfContacts = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($self->_memTypeSelected);
$duplicateMemberOfContacts = array_count_values($memberOfContacts);
foreach ($duplicateMemberOfContacts as $countDuplicate) {
if ($countDuplicate > 1) {
$errors['_qf_default'] = ts('Please do not select more than one membership associated with the same organization.');
}
}
}
if (!empty($errors)) {
return $errors;
}
if ($priceSetId && !$self->_mode && empty($params['record_contribution'])) {
$errors['record_contribution'] = ts('Record Membership Payment is required when you using price set.');
}
if (!$priceSetId && $self->_mode && empty($params['financial_type_id'])) {
$errors['financial_type_id'] = ts('Please enter the financial Type.');
}
if (!empty($params['record_contribution']) && empty($params['payment_instrument_id'])) {
$errors['payment_instrument_id'] = ts('Paid By is a required field.');
}
if (!empty($params['is_different_contribution_contact'])) {
if (empty($params['soft_credit_type_id'])) {
$errors['soft_credit_type_id'] = ts('Please Select a Soft Credit Type');
}
if (empty($params['soft_credit_contact_id'])) {
$errors['soft_credit_contact_id'] = ts('Please select a contact');
}
}
if (!empty($params['payment_processor_id'])) {
// validate payment instrument (e.g. credit card number)
CRM_Core_Payment_Form::validatePaymentInstrument($params['payment_processor_id'], $params, $errors, $self);
}
$joinDate = NULL;
if (!empty($params['join_date'])) {
$joinDate = CRM_Utils_Date::processDate($params['join_date']);
foreach ($self->_memTypeSelected as $memType) {
$startDate = NULL;
//.........这里部分代码省略.........
示例2: formRule
/**
* Function for validation
*
* @param array $params (ref.) an assoc array of name/value pairs
*
* @return mixed true or array of errors
* @access public
* @static
*/
public function formRule($params, $files, $self)
{
$errors = array();
$priceSetId = CRM_Utils_Array::value('price_set_id', $params);
if ($priceSetId) {
CRM_Price_BAO_Field::priceSetValidation($priceSetId, $params, $errors);
$priceFieldIDS = array();
foreach ($self->_priceSet['fields'] as $priceIds => $dontCare) {
if (!empty($params['price_' . $priceIds])) {
if (is_array($params['price_' . $priceIds])) {
foreach ($params['price_' . $priceIds] as $priceFldVal => $isSet) {
if ($isSet) {
$priceFieldIDS[] = $priceFldVal;
}
}
} else {
$priceFieldIDS[] = $params['price_' . $priceIds];
}
}
}
if (!empty($priceFieldIDS)) {
$ids = implode(',', $priceFieldIDS);
$count = CRM_Price_BAO_Set::getMembershipCount($ids);
foreach ($count as $id => $occurance) {
if ($occurance > 1) {
$errors['_qf_default'] = ts('Select at most one option associated with the same membership type.');
}
}
foreach ($priceFieldIDS as $priceFieldId) {
if ($id = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $priceFieldId, 'membership_type_id')) {
$self->_memTypeSelected[$id] = $id;
}
}
}
} elseif (!CRM_Utils_Array::value(1, $params['membership_type_id'])) {
$errors['membership_type_id'] = ts('Please select a membership type.');
} else {
$self->_memTypeSelected[] = $params['membership_type_id'][1];
}
// Return error if empty $self->_memTypeSelected
if ($priceSetId && empty($errors) && empty($self->_memTypeSelected)) {
$errors['_qf_default'] = ts('Select at least one membership option.');
}
if (!empty($errors) && count($self->_memTypeSelected) > 1) {
$memberOfContacts = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($self->_memTypeSelected);
$duplicateMemberOfContacts = array_count_values($memberOfContacts);
foreach ($duplicateMemberOfContacts as $countDuplicate) {
if ($countDuplicate > 1) {
$errors['_qf_default'] = ts('Please do not select more than one membership associated with the same organization.');
}
}
}
//check if contact is selected in standalone mode
if (isset($params['contact_select_id'][1]) && !$params['contact_select_id'][1]) {
$errors['contact[1]'] = ts('Please select a contact or create new contact');
}
if (!empty($errors)) {
return $errors;
}
if ($priceSetId && !$self->_mode && !CRM_Utils_Array::value('record_contribution', $params)) {
$errors['record_contribution'] = ts('Record Membership Payment is required when you using price set.');
}
if (CRM_Utils_Array::value('payment_processor_id', $params)) {
// make sure that credit card number and cvv are valid
if (CRM_Utils_Array::value('credit_card_type', $params)) {
if (CRM_Utils_Array::value('credit_card_number', $params) && !CRM_Utils_Rule::creditCardNumber($params['credit_card_number'], $params['credit_card_type'])) {
$errors['credit_card_number'] = ts("Please enter a valid Credit Card Number");
}
if (CRM_Utils_Array::value('cvv2', $params) && !CRM_Utils_Rule::cvv($params['cvv2'], $params['credit_card_type'])) {
$errors['cvv2'] = ts("Please enter a valid Credit Card Verification Number");
}
}
}
$joinDate = NULL;
if (CRM_Utils_Array::value('join_date', $params)) {
$joinDate = CRM_Utils_Date::processDate($params['join_date']);
foreach ($self->_memTypeSelected as $memType) {
$startDate = NULL;
if (CRM_Utils_Array::value('start_date', $params)) {
$startDate = CRM_Utils_Date::processDate($params['start_date']);
}
// if end date is set, ensure that start date is also set
// and that end date is later than start date
// If selected membership type has duration unit as 'lifetime'
// and end date is set, then give error
$endDate = NULL;
if (CRM_Utils_Array::value('end_date', $params)) {
$endDate = CRM_Utils_Date::processDate($params['end_date']);
}
$membershipDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType);
if ($startDate && CRM_Utils_Array::value('period_type', $membershipDetails) == 'rolling') {
//.........这里部分代码省略.........