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

Core/dev#692 : Support search arguments to Mailing Search form #15369

Closed
wants to merge 2 commits into from

Conversation

monishdeb
Copy link
Member

Overview

This PR extends the fix and make all possible mailing search filters to be used as a url arguments on forced search using 'Find Mailing' or 'Advance Search'

Before

Search arguments didn't work

After

Search arguments work

Technical Details

Brings some additional imporvement:

  1. Add 'YesNo' html type which renders boolean Yes/No field
  2. Adds HTML properties to Mailing and MailingJob columns
  3. Fixes bug in processSpecialFormValue()

@civibot
Copy link

civibot bot commented Oct 1, 2019

(Standard links)

@seamuslee001
Copy link
Contributor

Jenkins re test this please

@seamuslee001
Copy link
Contributor

@monishdeb I gave this a test and its not quite there

  1. In Advanced Search with the Advanced search Pane enabled for mailings, the mailing job status selector has gone from the top right
  2. When i did a search using the Advanced search form i got the following notices
Notice: Trying to get property '_sms' of non-object in CRM_Mailing_BAO_Query::buildSearchForm() (line 430 of /home/seamus/buildkit/build/47-test/sites/all/modules/civicrm/CRM/Mailing/BAO/Query.php).
Notice: Undefined index: status_id in CRM_Contact_BAO_Query::processSpecialFormValue() (line 6306 of /home/seamus/buildkit/build/47-test/sites/all/modules/civicrm/CRM/Contact/BAO/Query.php).
Notice: Undefined index: priority_id in CRM_Contact_BAO_Query::processSpecialFormValue() (line 6306 of /home/seamus/buildkit/build/47-test/sites/all/modules/civicrm/CRM/Contact/BAO/Query.php).
Notice: Trying to get property '_sms' of non-object in CRM_Mailing_BAO_Query::buildSearchForm() (line 430 of /home/seamus/buildkit/build/47-test/sites/all/modules/civicrm/CRM/Mailing/BAO/Query.php).
  1. I note that for advanced searches at least the mailing status field is switching from a single select to multi select which might be of an issue for smart groups

@eileenmcnaughton

@seamuslee001
Copy link
Contributor

Also there is a style issue here

@eileenmcnaughton
Copy link
Contributor

@monishdeb following @seamuslee001 initial review I have pulled out some parts of this & gotten them merged which should simplify - but also means it is stale

@monishdeb monishdeb force-pushed the core-692-1 branch 2 times, most recently from d5f95c8 to e1ea836 Compare October 29, 2019 09:56
@monishdeb
Copy link
Member Author

@eileenmcnaughton @seamuslee001 thanks for moving out parts of the codes in seperate PRs and getting those merged. I have rebased my PR and seems like its good to merge. Can you please check now?

@@ -1677,6 +1677,10 @@ public function addField($name, $props = [], $required = FALSE, $legacyDate = TR
$props['size'] = isset($props['size']) ? $props['size'] : 60;
return $this->add('password', $name, $label, $props, $required);

case 'YesNo':
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton Oct 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 we should work through this part first - the YesNo is a new thing for addField - it seems to be a specialised Radio - e.g also used for Contribution Is Test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton yeh its kind of a nicer looking radio i guess or checkbox.

seems like its used in a number of places

CRM/Contact/Form/Search/Criteria.php:    $form->addYesNo('uf_user', ts('CMS User?'), TRUE);
CRM/Contact/Form/Search/Criteria.php:    $form->addYesNo('is_deceased', ts('Deceased'), TRUE);
CRM/Pledge/BAO/Query.php:    $form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE);
CRM/Pledge/BAO/Query.php:    $form->addYesNo('pledge_acknowledge_date_is_not_null', ts('Acknowledgement sent?'), TRUE);
CRM/Contribute/BAO/Query.php:    $form->addYesNo('contribution_thankyou_date_is_not_null', ts('Thank-you sent?'), TRUE);
CRM/Contribute/BAO/Query.php:    $form->addYesNo('contribution_receipt_date_is_not_null', ts('Receipt sent?'), TRUE);
CRM/Contribute/BAO/Query.php:    $form->addYesNo('contribution_pay_later', ts('Contribution is Pay Later?'), TRUE);
CRM/Contribute/BAO/Query.php:    $form->addYesNo('contribution_recurring', ts('Contribution is Recurring?'), TRUE);
CRM/Contribute/BAO/Query.php:    $form->addYesNo('contribution_test', ts('Contribution is a Test?'), TRUE);
CRM/Contribute/BAO/Query.php:    $form->addYesNo('contribution_pcp_display_in_roll', ts('Personal Campaign Page Honor Roll?'), TRUE);
CRM/Activity/BAO/Query.php:    $form->addYesNo('activity_test', ts('Activity is a Test?'));
CRM/Member/BAO/Query.php:    $form->addYesNo('membership_is_current_member', ts('Current Member?'), TRUE);
CRM/Member/BAO/Query.php:    $form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE);
CRM/Member/BAO/Query.php:    $form->addYesNo('member_pay_later', ts('Pay Later?'), TRUE);
CRM/Member/BAO/Query.php:    $form->addYesNo('member_test', ts('Membership is a Test?'), TRUE);
CRM/Member/BAO/Query.php:    $form->addYesNo('member_is_override', ts('Membership Status Is Overriden?'), TRUE);
CRM/Event/Form/ManageEvent/Registration.php:      $form->addYesNo('is_confirm_enabled', ts('Use a confirmation screen?'), NULL, NULL, ['onclick' => "return showHideByValue('is_confirm_enabled','','confirm_screen_settings','block','radio',false);"]);
CRM/Event/Form/ManageEvent/Registration.php:    $form->addYesNo('is_email_confirm', ts('Send Confirmation Email?'), NULL, NULL, ['onclick' => "return showHideByValue('is_email_confirm','','confirmEmail','block','radio',false);"]);
CRM/Event/Form/ManageEvent/Fee.php:    $this->addYesNo('is_monetary',
CRM/Event/BAO/Query.php:    $form->addYesNo('participant_test', ts('Participant is a Test?'), TRUE);
CRM/Event/BAO/Query.php:    $form->addYesNo('participant_is_pay_later', ts('Participant is Pay Later?'), TRUE);
CRM/Admin/Form/SettingTrait.php:        elseif ($add === 'addYesNo' && ($props['type'] === 'Boolean')) {
CRM/Admin/Form/Preferences.php:            case 'YesNo':
CRM/Admin/Form/Preferences.php:          case 'YesNo':
CRM/Admin/Form/Setting/Smtp.php:    $this->addYesNo('smtpAuth', ts('Authentication?'), CRM_Utils_Array::value('smtpAuth', $props));
CRM/Admin/Form/Setting/Url.php:    $this->addYesNo('enableSSL', ts('Force Secure URLs (SSL)'));
CRM/Admin/Form/Setting/Url.php:    $this->addYesNo('verifySSL', ts('Verify SSL Certs'));
CRM/Core/Form.php:  public function addYesNo($id, $title, $allowClear = FALSE, $required = NULL, $attributes = []) {
CRM/Case/Form/Activity/ChangeCaseType.php:    $form->addYesNo('is_reset_timeline', ts('Reset Case Timeline?'), NULL, TRUE);
CRM/Mailing/Form/Component.php:    $this->addYesNo('is_default', ts('Default?'));
CRM/Mailing/Form/Component.php:    $this->addYesNo('is_active', ts('Enabled?'));
CRM/Mailing/Form/Search.php:    $this->addYesNo('is_archived', ts('Mailing is Archived'), TRUE);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton @seamuslee001 I think adding this option for addField extend the ability for boolean fields of the respective entity. Should I move this part in a separate PR ?

@@ -138,7 +138,7 @@ public static function select(&$query) {
* rather than a static function.
*/
public static function getSearchFieldMetadata() {
$fields = ['mailing_job_start_date'];
$fields = ['name', 'mailing_job_start_date', 'status', 'is_archived'];
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton Oct 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to give 'name' a unique name in the schema if it doesn't have one yet (easiest as a separate PR)

eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Oct 29, 2019
This is in support of civicrm#15369

Where the names in the search do not match the 'real names' we have 2 techniques

1) where adding a unique name to the schema gives a match we do that - here that is
the case for mailing_name
2) otherwise we ensure the schema has a unique name if appropriate &
rename the field in the upgrade scriptt

In this case when we look at CRM_Mailing_BAO_Query we don't see mailing_name
as present (only mailing_id which should be an entity reference field). However it
is used in the confusingly-not-related Mailing search so lets rename this
one at the same time.
}
}
if (in_array($element, array_keys($changeNames))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb we no longer handle renaming fields in the code -in this case we can probably avoid it altogether by adding uniquenames - #15652

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton should we still allow this code and throw a deprecated notice if any of such case arise where unique names were not present?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For current purposes we can just leave it unchanged can't we?

$query->_qill[$grouping][] = "Mailing Namename $op \"$value\"";
$name = 'name';
$query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_mailing.$name", $op, $value, 'String');
list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Mailing_DAO_Mailing', $name, $value, $op);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't made it generic to the other forms yet - but we started making the qill handling generic - would need some moving around

bf99326

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note that we have a getFields() function on Contribution_BAO_Query $fields = self::getFields(); & are working towards using that metadata for the various bits of value

@@ -26,8 +26,8 @@
<div class="crm-block crm-form-block crm-search-form-block">
<table class="form-layout">
<tr>
<td>{$form.mailing_name.label} {help id="id-mailing_name"}<br />
{$form.mailing_name.html|crmAddClass:big}
<td>{$form.name.label} {help id="id-mailing_name"}<br />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 gave this MOP - #15652 - won't need this when that is done

@monishdeb
Copy link
Member Author

@eileenmcnaughton I have updated this PR and moved additional changes in this PR #16478 Please have a look.

@jaapjansma
Copy link
Contributor

test this please

@jaapjansma
Copy link
Contributor

Betty and I are reviewing PRs and we came across this one. We dont know how to reproduce the problem which this PR fixes. We have asked a step by step instruction in the issue: https://lab.civicrm.org/dev/core/issues/692#note_33154

@jaapjansma
Copy link
Contributor

Betty and I are reviewing PR's and we came across this one and we don't know how to test this and we haven't had an answer. So we will close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants