本文整理汇总了PHP中CRM_Utils_Rule::positiveInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Rule::positiveInteger方法的具体用法?PHP CRM_Utils_Rule::positiveInteger怎么用?PHP CRM_Utils_Rule::positiveInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Rule
的用法示例。
在下文中一共展示了CRM_Utils_Rule::positiveInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
function preProcess()
{
$cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
$oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE);
if ($oid) {
$this->_id = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE);
} else {
$this->assign('hide_contact', TRUE);
$this->_id = $cid;
}
if (!CRM_Utils_Rule::positiveInteger($this->_id)) {
CRM_Core_Error::fatal('We need a valid discount ID for view');
}
$this->assign('id', $this->_id);
$defaults = array();
$params = array('id' => $this->_id);
require_once 'CRM/CiviDiscount/BAO/Item.php';
CRM_CiviDiscount_BAO_Item::retrieve($params, $defaults);
require_once 'CRM/CiviDiscount/BAO/Track.php';
if ($cid) {
$rows = CRM_CiviDiscount_BAO_Track::getUsageByContact($this->_id);
} else {
$rows = CRM_CiviDiscount_BAO_Track::getUsageByOrg($this->_id);
}
$this->assign('rows', $rows);
$this->assign('code_details', $defaults);
$this->ajaxResponse['tabCount'] = count($rows);
if (!empty($defaults['code'])) {
CRM_Utils_System::setTitle($defaults['code']);
}
}
示例2: isContactInGroup
/**
* Checks wether a contact is a member of a group
*
* This function is a copy of CRM_Contact_BAO_GroupContact::isContactInGroup but with
* a change so that the group contact cache won't be rebuild. Which somehow resulted
* in a deadlock
*
* @param $contact_id
* @param $group_id
* @return bool
*/
public static function isContactInGroup($contact_id, $group_id)
{
if (!CRM_Utils_Rule::positiveInteger($contact_id) || !CRM_Utils_Rule::positiveInteger($group_id)) {
return FALSE;
}
$params = array(array('group', 'IN', array($group_id => 1), 0, 0), array('contact_id', '=', $contact_id, 0, 0));
list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, array('contact_id'), null, null, 0, 1, false, false, true);
if (!empty($contacts)) {
return TRUE;
}
return FALSE;
}
示例3: retrieveAssigneeIdsByActivityId
/**
* Retrieve assignee_id by activity_id
*
* @param int $id ID of the activity
*
* @return void
*
* @access public
*
*/
static function retrieveAssigneeIdsByActivityId($activity_id)
{
$assigneeArray = array();
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $assigneeArray;
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$sql = "\nSELECT contact_id\nFROM civicrm_activity_contact\nINNER JOIN civicrm_contact ON contact_id = civicrm_contact.id\nWHERE activity_id = %1\nAND record_type_id = {$assigneeID}\nAND civicrm_contact.is_deleted = 0\n";
$assignment = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
while ($assignment->fetch()) {
$assigneeArray[] = $assignment->contact_id;
}
return $assigneeArray;
}
示例4: retrieveTargetIdsByActivityId
/**
* function to retrieve id of target contact by activity_id
*
* @param int $id ID of the activity
*
* @return mixed
*
* @access public
*
*/
static function retrieveTargetIdsByActivityId($activity_id)
{
$targetArray = array();
require_once 'CRM/Utils/Rule.php';
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $targetArray;
}
$target =& new CRM_Activity_BAO_ActivityTarget();
$target->activity_id = $activity_id;
$target->find();
$count = 1;
while ($target->fetch()) {
$targetArray[$count] = $target->target_contact_id;
$count++;
}
return $targetArray;
}
示例5: retrieveAssigneeIdsByActivityId
/**
* Retrieve assignee_id by activity_id
*
* @param int $id ID of the activity
*
* @return void
*
* @access public
*
*/
static function retrieveAssigneeIdsByActivityId($activity_id)
{
$assigneeArray = array();
require_once 'CRM/Utils/Rule.php';
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $assigneeArray;
}
$assignment =& new CRM_Activity_BAO_ActivityAssignment();
$assignment->activity_id = $activity_id;
$assignment->find();
$count = 1;
while ($assignment->fetch()) {
$assigneeArray[$count] = $assignment->assignee_contact_id;
$count++;
}
return $assigneeArray;
}
示例6: retrieveAssigneeIdsByActivityId
/**
* Retrieve assignee_id by activity_id
*
* @param int $id ID of the activity
*
* @return void
*
* @access public
*
*/
static function retrieveAssigneeIdsByActivityId($activity_id)
{
$assigneeArray = array();
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $assigneeArray;
}
$sql = '
SELECT assignee_contact_id
FROM civicrm_activity_assignment
JOIN civicrm_contact ON assignee_contact_id = civicrm_contact.id
WHERE activity_id = %1 AND civicrm_contact.is_deleted = 0
';
$assignment = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
while ($assignment->fetch()) {
$assigneeArray[] = $assignment->assignee_contact_id;
}
return $assigneeArray;
}
示例7: retrieveTargetIdsByActivityId
/**
* function to retrieve id of target contact by activity_id
*
* @param int $id ID of the activity
*
* @return mixed
*
* @access public
*
*/
static function retrieveTargetIdsByActivityId($activity_id)
{
$targetArray = array();
if (!CRM_Utils_Rule::positiveInteger($activity_id)) {
return $targetArray;
}
$sql = '
SELECT target_contact_id
FROM civicrm_activity_target
JOIN civicrm_contact ON target_contact_id = civicrm_contact.id
WHERE activity_id = %1 AND civicrm_contact.is_deleted = 0
';
$target = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer')));
while ($target->fetch()) {
$targetArray[] = $target->target_contact_id;
}
return $targetArray;
}
示例8: __construct
/**
* class constructor
*
* @param object CRM_Event_Controller
* @param int $action
*
* @return object CRM_Event_StateMachine
*/
function __construct($controller, $action = CRM_Core_Action::NONE)
{
parent::__construct($controller, $action);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $controller, true);
$is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary');
$pages = array('CRM_Event_Form_Registration_Register' => null);
//handle additional participant scenario, where we need to insert participant pages on runtime
$additionalParticipant = null;
// check that the controller has some data, hence we dont send the form name
// which results in an invalid argument error
$values = $controller->exportValues();
//first check POST value then QF
if (isset($_POST['additional_participants']) && CRM_Utils_Rule::positiveInteger($_POST['additional_participants'])) {
// we need to use $_POST since the QF framework has not yet been called
// and the additional participants page is the next one, so need to set this up
// now
$additionalParticipant = $_POST['additional_participants'];
} else {
if (isset($values['additional_participants']) && CRM_Utils_Rule::positiveInteger($values['additional_participants'])) {
$additionalParticipant = $values['additional_participants'];
}
}
if ($additionalParticipant) {
$additionalParticipant = CRM_Utils_Type::escape($additionalParticipant, 'Integer');
$controller->set('addParticipant', $additionalParticipant);
}
//to add instances of Additional Participant page, only if user has entered any additional participants
if ($additionalParticipant) {
require_once "CRM/Event/Form/Registration/AdditionalParticipant.php";
$extraPages =& CRM_Event_Form_Registration_AdditionalParticipant::getPages($additionalParticipant);
$pages = array_merge($pages, $extraPages);
}
$additionalPages = array('CRM_Event_Form_Registration_Confirm' => null, 'CRM_Event_Form_Registration_ThankYou' => null);
$pages = array_merge($pages, $additionalPages);
if (!$is_monetary) {
unset($pages['CRM_Event_Form_Registration_Confirm']);
}
$this->addSequentialPages($pages, $action);
}
示例9: preProcess
function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$this->_cloneID = CRM_Utils_Request::retrieve('cloneID', 'Positive', $this, FALSE, 0);
$this->set('BAOName', 'CRM_CiviDiscount_BAO_Item');
parent::preProcess();
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/cividiscount/discount/list', 'reset=1');
$session->pushUserContext($url);
// check and ensure that update / delete have a valid id
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
if (!CRM_Utils_Rule::positiveInteger($this->_id)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for update and/or delete'));
}
}
if ($this->_action & CRM_Core_Action::COPY) {
if (!CRM_Utils_Rule::positiveInteger($this->_cloneID)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for update and/or delete'));
}
}
CRM_Utils_System::setTitle(ts('Discounts'));
$this->_multiValued = array('memberships' => NULL, 'events' => NULL, 'pricesets' => NULL);
$this->select2style = array('placeholder' => ts('- none -'), 'multiple' => TRUE, 'class' => 'crm-select2 huge');
}
示例10: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = $this->_values;
if ($this->_id) {
$this->assign('id', $this->_id);
$this->_gid = $defaults['custom_group_id'];
//get the value for state or country
if ($defaults['data_type'] == 'StateProvince' && ($stateId = CRM_Utils_Array::value('default_value', $defaults))) {
$defaults['default_value'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_StateProvince', $stateId);
} elseif ($defaults['data_type'] == 'Country' && ($countryId = CRM_Utils_Array::value('default_value', $defaults))) {
$defaults['default_value'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Country', $countryId);
}
if ($defaults['data_type'] == 'ContactReference' && CRM_Utils_Array::value('filter', $defaults)) {
$contactRefFilter = 'Advance';
if (strpos($defaults['filter'], 'action=lookup') !== FALSE && strpos($defaults['filter'], 'group=') !== FALSE) {
$filterParts = explode('&', $defaults['filter']);
if (count($filterParts) == 2) {
$contactRefFilter = 'Group';
foreach ($filterParts as $part) {
if (strpos($part, 'group=') === FALSE) {
continue;
}
$groups = substr($part, strpos($part, '=') + 1);
foreach (explode(',', $groups) as $grp) {
if (CRM_Utils_Rule::positiveInteger($grp)) {
$defaults['group_id'][] = $grp;
}
}
}
}
}
$defaults['filter_selected'] = $contactRefFilter;
}
if (CRM_Utils_Array::value('data_type', $defaults)) {
$defaultDataType = array_search($defaults['data_type'], self::$_dataTypeKeys);
$defaultHTMLType = array_search($defaults['html_type'], self::$_dataToHTML[$defaultDataType]);
$defaults['data_type'] = array('0' => $defaultDataType, '1' => $defaultHTMLType);
$this->_defaultDataType = $defaults['data_type'];
}
$defaults['option_type'] = 2;
$this->assign('changeFieldType', CRM_Custom_Form_ChangeFieldType::fieldTypeTransitions($this->_values['data_type'], $this->_values['html_type']));
} else {
$defaults['is_active'] = 1;
$defaults['option_type'] = 1;
}
// set defaults for weight.
for ($i = 1; $i <= self::NUM_OPTION; $i++) {
$defaults['option_status[' . $i . ']'] = 1;
$defaults['option_weight[' . $i . ']'] = $i;
}
if ($this->_action & CRM_Core_Action::ADD) {
$fieldValues = array('custom_group_id' => $this->_gid);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_CustomField', $fieldValues);
$defaults['text_length'] = 255;
$defaults['note_columns'] = 60;
$defaults['note_rows'] = 4;
$defaults['is_view'] = 0;
}
if (CRM_Utils_Array::value('html_type', $defaults)) {
$dontShowLink = substr($defaults['html_type'], -14) == 'State/Province' || substr($defaults['html_type'], -7) == 'Country' ? 1 : 0;
}
if (isset($dontShowLink)) {
$this->assign('dontShowLink', $dontShowLink);
}
return $defaults;
}
示例11: isContactInGroup
static function isContactInGroup($contactID, $groupID)
{
if (!CRM_Utils_Rule::positiveInteger($contactID) || !CRM_Utils_Rule::positiveInteger($groupID)) {
return false;
}
$params = array('group' => array($groupID => 1), 'contact_id' => $contactID, 'return.contact_id' => 1);
require_once 'api/v2/Contact.php';
$contacts = civicrm_contact_search($params);
if (!empty($contacts)) {
return true;
}
return false;
}
示例12: deletePayments
/**
* Delete all pledge payments.
*
* @param int $id
* Pledge id.
*
* @return bool
*/
public static function deletePayments($id)
{
if (!CRM_Utils_Rule::positiveInteger($id)) {
return FALSE;
}
$transaction = new CRM_Core_Transaction();
$payment = new CRM_Pledge_DAO_PledgePayment();
$payment->pledge_id = $id;
if ($payment->find()) {
while ($payment->fetch()) {
//also delete associated contribution.
if ($payment->contribution_id) {
CRM_Contribute_BAO_Contribution::deleteContribution($payment->contribution_id);
}
self::del($payment->id);
}
}
$transaction->commit();
return TRUE;
}
示例13: testPositive
/**
* @dataProvider positiveDataProvider
*/
function testPositive($inputData, $expectedResult)
{
$this->assertEquals($expectedResult, CRM_Utils_Rule::positiveInteger($inputData));
}
示例14: formRule
//.........这里部分代码省略.........
$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']);
}
}
if (!empty($fields['is_recur'])) {
if ($fields['frequency_interval'] <= 0) {
$errors['frequency_interval'] = ts('Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).');
}
if ($fields['frequency_unit'] == '0') {
$errors['frequency_unit'] = ts('Please select a period (e.g. months, years ...) for how often you want to make this recurring contribution (EXAMPLE: Every 3 MONTHS).');
}
}
if (!empty($fields['is_recur']) && CRM_Utils_Array::value('payment_processor', $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', $fields) == 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::validateCreditCard($fields, $errors);
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;
}
示例15: formRule
//.........这里部分代码省略.........
}
}
if (!empty($priceFieldIDS)) {
$ids = implode(',', $priceFieldIDS);
$priceFieldIDS['id'] = $fields['priceSetId'];
$self->set('memberPriceFieldIDS', $priceFieldIDS);
$count = CRM_Price_BAO_PriceSet::getMembershipCount($ids);
foreach ($count as $id => $occurrence) {
if ($occurrence > 1) {
$errors['_qf_default'] = ts('You have selected multiple memberships for the same organization or entity. Please review your selections and choose only one membership per entity. Contact the site administrator if you need assistance.');
}
}
}
if (empty($priceFieldMemTypes) && $self->_membershipBlock['is_required'] == 1) {
$errors['_qf_default'] = ts('Please select at least one membership option.');
}
}
CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
if ($fields['amount'] < 0) {
$errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly');
}
$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.');
}
// 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');
}
}
}
}
// if the user has chosen a free membership or the amount is less than zero
// i.e. we don't need to validate payment related fields or profiles.
if ((double) $amount <= 0.0) {
return $errors;
}
if (CRM_Utils_Array::value('payment_processor_id', $fields) == NULL) {
$errors['payment_processor_id'] = ts('Payment Method is a required field.');
} else {
CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, !$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing');
}
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;
}