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


PHP _civicrm_api3_get_DAO函数代码示例

本文整理汇总了PHP中_civicrm_api3_get_DAO函数的典型用法代码示例。如果您正苦于以下问题:PHP _civicrm_api3_get_DAO函数的具体用法?PHP _civicrm_api3_get_DAO怎么用?PHP _civicrm_api3_get_DAO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: civicrm_api3_generic_setValue

/**
 * params must contain at least id=xx & {one of the fields from getfields}=value
 */
function civicrm_api3_generic_setValue($apiRequest)
{
    $entity = $apiRequest['entity'];
    $params = $apiRequest['params'];
    // we can't use _spec, doesn't work with generic
    civicrm_api3_verify_mandatory($params, NULL, array('id', 'field', 'value'));
    $id = $params['id'];
    if (!is_numeric($id)) {
        return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
    }
    $field = CRM_Utils_String::munge($params['field']);
    $value = $params['value'];
    $fields = civicrm_api($entity, 'getFields', array("version" => 3, "sequential"));
    // getfields error, shouldn't happen.
    if ($fields['is_error']) {
        return $fields;
    }
    $fields = $fields['values'];
    if (!array_key_exists($field, $fields)) {
        return civicrm_api3_create_error("Param 'field' ({$field}) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
    }
    $def = $fields[$field];
    if (array_key_exists('required', $def) && empty($value)) {
        return civicrm_api3_create_error(ts("This can't be empty, please provide a value"), array("error_code" => "required", "field" => $field));
    }
    switch ($def['type']) {
        case 1:
            //int
            if (!is_numeric($value)) {
                return civicrm_api3_create_error("Param '{$field}' must be a number", array('error_code' => 'NaN'));
            }
        case 2:
            //string
            require_once "CRM/Utils/Rule.php";
            if (!CRM_Utils_Rule::xssString($value)) {
                return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
            }
            if (array_key_exists('maxlength', $def)) {
                $value = substr($value, 0, $def['maxlength']);
            }
            break;
        case 16:
            //boolean
            $value = (bool) $value;
            break;
        case 4:
            //date
        //date
        default:
            return civicrm_api3_create_error("Param '{$field}' is of a type not managed yet. Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
    }
    if (CRM_Core_DAO::setFieldValue(_civicrm_api3_get_DAO($entity), $id, $field, $value)) {
        $entity = array('id' => $id, $field => $value);
        CRM_Utils_Hook::post('edit', $entity, $id, $entity);
        return civicrm_api3_create_success($entity);
    } else {
        return civicrm_api3_create_error("error assigning {$field}={$value} for {$entity} (id={$id})");
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:62,代码来源:Setvalue.php

示例2: civicrm_api3_contact_type_create

/**
 * create/update contact_type
 *
 * This API is used to create new contact_type or update any of the existing
 * In case of updating existing contact_type, id of that particular contact_type must
 * be in $params array.
 *
 * @param array $params  (referance) Associative array of property
 *                       name/value pairs to insert in new 'contact_type'
 *
 * @return array   contact_type array
 *
 * @access public
 */
function civicrm_api3_contact_type_create($params)
{
    civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id'));
    if (!array_key_exists('label', $params)) {
        $params['label'] = $params['name'];
    }
    if (!array_key_exists('is_active', $params)) {
        $params['is_active'] = TRUE;
    }
    $params['name'] = CRM_Utils_String::munge($params['name']);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
开发者ID:hguru,项目名称:224Civi,代码行数:26,代码来源:ContactType.php

示例3: civicrm_api3_case_type_create

/**
 * Create or update case type.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 * @return array
 *   API result array
 */
function civicrm_api3_case_type_create($params)
{
    civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__));
    // Computed properties.
    unset($params['is_forkable']);
    unset($params['is_forked']);
    if (!array_key_exists('is_active', $params) && empty($params['id'])) {
        $params['is_active'] = TRUE;
    }
    // This is an existing case-type.
    if (!empty($params['id']) && !CRM_Case_BAO_CaseType::isForked($params['id']) && !CRM_Case_BAO_CaseType::isForkable($params['id'])) {
        unset($params['definition']);
    }
    $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'CaseType');
    return _civicrm_api3_case_type_get_formatResult($result);
}
开发者ID:kidaa30,项目名称:yes,代码行数:26,代码来源:CaseType.php

示例4: getMockableBAOObjects

 /**
  * @param entityName
  */
 private function getMockableBAOObjects($entityName, $count = 2)
 {
     $baoString = _civicrm_api3_get_DAO($entityName);
     if (empty($baoString)) {
         $this->markTestIncomplete("Entity [{$entityName}] cannot be mocked - no known DAO");
         return;
     }
     $baos = array();
     $i = 0;
     while ($i < $count) {
         // create entities
         $baoObj = CRM_Core_DAO::createTestObject($baoString, array('currency' => 'USD'));
         $this->assertTrue(is_integer($baoObj->id), 'check first id');
         $this->deletableTestObjects[$baoString][] = $baoObj->id;
         $baos[] = $baoObj;
         $i++;
     }
     return $baos;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:22,代码来源:SyntaxConformanceTest.php

示例5: testGetDAO

 function testGetDAO()
 {
     $params = array('civicrm_api3_custom_group_get' => 'CRM_Core_DAO_CustomGroup', 'custom_group' => 'CRM_Core_DAO_CustomGroup', 'CustomGroup' => 'CRM_Core_DAO_CustomGroup', 'civicrm_api3_custom_field_get' => 'CRM_Core_DAO_CustomField', 'civicrm_api3_survey_get' => 'CRM_Campaign_DAO_Survey', 'civicrm_api3_pledge_payment_get' => 'CRM_Pledge_DAO_PledgePayment', 'civicrm_api3_website_get' => 'CRM_Core_DAO_Website', 'Membership' => 'CRM_Member_DAO_Membership');
     foreach ($params as $input => $expected) {
         $result = _civicrm_api3_get_DAO($input);
         $this->assertEquals($expected, $result);
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:8,代码来源:UtilsTest.php

示例6: _civicrm_api_get_fields

/**
 * Returns fields allowable by api.
 *
 * @param $entity
 *   String Entity to query.
 * @param bool $unique
 *   Index by unique fields?.
 * @param array $params
 *
 * @return array
 */
function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = array())
{
    $unsetIfEmpty = array('dataPattern', 'headerPattern', 'default', 'export', 'import');
    $dao = _civicrm_api3_get_DAO($entity);
    if (empty($dao)) {
        return array();
    }
    $d = new $dao();
    $fields = $d->fields();
    // replace uniqueNames by the normal names as the key
    if (empty($unique)) {
        foreach ($fields as $name => &$field) {
            //getting rid of unused attributes
            foreach ($unsetIfEmpty as $attr) {
                if (empty($field[$attr])) {
                    unset($field[$attr]);
                }
            }
            if ($name == $field['name']) {
                continue;
            }
            if (array_key_exists($field['name'], $fields)) {
                $field['error'] = 'name conflict';
                // it should never happen, but better safe than sorry
                continue;
            }
            $fields[$field['name']] = $field;
            $fields[$field['name']]['uniqueName'] = $name;
            unset($fields[$name]);
        }
    }
    // Translate FKClassName to the corresponding api
    foreach ($fields as $name => &$field) {
        if (!empty($field['FKClassName'])) {
            $FKApi = CRM_Core_DAO_AllCoreTables::getBriefName($field['FKClassName']);
            if ($FKApi) {
                $field['FKApiName'] = $FKApi;
            }
        }
    }
    $fields += _civicrm_api_get_custom_fields($entity, $params);
    return $fields;
}
开发者ID:sugan2111,项目名称:Drupal_code,代码行数:54,代码来源:utils.php

示例7: civicrm_api3_generic_setValue

/**
 * params must contain at least id=xx & {one of the fields from getfields}=value
 */
function civicrm_api3_generic_setValue($apiRequest)
{
    $entity = $apiRequest['entity'];
    $params = $apiRequest['params'];
    // we can't use _spec, doesn't work with generic
    civicrm_api3_verify_mandatory($params, NULL, array('id', 'field', 'value'));
    $id = $params['id'];
    if (!is_numeric($id)) {
        return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
    }
    $field = CRM_Utils_String::munge($params['field']);
    $value = $params['value'];
    $fields = civicrm_api($entity, 'getFields', array('version' => 3, 'action' => 'create', "sequential"));
    // getfields error, shouldn't happen.
    if ($fields['is_error']) {
        return $fields;
    }
    $fields = $fields['values'];
    if (!array_key_exists($field, $fields)) {
        return civicrm_api3_create_error("Param 'field' ({$field}) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
    }
    $def = $fields[$field];
    // Disallow empty values except for the number zero.
    // TODO: create a utility for this since it's needed in many places
    // if (array_key_exists('required', $def) && CRM_Utils_System::isNull($value)) {
    if (array_key_exists('required', $def) && empty($value) && $value !== '0' && $value !== 0) {
        return civicrm_api3_create_error(ts("This can't be empty, please provide a value"), array("error_code" => "required", "field" => $field));
    }
    switch ($def['type']) {
        case CRM_Utils_Type::T_INT:
            if (!is_numeric($value)) {
                return civicrm_api3_create_error("Param '{$field}' must be a number", array('error_code' => 'NaN'));
            }
        case CRM_Utils_Type::T_STRING:
        case CRM_Utils_Type::T_TEXT:
            if (!CRM_Utils_Rule::xssString($value)) {
                return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
            }
            if (array_key_exists('maxlength', $def)) {
                $value = substr($value, 0, $def['maxlength']);
            }
            break;
        case CRM_Utils_Type::T_DATE:
            $value = CRM_Utils_Type::escape($value, "Date", false);
            if (!$value) {
                return civicrm_api3_create_error("Param '{$field}' is not a date. format YYYYMMDD or YYYYMMDDHHMMSS");
            }
            break;
        case CRM_Utils_Type::T_BOOLEAN:
            $value = (bool) $value;
            break;
        default:
            return civicrm_api3_create_error("Param '{$field}' is of a type not managed yet (" . $def['type'] . "). Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
    }
    $dao_name = _civicrm_api3_get_DAO($entity);
    if (CRM_Core_DAO::setFieldValue($dao_name, $id, $field, $value)) {
        $params = array('id' => $id, $field => $value);
        $entityDAO = new $dao_name();
        $entityDAO->copyValues($params);
        CRM_Utils_Hook::post('edit', $entity, $entityDAO->id, $entityDAO);
        return civicrm_api3_create_success($params);
    } else {
        return civicrm_api3_create_error("error assigning {$field}={$value} for {$entity} (id={$id})");
    }
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:68,代码来源:Setvalue.php

示例8: _civicrm_api_get_fields

function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = array())
{
    $unsetIfEmpty = array('dataPattern', 'headerPattern', 'default', 'export', 'import');
    $dao = _civicrm_api3_get_DAO($entity);
    if (empty($dao)) {
        return array();
    }
    $file = str_replace('_', '/', $dao) . ".php";
    require_once $file;
    $d = new $dao();
    $fields = $d->fields();
    // replace uniqueNames by the normal names as the key
    if (empty($unique)) {
        foreach ($fields as $name => &$field) {
            //getting rid of unused attributes
            foreach ($unsetIfEmpty as $attr) {
                if (empty($field[$attr])) {
                    unset($field[$attr]);
                }
            }
            if ($name == $field['name']) {
                continue;
            }
            if (array_key_exists($field['name'], $fields)) {
                $field['error'] = 'name conflict';
                // it should never happen, but better safe than sorry
                continue;
            }
            $fields[$field['name']] = $field;
            $fields[$field['name']]['uniqueName'] = $name;
            unset($fields[$name]);
        }
    }
    $fields += _civicrm_api_get_custom_fields($entity, $params);
    return $fields;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:36,代码来源:utils.php

示例9: civicrm_api3_country_get

/**
 * Retrieve one or more countryies.
 *
 * @param array $params
 *   Array per getfields metadata.
 *
 * @return array
 *   api result array
 */
function civicrm_api3_country_get($params)
{
    return _civicrm_api3_basic_get(_civicrm_api3_get_DAO(__FUNCTION__), $params);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:13,代码来源:Country.php

示例10: civicrm_api3_generic_setValue

/**
 * Set a single value using the api.
 *
 * This function is called when no specific setvalue api exists.
 * Params must contain at least id=xx & {one of the fields from getfields}=value
 *
 * @param array $apiRequest
 *
 * @throws API_Exception
 * @return array
 */
function civicrm_api3_generic_setValue($apiRequest)
{
    $entity = $apiRequest['entity'];
    $params = $apiRequest['params'];
    $id = $params['id'];
    if (!is_numeric($id)) {
        return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
    }
    $field = CRM_Utils_String::munge($params['field']);
    $value = $params['value'];
    $fields = civicrm_api($entity, 'getFields', array('version' => 3, 'action' => 'create', "sequential"));
    // getfields error, shouldn't happen.
    if ($fields['is_error']) {
        return $fields;
    }
    $fields = $fields['values'];
    $isCustom = strpos($field, 'custom_') === 0;
    // Trim off the id portion of a multivalued custom field name
    $fieldKey = $isCustom && substr_count($field, '_') > 1 ? rtrim(rtrim($field, '1234567890'), '_') : $field;
    if (!array_key_exists($fieldKey, $fields)) {
        return civicrm_api3_create_error("Param 'field' ({$field}) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
    }
    $def = $fields[$fieldKey];
    $title = CRM_Utils_Array::value('title', $def, ts('Field'));
    // Disallow empty values except for the number zero.
    // TODO: create a utility for this since it's needed in many places
    if (!empty($def['required']) || !empty($def['is_required'])) {
        if ((empty($value) || $value === 'null') && $value !== '0' && $value !== 0) {
            return civicrm_api3_create_error(ts('%1 is a required field.', array(1 => $title)), array("error_code" => "required", "field" => $field));
        }
    }
    switch ($def['type']) {
        case CRM_Utils_Type::T_FLOAT:
            if (!is_numeric($value) && !empty($value) && $value !== 'null') {
                return civicrm_api3_create_error(ts('%1 must be a number.', array(1 => $title)), array('error_code' => 'NaN'));
            }
            break;
        case CRM_Utils_Type::T_INT:
            if (!CRM_Utils_Rule::integer($value) && !empty($value) && $value !== 'null') {
                return civicrm_api3_create_error(ts('%1 must be a number.', array(1 => $title)), array('error_code' => 'NaN'));
            }
            break;
        case CRM_Utils_Type::T_STRING:
        case CRM_Utils_Type::T_TEXT:
            if (!CRM_Utils_Rule::xssString($value)) {
                return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
            }
            if (array_key_exists('maxlength', $def)) {
                $value = substr($value, 0, $def['maxlength']);
            }
            break;
        case CRM_Utils_Type::T_DATE:
            $value = CRM_Utils_Type::escape($value, "Date", FALSE);
            if (!$value) {
                return civicrm_api3_create_error("Param '{$field}' is not a date. format YYYYMMDD or YYYYMMDDHHMMSS");
            }
            break;
        case CRM_Utils_Type::T_BOOLEAN:
            // Allow empty value for non-required fields
            if ($value === '' || $value === 'null') {
                $value = '';
            } else {
                $value = (bool) $value;
            }
            break;
        default:
            return civicrm_api3_create_error("Param '{$field}' is of a type not managed yet (" . $def['type'] . "). Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
    }
    $dao_name = _civicrm_api3_get_DAO($entity);
    $params = array('id' => $id, $field => $value);
    if ((!empty($def['pseudoconstant']) || !empty($def['option_group_id'])) && $value !== '' && $value !== 'null') {
        _civicrm_api3_api_match_pseudoconstant($params[$field], $entity, $field, $def);
    }
    CRM_Utils_Hook::pre('edit', $entity, $id, $params);
    // Custom fields
    if ($isCustom) {
        CRM_Utils_Array::crmReplaceKey($params, 'id', 'entityID');
        // Treat 'null' as empty value. This is awful but the rest of the code supports it.
        if ($params[$field] === 'null') {
            $params[$field] = '';
        }
        CRM_Core_BAO_CustomValueTable::setValues($params);
        CRM_Utils_Hook::post('edit', $entity, $id, CRM_Core_DAO::$_nullObject);
    } elseif (CRM_Core_DAO::setFieldValue($dao_name, $id, $field, $params[$field])) {
        $entityDAO = new $dao_name();
        $entityDAO->copyValues($params);
        CRM_Utils_Hook::post('edit', $entity, $entityDAO->id, $entityDAO);
    } else {
        return civicrm_api3_create_error("error assigning {$field}={$value} for {$entity} (id={$id})");
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:Setvalue.php

示例11: civicrm_api3_mailing_group_getfields

function civicrm_api3_mailing_group_getfields($params)
{
    $dao = _civicrm_api3_get_DAO('Subscribe');
    $d = new $dao();
    $fields = $d->fields();
    $d->free();
    $dao = _civicrm_api3_get_DAO('Unsubscribe');
    $d = new $dao();
    $fields = $fields + $d->fields();
    $d->free();
    // CRM-13830 - prevent the api wrapper from helping out with pseudoconstants
    // Since these fields don't belong to this entity it will fail
    foreach ($fields as &$field) {
        unset($field['pseudoconstant']);
    }
    return civicrm_api3_create_success($fields);
}
开发者ID:hguru,项目名称:224Civi,代码行数:17,代码来源:MailingGroup.php

示例12: civicrm_api3_mailing_group_getfields

function civicrm_api3_mailing_group_getfields($params)
{
    $dao = _civicrm_api3_get_DAO('Subscribe');
    $file = str_replace('_', '/', $dao) . ".php";
    require_once $file;
    $d = new $dao();
    $fields = $d->fields();
    $d->free();
    $dao = _civicrm_api3_get_DAO('Unsubscribe');
    $file = str_replace('_', '/', $dao) . ".php";
    require_once $file;
    $d = new $dao();
    $fields = $fields + $d->fields();
    $d->free();
    return civicrm_api3_create_success($fields);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:16,代码来源:MailingGroup.php

示例13: civicrm_api3_profile_getfields

function civicrm_api3_profile_getfields($params)
{
    $dao = _civicrm_api3_get_DAO('UFGroup');
    $file = str_replace('_', '/', $dao) . ".php";
    require_once $file;
    $d = new $dao();
    $fields = $d->fields();
    return civicrm_api3_create_success($fields);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:9,代码来源:Profile.php


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