-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#3692: use buildOptions for activityType, activityStatus where easy. Also a relationshipType #23880
Conversation
(Standard links)
|
I made another pass. I changed some of the "get" to "search" for fetching statuses, where the original code was not including inactive items. And I fixed a few others. In all cases I tried to ensure the original filtering was preserved. Where fetching an array of activity types or statuses was only used to find the label I either left it to fetch all, or switched it to use There were a couple tricky spots where it either needed to only include case activities or exclude. For that I used For reference the original
In each case I went over the flags and ensured they would still match. The replacement |
CRM/Report/Form/Activity.php
Outdated
@@ -564,7 +564,8 @@ public function where($recordType = NULL) { | |||
empty($this->_params['activity_type_id_value']) | |||
) { | |||
if (empty($this->_params['include_case_activities_value'])) { | |||
$this->activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'label', TRUE); | |||
$componentId = CRM_Core_Component::getComponentID('CiviCase'); | |||
$this->activityTypes = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, " AND v.component_id !={$componentId} OR v.component_id IS NULL"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the test fails seem to be here. Because $componentId is null if civicase isn't enabled.
CRM_Report_Form_ActivityTest.testLongCustomFieldNames
CRM_Report_Form_ActivityTest.testTargetAddressFields
api_v3_ReportTemplateTest.testActivityDetails
api_v3_ReportTemplateTest.testActivityDetailsNullFilters
api_v3_ReportTemplateTest.testActivityDetailsContactFilter
api_v3_ReportTemplateTest.testReportTemplateSelectWhere with data set #2
api_v3_ReportTemplateTest.testReportTemplateGetRowsAllReports with data set #2
api_v3_ReportTemplateTest.testReportTemplateGetRowsAllReportsACL with data set #2
api_v3_ReportTemplateTest.testReportTemplateGetStatisticsAllReports with data set #2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'll see if my update fixes that.
@@ -2511,7 +2509,7 @@ public static function getContactActivitySelector(&$params) { | |||
} | |||
|
|||
$activity['activity_date_time'] = CRM_Utils_Date::customFormat($values['activity_date_time']); | |||
$activity['status_id'] = $activityStatus[$values['status_id']]; | |||
$activity['status_id'] = CRM_Core_Pseudoconstant::getLabel('CRM_Activity_BAO_Activity', 'status_id', $values['status_id']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't the same - it now includes disabled. I personally like that but some people won't.
@@ -143,7 +143,7 @@ public function getDefaultEntity() { | |||
public function setFields() { | |||
// Remove print document activity type | |||
$unwanted = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, "AND v.name = 'Print PDF Letter'"); | |||
$activityTypes = array_diff_key(CRM_Core_PseudoConstant::ActivityType(FALSE), $unwanted); | |||
$activityTypes = array_diff_key(CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'search'), $unwanted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't the same. Before it didn't include case activity types and now it does and also all the ones with filter=1.
@@ -25,7 +25,7 @@ public function setUp(): void { | |||
} | |||
|
|||
public function testSequence() { | |||
$actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name')); | |||
$actStatuses = array_flip(\CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the same, but for it's use here in the test is ok.
CRM/Contribute/BAO/Contribution.php
Outdated
@@ -1234,7 +1235,7 @@ public static function deleteContribution($id) { | |||
$params = [ | |||
'source_record_id' => $id, | |||
// activity type id for contribution | |||
'activity_type_id' => 6, | |||
'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Contribution'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the number 6, but ok. (grin)
Unfortunately this has gone stale & needs a rebase - I pulled out a handful of small changes into separate commits so this will lose a bit of bulk when it is rebased |
I've rebased this. Though would need to check a few more comments before it's ready. |
Can one of the admins verify this patch? |
@@ -70,7 +70,7 @@ public function preProcess() { | |||
CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails); | |||
|
|||
//get the survey activities. | |||
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@demeritcowboy these swaps are safe aren't they? This PR is stale & I think turned out to be way trickier than initial appearance but I'm thinking maybe I can salvage some of the bits that are straight foward
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of them might be.
civicrm#23880 is thoroughly stale so I'm closing it - but just thought I'd rescue a couple of changes These are in the barely maintained legacycustomsearches so of marginal risk & marginal benefit but since I looked maybe no-one else has to ever again...
civicrm#23880 is thoroughly stale so I'm closing it - but just thought I'd rescue a couple of changes These are in the barely maintained legacycustomsearches so of marginal risk & marginal benefit but since I looked maybe no-one else has to ever again...
I'm going to close this out because it's stale - it probably stalled on some of the challenges picked up in the review. I did save the last couple of changes in #28384 (just because I randomly started from the bottom) |
civicrm#23880 is thoroughly stale so I'm closing it - but just thought I'd rescue a couple of changes These are in the barely maintained legacycustomsearches so of marginal risk & marginal benefit but since I looked maybe no-one else has to ever again...
Fixes https://lab.civicrm.org/dev/core/-/issues/3692
This might be hard to test. I focused on the ones that were more straightforward and left the ones that might need more decisions.