Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
C
Core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 977
    • Issues 977
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • Core
  • Issues
  • #692

Closed
Open
Opened Feb 04, 2019 by Monish Deb@monish.debDeveloper

Unable to use url search arguments in 'Advanced Search' using force=1

Currently, it is not possible to use URL search arguments in 'Advanced Search' using force=1 to load search results. This is no longer working except for mailing params which are manually handled here.

Following are the steps to support URL search arguments Civi component-wise:

  1. All the search forms extends the parent class CRM_Core_Form_Search that will define a new function loadSearchParamsFromUrl(). Definition as follows
function loadSearchParamsFromUrl() {
  // In case no component is defined then lookout for basic contact search fields + all enanbled components search fields
  if (!$this->_component) {
      if (method_exists('CRM_Contact_Form_Search', 'setSearchParamFromUrl')) {
        CRM_Contact_Form_Search::setSearchParamFromUrl($this);
      }
      foreach ($enabledComponents as $component) {
        $searchClass = $component->namespace . '_Form_Search';
        if (method_exists($searchClass, 'setSearchParamFromUrl')) {
          $searchClass::setSearchParamFromUrl($form);
        }
      }
    }
    elseif (array_key_exists($this->_component, $enabledComponents)) { // $_component = 'CiviMail'
      $searchClass = $enabledComponents[$this->_component]->namespace . '_Form_Search'; 
      if (method_exists($searchClass, 'setSearchParamFromUrl')) { 
        // call CRM_Mailing_Form_Search::setSearchParamFromUrl()
        $searchClass::setSearchParamFromUrl($form);
      }
    }
}
  1. This function will be called by respective search form to find the search arguments from URL and set them accordingly. And will be handled in SearchClass::setSearchParamFromUrl($form); as:
class CRM_Contact_Form_Search {
...
 public static function setSearchParamFromUrl(&$form) {
    foreach (CRM_Contact_Form_Search_Criteria::getBasicSearchFields() as $name => $type) {
      if ($value = CRM_Utils_Request::retrieve($name, $type)) {
        $form->_formValues[$name] = $value;
      }
    }

    $form->_params = CRM_Contact_BAO_Query::convertFormValues($form->_formValues);
    $form->set('formValues', $form->_formValues);
    $form->set('queryParams', $form->_params);
 }
}

The intent is to generalize the workflow and let each component's search form decide and hosts its list of search arguments (on basis of enabled component) rather than manually handling them in different places.

Edited Feb 04, 2019 by Monish Deb
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
5.11
Milestone
5.11 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: dev/core#692