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


PHP CRM_Utils_Rule::currencyCode方法代码示例

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


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

示例1: create

 /**
  * takes an associative array and creates a financial transaction object
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Core_BAO_FinancialTrxn object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     $trxn = new CRM_Core_DAO_FinancialTrxn();
     $trxn->copyValues($params);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($trxn->currency)) {
         require_once 'CRM/Core/Config.php';
         $config = CRM_Core_Config::singleton();
         $trxn->currency = $config->defaultCurrency;
     }
     // if a transaction already exists for a contribution id, lets get the finTrxnId and entityFinTrxId
     $fids = self::getFinancialTrxnIds($params['contribution_id'], 'civicrm_contribution');
     if ($fids['financialTrxnId']) {
         $trxn->id = $fids['financialTrxnId'];
     }
     $trxn->save();
     $contributionAmount = CRM_Utils_Array::value('net_amount', $params);
     if (!$contributionAmount && isset($params['total_amount'])) {
         $contributionAmount = $params['total_amount'];
     }
     // save to entity_financial_trxn table
     $entity_financial_trxn_params = array('entity_table' => "civicrm_contribution", 'entity_id' => $params['contribution_id'], 'financial_trxn_id' => $trxn->id, 'amount' => $contributionAmount, 'currency' => $trxn->currency);
     $entity_trxn =& new CRM_Core_DAO_EntityFinancialTrxn();
     $entity_trxn->copyValues($entity_financial_trxn_params);
     if ($fids['entityFinancialTrxnId']) {
         $entity_trxn->id = $fids['entityFinancialTrxnId'];
     }
     $entity_trxn->save();
     return $trxn;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:39,代码来源:FinancialTrxn.php

示例2: create

 /**
  * takes an associative array and creates a financial transaction object
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Contribute_BAO_FinancialTrxn object
  * @access public
  * @static
  */
 function create(&$params)
 {
     $trxn =& new CRM_Contribute_DAO_FinancialTrxn();
     $trxn->copyValues($params);
     $trxn->domain_id = CRM_Core_Config::domainID();
     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;
     }
     return $trxn->save();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:22,代码来源:FinancialTrxn.php

示例3: create

 /**
  * takes an associative array and creates a financial transaction object
  *
  * @param array  $params (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Contribute_BAO_FinancialTrxn object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     $trxn =& new CRM_Contribute_DAO_FinancialTrxn();
     $trxn->copyValues($params);
     require_once 'CRM/Utils/Rule.php';
     if (!CRM_Utils_Rule::currencyCode($trxn->currency)) {
         require_once 'CRM/Core/Config.php';
         $config =& CRM_Core_Config::singleton();
         $trxn->currency = $config->defaultCurrency;
     }
     // if a transaction already exists for a contribution id, lets get the id
     $id = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_FinancialTrxn', $trxn->contribution_id, 'id', 'contribution_id');
     if ($id) {
         $trxn->id = $id;
     }
     return $trxn->save();
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:26,代码来源:FinancialTrxn.php

示例4: create

 /**
  * Takes an associative array and creates a financial transaction object.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @param string $trxnEntityTable
  *   Entity_table.
  *
  * @return CRM_Core_BAO_FinancialTrxn
  */
 public static function create(&$params, $trxnEntityTable = NULL)
 {
     $trxn = new CRM_Financial_DAO_FinancialTrxn();
     $trxn->copyValues($params);
     if (!CRM_Utils_Rule::currencyCode($trxn->currency)) {
         $trxn->currency = CRM_Core_Config::singleton()->defaultCurrency;
     }
     $trxn->save();
     // save to entity_financial_trxn table
     $entityFinancialTrxnParams = array('entity_table' => "civicrm_contribution", 'financial_trxn_id' => $trxn->id, 'amount' => $params['total_amount'], 'currency' => $trxn->currency);
     if (!empty($trxnEntityTable)) {
         $entityFinancialTrxnParams['entity_table'] = $trxnEntityTable['entity_table'];
         $entityFinancialTrxnParams['entity_id'] = $trxnEntityTable['entity_id'];
     } else {
         $entityFinancialTrxnParams['entity_id'] = $params['contribution_id'];
     }
     $entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn();
     $entityTrxn->copyValues($entityFinancialTrxnParams);
     $entityTrxn->save();
     return $trxn;
 }
开发者ID:vincent1892,项目名称:civicrm-core,代码行数:32,代码来源:FinancialTrxn.php

示例5: CRM_Event_BAO_Participant

 /**
  * takes an associative array and creates a participant object
  *
  * the function extract all the params it needs to initialize the create a
  * participant 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_Event_BAO_Participant object
  * @access public
  * @static
  */
 static function &add(&$params)
 {
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Participant', null, $params);
     }
     // converting dates to mysql format
     if (CRM_Utils_Array::value('register_date', $params)) {
         $params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
     }
     if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
         $params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
     }
     if (CRM_Utils_Array::value('participant_fee_amount', $params)) {
         $params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
     }
     $participantBAO = new CRM_Event_BAO_Participant();
     if (CRM_Utils_Array::value('id', $params)) {
         $participantBAO->id = CRM_Utils_Array::value('id', $params);
         $participantBAO->find(true);
         $participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
     }
     $participantBAO->copyValues($params);
     //CRM-6910
     //1. If currency present, it should be valid one.
     //2. We should have currency when amount is not null.
     require_once 'CRM/Utils/Rule.php';
     $currency = $participantBAO->fee_currency;
     if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
         if (!CRM_Utils_Rule::currencyCode($currency)) {
             $config = CRM_Core_Config::singleton();
             $currency = $config->defaultCurrency;
         }
     }
     $participantBAO->fee_currency = $currency;
     $participantBAO->save();
     $session =& CRM_Core_Session::singleton();
     // reset the group contact cache for this group
     require_once 'CRM/Contact/BAO/GroupContactCache.php';
     CRM_Contact_BAO_GroupContactCache::remove();
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
     } else {
         CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
     }
     return $participantBAO;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Participant.php

示例6: validate

 function validate()
 {
     if (CRM_Utils_System::isNull($this->_value)) {
         return true;
     }
     switch ($this->_name) {
         case 'contact_id':
             // note: we validate extistence of the contact in API, upon
             // insert (it would be too costlty to do a db call here)
             return CRM_Utils_Rule::integer($this->_value);
             break;
         case 'receive_date':
         case 'cancel_date':
         case 'receipt_date':
         case 'thankyou_date':
             return CRM_Utils_Rule::date($this->_value);
             break;
         case 'non_deductible_amount':
         case 'total_amount':
         case 'fee_amount':
         case 'net_amount':
             return CRM_Utils_Rule::money($this->_value);
             break;
         case 'trxn_id':
             static $seenTrxnIds = array();
             if (in_array($this->_value, $seenTrxnIds)) {
                 return false;
             } elseif ($this->_value) {
                 $seenTrxnIds[] = $this->_value;
                 return true;
             } else {
                 $this->_value = null;
                 return true;
             }
             break;
         case 'currency':
             return CRM_Utils_Rule::currencyCode($this->_value);
             break;
         case 'contribution_type':
             static $contributionTypes = null;
             if (!$contributionTypes) {
                 $contributionTypes =& CRM_Contribute_PseudoConstant::contributionType();
             }
             if (in_array($this->_value, $contributionTypes)) {
                 return true;
             } else {
                 return false;
             }
             break;
         case 'payment_instrument':
             static $paymentInstruments = null;
             if (!$paymentInstruments) {
                 $paymentInstruments =& CRM_Contribute_PseudoConstant::paymentInstrument();
             }
             if (in_array($this->_value, $paymentInstruments)) {
                 return true;
             } else {
                 return false;
             }
             break;
         default:
             break;
     }
     // check whether that's a valid custom field id
     // and if so, check the contents' validity
     if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) {
         static $customFields = null;
         if (!$customFields) {
             $customFields =& CRM_Core_BAO_CustomField::getFields('Contribution');
         }
         if (!array_key_exists($customFieldID, $customFields)) {
             return false;
         }
         return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value);
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:77,代码来源:Field.php

示例7: _crm_format_contrib_params

/**
 * take the input parameter list as specified in the data model and 
 * convert it into the same format that we use in QF and BAO object
 *
 * @param array  $params       Associative array of property name/value
 *                             pairs to insert in new contact.
 * @param array  $values       The reformatted properties that we can use internally
 *                            '
 * @return array|CRM_Error
 * @access public
 */
function _crm_format_contrib_params(&$params, &$values, $create = false)
{
    // copy all the contribution fields as is
    $fields =& CRM_Contribute_DAO_Contribution::fields();
    _crm_store_values($fields, $params, $values);
    foreach ($params as $key => $value) {
        // ignore empty values or empty arrays etc
        if (CRM_Utils_System::isNull($value)) {
            continue;
        }
        switch ($key) {
            case 'contribution_contact_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return _crm_error("contact_id not valid: {$value}");
                }
                $dao =& new CRM_Core_DAO();
                $qParams = array();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
                if (!$svq) {
                    return _crm_error("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
                }
                $values['contact_id'] = $values['contribution_contact_id'];
                unset($values['contribution_contact_id']);
                break;
            case 'receive_date':
            case 'cancel_date':
            case 'receipt_date':
            case 'thankyou_date':
                if (!CRM_Utils_Rule::date($value)) {
                    return _crm_error("{$key} not a valid date: {$value}");
                }
                break;
            case 'non_deductible_amount':
            case 'total_amount':
            case 'fee_amount':
            case 'net_amount':
                if (!CRM_Utils_Rule::money($value)) {
                    return _crm_error("{$key} not a valid amount: {$value}");
                }
                break;
            case 'currency':
                if (!CRM_Utils_Rule::currencyCode($value)) {
                    return _crm_error("currency not a valid code: {$value}");
                }
                break;
            case 'contribution_type':
                require_once 'CRM/Contribute/PseudoConstant.php';
                $values['contribution_type_id'] = CRM_Utils_Array::key(ucfirst($value), CRM_Contribute_PseudoConstant::contributionType());
                break;
            case 'payment_instrument':
                require_once 'CRM/Core/OptionGroup.php';
                $values['payment_instrument_id'] = CRM_Core_OptionGroup::getValue('payment_instrument', $value);
                break;
            case 'contribution_status_id':
                require_once 'CRM/Core/OptionGroup.php';
                $values['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', $value);
                break;
            default:
                break;
        }
    }
    if (array_key_exists('note', $params)) {
        $values['note'] = $params['note'];
    }
    _crm_format_custom_params($params, $values, 'Contribution');
    if ($create) {
        // CRM_Contribute_BAO_Contribution::add() handles contribution_source
        // So, if $values contains contribution_source, convert it to source
        $changes = array('contribution_source' => 'source');
        foreach ($changes as $orgVal => $changeVal) {
            if (isset($values[$orgVal])) {
                $values[$changeVal] = $values[$orgVal];
                unset($values[$orgVal]);
            }
        }
    }
    return null;
}
开发者ID:ksecor,项目名称:civicrm,代码行数:89,代码来源:utils.php

示例8: _civicrm_api3_deprecated_formatted_param


//.........这里部分代码省略.........
                    if ($contactId->find(TRUE)) {
                        $contactType->id = $contactId->contact_id;
                        if ($contactType->find(TRUE)) {
                            if ($params['contact_type'] != $contactType->contact_type) {
                                return civicrm_api3_create_error("Contact Type is wrong: {$contactType->contact_type}");
                            }
                        }
                    }
                } else {
                    if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
                        return civicrm_api3_create_error("Empty Contribution and Invoice and Transaction ID. Row was skipped.");
                    } else {
                        return civicrm_api3_create_error("Empty Contact and External ID. Row was skipped.");
                    }
                }
                break;
            case 'receive_date':
            case 'cancel_date':
            case 'receipt_date':
            case 'thankyou_date':
                if (!CRM_Utils_Rule::dateTime($value)) {
                    return civicrm_api3_create_error("{$key} not a valid date: {$value}");
                }
                break;
            case 'non_deductible_amount':
            case 'total_amount':
            case 'fee_amount':
            case 'net_amount':
                if (!CRM_Utils_Rule::money($value)) {
                    return civicrm_api3_create_error("{$key} not a valid amount: {$value}");
                }
                break;
            case 'currency':
                if (!CRM_Utils_Rule::currencyCode($value)) {
                    return civicrm_api3_create_error("currency not a valid code: {$value}");
                }
                break;
            case 'financial_type':
                require_once 'CRM/Contribute/PseudoConstant.php';
                $contriTypes = CRM_Contribute_PseudoConstant::financialType();
                foreach ($contriTypes as $val => $type) {
                    if (strtolower($value) == strtolower($type)) {
                        $values['financial_type_id'] = $val;
                        break;
                    }
                }
                if (empty($values['financial_type_id'])) {
                    return civicrm_api3_create_error("Financial Type is not valid: {$value}");
                }
                break;
            case 'payment_instrument':
                require_once 'CRM/Core/OptionGroup.php';
                $values['payment_instrument_id'] = CRM_Core_OptionGroup::getValue('payment_instrument', $value);
                if (empty($values['payment_instrument_id'])) {
                    return civicrm_api3_create_error("Payment Instrument is not valid: {$value}");
                }
                break;
            case 'contribution_status_id':
                require_once 'CRM/Core/OptionGroup.php';
                if (!($values['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', $value))) {
                    return civicrm_api3_create_error("Contribution Status is not valid: {$value}");
                }
                break;
            case 'soft_credit':
                // import contribution record according to select contact type
                // validate contact id and external identifier.
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:67,代码来源:DeprecatedUtils.php

示例9: _civicrm_api3_validate_string

/**
 * Validate string fields being passed into API.
 * @param array $params params from civicrm_api
 * @param string $fieldName uniquename of field being checked
 * @param array $fieldInfo array of fields from getfields function
 * @param string $entity
 * @throws API_Exception
 * @throws Exception
 */
function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity)
{
    // If fieldname exists in params
    $value = CRM_Utils_Array::value($fieldName, $params, '');
    if (!is_array($value)) {
        $value = (string) $value;
    } else {
        //@todo what do we do about passed in arrays. For many of these fields
        // the missing piece of functionality is separating them to a separated string
        // & many save incorrectly. But can we change them wholesale?
    }
    if ($value) {
        if (!CRM_Utils_Rule::xssString($value)) {
            throw new Exception('Illegal characters in input (potential scripting attack)');
        }
        if ($fieldName == 'currency') {
            if (!CRM_Utils_Rule::currencyCode($value)) {
                throw new Exception("Currency not a valid code: {$value}");
            }
        }
        if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options'])) {
            _civicrm_api3_api_match_pseudoconstant($params, $entity, $fieldName, $fieldInfo);
        } elseif (is_string($value) && !empty($fieldInfo['maxlength']) && strlen(utf8_decode($value)) > $fieldInfo['maxlength']) {
            throw new API_Exception("Value for {$fieldName} is " . strlen(utf8_decode($value)) . " characters  - This field has a maxlength of {$fieldInfo['maxlength']} characters.", 2100, array('field' => $fieldName));
        }
    }
}
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:36,代码来源:utils.php

示例10: _civicrm_api3_validate_string

/**
 * Validate string fields being passed into API.
 *
 * @param array $params
 *   Params from civicrm_api.
 * @param string $fieldName
 *   Uniquename of field being checked.
 * @param array $fieldInfo
 *   Array of fields from getfields function.
 * @param string $entity
 *
 * @throws API_Exception
 * @throws Exception
 */
function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity)
{
    list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
    if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE || CRM_Utils_System::isNull($fieldValue)) {
        return;
    }
    if (!is_array($fieldValue)) {
        $fieldValue = (string) $fieldValue;
    } else {
        //@todo what do we do about passed in arrays. For many of these fields
        // the missing piece of functionality is separating them to a separated string
        // & many save incorrectly. But can we change them wholesale?
    }
    if ($fieldValue) {
        foreach ((array) $fieldValue as $value) {
            if (!CRM_Utils_Rule::xssString($fieldValue)) {
                throw new Exception('Input contains illegal SCRIPT tag.');
            }
            if ($fieldName == 'currency') {
                //When using IN operator $fieldValue is a array of currency codes
                if (!CRM_Utils_Rule::currencyCode($value)) {
                    throw new Exception("Currency not a valid code: {$currency}");
                }
            }
        }
    }
    if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options'])) {
        _civicrm_api3_api_match_pseudoconstant($fieldValue, $entity, $fieldName, $fieldInfo);
    } elseif (is_string($fieldValue) && !empty($fieldInfo['maxlength']) && strlen(utf8_decode($fieldValue)) > $fieldInfo['maxlength']) {
        throw new API_Exception("Value for {$fieldName} is " . strlen(utf8_decode($value)) . " characters  - This field has a maxlength of {$fieldInfo['maxlength']} characters.", 2100, array('field' => $fieldName));
    }
    if (!empty($op)) {
        $params[$fieldName][$op] = $fieldValue;
    } else {
        $params[$fieldName] = $fieldValue;
    }
}
开发者ID:sugan2111,项目名称:Drupal_code,代码行数:51,代码来源:utils.php

示例11: CRM_Core_Config

 /**
  * The constructor. Basically redefines the class variables if
  * it finds a constant definition for that class variable
  *
  * @return object
  * @access private
  */
 function CRM_Core_Config()
 {
     require_once 'CRM/Core/Session.php';
     $session =& CRM_Core_Session::singleton();
     if (defined('CIVICRM_DOMAIN_ID')) {
         $GLOBALS['_CRM_CORE_CONFIG']['_domainID'] = CIVICRM_DOMAIN_ID;
     } else {
         $GLOBALS['_CRM_CORE_CONFIG']['_domainID'] = 1;
     }
     $session->set('domainID', $GLOBALS['_CRM_CORE_CONFIG']['_domainID']);
     // we figure this out early, since some config parameters are loaded
     // based on what components are enabled
     if (defined('ENABLE_COMPONENTS')) {
         $this->enableComponents = explode(',', ENABLE_COMPONENTS);
         for ($i = 0; $i < count($this->enableComponents); $i++) {
             $this->enableComponents[$i] = trim($this->enableComponents[$i]);
         }
     }
     if (defined('CIVICRM_DSN')) {
         $this->dsn = CIVICRM_DSN;
     }
     if (defined('UF_DSN')) {
         $this->ufDSN = UF_DSN;
     }
     if (defined('UF_USERTABLENAME')) {
         $this->ufUserTableName = UF_USERTABLENAME;
     }
     if (defined('CIVICRM_DEBUG')) {
         $this->debug = CIVICRM_DEBUG;
     }
     if (defined('CIVICRM_DAO_DEBUG')) {
         $this->daoDebug = CIVICRM_DAO_DEBUG;
     }
     if (defined('CIVICRM_DAO_FACTORY_CLASS')) {
         $this->DAOFactoryClass = CIVICRM_DAO_FACTORY_CLASS;
     }
     if (defined('CIVICRM_SMARTYDIR')) {
         $this->smartyDir = CIVICRM_SMARTYDIR;
     }
     if (defined('CIVICRM_PLUGINSDIR')) {
         $this->pluginsDir = CIVICRM_PLUGINSDIR;
     }
     if (defined('CIVICRM_TEMPLATEDIR')) {
         $this->templateDir = CIVICRM_TEMPLATEDIR;
     }
     if (defined('CIVICRM_TEMPLATE_COMPILEDIR')) {
         $this->templateCompileDir = CIVICRM_TEMPLATE_COMPILEDIR;
         // make sure this directory exists
         CRM_Utils_File::createDir($this->templateCompileDir);
     }
     if (defined('CIVICRM_RESOURCEBASE')) {
         $this->resourceBase = CRM_Core_Config::addTrailingSlash(CIVICRM_RESOURCEBASE, '/');
     }
     if (defined('CIVICRM_UPLOADDIR')) {
         $this->uploadDir = CRM_Core_Config::addTrailingSlash(CIVICRM_UPLOADDIR);
         CRM_Utils_File::createDir($this->uploadDir);
     }
     if (defined('CIVICRM_IMAGE_UPLOADDIR')) {
         $this->imageUploadDir = CRM_Core_Config::addTrailingSlash(CIVICRM_IMAGE_UPLOADDIR);
         CRM_Utils_File::createDir($this->imageUploadDir);
     }
     if (defined('CIVICRM_IMAGE_UPLOADURL')) {
         $this->imageUploadURL = CRM_Core_Config::addTrailingSlash(CIVICRM_IMAGE_UPLOADURL, '/');
     }
     if (defined('CIVICRM_CLEANURL')) {
         $this->cleanURL = CIVICRM_CLEANURL;
     }
     if (defined('CIVICRM_COUNTRY_LIMIT')) {
         $isoCodes = preg_split('/[^a-zA-Z]/', CIVICRM_COUNTRY_LIMIT);
         $this->countryLimit = array_filter($isoCodes);
     }
     if (defined('CIVICRM_PROVINCE_LIMIT')) {
         $isoCodes = preg_split('/[^a-zA-Z]/', CIVICRM_PROVINCE_LIMIT);
         $provinceLimitList = array_filter($isoCodes);
         if (!empty($provinceLimitList)) {
             $this->provinceLimit = array_filter($isoCodes);
         }
     }
     // Note: we can't change the ISO code to country_id
     // here, as we can't access the database yet...
     if (defined('CIVICRM_DEFAULT_CONTACT_COUNTRY')) {
         $this->defaultContactCountry = CIVICRM_DEFAULT_CONTACT_COUNTRY;
     }
     if (defined('CIVICONTRIBUTE_DEFAULT_CURRENCY') and CRM_Utils_Rule::currencyCode(CIVICONTRIBUTE_DEFAULT_CURRENCY)) {
         $this->defaultCurrency = CIVICONTRIBUTE_DEFAULT_CURRENCY;
     }
     if (defined('CIVICRM_LC_MESSAGES')) {
         $this->lcMessages = CIVICRM_LC_MESSAGES;
     }
     if (defined('CIVICRM_ADDRESS_FORMAT')) {
         // trim the format and unify line endings to LF
         $format = trim(CIVICRM_ADDRESS_FORMAT);
         $format = str_replace(array("\r\n", "\r"), "\n", $format);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:101,代码来源:Config.php

示例12: key

 /**
  * Takes an associative array and creates a participant object.
  *
  * the function extract all the params it needs to initialize the create a
  * participant object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  *
  * @return CRM_Event_BAO_Participant
  */
 public static function &add(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Participant', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Participant', NULL, $params);
     }
     // converting dates to mysql format
     if (!empty($params['register_date'])) {
         $params['register_date'] = CRM_Utils_Date::isoToMysql($params['register_date']);
     }
     if (!empty($params['participant_fee_amount'])) {
         $params['participant_fee_amount'] = CRM_Utils_Rule::cleanMoney($params['participant_fee_amount']);
     }
     if (!empty($params['fee_amount'])) {
         $params['fee_amount'] = CRM_Utils_Rule::cleanMoney($params['fee_amount']);
     }
     // ensure that role ids are encoded as a string
     if (isset($params['role_id']) && is_array($params['role_id'])) {
         if (in_array(key($params['role_id']), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
             $op = key($params['role_id']);
             $params['role_id'] = $params['role_id'][$op];
         } else {
             $params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['role_id']);
         }
     }
     $participantBAO = new CRM_Event_BAO_Participant();
     if (!empty($params['id'])) {
         $participantBAO->id = CRM_Utils_Array::value('id', $params);
         $participantBAO->find(TRUE);
         $participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date);
     }
     $participantBAO->copyValues($params);
     //CRM-6910
     //1. If currency present, it should be valid one.
     //2. We should have currency when amount is not null.
     $currency = $participantBAO->fee_currency;
     if ($currency || !CRM_Utils_System::isNull($participantBAO->fee_amount)) {
         if (!CRM_Utils_Rule::currencyCode($currency)) {
             $config = CRM_Core_Config::singleton();
             $currency = $config->defaultCurrency;
         }
     }
     $participantBAO->fee_currency = $currency;
     $participantBAO->save();
     $session = CRM_Core_Session::singleton();
     CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Participant', $participantBAO->id, $participantBAO);
     } else {
         CRM_Utils_Hook::post('create', 'Participant', $participantBAO->id, $participantBAO);
     }
     return $participantBAO;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:66,代码来源:Participant.php

示例13: 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
  */
 static function add(&$params, $ids = array())
 {
     if (empty($params)) {
         return;
     }
     //per http://wiki.civicrm.org/confluence/display/CRM/Database+layer we are moving away from $ids array
     $contributionID = CRM_Utils_Array::value('contribution', $ids, CRM_Utils_Array::value('id', $params));
     $duplicates = array();
     if (self::checkDuplicate($params, $duplicates, $contributionID)) {
         $error = CRM_Core_Error::singleton();
         $d = implode(', ', $duplicates);
         $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', array($d), "Duplicate error - existing contribution record(s) have a matching Transaction ID or Invoice ID. Contribution record ID(s) are: {$d}");
         return $error;
     }
     // first clean up all the money fields
     $moneyFields = array('total_amount', 'net_amount', 'fee_amount', 'non_deductible_amount');
     //if priceset is used, no need to cleanup money
     if (CRM_Utils_Array::value('skipCleanMoney', $params)) {
         unset($moneyFields[0]);
     }
     foreach ($moneyFields as $field) {
         if (isset($params[$field])) {
             $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]);
         }
     }
     // CRM-13420, set payment instrument to default if payment_instrument_id is empty
     if (!$contributionID && !CRM_Utils_Array::value('payment_instrument_id', $params)) {
         $params['payment_instrument_id'] = key(CRM_Core_OptionGroup::values('payment_instrument', FALSE, FALSE, FALSE, 'AND is_default = 1'));
     }
     if (CRM_Utils_Array::value('payment_instrument_id', $params)) {
         $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
         if ($params['payment_instrument_id'] != array_search('Check', $paymentInstruments)) {
             $params['check_number'] = 'null';
         }
     }
     // contribution status is missing, choose Completed as default status
     // do this for create mode only
     if (!$contributionID && !CRM_Utils_Array::value('contribution_status_id', $params)) {
         $params['contribution_status_id'] = CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name');
     }
     if ($contributionID) {
         CRM_Utils_Hook::pre('edit', 'Contribution', $contributionID, $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Contribution', NULL, $params);
     }
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->copyValues($params);
     $contribution->id = $contributionID;
     if (!CRM_Utils_Rule::currencyCode($contribution->currency)) {
         $config = CRM_Core_Config::singleton();
         $contribution->currency = $config->defaultCurrency;
     }
     if ($contributionID) {
         $params['prevContribution'] = self::getValues(array('id' => $contributionID), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
     }
     $result = $contribution->save();
     // Add financial_trxn details as part of fix for CRM-4724
     $contribution->trxn_result_code = CRM_Utils_Array::value('trxn_result_code', $params);
     $contribution->payment_processor = CRM_Utils_Array::value('payment_processor', $params);
     //add Account details
     $params['contribution'] = $contribution;
     self::recordFinancialAccounts($params);
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
     if ($contributionID) {
         CRM_Utils_Hook::post('edit', 'Contribution', $contribution->id, $contribution);
     } else {
         CRM_Utils_Hook::post('create', 'Contribution', $contribution->id, $contribution);
     }
     return $result;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:85,代码来源:Contribution.php

示例14: 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

示例15: _crm_validate_formatted_contribution

/**
 * Validate a formatted contribution parameter list.
 *
 * @param array $params  Structured parameter list (as in crm_format_params)
 *
 * @return bool|CRM_Core_Error
 * @access public
 */
function _crm_validate_formatted_contribution(&$params)
{
    static $domainID = null;
    if (!$domainID) {
        $config =& CRM_Core_Config::singleton();
        $domainID = $config->domainID();
    }
    foreach ($params as $key => $value) {
        switch ($key) {
            case 'contact_id':
                if (!CRM_Utils_Rule::integer($value)) {
                    return _crm_error("contact_id not valid: {$value}");
                }
                $dao =& new CRM_Core_DAO();
                $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE domain_id = {$domainID} AND id = {$value}");
                if (!$svq) {
                    return _crm_error("there's no contact with contact_id of {$value}");
                }
                break;
            case 'receive_date':
            case 'cancel_date':
            case 'receipt_date':
            case 'thankyou_date':
                if (!CRM_Utils_Rule::date($value)) {
                    return _crm_error("{$key} not a valid date: {$value}");
                }
                break;
            case 'non_deductible_amount':
            case 'total_amount':
            case 'fee_amount':
            case 'net_amount':
                if (!CRM_Utils_Rule::money($value)) {
                    return _crm_error("{$key} not a valid amount: {$value}");
                }
                break;
            case 'currency':
                if (!CRM_Utils_Rule::currencyCode($value)) {
                    return _crm_error("currency not a valid code: {$value}");
                }
                break;
            default:
                break;
        }
    }
    /* Validate custom data fields */
    if (is_array($params['custom'])) {
        foreach ($params['custom'] as $key => $custom) {
            if (is_array($custom)) {
                $valid = CRM_Core_BAO_CustomValue::typecheck($custom['type'], $custom['value']);
                if (!$valid) {
                    return _crm_error('Invalid value for custom field \'' . $custom['name'] . '\'');
                }
                if ($custom['type'] == 'Date') {
                    $params['custom'][$key]['value'] = str_replace('-', '', $params['custom'][$key]['value']);
                }
            }
        }
    }
    return true;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:68,代码来源:utils.php


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