Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-16036 replace basic_get innids with sql builder #6488

Merged
merged 31 commits into from Aug 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1b68d37
CRM-16036 - unit test: search event on custom field.
johanv Mar 2, 2015
4eea368
Created a custom civicrm_api3_get_using_query_object.
johanv Mar 3, 2015
efdf200
Filter on custom fields.
johanv Mar 3, 2015
4b217ae
Some documentation, and better handling of fields to select.
johanv Mar 4, 2015
836231f
Return fields as requested by the return option.
johanv Mar 4, 2015
fb214de
Some code refactoring.
johanv Mar 5, 2015
683e39e
Changed key and values of the $select_fields array.
johanv Mar 5, 2015
a50d9fb
Return all fields if no return option is given.
johanv Mar 5, 2015
5d5c3c2
Populate $select_fields more efficiently.
johanv Mar 5, 2015
bd744b8
Support other filters than '='.
johanv Mar 5, 2015
f4b04d2
Sort and limit options.
johanv Mar 5, 2015
e13654d
Free the query DAO.
johanv Mar 6, 2015
84c546a
Fixed whitespace issues.
johanv Mar 6, 2015
7cbc050
Build query using CRM_Utils_SQL_Select.
johanv Mar 9, 2015
22e9710
A unit test for searching memberships on custom field values.
johanv Mar 10, 2015
6a271fe
CRM-16036 - A hack around the issue.
johanv Mar 10, 2015
2b61688
CRM-16036 - Pleasing the php 5.3 gods :-)
johanv Mar 10, 2015
faee609
Using CRM_Utils_Array::first.
johanv Mar 11, 2015
d9bd98e
CRM-16036 - Contact reference custom values are returned incorrectly.
johanv Mar 19, 2015
bee644e
CRM-16036 - Now contact references are returned the right way.
johanv Mar 19, 2015
1c9cf44
CRM-16036 - Fix for chaining.
johanv Aug 3, 2015
7d49d7b
Fixing style issues, as usual.
johanv Aug 3, 2015
3dc81e0
CRM-16036 - extra unit test.
johanv Aug 3, 2015
722cc9f
Whitespace fixes.
johanv Aug 6, 2015
0f3699b
CRM-16036 Eileen in prog
eileenmcnaughton Aug 6, 2015
2b28667
upport tested format return=custom
eileenmcnaughton Aug 9, 2015
b766580
CRM-16036 stop overwriting of where clauses
eileenmcnaughton Aug 10, 2015
0298287
CRM-16036 fixes to make all tess pass with new internalsx
eileenmcnaughton Aug 10, 2015
04dd49e
CRM-16036 - remove getfields from mailing test as it is producing inc…
eileenmcnaughton Aug 12, 2015
877f9c2
remove auto-grant test - this was a prototype for the single-value-al…
eileenmcnaughton Aug 12, 2015
4ac3496
CRM-16036 fix for tests
eileenmcnaughton Aug 13, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 20 additions & 1 deletion api/v3/Activity.php
Expand Up @@ -242,7 +242,25 @@ function civicrm_api3_activity_get($params) {
}
}
else {
$activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity');
$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 = ' . $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']) {
Expand Down Expand Up @@ -280,6 +298,7 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) {
$returns[$returnkey] = $v;
}
}

$returns['source_contact_id'] = 1;
foreach ($returns as $n => $v) {
switch ($n) {
Expand Down
1 change: 1 addition & 0 deletions api/v3/Dashboard.php
Expand Up @@ -72,6 +72,7 @@ function _civicrm_api3_dashboard_create_spec(&$params) {
* @return array
*/
function civicrm_api3_dashboard_get($params) {
// NEVER COPY THIS. No idea why a newish api would not use basic_get.
$bao = new CRM_Core_BAO_Dashboard();
_civicrm_api3_dao_set_filter($bao, $params, TRUE);
$dashlets = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'Dashboard');
Expand Down
29 changes: 11 additions & 18 deletions api/v3/Event.php
Expand Up @@ -125,34 +125,27 @@ function civicrm_api3_event_get($params) {
unset($params['return.max_results']);
}

$eventDAO = new CRM_Event_BAO_Event();
_civicrm_api3_dao_set_filter($eventDAO, $params, TRUE);

$extraSql = array();
if (!empty($params['isCurrent'])) {
$eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
$extraSql['where'] = array('civicrm_event' => '(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();
$events = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Event', $extraSql, TRUE);
$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 ($options['is_count']) {
return civicrm_api3_create_success($events, $params, 'Event', 'get');
}
foreach ($events as $id => $event) {
if (!empty($params['return.is_full'])) {
_civicrm_api3_event_getisfull($event, $eventDAO->id);
_civicrm_api3_event_getisfull($events, $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);
_civicrm_api3_event_get_legacy_support_42($events, $id);
if (!empty($options['return'])) {
$event[$eventDAO->id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventDAO->id);
$events[$id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id);
}
}

return civicrm_api3_create_success($event, $params, 'Event', 'get', $eventDAO);
return civicrm_api3_create_success($events, $params, 'Event', 'get');
}

/**
Expand Down
27 changes: 0 additions & 27 deletions api/v3/MailingGroup.php
Expand Up @@ -130,30 +130,3 @@ function civicrm_api3_mailing_group_get($params) {
function civicrm_api3_mailing_group_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}

/**
* Get metadata for mailing group functions.
*
* @param array $params
*
* @return array
*/
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, $params, 'MailingGroup', 'getfields');
}
1 change: 1 addition & 0 deletions api/v3/WordReplacement.php
Expand Up @@ -43,6 +43,7 @@
* @throws \API_Exception
*/
function civicrm_api3_word_replacement_get($params) {
// NEVER COPY THIS. No idea why a newish api would not use basic_get.
$bao = new CRM_Core_BAO_WordReplacement();
_civicrm_api3_dao_set_filter($bao, $params, TRUE);
$wordReplacements = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'WordReplacement');
Expand Down