diff --git a/CHANGELOG.md b/CHANGELOG.md index e75107b6aa980652474658af238825348524797c..9ad8753b2e393e5124cb93d4fdafc7e32220201c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Add support for filter defaults to be set using the URL. * Added Filter for World Region * Added Output for World Region +* Fixed integration with search action designer extension for the Search/Report output. # Version 1.11.0 diff --git a/CRM/DataprocessorSearch/Form/Search.php b/CRM/DataprocessorSearch/Form/Search.php index b107e8fd8c08572a52306b1d4f2cf156dd19c42f..9d39e51adb90ab22b155dbddada1d09297708d0d 100644 --- a/CRM/DataprocessorSearch/Form/Search.php +++ b/CRM/DataprocessorSearch/Form/Search.php @@ -78,6 +78,30 @@ class CRM_DataprocessorSearch_Form_Search extends CRM_DataprocessorSearch_Form_A return false; } + /** + * Return altered rows + * + * Save the ids into the queryParams value. So that when an action is done on the selected record + * or on all records, the queryParams will hold all the case ids so that in the next step only the selected record, or the first + * all records are populated. + */ + protected function retrieveEntityIds() { + $this->dataProcessorClass->getDataFlow()->setLimit(false); + $this->dataProcessorClass->getDataFlow()->setOffset(0); + $this->entityIDs = []; + $id_field = $this->getIdFieldName(); + try { + while($record = $this->dataProcessorClass->getDataFlow()->nextRecord()) { + if ($id_field && isset($record[$id_field])) { + $this->entityIDs[] = $record[$id_field]->rawValue; + } + } + } catch (\Civi\DataProcessor\DataFlow\EndOfFlowException $e) { + // Do nothing + } + $this->controller->set('entityIds', $this->entityIDs); + } + /** * Builds the list of tasks or actions that a searcher can perform on a result set. * diff --git a/CRM/DataprocessorSearch/Form/Task/SearchActionDesigner.php b/CRM/DataprocessorSearch/Form/Task/SearchActionDesigner.php index e2221b6eeb7e308dedbe4fc71737775223ed72c9..f3155e596c6632dd13da8a399a5fcb35425cbd91 100644 --- a/CRM/DataprocessorSearch/Form/Task/SearchActionDesigner.php +++ b/CRM/DataprocessorSearch/Form/Task/SearchActionDesigner.php @@ -4,11 +4,47 @@ * @license AGPL-3.0 */ +use CRM_Dataprocessor_ExtensionUtil as E; + class CRM_DataprocessorSearch_Form_Task_SearchActionDesigner extends CRM_Searchactiondesigner_Form_Task_Task { protected function setEntityShortName() { self::$entityShortname = 'DataprocessorSearch'; } + public function preProcess() { + $this->setEntityShortName(); + $session = CRM_Core_Session::singleton(); + $url = $session->readUserContext(); + $session->replaceUserContext($url); + + $searchFormValues = $this->controller->exportValues($this->get('searchFormName')); + $this->_task = $searchFormValues['task']; + $className = 'CRM_' . ucfirst(self::$entityShortname) . '_Task'; + $entityTasks = $className::tasks(); + $this->assign('taskName', $entityTasks[$this->_task]); + + $entityIds = []; + if ($searchFormValues['radio_ts'] == 'ts_sel') { + foreach ($searchFormValues as $name => $value) { + if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { + $entityIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); + } + } + } else { + $entityIds = $this->get('entityIds'); + } + $this->_entityIds = $this->_componentIds = $entityIds; + + if (strpos($this->_task,'searchactiondesigner_') !== 0) { + throw new \Exception(E::ts('Invalid search task')); + } + $this->searchTaskId = substr($this->_task, 21); + + $this->searchTask = civicrm_api3('SearchTask', 'getsingle', array('id' => $this->searchTaskId)); + $this->assign('searchTask', $this->searchTask); + $this->assign('status', E::ts("Number of selected records: %1", array(1=>count($this->_entityIds)))); + } + -} \ No newline at end of file +}