Merge pull request #23707 from eileenmcnaughton/import_activity
[civicrm-core.git] / CRM / Case / Form / Task.php
index 0734653c2f3b27cdf1bc22adcb6f2211f48c3784..b52a37bdd0a24afd68187323cb4f7a25377beef9 100644 (file)
@@ -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();
   }
 
   /**
@@ -80,7 +76,7 @@ class CRM_Case_Form_Task extends CRM_Core_Form_Task {
       if (empty($caseID) && !empty($this->_caseIds[$index])) {
         $caseID = $this->_caseIds[$index];
       }
-      $rows[] = ['contactId' => $contactID, 'caseId' => $caseID];
+      $rows[] = ['contact_id' => $contactID, 'schema' => ['caseId' => $caseID, 'contactId' => $contactID]];
     }
     return $rows;
   }
@@ -103,4 +99,28 @@ class CRM_Case_Form_Task extends CRM_Core_Form_Task {
     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'];
+  }
+
 }