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


PHP CRM_Contribute_BAO_Contribution::checkDuplicate方法代码示例

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


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

示例1: add

 /**
  * takes an associative array and creates a contribution object
  *
  * the function extract all the params it needs to initialize the create a
  * contribution object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contribute_BAO_Contribution object
  * @access public
  * @static
  */
 function add(&$params, &$ids)
 {
     require_once 'CRM/Utils/Hook.php';
     $duplicates = array();
     if (CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicates)) {
         $error =& CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_CORE_ERROR_DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Found matching contribution(s): {$d}");
         return $error;
     }
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $ids['contribution'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', null, $params);
     }
     $contribution =& new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->domain_id = CRM_Utils_Array::value('domain', $ids, CRM_Core_Config::domainID());
     $contribution->id = CRM_Utils_Array::value('contribution', $ids);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         require_once 'CRM/Core/Config.php';
         $config =& CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     $result = $contribution->save();
     if (CRM_Utils_Array::value('contribution', $ids)) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:47,代码来源:Contribution.php

示例2: rules

 protected static function rules($params, $files, $self)
 {
     $errors = array();
     $secondaryContactId = CRM_Utils_Array::value('secondary_contact_id', $params);
     $sendConfirmation = CRM_Utils_Array::value('send_confirmation', $params);
     if ($sendConfirmation) {
         $emailTo = CRM_Utils_Array::value('email_to', $params);
         if (!$emailTo) {
             $errors['email_to'] = ts('Please select a contact(s) to send email to.');
         }
         if (!$self->_id) {
             if ($emailTo == 2 && !$secondaryContactId || $emailTo == 3 && !$secondaryContactId) {
                 $errors['email_to'] = ts('Please select a secondary contact.');
             }
         }
         $fromEmailAddreess = CRM_Utils_Array::value('from_email_address', $params);
         if (!$fromEmailAddreess) {
             $errors['from_email_address'] = ts('Please select a from email address.');
         }
     }
     $recordContribution = CRM_Utils_Array::value('record_contribution', $params);
     if ($recordContribution) {
         $selectPaymentContact = CRM_Utils_Array::value('select_payment_contact', $params);
         if (!$selectPaymentContact) {
             $errors['select_payment_contact'] = ts('Please select a contact for recording payment.');
         }
         if (!$self->_id) {
             if ($selectPaymentContact == 2 && !$secondaryContactId) {
                 $errors['select_payment_contact'] = ts('Please select a contact for recording payment');
             }
         }
         $financialTypeId = CRM_Utils_Array::value('financial_type_id', $params);
         if (!$financialTypeId) {
             $errors['financial_type_id'] = ts('Please select a financial type.');
         }
         $trxnId = CRM_Utils_Array::value('trxn_id', $params);
         $duplicates = array();
         if ($trxnId && CRM_Contribute_BAO_Contribution::checkDuplicate(array('trxn_id' => $trxnId), $duplicates)) {
             $d = implode(', ', $duplicates);
             $errors['trxn_id'] = "Duplicate error - existing contribution record(s) have a matching Transaction ID. Contribution record ID is: {$d}";
         }
         $receivedDate = CRM_Utils_Array::value('receive_date', $params);
         if (!$receivedDate) {
             $errors['receive_date'] = ts('This field is required.');
         }
         $paymentInstrumentId = CRM_Utils_Array::value('payment_instrument_id', $params);
         if (!$paymentInstrumentId) {
             $errors['payment_instrument_id'] = ts('Please select a payment instrument.');
         }
         $contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $params);
         if (!$contributionStatusId) {
             $errors['contribution_status_id'] = ts('Please select a valid payment status.');
         }
     }
     return $errors;
 }
开发者ID:sushantpaste,项目名称:civibooking,代码行数:56,代码来源:Base.php

示例3:

function &_crm_duplicate_formatted_contribution(&$params)
{
    require_once 'CRM/Contribute/BAO/Contribution.php';
    return CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicate);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:5,代码来源:utils.php

示例4: _civicrm_contribute_duplicate_check

/**
 * Check if there is a contribution with the same trxn_id or invoice_id
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs to insert in new contribution.
 *
 * @return array|CRM_Error
 * @access private
 */
function _civicrm_contribute_duplicate_check(&$params)
{
    require_once 'CRM/Contribute/BAO/Contribution.php';
    $duplicates = array();
    $result = CRM_Contribute_BAO_Contribution::checkDuplicate($params, $duplicates);
    if ($result) {
        $d = implode(', ', $duplicates);
        $error = CRM_Core_Error::createError("Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}", CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', $d);
        return civicrm_create_error($error->pop(), $d);
    } else {
        return array();
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:22,代码来源:Contribute.php


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