Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#2066 [WIP] Add support for calling (some) contribution actions in stand alone mode #18592

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CRM/Activity/Export/Form/Map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class gets the name of the file to upload
*/
class CRM_Activity_Export_Form_Map extends CRM_Export_Form_Map {

}
39 changes: 39 additions & 0 deletions CRM/Activity/Export/Form/Select.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class gets the name of the file to upload
*/
class CRM_Activity_Export_Form_Select extends CRM_Export_Form_Select {

/**
* Call the pre-processing function.
*/
protected function callPreProcessing(): void {
CRM_Activity_Form_Task::preProcessCommon($this);
}

/**
* Does this export offer contact merging.
*
* @return bool
*/
protected function isShowContactMergeOptions() {
return FALSE;
}

}
4 changes: 2 additions & 2 deletions CRM/Activity/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static function tasks() {
self::TASK_EXPORT => [
'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,
],
Expand Down
23 changes: 23 additions & 0 deletions CRM/Contact/Export/Form/Map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class gets the name of the file to upload
*/
class CRM_Contact_Export_Form_Map extends CRM_Export_Form_Map {

}
39 changes: 39 additions & 0 deletions CRM/Contact/Export/Form/Select.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class gets the name of the file to upload
*/
class CRM_Contact_Export_Form_Select extends CRM_Export_Form_Select {

/**
* Call the pre-processing function.
*/
protected function callPreProcessing(): void {
CRM_Contact_Form_Task::preProcessCommon($this);
}

/**
* Does this export offer contact merging.
*
* @return bool
*/
protected function isShowContactMergeOptions() {
return TRUE;
}

}
4 changes: 2 additions & 2 deletions CRM/Contact/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public static function tasks() {
self::TASK_EXPORT => 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,
),
Expand Down
35 changes: 35 additions & 0 deletions CRM/Contribute/Controller/Task.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
* Class CRM_Export_Controller_Standalone
*/
class CRM_Contribute_Controller_Task extends CRM_Core_Controller_Task {

/**
* Get the name used to construct the class.
*
* @return string
*/
public function getEntity():string {
return 'Contribution';
}

/**
* Get the available tasks for the entity.
*
* @return array
*/
public function getAvailableTasks():array {
return CRM_Contribute_Task::tasks();
}

}
23 changes: 23 additions & 0 deletions CRM/Contribute/Export/Form/Map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class gets the name of the file to upload
*/
class CRM_Contribute_Export_Form_Map extends CRM_Export_Form_Map {

}
39 changes: 39 additions & 0 deletions CRM/Contribute/Export/Form/Select.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

/**
* This class gets the name of the file to upload
*/
class CRM_Contribute_Export_Form_Select extends CRM_Export_Form_Select {

/**
* Call the pre-processing function.
*/
protected function callPreProcessing(): void {
CRM_Contribute_Form_Task::preProcessCommon($this);
}

/**
* Does this export offer contact merging.
*
* @return bool
*/
protected function isShowContactMergeOptions() {
return FALSE;
}

}
29 changes: 20 additions & 9 deletions CRM/Contribute/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ public function preProcess() {
}

/**
* @param \CRM_Core_Form_Task $form
* Get the contribution ids to act on.
*
* @return array
*/
public function getIDs() {
if ($this->controller->get('id')) {
return (array) $this->controller->get('id');
}
return array_keys($this->_contributionIds);
}

/**
* @param \CRM_Contribute_Form_Task $form
*
* @throws \CRM_Core_Exception
*/
Expand All @@ -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)) {
Expand Down Expand Up @@ -117,26 +128,26 @@ 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;
}
}
$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
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Task/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
12 changes: 6 additions & 6 deletions CRM/Contribute/Form/Task/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Task/PDFLetterCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions CRM/Contribute/Selector/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading