diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index 1edf516e6f88..e652726a608d 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -56,7 +56,7 @@ public static function getCaseGlobalRelationships() { // get the total row count CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, NULL, FALSE, TRUE, NULL, NULL); // limit the rows - $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, $params['sortBy'], $showLinks = TRUE, FALSE, $params['offset'], $params['rp']); + $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, $params['sortBy'] ?? NULL, $showLinks = TRUE, FALSE, $params['offset'], $params['rp']); $relationships = []; // after sort we can update username fields to be a url @@ -101,11 +101,14 @@ public static function getCaseClientRelationships() { } // sort clientRelationships array using jquery call params - foreach ($clientRelationships as $key => $row) { - $sortArray[$key] = $row[$params['_raw_values']['sort'][0]]; + $sortArray = []; + if (!empty($params['_raw_values']['sort'])) { + foreach ($clientRelationships as $key => $row) { + $sortArray[$key] = $row[$params['_raw_values']['sort'][0]]; + } + $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]); + array_multisort($sortArray, constant($sort_type), $clientRelationships); } - $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]); - array_multisort($sortArray, constant($sort_type), $clientRelationships); $relationships = []; // after sort we can update username fields to be a url @@ -181,11 +184,14 @@ public static function getCaseRoles() { } // sort clientRelationships array using jquery call params - foreach ($caseRelationships as $key => $row) { - $sortArray[$key] = $row[$params['_raw_values']['sort'][0]]; + $sortArray = []; + if (!empty($params['_raw_values']['sort'])) { + foreach ($caseRelationships as $key => $row) { + $sortArray[$key] = $row[$params['_raw_values']['sort'][0]]; + } + $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]); + array_multisort($sortArray, constant($sort_type), $caseRelationships); } - $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]); - array_multisort($sortArray, constant($sort_type), $caseRelationships); $relationships = []; diff --git a/CRM/Case/Page/AJAX.php b/CRM/Case/Page/AJAX.php index feb48af2a0cb..abf2858d8778 100644 --- a/CRM/Case/Page/AJAX.php +++ b/CRM/Case/Page/AJAX.php @@ -182,7 +182,7 @@ public static function getCases() { $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters); - $allCases = (bool) $params['all']; + $allCases = !empty($params['all']); $cases = CRM_Case_BAO_Case::getCases($allCases, $params);