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 for some additional url params #14921

Merged
merged 1 commit into from
Aug 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Search/Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function normalizeDefaultValues(&$defaults) {
* id of the tagset.
*/
if (isset($defaults['contact_tags'])) {
foreach ($defaults['contact_tags'] as $key => $tagId) {
foreach ((array) $defaults['contact_tags'] as $key => $tagId) {
if (!is_array($tagId)) {
$parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $tagId, 'parent_id');
$element = "contact_taglist[$parentId]";
Expand Down
7 changes: 4 additions & 3 deletions CRM/Contact/Form/Search/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public static function basic(&$form) {
}
}

// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Complete OR Partial Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));

//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'contact_source'));

Expand Down Expand Up @@ -257,10 +254,14 @@ public static function basic(&$form) {

/**
* Get the metadata for fields to be included on the contact search form.
*
* @throws \CiviCRM_API3_Exception
*/
public static function getSearchFieldMetadata() {
$fields = [
'sort_name' => ['title' => ts('Complete OR Partial Name'), 'template_grouping' => 'basic'],
'email' => ['title' => ts('Complete OR Partial Email'), 'entity' => 'Email', 'template_grouping' => 'basic'],
'contact_tags' => ['name' => 'contact_tags', 'type' => CRM_Utils_Type::T_INT, 'is_pseudofield' => TRUE, 'template_grouping' => 'basic'],
];
$metadata = civicrm_api3('Contact', 'getfields', [])['values'];
foreach ($fields as $fieldName => $field) {
Expand Down
11 changes: 8 additions & 3 deletions CRM/Core/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,17 @@ public function addFormFieldsFromMetadata() {
$this->_action = CRM_Core_Action::ADVANCED;
foreach ($this->getSearchFieldMetadata() as $entity => $fields) {
foreach ($fields as $fieldName => $fieldSpec) {
if ($fieldSpec['type'] === CRM_Utils_Type::T_DATE || $fieldSpec['type'] === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)) {
$fieldType = $fieldSpec['type'] ?? '';
if ($fieldType === CRM_Utils_Type::T_DATE || $fieldType === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)) {
$title = empty($fieldSpec['unique_title']) ? $fieldSpec['title'] : $fieldSpec['unique_title'];
$this->addDatePickerRange($fieldName, $title, ($fieldSpec['type'] === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)));
$this->addDatePickerRange($fieldName, $title, ($fieldType === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)));
}
else {
$props = ['entity' => $entity];
// Not quite sure about moving to a mix of keying by entity vs permitting entity to
// be passed in. The challenge of the former is that it doesn't permit ordering.
// Perhaps keying was the wrong starting point & we should do a flat array as all
// fields eventually need to be unique.
$props = ['entity' => $fieldSpec['entity'] ?? $entity];
if (isset($fields[$fieldName]['unique_title'])) {
$props['label'] = $fields[$fieldName]['unique_title'];
}
Expand Down