-
-
Notifications
You must be signed in to change notification settings - Fork 824
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-21720 Cleanup search classes to use enumerators instead of hardcoded values #11600
CRM-21720 Cleanup search classes to use enumerators instead of hardcoded values #11600
Conversation
CRM/Contact/Form/Search.php
Outdated
@@ -326,25 +337,15 @@ public static function getModeSelect() { | |||
*/ | |||
public function buildTaskList() { | |||
if ($this->_context !== 'amtg') { |
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.
If you figure out what amtg stands for & when it arises please comment the code. My best guess at the moment is that it is 'add member to group'
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.
@eileenmcnaughton i think your right as per
civicrm-core/CRM/Contact/Form/Search.php
Line 180 in a4aae59
'amtg' => 'Add members to group', |
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.
Yes, the search classes have a few of these strings - see https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/Form/Search.php#L176
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.
Anyway, I've inserted a comment just above that line
|
||
if (isset($this->_ssID)) { | ||
if ($permission == CRM_Core_Permission::EDIT) { | ||
$tasks = $tasks + CRM_Contact_Task::optionalTaskTitle(); |
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.
there are still 2 places where optionalTaskTitle() is referred to that can go
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 think those are removed via #11764
@@ -464,7 +452,7 @@ public function buildQuickForm() { | |||
'class' => 'crm-form-submit', | |||
) | |||
); | |||
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_CONTACTS); | |||
$this->add('hidden', 'task', CRM_Contact_Task::GROUP_ADD); |
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'm still reading but GROUP_ADD doesn't exist on my version that I can see
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.
It exists once #11240 is merged
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.
It is now in CRM/Core/Task.php which is part of core.
On contact search I just found the tasks missing - Also note that they are not alphabetically sorted - I noticed an 'asort' was removed Some thoughts about things to verify before merge
|
if (isset($formValues['group_type']) && | ||
is_array($formValues['group_type']) | ||
) { | ||
if (isset($formValues['group_type']) && is_array($formValues['group_type']) && count($formValues['group_type'])) { |
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 think this is an unrelated change. It makes sense though from what I can see - if there is no group_type but it is set & is an array save as 'no group type'
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.
Yes, it fixes a PHP notice as the code was not checking for an empty array, but looking at it I believe it intended to as it doesn't make sense otherwise. It's pulling a group type from the form into a variable, if there isn't one it can't do that so sets an empty string in the else below.
@@ -103,15 +103,10 @@ public function taskName($controller, $formName = 'Search') { | |||
} | |||
$this->_controller->set('task', $value); | |||
|
|||
if ($value) { |
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.
Any idea how to get to this line without $value to test?
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 was causing a bug in some situations, as it was falling back to the contact task and would try and return the default task for contact tasks no matter what context we were in (eg. in member context). I think you could trigger it by editing a smart search and changing the "View results as" to be something other than contacts. But it should not be possible to get there with no value for $value unless you are doing something wierd and it doesn't make sense (in my opinion) to fall back to the contact task handler, as it defines a different set of tasks which are potentially not applicable to the current context.
By removing the check for $value we are always calling the relevant getTask() handler for the context.
@eileenmcnaughton What I failed to mention was that this should be merged AFTER #11240 as it relies on changes in that PR (eg. GROUP_ADD is defined in CRM_Core_Task). Sorry! |
fb13128
to
9d1ed2c
Compare
9d1ed2c
to
eda34f9
Compare
Per comments on #11764 this works in conjunction with that so merging both |
Overview
Follow on from CRM-21391 to tidy up code for search classes (specifically in relation to search tasks)
Ref #11240