X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FForm%2FTask.php;h=b52a37bdd0a24afd68187323cb4f7a25377beef9;hb=2b4ed181a658c1959ff66f5c9cd16b4475638121;hp=917b59ab584bd3a19dbcfcd838c5a150eef75fec;hpb=2f36a39fa513d1bba497b5a540343d01308c99fb;p=civicrm-core.git diff --git a/CRM/Case/Form/Task.php b/CRM/Case/Form/Task.php index 917b59ab58..b52a37bdd0 100644 --- a/CRM/Case/Form/Task.php +++ b/CRM/Case/Form/Task.php @@ -34,11 +34,7 @@ class CRM_Case_Form_Task extends CRM_Core_Form_Task { * @inheritDoc */ public function setContactIDs() { - // @todo Parameters shouldn't be needed and should be class member - // variables instead, set appropriately by each subclass. - $this->_contactIds = $this->getContactIDsFromComponent($this->_entityIds, - 'civicrm_case_contact', 'case_id' - ); + $this->_contactIds = $this->getContactIDs(); } /** @@ -68,4 +64,63 @@ class CRM_Case_Form_Task extends CRM_Core_Form_Task { return 'ORDER BY ' . implode(',', $order_array); } + /** + * Get the rows from the results to be pdf-d. + * + * @return array + */ + protected function getRows(): array { + $rows = []; + foreach ($this->_contactIds as $index => $contactID) { + $caseID = $this->getVar('_caseId'); + if (empty($caseID) && !empty($this->_caseIds[$index])) { + $caseID = $this->_caseIds[$index]; + } + $rows[] = ['contact_id' => $contactID, 'schema' => ['caseId' => $caseID, 'contactId' => $contactID]]; + } + return $rows; + } + + /** + * Get the name of the table for the relevant entity. + * + * @return string + */ + public function getTableName() { + return 'civicrm_case'; + } + + /** + * Get the entity alias field. + * + * @return string + */ + public function getEntityAliasField() { + return 'case_id'; + } + + protected function getContactIDs(): array { + if (isset($this->_contactIds)) { + return $this->_contactIds; + } + $contactIDSFromUrl = CRM_Utils_Request::retrieve('cid', 'CommaSeparatedIntegers', $this); + if (!empty($contactIDSFromUrl)) { + return explode(',', $contactIDSFromUrl); + } + // @todo Parameters shouldn't be needed and should be class member + // variables instead, set appropriately by each subclass. + return $this->getContactIDsFromComponent($this->_entityIds, + 'civicrm_case_contact', 'case_id' + ); + } + + /** + * Get the token processor schema required to list any tokens for this task. + * + * @return array + */ + protected function getTokenSchema(): array { + return ['contactId', 'caseId']; + } + }