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


PHP civicrm_api3_verify_mandatory函数代码示例

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


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

示例1: civicrm_api3_entity_get

/**
 *  returns the list of all the entities that you can manipulate via the api. The entity of this API call is the entity, that isn't a real civicrm entity as in something stored in the DB, but an abstract meta object. My head is going to explode. In a meta way.
 */
function civicrm_api3_entity_get($params)
{
    civicrm_api3_verify_mandatory($params);
    $entities = array();
    $include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path()));
    #$include_dirs = array(dirname(__FILE__). '/../../');
    foreach ($include_dirs as $include_dir) {
        $api_dir = implode(DIRECTORY_SEPARATOR, array($include_dir, 'api', 'v3'));
        if (!is_dir($api_dir)) {
            continue;
        }
        $iterator = new DirectoryIterator($api_dir);
        foreach ($iterator as $fileinfo) {
            $file = $fileinfo->getFilename();
            // Check for entities with a master file ("api/v3/MyEntity.php")
            $parts = explode(".", $file);
            if (end($parts) == "php" && $file != "utils.php" && !preg_match('/Tests?.php$/', $file)) {
                // without the ".php"
                $entities[] = substr($file, 0, -4);
            }
            // Check for entities with standalone action files ("api/v3/MyEntity/MyAction.php")
            $action_dir = $api_dir . DIRECTORY_SEPARATOR . $file;
            if (preg_match('/^[A-Z][A-Za-z0-9]*$/', $file) && is_dir($action_dir)) {
                if (count(glob("{$action_dir}/[A-Z]*.php")) > 0) {
                    $entities[] = $file;
                }
            }
        }
    }
    $entities = array_diff($entities, array('Generic'));
    $entities = array_unique($entities);
    sort($entities);
    return civicrm_api3_create_success($entities);
}
开发者ID:hguru,项目名称:224Civi,代码行数:37,代码来源:Entity.php

示例2: civicrm_api3_generic_getActions

/**
 * Get available api actions.
 *
 * @param array $apiRequest
 *
 * @return array
 * @throws API_Exception
 */
function civicrm_api3_generic_getActions($apiRequest)
{
    civicrm_api3_verify_mandatory($apiRequest, NULL, array('entity'));
    $mfp = \Civi::service('magic_function_provider');
    $actions = $mfp->getActionNames($apiRequest['version'], $apiRequest['entity']);
    return civicrm_api3_create_success($actions, $apiRequest['params'], $apiRequest['entity'], 'getactions');
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:15,代码来源:Getactions.php

示例3: civicrm_api3_generic_getActions

/**
 * @param $apiRequest
 *
 * @return array
 * @throws API_Exception
 */
function civicrm_api3_generic_getActions($apiRequest)
{
    civicrm_api3_verify_mandatory($apiRequest, NULL, array('entity'));
    $mfp = \Civi\Core\Container::singleton()->get('magic_function_provider');
    $actions = $mfp->getActionNames($apiRequest['version'], $apiRequest['entity']);
    return civicrm_api3_create_success($actions);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:13,代码来源:Getactions.php

示例4: civicrm_api3_membership_status_update

/**
 * Update an existing membership status.
 *
 * This api is used for updating an existing membership status.
 * Required parameters: id of a membership status
 *
 * @param array $params
 *   Array of name/value property values of civicrm_membership_status.
 *
 * @deprecated - should just use create
 *
 * @return array
 *   Array of updated membership status property values
 */
function civicrm_api3_membership_status_update($params)
{
    civicrm_api3_verify_mandatory($params, NULL, array('id'));
    //don't allow duplicate names.
    $name = CRM_Utils_Array::value('name', $params);
    if ($name) {
        $status = new CRM_Member_DAO_MembershipStatus();
        $status->name = $params['name'];
        if ($status->find(TRUE) && $status->id != $params['id']) {
            return civicrm_api3_create_error(ts('A membership status with this name already exists.'));
        }
    }
    $membershipStatusBAO = new CRM_Member_BAO_MembershipStatus();
    $membershipStatusBAO->id = $params['id'];
    if ($membershipStatusBAO->find(TRUE)) {
        $fields = $membershipStatusBAO->fields();
        foreach ($fields as $name => $field) {
            if (array_key_exists($name, $params)) {
                $membershipStatusBAO->{$name} = $params[$name];
            }
        }
        $membershipStatusBAO->save();
    }
    $membershipStatus = array();
    _civicrm_api3_object_to_array(clone $membershipStatusBAO, $membershipStatus);
    $membershipStatus['is_error'] = 0;
    return $membershipStatus;
}
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:42,代码来源:MembershipStatus.php

示例5: civicrm_api3_case_type_get

/**
 * Function to retrieve case types
 *
 * @param $params
 *
 * @return array $caseTypes case types keyed by id
 * @access public
 */
function civicrm_api3_case_type_get($params)
{
    civicrm_api3_verify_mandatory($params);
    $caseTypes = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
    // format case type, to fetch xml definition
    return _civicrm_api3_case_type_get_formatResult($caseTypes);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:15,代码来源:CaseType.php

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

示例7: civicrm_api3_mailing_event_queue_create

/**
 * Handle a queue event.
 *
 * @param array $params
 *   Array of property.
 *
 * @throws Exception
 * @return array
 *   api result array
 */
function civicrm_api3_mailing_event_queue_create($params)
{
    if (!array_key_exists('id', $params) && !array_key_exists('email_id', $params) && !array_key_exists('phone_id', $params)) {
        throw new API_Exception("Mandatory key missing from params array: id, email_id, or phone_id field is required");
    }
    civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_MailingJob', array('job_id', 'contact_id'), FALSE);
    return _civicrm_api3_basic_create('CRM_Mailing_Event_BAO_Queue', $params);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:18,代码来源:MailingEventQueue.php

示例8: civicrm_api3_membership_type_create

/**
 * API to Create or update a Membership Type
 *
 * @param   array  $params  an associative array of name/value property values of civicrm_membership_type
 *
 * @return array $result newly created or updated membership type property values.
 * @access public
 * {getfields MembershipType_get}
 */
function civicrm_api3_membership_type_create($params)
{
    $values = $params;
    civicrm_api3_verify_mandatory($values, 'CRM_Member_DAO_MembershipType');
    $ids['membershipType'] = CRM_Utils_Array::value('id', $values);
    $ids['memberOfContact'] = CRM_Utils_Array::value('member_of_contact_id', $values);
    $ids['contributionType'] = CRM_Utils_Array::value('contribution_type_id', $values);
    require_once 'CRM/Member/BAO/MembershipType.php';
    $membershipTypeBAO = CRM_Member_BAO_MembershipType::add($values, $ids);
    $membershipType = array();
    _civicrm_api3_object_to_array($membershipTypeBAO, $membershipType[$membershipTypeBAO->id]);
    CRM_Member_PseudoConstant::membershipType(NULL, TRUE);
    return civicrm_api3_create_success($membershipType, $params, 'membership_type', 'create', $membershipTypeBAO);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:23,代码来源:MembershipType.php

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

示例10: civicrm_api3_website_delete

/**
 * Deletes an existing Website.
 *
 * @todo convert to using Basic delete - BAO function non standard
 *
 * @param array $params
 *
 * @return array
 *   API result array
 * @throws \API_Exception
 */
function civicrm_api3_website_delete($params)
{
    //DO NOT USE THIS FUNCTION AS THE BASIS FOR A NEW API http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
    civicrm_api3_verify_mandatory($params, NULL, array('id'));
    _civicrm_api3_check_edit_permissions('CRM_Core_BAO_Website', array('id' => $params['id']));
    $websiteDAO = new CRM_Core_DAO_Website();
    $websiteDAO->id = $params['id'];
    if ($websiteDAO->find()) {
        while ($websiteDAO->fetch()) {
            $websiteDAO->delete();
            return civicrm_api3_create_success(1, $params, 'Website', 'delete');
        }
    } else {
        throw new API_Exception('Could not delete Website with id ' . $params['id']);
    }
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:Website.php

示例11: onApiPrepare

 /**
  * @param \Civi\API\Event\PrepareEvent $event
  *   API preparation event.
  *
  * @throws \API_Exception
  */
 public function onApiPrepare(\Civi\API\Event\PrepareEvent $event)
 {
     $apiRequest = $event->getApiRequest();
     if ($apiRequest['version'] > 3) {
         return;
     }
     $apiRequest['fields'] = _civicrm_api3_api_getfields($apiRequest);
     _civicrm_api3_swap_out_aliases($apiRequest, $apiRequest['fields']);
     if (strtolower($apiRequest['action']) != 'getfields') {
         if (empty($apiRequest['params']['id'])) {
             $apiRequest['params'] = array_merge($this->getDefaults($apiRequest['fields']), $apiRequest['params']);
         }
         // Note: If 'id' is set then verify_mandatory will only check 'version'.
         civicrm_api3_verify_mandatory($apiRequest['params'], NULL, $this->getRequired($apiRequest['fields']));
     }
     $event->setApiRequest($apiRequest);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:23,代码来源:APIv3SchemaAdapter.php

示例12: civicrm_api3_event_create

/**
 * Create a Event.
 *
 * @param array $params
 *   Input parameters.
 *
 * @return array
 *   API result Array.
 */
function civicrm_api3_event_create($params)
{
    // Required fields for creating an event
    if (empty($params['id']) && empty($params['is_template'])) {
        civicrm_api3_verify_mandatory($params, NULL, array('start_date', 'title', array('event_type_id', 'template_id')));
    } elseif (empty($params['id']) && !empty($params['is_template'])) {
        civicrm_api3_verify_mandatory($params, NULL, array('template_title'));
    }
    // Clone event from template
    if (!empty($params['template_id']) && empty($params['id'])) {
        $copy = CRM_Event_BAO_Event::copy($params['template_id']);
        $params['id'] = $copy->id;
        unset($params['template_id']);
    }
    _civicrm_api3_event_create_legacy_support_42($params);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Event');
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:26,代码来源:Event.php

示例13: civicrm_api3_generic_getActions

function civicrm_api3_generic_getActions($params)
{
    civicrm_api3_verify_mandatory($params, NULL, array('entity'));
    $r = civicrm_api('Entity', 'Get', array('version' => 3));
    $entity = CRM_Utils_String::munge($params['entity']);
    if (!in_array($entity, $r['values'])) {
        return civicrm_api3_create_error("Entity " . $entity . " invalid. Use api.entity.get to have the list", array('entity' => $r['values']));
    }
    _civicrm_api_loadEntity($entity);
    $functions = get_defined_functions();
    $actions = array();
    $prefix = 'civicrm_api3_' . strtolower($entity) . '_';
    $prefixGeneric = 'civicrm_api3_generic_';
    foreach ($functions['user'] as $fct) {
        if (strpos($fct, $prefix) === 0) {
            $actions[] = substr($fct, strlen($prefix));
        } elseif (strpos($fct, $prefixGeneric) === 0) {
            $actions[] = substr($fct, strlen($prefixGeneric));
        }
    }
    return civicrm_api3_create_success($actions);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:22,代码来源:Getactions.php

示例14: civicrm_api3_mailing_a_b_graph_stats

/**
 * Send graph detail for A/B tests mail.
 *
 * @param array $params
 *
 * @return array
 * @throws API_Exception
 */
function civicrm_api3_mailing_a_b_graph_stats($params)
{
    civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_MailingAB', array('id'), FALSE);
    $defaults = array('criteria' => 'Open', 'target_date' => CRM_Utils_Time::getTime('YmdHis'), 'split_count' => 6, 'split_count_select' => 1);
    $params = array_merge($defaults, $params);
    $mailingAB = civicrm_api3('MailingAB', 'getsingle', array('id' => $params['id']));
    $graphStats = array();
    $ABFormat = array('A' => 'mailing_id_a', 'B' => 'mailing_id_b');
    foreach ($ABFormat as $name => $column) {
        switch (strtolower($params['criteria'])) {
            case 'open':
                $result = CRM_Mailing_Event_BAO_Opened::getRows($mailingAB['mailing_id_a'], NULL, TRUE, 0, 1, "civicrm_mailing_event_opened.time_stamp ASC");
                $startDate = CRM_Utils_Date::processDate($result[0]['date']);
                $targetDate = CRM_Utils_Date::processDate($params['target_date']);
                $dateDuration = round(round(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
                $toDate = strtotime($startDate) + $dateDuration * $params['split_count_select'];
                $toDate = date('YmdHis', $toDate);
                $graphStats[$name] = array($params['split_count_select'] => array('count' => CRM_Mailing_Event_BAO_Opened::getTotalCount($mailingAB[$column], NULL, TRUE, $toDate), 'time' => CRM_Utils_Date::customFormat($toDate)));
                break;
            case 'total unique clicks':
                $result = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB['mailing_id_a'], NULL, TRUE, 0, 1, "civicrm_mailing_event_trackable_url_open.time_stamp ASC");
                $startDate = CRM_Utils_Date::processDate($result[0]['date']);
                $targetDate = CRM_Utils_Date::processDate($params['target_date']);
                $dateDuration = round(abs(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
                $toDate = strtotime($startDate) + $dateDuration * $params['split_count_select'];
                $toDate = date('YmdHis', $toDate);
                $graphStats[$name] = array($params['split_count_select'] => array('count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, NULL, $toDate), 'time' => CRM_Utils_Date::customFormat($toDate)));
                break;
            case 'total clicks on a particular link':
                if (empty($params['target_url'])) {
                    throw new API_Exception("Provide url to get stats result for total clicks on a particular link");
                }
                // FIXME: doesn't make sense to get url_id mailing_id_(a|b) while getting start date in mailing_id_a
                $url_id = CRM_Mailing_BAO_TrackableURL::getTrackerURLId($mailingAB[$column], $params['target_url']);
                $result = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB['mailing_id_a'], NULL, FALSE, $url_id, 0, 1, "civicrm_mailing_event_trackable_url_open.time_stamp ASC");
                $startDate = CRM_Utils_Date::processDate($result[0]['date']);
                $targetDate = CRM_Utils_Date::processDate($params['target_date']);
                $dateDuration = round(abs(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
                $toDate = strtotime($startDate) + $dateDuration * $params['split_count_select'];
                $toDate = CRM_Utils_Date::processDate($toDate);
                $graphStats[$name] = array($params['split_count_select'] => array('count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, $url_id, $toDate), 'time' => CRM_Utils_Date::customFormat($toDate)));
                break;
        }
    }
    return civicrm_api3_create_success($graphStats);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:54,代码来源:MailingAB.php

示例15: civicrm_api3_group_contact_update_status

/**
 * Update group contact status.
 *
 * @deprecated - this should be part of create but need to know we aren't missing something
 *
 * @param array $params
 *
 * @return bool
 * @throws \API_Exception
 */
function civicrm_api3_group_contact_update_status($params)
{
    civicrm_api3_verify_mandatory($params, NULL, array('contact_id', 'group_id'));
    CRM_Contact_BAO_GroupContact::addContactsToGroup(array($params['contact_id']), $params['group_id'], CRM_Utils_Array::value('method', $params, 'API'), 'Added', CRM_Utils_Array::value('tracking', $params));
    return TRUE;
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:16,代码来源:GroupContact.php


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