Skip to content

Commit

Permalink
dev/core#934 wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed May 3, 2019
1 parent 0938c0f commit ac7df61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Civi/API/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ protected function buildOrderBy() {
}
}
else {
throw new \API_Exception("Unknown field specified for sort. Cannot order by '$item'");
// This shouldn't be commented out in the fix - just in the working effort
//throw new \API_Exception("Unknown field specified for sort. Cannot order by '$item'");
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions api/v3/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ function _civicrm_api3_activity_get_spec(&$params) {
function civicrm_api3_activity_get($params) {
$options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
$sql = CRM_Utils_SQL_Select::fragment();
if (in_array(['source_contact_name', 'source_contact_name desc', 'source_contact_name asc'], $options['return'])) {
$sql->join(
'source_contact',
'!joinType civicrm_activity_contact !alias ON (!alias.activity_id = a.id AND record_type_id = ' . CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source') . ')',
['!alias' => 'source_contact', 'joinType' => 'left ']
);
}

_civicrm_api3_activity_get_extraFilters($params, $sql);

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/BAO/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public function testGetActivitiesforContactSummary() {
'activity_type_id' => NULL,
'offset' => 0,
'rowCount' => 0,
'sort' => NULL,
'sort' => 'source_contact_name desc',
);

//since we are loading activities from dataset, we know total number of activities for this contact
Expand Down

0 comments on commit ac7df61

Please sign in to comment.