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


PHP CRM_Case_BAO_Case::save方法代码示例

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


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

示例1: civicrm_api3_case_update

/**
* Update a specified case.
*
* @param  array(
   //REQUIRED:
* 'case_id' => int
*
* //OPTIONAL
* 'status_id' => int
* 'start_date' => str datestamp
* 'contact_id' => int // case client
*
* @return Updated case
*
* @access public
*
*/
function civicrm_api3_case_update($params)
{
    //check parameters
    civicrm_api3_verify_mandatory($params, NULL, array('id'));
    // return error if modifing creator id
    if (array_key_exists('creator_id', $params)) {
        return civicrm_api3_create_error(ts('You cannot update creator id'));
    }
    $mCaseId = array();
    $origContactIds = array();
    // get original contact id and creator id of case
    if (!empty($params['contact_id'])) {
        $origContactIds = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($params['id']);
        $origContactId = $origContactIds[1];
    }
    if (count($origContactIds) > 1) {
        // check valid orig contact id
        if (!empty($params['orig_contact_id']) && !in_array($params['orig_contact_id'], $origContactIds)) {
            return civicrm_api3_create_error('Invalid case contact id (orig_contact_id)');
        } elseif (empty($params['orig_contact_id'])) {
            return civicrm_api3_create_error('Case is linked with more than one contact id. Provide the required params orig_contact_id to be replaced');
        }
        $origContactId = $params['orig_contact_id'];
    }
    // check for same contact id for edit Client
    if (!empty($params['contact_id']) && !in_array($params['contact_id'], $origContactIds)) {
        $mCaseId = CRM_Case_BAO_Case::mergeCases($params['contact_id'], $params['case_id'], $origContactId, NULL, TRUE);
    }
    if (!empty($mCaseId[0])) {
        $params['id'] = $mCaseId[0];
    }
    $dao = new CRM_Case_BAO_Case();
    $dao->id = $params['id'];
    $dao->copyValues($params);
    $dao->save();
    $case = array();
    _civicrm_api3_object_to_array($dao, $case);
    return civicrm_api3_create_success($case, $params, 'case', 'update', $dao);
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:56,代码来源:Case.php

示例2: civicrm_case_update

/**
 * Update a specified case.
 *
 * @param  array( //REQUIRED:
 *                  'case_id'          => int
 *
 *                //OPTIONAL
 *                  'status_id'        => int
 *                  'start_date'       => str datestamp
 *                  'contact_id'       => int // case client
 *                  'creator_id'       => int // case manager
 *  
 * @return Updated case
 *
 * @access public
 *
 */
function civicrm_case_update(&$params)
{
    _civicrm_initialize();
    $errors = array();
    //check for various error and required conditions
    $errors = _civicrm_case_check_params($params, 'update');
    if (!empty($errors)) {
        return $errors;
    }
    // return error if modifing creator id
    if (array_key_exists('creator_id', $params)) {
        return civicrm_create_error(ts('You have no provision to update creator id'));
    }
    $mCaseId = array();
    $origContactIds = array();
    // get original contact id and creator id of case
    if ($params['contact_id']) {
        $origContactIds = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($params['case_id']);
        $origContactId = $origContactIds[1];
    }
    if (count($origContactIds) > 1) {
        // check valid orig contact id
        if ($params['orig_contact_id'] && !in_array($params['orig_contact_id'], $origContactIds)) {
            return civicrm_create_error(ts('Invalid case contact id (orig_contact_id)'));
        } else {
            if (!$params['orig_contact_id']) {
                return civicrm_create_error(ts('Case is linked with more than one contact id. Provide the required params orig_contact_id to be replaced'));
            }
        }
        $origContactId = $params['orig_contact_id'];
    }
    // check for same contact id for edit Client
    if ($params['contact_id'] && !in_array($params['contact_id'], $origContactIds)) {
        $mCaseId = CRM_Case_BAO_Case::mergeCases($params['contact_id'], $params['case_id'], $origContactId, null, true);
    }
    if (CRM_Utils_Array::value('0', $mCaseId)) {
        $params['case_id'] = $mCaseId[0];
    }
    $dao = new CRM_Case_BAO_Case();
    $dao->id = $params['case_id'];
    $dao->copyValues($params);
    $dao->save();
    $case = array();
    _civicrm_object_to_array($dao, $case);
    return civicrm_create_success($case);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:63,代码来源:Case.php


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