diff --git a/CRM/Activity/Export/Form/Map.php b/CRM/Activity/Export/Form/Map.php
new file mode 100644
index 000000000000..b977bef10de6
--- /dev/null
+++ b/CRM/Activity/Export/Form/Map.php
@@ -0,0 +1,23 @@
+ [
'title' => ts('Export activities'),
'class' => [
- 'CRM_Export_Form_Select',
- 'CRM_Export_Form_Map',
+ 'CRM_Activity_Export_Form_Select',
+ 'CRM_Activity_Export_Form_Map',
],
'result' => FALSE,
],
diff --git a/CRM/Contact/Export/Form/Map.php b/CRM/Contact/Export/Form/Map.php
new file mode 100644
index 000000000000..7e1451ebea00
--- /dev/null
+++ b/CRM/Contact/Export/Form/Map.php
@@ -0,0 +1,23 @@
+ array(
'title' => ts('Export contacts'),
'class' => array(
- 'CRM_Export_Form_Select',
- 'CRM_Export_Form_Map',
+ 'CRM_Contact_Export_Form_Select',
+ 'CRM_Contact_Export_Form_Map',
),
'result' => FALSE,
),
diff --git a/CRM/Contribute/Controller/Task.php b/CRM/Contribute/Controller/Task.php
new file mode 100644
index 000000000000..aad2f053fa46
--- /dev/null
+++ b/CRM/Contribute/Controller/Task.php
@@ -0,0 +1,35 @@
+controller->get('id')) {
+ return (array) $this->controller->get('id');
+ }
+ return array_keys($this->_contributionIds);
+ }
+
+ /**
+ * @param \CRM_Contribute_Form_Task $form
*
* @throws \CRM_Core_Exception
*/
@@ -63,15 +75,14 @@ public static function preProcessCommon(&$form) {
$contributeTasks = CRM_Contribute_Task::tasks();
$form->assign('taskName', CRM_Utils_Array::value($form->_task, $contributeTasks));
- $ids = [];
if (isset($values['radio_ts']) && $values['radio_ts'] == 'ts_sel') {
foreach ($values as $name => $value) {
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
- $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
+ $form->_contributionIds[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
}
}
}
- else {
+ elseif (!$form->getIDs()) {
$queryParams = $form->get('queryParams');
$isTest = FALSE;
if (is_array($queryParams)) {
@@ -117,7 +128,7 @@ public static function preProcessCommon(&$form) {
}
$result = $query->searchQuery(0, 0, $sortOrder);
while ($result->fetch()) {
- $ids[] = $result->contribution_id;
+ $form->_contributionIds[] = $result->contribution_id;
if ($form->_includesSoftCredits) {
$contactIds[$result->contact_id] = $result->contact_id;
$contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
@@ -125,18 +136,18 @@ public static function preProcessCommon(&$form) {
}
$form->assign('totalSelectedContributions', $form->get('rowCount'));
}
+ $form->_componentIds = $form->_contributionIds;
- if (!empty($ids)) {
- $form->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $ids) . ' ) ';
+ if (!empty($form->getIDs())) {
+ $form->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $form->getIDs()) . ' ) ';
- $form->assign('totalSelectedContributions', count($ids));
+ $form->assign('totalSelectedContributions', count($form->getIDs()));
}
if (!empty($form->_includesSoftCredits) && !empty($contactIds)) {
$form->_contactIds = $contactIds;
$form->_contributionContactIds = $contributionContactIds;
}
- $form->_contributionIds = $form->_componentIds = $ids;
$form->set('contributionIds', $form->_contributionIds);
//set the context for redirection for any task actions
diff --git a/CRM/Contribute/Form/Task/Delete.php b/CRM/Contribute/Form/Task/Delete.php
index 1b8aa33f988b..30b05bccb778 100644
--- a/CRM/Contribute/Form/Task/Delete.php
+++ b/CRM/Contribute/Form/Task/Delete.php
@@ -88,7 +88,7 @@ public function buildQuickForm() {
*/
public function postProcess() {
$deleted = $failed = 0;
- foreach ($this->_contributionIds as $contributionId) {
+ foreach ($this->getIDs() as $contributionId) {
if (CRM_Contribute_BAO_Contribution::deleteContribution($contributionId)) {
$deleted++;
}
diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php
index 7b99516a88b9..33df631b205a 100644
--- a/CRM/Contribute/Form/Task/PDF.php
+++ b/CRM/Contribute/Form/Task/PDF.php
@@ -39,11 +39,11 @@ public function preProcess() {
$this, FALSE
);
- if ($id) {
- $this->_contributionIds = [$id];
- $this->_componentClause = " civicrm_contribution.id IN ( $id ) ";
- $this->_single = TRUE;
- $this->assign('totalSelectedContributions', 1);
+ if ($this->getIDs()) {
+ $this->_contributionIds = $this->getIDs();
+ $this->_componentClause = ' civicrm_contribution.id IN ( ' . implode(',', $this->getIDs()) . ' ) ';
+ $this->_single = count($this->getIDs()) === 1;
+ $this->assign('totalSelectedContributions', count($this->getIDs()));
}
else {
parent::preProcess();
@@ -139,7 +139,7 @@ public function postProcess() {
$template = CRM_Core_Smarty::singleton();
$params = $this->controller->exportValues($this->_name);
- $elements = self::getElements($this->_contributionIds, $params, $this->_contactIds);
+ $elements = self::getElements($this->getIDs(), $params, $this->_contactIds);
foreach ($elements['details'] as $contribID => $detail) {
$input = $ids = [];
diff --git a/CRM/Contribute/Form/Task/PDFLetterCommon.php b/CRM/Contribute/Form/Task/PDFLetterCommon.php
index a201830384ea..40e37d139478 100644
--- a/CRM/Contribute/Form/Task/PDFLetterCommon.php
+++ b/CRM/Contribute/Form/Task/PDFLetterCommon.php
@@ -77,7 +77,7 @@ public static function postProcess(&$form, $formValues = NULL) {
// skip some contacts ?
$skipOnHold = $form->skipOnHold ?? FALSE;
$skipDeceased = $form->skipDeceased ?? TRUE;
- $contributionIDs = $form->getVar('_contributionIds');
+ $contributionIDs = $form->getIDs();
if ($form->_includesSoftCredits) {
//@todo - comment on what is stored there
$contributionIDs = $form->getVar('_contributionContactIds');
diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php
index 010d05116d85..56899a8e7335 100644
--- a/CRM/Contribute/Selector/Search.php
+++ b/CRM/Contribute/Selector/Search.php
@@ -445,6 +445,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
'title' => $buttonName,
];
}
+ $links += CRM_Contribute_Task::getContextualLinks($row);
$row['action'] = CRM_Core_Action::formLink(
$links,
diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php
index 24feae8a8797..ff4f22e83a9d 100644
--- a/CRM/Contribute/Task.php
+++ b/CRM/Contribute/Task.php
@@ -50,19 +50,28 @@ public static function tasks() {
'title' => ts('Delete contributions'),
'class' => 'CRM_Contribute_Form_Task_Delete',
'result' => FALSE,
+ 'key' => 'delete',
+ 'is_support_standalone' => TRUE,
+ 'is_single_mode' => FALSE,
],
self::TASK_PRINT => [
'title' => ts('Print selected rows'),
'class' => 'CRM_Contribute_Form_Task_Print',
'result' => FALSE,
+ 'key' => 'print',
+ 'is_support_standalone' => TRUE,
+ // It works - just seems a bit odd.
+ 'is_single_mode' => FALSE,
],
self::TASK_EXPORT => [
'title' => ts('Export contributions'),
'class' => [
- 'CRM_Export_Form_Select',
- 'CRM_Export_Form_Map',
+ 'CRM_Contribute_Export_Form_Select',
+ 'CRM_Contribute_Export_Form_Map',
],
+ 'key' => 'export',
'result' => FALSE,
+ 'is_single_mode' => FALSE,
],
self::BATCH_UPDATE => [
'title' => ts('Update multiple contributions'),
@@ -70,35 +79,68 @@ public static function tasks() {
'CRM_Contribute_Form_Task_PickProfile',
'CRM_Contribute_Form_Task_Batch',
],
+ 'key' => 'batch_update',
'result' => TRUE,
+ 'is_support_standalone' => FALSE,
+ 'is_single_mode' => FALSE,
],
self::TASK_EMAIL => [
'title' => ts('Email - send now (to %1 or less)', [
1 => Civi::settings()
->get('simple_mail_limit'),
]),
+ 'title_single_mode' => ts('Email'),
+ 'key' => 'email',
+ 'name' => ts('Email'),
'class' => 'CRM_Contribute_Form_Task_Email',
'result' => TRUE,
+ // Not yet!
+ 'is_support_standalone' => FALSE,
+ 'is_single_mode' => FALSE,
],
self::UPDATE_STATUS => [
'title' => ts('Record payments for contributions'),
'class' => 'CRM_Contribute_Form_Task_Status',
'result' => TRUE,
+ 'key' => 'update_status',
+ 'is_support_standalone' => TRUE,
+ // We have a better link we can use for a single.
+ 'is_single_mode' => FALSE,
],
self::PDF_RECEIPT => [
'title' => ts('Receipts - print or email'),
'class' => 'CRM_Contribute_Form_Task_PDF',
'result' => FALSE,
+ 'name' => ts('Receipt'),
+ 'is_support_standalone' => TRUE,
+ 'key' => 'receipt',
+ 'filters' => ['contribution_status_id' => [CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')]],
+ 'is_single_mode' => TRUE,
],
self::PDF_THANKYOU => [
'title' => ts('Thank-you letters - print or email'),
'class' => 'CRM_Contribute_Form_Task_PDFLetter',
'result' => FALSE,
+ 'name' => ts('Thank'),
+ 'key' => 'thankyou',
+ 'is_support_standalone' => TRUE,
+ 'is_single_mode' => TRUE,
+ 'filters' => ['contribution_status_id' => [CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')]],
],
self::PDF_INVOICE => [
'title' => ts('Invoices - print or email'),
'class' => 'CRM_Contribute_Form_Task_Invoice',
+ 'name' => ts('Invoice'),
'result' => FALSE,
+ 'key' => 'invoice',
+ 'is_support_standalone' => TRUE,
+ 'is_single_mode' => TRUE,
+ 'filters' => [
+ 'contribution_status_id' => [
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'),
+ CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid'),
+ ],
+ ],
],
];
@@ -123,6 +165,35 @@ public static function tasks() {
return self::$_tasks;
}
+ /**
+ * Get links appropriate to the context of the row.
+ *
+ * @param $row
+ *
+ * @return array
+ */
+ public static function getContextualLinks($row) {
+ $tasks = self::tasks();
+ foreach ($tasks as $key => $task) {
+ if (empty($task['is_single_mode'])) {
+ unset($tasks[$key]);
+ continue;
+ }
+ if (!empty($task['filters'])) {
+ foreach ($task['filters'] as $filter => $values) {
+ if (!in_array($row[$filter], $values, FALSE)) {
+ unset($tasks[$key]);
+ continue 2;
+ }
+ }
+ }
+ $tasks[$key]['url'] = 'civicrm/contribute/task';
+ $tasks[$key]['qs'] = ['reset' => 1, 'id' => $row['contribution_id'], 'task' => $task['key']];
+ $tasks[$key]['title'] = $task['title_single_mode'] ?? $task['title'];
+ }
+ return $tasks;
+ }
+
/**
* Show tasks selectively based on the permission level
* of the user
diff --git a/CRM/Contribute/xml/Menu/Contribute.xml b/CRM/Contribute/xml/Menu/Contribute.xml
index cfafe7f6c395..be445b9f4038 100644
--- a/CRM/Contribute/xml/Menu/Contribute.xml
+++ b/CRM/Contribute/xml/Menu/Contribute.xml
@@ -329,4 +329,10 @@