本文整理汇总了PHP中_civicrm_api3_get_options_from_params函数的典型用法代码示例。如果您正苦于以下问题:PHP _civicrm_api3_get_options_from_params函数的具体用法?PHP _civicrm_api3_get_options_from_params怎么用?PHP _civicrm_api3_get_options_from_params使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_civicrm_api3_get_options_from_params函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _civicrm_api3_mailing_contact_getresults
/**
* This is a wrapper for the functions that return the results from the 'quasi-entity' mailing contact.
*
* @param array $params
* @param bool $count
*
* @throws Exception
*/
function _civicrm_api3_mailing_contact_getresults($params, $count)
{
if (empty($params['type'])) {
//ie. because the api is an anomaly & passing in id is not valid
throw new Exception('This api call does not accept api as a parameter');
}
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'contribution', 'get');
$fnName = '_civicrm_api3_mailing_contact_get_' . strtolower($params['type']);
return $fnName($params['contact_id'], $options['offset'], $options['limit'], $options['sort'], $count);
}
示例2: civicrm_api3_group_get
/**
* Returns array of groups matching a set of one or more Group properties.
*
* @param array $params
* Array of properties. If empty, all records will be returned.
*
* @return array
* Array of matching groups
*/
function civicrm_api3_group_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get');
if (empty($options['return']) || !in_array('member_count', $options['return'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group');
}
$groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group');
foreach ($groups as $id => $group) {
$groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
}
return civicrm_api3_create_success($groups, $params, 'Group', 'get');
}
示例3: civicrm_api3_group_get
/**
* Returns array of groups matching a set of one or more Group properties.
*
* @param array $params
* Array of properties. If empty, all records will be returned.
*
* @return array
* Array of matching groups
*/
function civicrm_api3_group_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get');
if ((empty($options['return']) || !in_array('member_count', $options['return'])) && empty($params['check_permissions'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group');
}
$groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group');
foreach ($groups as $id => $group) {
if (!empty($params['check_permissions']) && !CRM_Contact_BAO_Group::checkPermission($group['id'])) {
unset($groups[$id]);
} elseif (!empty($options['return']) && in_array('member_count', $options['return'])) {
$groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
}
}
return civicrm_api3_create_success($groups, $params, 'Group', 'get');
}
示例4: civicrm_api3_membership_get
/**
* Get contact membership record.
*
* This api will return the membership records for the contacts
* having membership based on the relationship with the direct members.
*
* @param Array $params key/value pairs for contact_id and some
* options affecting the desired results; has legacy support
* for just passing the contact_id itself as the argument
*
* @return Array of all found membership property values.
* @access public
* @todo needs some love - basically only a get for a given contact right now
* {@getfields membership_get}
*/
function civicrm_api3_membership_get($params)
{
$activeOnly = $membershipTypeId = $membershipType = NULL;
$contactID = CRM_Utils_Array::value('contact_id', $params);
if (!empty($params['filters']) && is_array($params['filters'])) {
$activeOnly = CRM_Utils_Array::value('is_current', $params['filters'], FALSE);
}
$activeOnly = CRM_Utils_Array::value('active_only', $params, $activeOnly);
if (!empty($params['contact_id']) && !is_array($params['contact_id'])) {
$membershipValues = _civicrm_api3_membership_get_customv2behaviour($params, $membershipTypeId, $activeOnly);
} else {
//legacy behaviour only ever worked when contact_id passed in - use standard api function otherwise
$membershipValues = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE);
}
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'membership', 'get');
$return = $options['return'];
if (empty($membershipValues) || !empty($return) && !array_key_exists('related_contact_id', $return) && !array_key_exists('relationship_name', $return)) {
return civicrm_api3_create_success($membershipValues, $params, 'membership', 'get');
}
$members = _civicrm_api3_membership_relationsship_get_customv2behaviour($params, $membershipValues, $contactID);
return civicrm_api3_create_success($members, $params, 'membership', 'get');
}
示例5: civicrm_api3_activity_get
/**
* Gets a CiviCRM activity according to parameters.
*
* @param array $params
* Array per getfields documentation.
*
* @return array API result array
* API result array
*
* @throws \API_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
function civicrm_api3_activity_get($params)
{
if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('view all activities')) {
// In absence of view all activities permission it's possible to see a specific activity by ACL.
// Note still allowing view all activities to override ACLs is based on the 'don't change too much
// if you are not sure principle' and it could be argued that the ACLs should always be applied.
if (empty($params['id']) || !empty($params['contact_id'])) {
// We fall back to the original blunt permissions if we don't have an id to check or we are about
// to go to the weird place that the legacy 'contact_id' parameter takes us to.
throw new \Civi\API\Exception\UnauthorizedException("Cannot access activities. Required permission: 'view all activities''");
}
if (!CRM_Activity_BAO_Activity::checkPermission($params['id'], CRM_Core_Action::VIEW)) {
throw new \Civi\API\Exception\UnauthorizedException('You do not have permission to view this activity');
}
}
if (!empty($params['contact_id'])) {
$activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
// BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write
// happens it won't get missed.
foreach ($activities as $key => $activityArray) {
$activities[$key]['id'] = $key;
}
} else {
$sql = CRM_Utils_SQL_Select::fragment();
$options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
$options = $options['values'];
$activityContactOptions = array('target_contact_id' => array_search('Activity Targets', $options), 'source_contact_id' => array_search('Activity Source', $options), 'assignee_contact_id' => array_search('Activity Assignees', $options));
foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
if (!empty($params[$activityContactName])) {
// If the intent is to have multiple joins -- one for each relation -- then you would
// need different table aliases. Consider replacing 'ac' and passing in a '!alias' param,
// with a different value for each relation.
$sql->join('activity_' . $activityContactName, 'LEFT JOIN civicrm_activity_contact ac ON a.id = ac.activity_id AND ac.record_type_id = #typeId', array('typeId' => $activityContactValue));
$sql->where('ac.contact_id IN (#cid)', array('cid' => $params[$activityContactName]));
}
}
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $sql);
}
$options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
if ($options['is_count']) {
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
$activities = _civicrm_api3_activity_get_formatResult($params, $activities);
//legacy custom data get - so previous formatted response is still returned too
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
示例6: civicrm_api3_pledge_get
/**
* Retrieve a set of pledges, given a set of input params
*
* @param array $params (reference ) input parameters. Use interogate for possible fields
*
* @return array (reference ) array of pledges, if error an array with an error id and error message
* {@getfields pledge_get}
* @example PledgeGet.php
* @access public
*/
function civicrm_api3_pledge_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'pledge', 'get');
if (empty($options['return'])) {
$options['return'] = CRM_Pledge_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_PLEDGE);
} else {
$options['return']['pledge_id'] = 1;
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($options['input_params']);
$query = new CRM_Contact_BAO_Query($newParams, $options['return'], NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_PLEDGE);
list($select, $from, $where) = $query->query();
$sql = "{$select} {$from} {$where}";
if (!empty($options['sort'])) {
$sql .= " ORDER BY " . $options['sort'];
}
$sql .= " LIMIT " . $options['offset'] . " , " . $options['limit'];
$dao = CRM_Core_DAO::executeQuery($sql);
$pledge = array();
while ($dao->fetch()) {
$pledge[$dao->pledge_id] = $query->store($dao);
}
return civicrm_api3_create_success($pledge, $params, 'pledge', 'get', $dao);
}
示例7: __construct
/**
* @param string $bao_name
* Name of BAO
* @param array $params
* As passed into api get function.
* @param bool $isFillUniqueFields
* Do we need to ensure unique fields continue to be populated for this api? (backward compatibility).
*/
public function __construct($bao_name, $params, $isFillUniqueFields)
{
$this->bao = new $bao_name();
$this->entity = _civicrm_api_get_entity_name_from_dao($this->bao);
$this->params = $params;
$this->isFillUniqueFields = $isFillUniqueFields;
$this->checkPermissions = \CRM_Utils_Array::value('check_permissions', $this->params, FALSE);
$this->options = _civicrm_api3_get_options_from_params($this->params);
$this->entityFieldNames = _civicrm_api3_field_names(_civicrm_api3_build_fields_array($this->bao));
// Call this function directly instead of using the api wrapper to force unique field names off
require_once 'api/v3/Generic.php';
$apiSpec = \civicrm_api3_generic_getfields(array('entity' => $this->entity, 'version' => 3, 'params' => array('action' => 'get')), FALSE);
$this->apiFieldSpec = $apiSpec['values'];
$this->query = \CRM_Utils_SQL_Select::from($this->bao->tableName() . " a");
}
示例8: __construct
/**
* @param string $baoName
* Name of BAO
* @param array $params
* As passed into api get function.
* @param bool $isFillUniqueFields
* Do we need to ensure unique fields continue to be populated for this api? (backward compatibility).
*/
public function __construct($baoName, $params, $isFillUniqueFields)
{
$bao = new $baoName();
$this->entity = _civicrm_api_get_entity_name_from_dao($bao);
$this->params = $params;
$this->isFillUniqueFields = $isFillUniqueFields;
$this->checkPermissions = \CRM_Utils_Array::value('check_permissions', $this->params, FALSE);
$this->options = _civicrm_api3_get_options_from_params($this->params);
$this->entityFieldNames = _civicrm_api3_field_names(_civicrm_api3_build_fields_array($bao));
// Call this function directly instead of using the api wrapper to force unique field names off
require_once 'api/v3/Generic.php';
$apiSpec = \civicrm_api3_generic_getfields(array('entity' => $this->entity, 'version' => 3, 'params' => array('action' => 'get')), FALSE);
$this->apiFieldSpec = $apiSpec['values'];
$this->query = \CRM_Utils_SQL_Select::from($bao->tableName() . ' ' . self::MAIN_TABLE_ALIAS);
$bao->free();
// Add ACLs first to avoid redundant subclauses
$this->query->where($this->getAclClause(self::MAIN_TABLE_ALIAS, $baoName));
}
示例9: civicrm_api3_contribution_get
/**
* Retrieve a set of contributions, given a set of input params
*
* @param array $params (reference ) input parameters
* @param array $returnProperties Which properties should be included in the
* returned Contribution object. If NULL, the default
* set of properties will be included.
*
* @return array (reference ) array of contributions, if error an array with an error id and error message
* @static void
* @access public
* {@getfields Contribution_get}
* @example ContributionGet.php
*/
function civicrm_api3_contribution_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'contribution', 'get');
$sort = CRM_Utils_Array::value('sort', $options, NULL);
$offset = CRM_Utils_Array::value('offset', $options);
$rowCount = CRM_Utils_Array::value('limit', $options);
$smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
$inputParams = CRM_Utils_Array::value('input_params', $options, array());
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
if (empty($returnProperties)) {
$returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
$query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTRIBUTE);
list($select, $from, $where, $having) = $query->query();
$sql = "{$select} {$from} {$where} {$having}";
if (!empty($sort)) {
$sql .= " ORDER BY {$sort} ";
}
$sql .= " LIMIT {$offset}, {$rowCount} ";
$dao = CRM_Core_DAO::executeQuery($sql);
$contribution = array();
while ($dao->fetch()) {
//CRM-8662
$contribution_details = $query->store($dao);
$softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE);
$contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution);
if (isset($contribution[$dao->contribution_id]['financial_type_id'])) {
$contribution[$dao->contribution_id]['financial_type_id'] = $contribution[$dao->contribution_id]['financial_type_id'];
}
// format soft credit for backward compatibility
_civicrm_api3_format_soft_credit($contribution[$dao->contribution_id]);
}
return civicrm_api3_create_success($contribution, $params, 'contribution', 'get', $dao);
}
示例10: civicrm_api3_participant_get
/**
* Retrieve a specific participant, given a set of input params
* If more than one matching participant exists, return an error, unless
* the client has requested to return the first found contact
*
* @param array $params (reference ) input parameters
*
* @return array (reference ) array of properties, if error an array with an error id and error message
* {@getfields participant_get}
* @access public
*/
function civicrm_api3_participant_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'participant', 'get');
$sort = CRM_Utils_Array::value('sort', $options, NULL);
$offset = CRM_Utils_Array::value('offset', $options);
$rowCount = CRM_Utils_Array::value('limit', $options);
$smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
$inputParams = CRM_Utils_Array::value('input_params', $options, array());
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
if (empty($returnProperties)) {
$returnProperties = CRM_Event_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_EVENT);
}
$newParams = CRM_Contact_BAO_Query::convertFormValues($inputParams);
$query = new CRM_Contact_BAO_Query($newParams, $returnProperties, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT);
list($select, $from, $where, $having) = $query->query();
$sql = "{$select} {$from} {$where} {$having}";
if (!empty($sort)) {
$sql .= " ORDER BY {$sort} ";
}
$sql .= " LIMIT {$offset}, {$rowCount} ";
$dao = CRM_Core_DAO::executeQuery($sql);
$participant = array();
while ($dao->fetch()) {
$participant[$dao->participant_id] = $query->store($dao);
_civicrm_api3_custom_data_get($participant[$dao->participant_id], 'Participant', $dao->participant_id, NULL);
}
return civicrm_api3_create_success($participant, $params, 'participant', 'get', $dao);
}
示例11: civicrm_api3_activity_get
/**
* Gets a CiviCRM activity according to parameters.
*
* @param array $params
* Array per getfields documentation.
*
* @return array
* API result array
*/
function civicrm_api3_activity_get($params)
{
if (!empty($params['contact_id'])) {
$activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
// BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write
// happens it won't get missed.
foreach ($activities as $key => $activityArray) {
$activities[$key]['id'] = $key;
}
} else {
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity');
}
$options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
if ($options['is_count']) {
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
$activities = _civicrm_api3_activity_get_formatResult($params, $activities);
//legacy custom data get - so previous formatted response is still returned too
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
示例12: civicrm_api3_event_get
/**
* Get Event record.
*
*
* @param array $params an associative array of name/value property values of civicrm_event
* {@getfields event_get}
*
* @return Array of all found event property values.
* @access public
*
*/
function civicrm_api3_event_get($params)
{
//legacy support for $params['return.sort']
if (!empty($params['return.sort'])) {
$params['options']['sort'] = $params['return.sort'];
unset($params['return.sort']);
}
//legacy support for $params['return.offset']
if (!empty($params['return.offset'])) {
$params['options']['offset'] = $params['return.offset'];
unset($params['return.offset']);
}
//legacy support for $params['return.max_results']
if (!empty($params['return.max_results'])) {
$params['options']['limit'] = $params['return.max_results'];
unset($params['return.max_results']);
}
$eventDAO = new CRM_Event_BAO_Event();
_civicrm_api3_dao_set_filter($eventDAO, $params, TRUE, 'Event');
if (!empty($params['is_template'])) {
$eventDAO->whereAdd('( is_template = 1 )');
} elseif (empty($eventDAO->id)) {
$eventDAO->whereAdd('( is_template IS NULL ) OR ( is_template = 0 )');
}
if (!empty($params['isCurrent'])) {
$eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
}
// @todo should replace all this with _civicrm_api3_dao_to_array($bao, $params, FALSE, $entity) - but we still have
// the return.is_full to deal with.
// NB the std dao_to_array function should only return custom if required.
$event = array();
$options = _civicrm_api3_get_options_from_params($params);
$eventDAO->find();
while ($eventDAO->fetch()) {
$event[$eventDAO->id] = array();
CRM_Core_DAO::storeValues($eventDAO, $event[$eventDAO->id]);
if (!empty($params['return.is_full'])) {
_civicrm_api3_event_getisfull($event, $eventDAO->id);
}
_civicrm_api3_event_get_legacy_support_42($event, $eventDAO->id);
_civicrm_api3_custom_data_get($event[$eventDAO->id], 'Event', $eventDAO->id, NULL, $eventDAO->event_type_id);
if (!empty($options['return'])) {
$event[$eventDAO->id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventDAO->id);
}
}
//end of the loop
return civicrm_api3_create_success($event, $params, 'event', 'get', $eventDAO);
}
示例13: civicrm_api3_activity_get
/**
* Gets a CiviCRM activity according to parameters.
*
* @param array $params
* Array per getfields documentation.
*
* @return array
* API result array
*/
function civicrm_api3_activity_get($params)
{
if (!empty($params['contact_id'])) {
$activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
// BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write
// happens it won't get missed.
foreach ($activities as $key => $activityArray) {
$activities[$key]['id'] = $key;
}
} else {
$extraSql = array();
$options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
$options = $options['values'];
$activityContactOptions = array('target_contact_id' => array_search('Activity Targets', $options), 'source_contact_id' => array_search('Activity Source', $options), 'assignee_contact_id' => array_search('Activity Assignees', $options));
foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
if (!empty($params[$activityContactName])) {
$extraSql['join'][] = array('activity_' . $activityContactName => '
LEFT JOIN civicrm_activity_contact ac ON a.id = ac.activity_id AND ac.record_type_id = ' . (int) $activityContactValue);
// Note that if we later need to change the int to an array we would need sql escaping.
$extraSql['where'] = array('activity_' . $activityContactName => 'ac.contact_id = ' . (int) $params[$activityContactName]);
}
}
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $extraSql);
}
$options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
if ($options['is_count']) {
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
$activities = _civicrm_api3_activity_get_formatResult($params, $activities);
//legacy custom data get - so previous formatted response is still returned too
return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
}
示例14: civicrm_api3_group_get
/**
* Returns array of groups matching a set of one or more group properties
*
* @param array $params (referance) Array of one or more valid
* property_name=>value pairs. If $params is set
* as null, all groups will be returned
*
* @return array Array of matching groups
* @example GroupGet.php
* {@getfields group_get}
* @access public
*/
function civicrm_api3_group_get($params)
{
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'group', 'get');
$sort = CRM_Utils_Array::value('sort', $options, NULL);
$offset = CRM_Utils_Array::value('offset', $options);
$rowCount = CRM_Utils_Array::value('limit', $options);
$returnProperties = CRM_Utils_Array::value('return', $options, NULL);
$inputParams = CRM_Utils_Array::value('input_params', $options, array());
if (is_array($returnProperties) && !empty($returnProperties)) {
// group function takes $returnProperties in non standard format & doesn't add id
unset($returnProperties['group_id']);
$returnProperties['id'] = 1;
$returnProperties = array_keys($returnProperties);
}
if (!empty($inputParams['group_id'])) {
$inputParams['id'] = $inputParams['group_id'];
}
$groupObjects = CRM_Contact_BAO_Group::getGroups($inputParams, $returnProperties, $sort, $offset, $rowCount);
if (empty($groupObjects)) {
return civicrm_api3_create_success(FALSE);
}
$groups = array();
foreach ($groupObjects as $group) {
_civicrm_api3_object_to_array($group, $groups[$group->id]);
_civicrm_api3_custom_data_get($groups[$group->id], 'Group', $group->id);
}
return civicrm_api3_create_success($groups, $params, 'group', 'create');
}
示例15: _civicrm_api3_apply_options_to_dao
function _civicrm_api3_apply_options_to_dao(&$params, &$dao, $entity)
{
$options = _civicrm_api3_get_options_from_params($params, false, $entity);
$dao->limit((int) $options['offset'], (int) $options['limit']);
if (!empty($options['sort'])) {
$dao->orderBy($options['sort']);
}
}