当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_Form::validateMandatoryFields方法代码示例

本文整理汇总了PHP中CRM_Core_Form::validateMandatoryFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::validateMandatoryFields方法的具体用法?PHP CRM_Core_Form::validateMandatoryFields怎么用?PHP CRM_Core_Form::validateMandatoryFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_Form的用法示例。


在下文中一共展示了CRM_Core_Form::validateMandatoryFields方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validatePaymentValues

 /**
  * @param $self
  * @param $fields
  *
  * @return bool
  */
 public function validatePaymentValues($self, $fields)
 {
     if (!empty($self->_params[0]['bypass_payment']) || $self->_allowWaitlist || empty($self->_fields) || CRM_Utils_Array::value('amount', $self->_params[0]) > 0) {
         return TRUE;
     }
     $validatePayement = FALSE;
     if (!empty($fields['priceSetId'])) {
         $lineItem = array();
         CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
         if ($fields['amount'] > 0) {
             $validatePayement = TRUE;
             // $self->_forcePayement = true;
             // return false;
         }
     } elseif (!empty($fields['amount']) && CRM_Utils_Array::value('value', $self->_values['fee'][$fields['amount']]) > 0) {
         $validatePayement = TRUE;
     }
     if (!$validatePayement) {
         return TRUE;
     }
     $errors = array();
     CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
     // validate supplied payment instrument values (e.g. credit card number and cvv)
     $payment_processor_id = $self->_params[0]['payment_processor'];
     CRM_Core_Payment_Form::validatePaymentInstrument($payment_processor_id, $self->_params[0], $errors, $self);
     if (!empty($errors)) {
         return FALSE;
     }
     foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
         if ($greetingType = CRM_Utils_Array::value($greeting, $self->_params[0])) {
             $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
             if ($customizedValue == $greetingType && empty($self->_params[0][$greeting . '_custom'])) {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:44,代码来源:AdditionalParticipant.php

示例2: formRule


//.........这里部分代码省略.........
         $amount = $fields['amount'];
     }
     if (isset($fields['selectProduct']) && $fields['selectProduct'] != 'no_thanks') {
         $productDAO = new CRM_Contribute_DAO_Product();
         $productDAO->id = $fields['selectProduct'];
         $productDAO->find(TRUE);
         $min_amount = $productDAO->min_contribution;
         if ($amount < $min_amount) {
             $errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money::format($min_amount)));
             CRM_Core_Session::setStatus($errors['selectProduct']);
         }
     }
     //CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
     CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
     if (!empty($fields['is_recur']) && CRM_Utils_Array::value('payment_processor_id', $fields) == 0) {
         $errors['_qf_default'] = ts('You cannot set up a recurring contribution if you are not paying online by credit card.');
     }
     if (!empty($fields['is_for_organization']) && !property_exists($self, 'organizationName')) {
         if (empty($fields['onbehalf']['organization_name'])) {
             if (!empty($fields['org_option']) && !$fields['onbehalfof_id']) {
                 $errors['organization_id'] = ts('Please select an organization or enter a new one.');
             } elseif (empty($fields['org_option'])) {
                 $errors['onbehalf']['organization_name'] = ts('Please enter the organization name.');
             }
         }
         foreach ($fields['onbehalf'] as $key => $value) {
             if (strstr($key, 'email')) {
                 $emailLocType = explode('-', $key);
             }
         }
         if (empty($fields['onbehalf']["email-{$emailLocType[1]}"])) {
             $errors['onbehalf']["email-{$emailLocType[1]}"] = ts('Organization email is required.');
         }
     }
     // validate PCP fields - if not anonymous, we need a nick name value
     if ($self->_pcpId && !empty($fields['pcp_display_in_roll']) && CRM_Utils_Array::value('pcp_is_anonymous', $fields) == 0 && CRM_Utils_Array::value('pcp_roll_nickname', $fields) == '') {
         $errors['pcp_roll_nickname'] = ts('Please enter a name to include in the Honor Roll, or select \'contribute anonymously\'.');
     }
     // return if this is express mode
     $config = CRM_Core_Config::singleton();
     if ($self->_paymentProcessor && $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
         if (!empty($fields[$self->_expressButtonName . '_x']) || !empty($fields[$self->_expressButtonName . '_y']) || CRM_Utils_Array::value($self->_expressButtonName, $fields)) {
             return $errors;
         }
     }
     //validate the pledge fields.
     if (!empty($self->_values['pledge_block_id'])) {
         //validation for pledge payment.
         if (!empty($self->_values['pledge_id'])) {
             if (empty($fields['pledge_amount'])) {
                 $errors['pledge_amount'] = ts('At least one payment option needs to be checked.');
             }
         } elseif (!empty($fields['is_pledge'])) {
             if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_installments', $fields)) == FALSE) {
                 $errors['pledge_installments'] = ts('Please enter a valid number of pledge installments.');
             } else {
                 if (CRM_Utils_Array::value('pledge_installments', $fields) == NULL) {
                     $errors['pledge_installments'] = ts('Pledge Installments is required field.');
                 } elseif (CRM_Utils_array::value('pledge_installments', $fields) == 1) {
                     $errors['pledge_installments'] = ts('Pledges consist of multiple scheduled payments. Select one-time contribution if you want to make your gift in a single payment.');
                 } elseif (CRM_Utils_array::value('pledge_installments', $fields) == 0) {
                     $errors['pledge_installments'] = ts('Pledge Installments field must be > 1.');
                 }
             }
             //validation for Pledge Frequency Interval.
             if (CRM_Utils_Rule::positiveInteger(CRM_Utils_Array::value('pledge_frequency_interval', $fields)) == FALSE) {
                 $errors['pledge_frequency_interval'] = ts('Please enter a valid Pledge Frequency Interval.');
             } else {
                 if (CRM_Utils_Array::value('pledge_frequency_interval', $fields) == NULL) {
                     $errors['pledge_frequency_interval'] = ts('Pledge Frequency Interval. is required field.');
                 } elseif (CRM_Utils_array::value('pledge_frequency_interval', $fields) == 0) {
                     $errors['pledge_frequency_interval'] = ts('Pledge frequency interval field must be > 0');
                 }
             }
         }
     }
     // also return if paylater mode
     if (CRM_Utils_Array::value('payment_processor_id', $fields) == 0 && $self->_isBillingAddressRequiredForPayLater == 0) {
         return empty($errors) ? TRUE : $errors;
     }
     // if the user has chosen a free membership or the amount is less than zero
     // i.e. we skip calling the payment processor and hence dont need credit card
     // info
     if ((double) $amount <= 0.0) {
         return $errors;
     }
     if (!empty($self->_paymentFields)) {
         CRM_Core_Form::validateMandatoryFields($self->_paymentFields, $fields, $errors);
     }
     CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, $self);
     foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
         if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
             $customizedValue = CRM_Core_OptionGroup::getValue($greeting, 'Customized', 'name');
             if ($customizedValue == $greetingType && empty($fielse[$greeting . '_custom'])) {
                 $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', array(1 => ucwords(str_replace('_', " ", $greeting))));
             }
         }
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:101,代码来源:Main.php

示例3: validatePaymentInstrument

 /**
  * Default payment instrument validation.
  *
  * Implement the usual Luhn algorithm via a static function in the CRM_Core_Payment_Form if it's a credit card
  * Not a static function, because I need to check for payment_type.
  *
  * @param array $values
  * @param array $errors
  */
 public function validatePaymentInstrument($values, &$errors)
 {
     if ($this->_paymentProcessor['payment_processor_type'] == 'PayPal' && !$this->isPaypalExpress($values)) {
         CRM_Core_Payment_Form::validateCreditCard($this->_paymentProcessor['id'], $values, $errors);
         CRM_Core_Form::validateMandatoryFields($this->getMandatoryFields(), $values, $errors);
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:16,代码来源:PayPalImpl.php

示例4: formRule

 /**
  * @param $fields
  * @param $files
  * @param $self
  *
  * @return array|bool
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) {
         $payment = CRM_Core_Payment::singleton($self->_mode, $self->_paymentProcessor, CRM_Core_DAO::$_nullObject);
         $error = $payment->checkConfig($self->_mode);
         if ($error) {
             $errors['_qf_default'] = $error;
         }
         CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
         // validate payment instrument values (e.g. credit card number)
         CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessor['id'], $fields, $errors, $self);
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:agloa,项目名称:tournament,代码行数:22,代码来源:Payment.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();
     //check that either an email or firstname+lastname is included in the form(CRM-9587)
     self::checkProfileComplete($fields, $errors, $self->_eventId);
     //To check if the user is already registered for the event(CRM-2426)
     if (!$self->_skipDupeRegistrationCheck) {
         self::checkRegistration($fields, $self);
     }
     //check for availability of registrations.
     if (!$self->_allowConfirmation && !CRM_Utils_Array::value('bypass_payment', $fields) && is_numeric($self->_availableRegistrations) && CRM_Utils_Array::value('additional_participants', $fields) >= $self->_availableRegistrations) {
         $errors['additional_participants'] = ts("There is only enough space left on this event for %1 participant(s).", array(1 => $self->_availableRegistrations));
     }
     // during confirmation don't allow to increase additional participants, CRM-4320
     if ($self->_allowConfirmation && CRM_Utils_Array::value('additional_participants', $fields) && is_array($self->_additionalParticipantIds) && $fields['additional_participants'] > count($self->_additionalParticipantIds)) {
         $errors['additional_participants'] = ts("Oops. It looks like you are trying to increase the number of additional people you are registering for. You can confirm registration for a maximum of %1 additional people.", array(1 => count($self->_additionalParticipantIds)));
     }
     //don't allow to register w/ waiting if enough spaces available.
     if (CRM_Utils_Array::value('bypass_payment', $fields)) {
         if (!is_numeric($self->_availableRegistrations) || !CRM_Utils_Array::value('priceSetId', $fields) && CRM_Utils_Array::value('additional_participants', $fields) < $self->_availableRegistrations) {
             $errors['bypass_payment'] = ts("Oops. There are enough available spaces in this event. You can not add yourself to the waiting list.");
         }
     }
     if (CRM_Utils_Array::value('additional_participants', $fields) && !CRM_Utils_Rule::positiveInteger($fields['additional_participants'])) {
         $errors['additional_participants'] = ts('Please enter a whole number for Number of additional people.');
     }
     // priceset validations
     if (CRM_Utils_Array::value('priceSetId', $fields)) {
         //format params.
         $formatted = self::formatPriceSetParams($self, $fields);
         $ppParams = array($formatted);
         $priceSetErrors = self::validatePriceSet($self, $ppParams);
         $primaryParticipantCount = self::getParticipantCount($self, $ppParams);
         //get price set fields errors in.
         $errors = array_merge($errors, CRM_Utils_Array::value(0, $priceSetErrors, array()));
         $totalParticipants = $primaryParticipantCount;
         if (CRM_Utils_Array::value('additional_participants', $fields)) {
             $totalParticipants += $fields['additional_participants'];
         }
         if (!CRM_Utils_Array::value('bypass_payment', $fields) && !$self->_allowConfirmation && is_numeric($self->_availableRegistrations) && $self->_availableRegistrations < $totalParticipants) {
             $errors['_qf_default'] = ts("Only %1 Registrations available.", array(1 => $self->_availableRegistrations));
         }
         $lineItem = array();
         CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
         if ($fields['amount'] < 0) {
             $errors['_qf_default'] = ts('Event Fee(s) can not be less than zero. Please select the options accordingly');
         }
     }
     if ($self->_values['event']['is_monetary']) {
         if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 && !isset($fields['payment_processor'])) {
             $errors['payment_processor'] = ts('Please select a Payment Method');
         }
         if (is_array($self->_paymentProcessor)) {
             $payment = CRM_Core_Payment::singleton($self->_mode, $self->_paymentProcessor, $this);
             $error = $payment->checkConfig($self->_mode);
             if ($error) {
                 $errors['_qf_default'] = $error;
             }
         }
         // return if this is express mode
         if ($self->_paymentProcessor && $self->_paymentProcessor['billing_mode'] & CRM_Core_Payment::BILLING_MODE_BUTTON) {
             if (CRM_Utils_Array::value($self->_expressButtonName . '_x', $fields) || CRM_Utils_Array::value($self->_expressButtonName . '_y', $fields) || CRM_Utils_Array::value($self->_expressButtonName, $fields)) {
                 return empty($errors) ? TRUE : $errors;
             }
         }
         $isZeroAmount = $skipPaymentValidation = FALSE;
         if (CRM_Utils_Array::value('priceSetId', $fields)) {
             if (CRM_Utils_Array::value('amount', $fields) == 0) {
                 $isZeroAmount = TRUE;
             }
         } elseif (CRM_Utils_Array::value('amount', $fields) && (isset($self->_values['discount'][$fields['amount']]) && CRM_Utils_Array::value('value', $self->_values['discount'][$fields['amount']]) == 0)) {
             $isZeroAmount = TRUE;
         } elseif (CRM_Utils_Array::value('amount', $fields) && (isset($self->_values['fee'][$fields['amount']]) && CRM_Utils_Array::value('value', $self->_values['fee'][$fields['amount']]) == 0)) {
             $isZeroAmount = TRUE;
         }
         if ($isZeroAmount && !($self->_forcePayement && CRM_Utils_Array::value('additional_participants', $fields))) {
             $skipPaymentValidation = TRUE;
         }
         // also return if paylater mode or zero fees for valid members
         if (CRM_Utils_Array::value('is_pay_later', $fields) || CRM_Utils_Array::value('bypass_payment', $fields) || $skipPaymentValidation || !$self->_allowConfirmation && ($self->_requireApproval || $self->_allowWaitlist)) {
             return empty($errors) ? TRUE : $errors;
         }
         if (!empty($self->_paymentFields)) {
             CRM_Core_Form::validateMandatoryFields($self->_paymentFields, $fields, $errors);
         }
         CRM_Core_Payment_Form::validateCreditCard($fields, $errors);
     }
     foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
         if ($greetingType = CRM_Utils_Array::value($greeting, $fields)) {
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Register.php

示例6: 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();
     CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
     // validate the payment instrument values (e.g. credit card number)
     CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessor['id'], $fields, $errors, $self);
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:indydas,项目名称:civi-demo,代码行数:21,代码来源:UpdateBilling.php

示例7: validatePaymentInstrument

 /**
  * Default payment instrument validation.
  *
  * Implement the usual Luhn algorithm via a static function in the CRM_Core_Payment_Form if it's a credit card
  * Not a static function, because I need to check for payment_type.
  *
  * @param array $values
  * @param array $errors
  */
 public function validatePaymentInstrument($values, &$errors)
 {
     CRM_Core_Form::validateMandatoryFields($this->getMandatoryFields(), $values, $errors);
     if ($this->_paymentProcessor['payment_type'] == 1) {
         CRM_Core_Payment_Form::validateCreditCard($this->_paymentProcessor['id'], $values, $errors);
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:16,代码来源:Payment.php

示例8: 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();
     CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
     // make sure that credit card number and cvv are valid
     CRM_Core_Payment_Form::validateCreditCard($fields, $errors);
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:19,代码来源:UpdateBilling.php

示例9: formRule

 /**
  * @param $fields
  * @param $files
  * @param $self
  *
  * @return array|bool
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) {
         CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
         // validate payment instrument values (e.g. credit card number)
         CRM_Core_Payment_Form::validatePaymentInstrument($self->_paymentProcessor['id'], $fields, $errors, $self);
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:17,代码来源:Payment.php

示例10: formRule

 /**
  * @param $fields
  * @param $files
  * @param $self
  *
  * @return array|bool
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) {
         $payment =& CRM_Core_Payment::singleton($self->_mode, $self->_paymentProcessor, $this);
         $error = $payment->checkConfig($self->_mode);
         if ($error) {
             $errors['_qf_default'] = $error;
         }
         CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors);
         // make sure that credit card number and cvv are valid
         CRM_Core_Payment_Form::validateCreditCard($fields, $errors);
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:22,代码来源:Payment.php


注:本文中的CRM_Core_Form::validateMandatoryFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。