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


PHP CRM_Core_Error::createAPISuccess方法代码示例

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


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

示例1: setValues

 /**
  * Function to take in an array of entityID, custom_XXX => value
  * and set the value in the appropriate table. Should also be able
  * to set the value to null. Follows api parameter/return conventions
  *
  * @array $params
  *
  * @return array 
  * @static
  */
 static function setValues(&$params)
 {
     require_once 'CRM/Utils/Type.php';
     if (!isset($params['entityID']) || CRM_Utils_Type::escape($params['entityID'], 'Integer', false) === null) {
         return CRM_Core_Error::createAPIError(ts('entityID needs to be set and of type Integer'));
     }
     // first collect all the id/value pairs. The format is:
     // custom_X => value or custom_X_VALUEID => value (for multiple values), VALUEID == -1, -2 etc for new insertions
     $values = array();
     $fieldValues = array();
     require_once 'CRM/Core/BAO/CustomField.php';
     foreach ($params as $n => $v) {
         if ($customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($n, true)) {
             $fieldID = (int) $customFieldInfo[0];
             if (CRM_Utils_Type::escape($fieldID, 'Integer', false) === null) {
                 return CRM_Core_Error::createAPIError(ts('field ID needs to be of type Integer for index %1', array(1 => $fieldID)));
             }
             if (!array_key_exists($fieldID, $fieldValues)) {
                 $fieldValues[$fieldID] = array();
             }
             $id = -1;
             if ($customFieldInfo[1]) {
                 $id = (int) $customFieldInfo[1];
             }
             $fieldValues[$fieldID][] = array('value' => $v, 'id' => $id);
         }
     }
     $fieldIDList = implode(',', array_keys($fieldValues));
     // format it so that we can just use create
     $sql = "\nSELECT cg.table_name  as table_name ,\n       cg.id          as cg_id      ,\n       cg.is_multiple as is_multiple,\n       cf.column_name as column_name,\n       cf.id          as cf_id      ,\n       cf.data_type   as data_type \nFROM   civicrm_custom_group cg,\n       civicrm_custom_field cf\nWHERE  cf.custom_group_id = cg.id\nAND    cf.id IN ( {$fieldIDList} )\n";
     $dao = CRM_Core_DAO::executeQuery($sql);
     $cvParams = array();
     while ($dao->fetch()) {
         // ensure that value is of the right data type
         $dataType = $dao->data_type == 'Date' ? 'Timestamp' : $dao->data_type;
         foreach ($fieldValues[$dao->cf_id] as $fieldValue) {
             if (CRM_Utils_Type::escape($fieldValue['value'], $dataType, false) === null) {
                 return CRM_Core_Error::createAPIError(ts('value: %1 is not of the right field data type: %2', array(1 => $fieldValue['value'], 2 => $dao->data_type)));
             }
             $cvParam = array('entity_id' => $params['entityID'], 'value' => $fieldValue['value'], 'type' => $dataType, 'custom_field_id' => $dao->cf_id, 'custom_group_id' => $dao->cg_id, 'table_name' => $dao->table_name, 'column_name' => $dao->column_name, 'is_multiple' => $dao->is_multiple);
             if (!array_key_exists($dao->table_name, $cvParams)) {
                 $cvParams[$dao->table_name] = array();
             }
             if (!array_key_exists($fieldValue['id'], $cvParams[$dao->table_name])) {
                 $cvParams[$dao->table_name][$fieldValue['id']] = array();
             }
             if ($fieldValue['id'] > 0) {
                 $cvParam['id'] = $fieldValue['id'];
             }
             $cvParams[$dao->table_name][$fieldValue['id']][] = $cvParam;
         }
     }
     if (!empty($cvParams)) {
         self::create($cvParams);
         return CRM_Core_Error::createAPISuccess();
     }
     return CRM_Core_Error::createAPIError(ts('Unknown error'));
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:68,代码来源:CustomValueTable.php

示例2: civicrm_create_success

/**
 *
 * @param <type> $result
 * @return <type>
 */
function civicrm_create_success($result = 1)
{
    return CRM_Core_Error::createAPISuccess($result);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:9,代码来源:utils.php


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