3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
35 * Class to represent the actions that can be performed on a group of contacts.
37 * Used by the search forms.
39 class CRM_Contribute_Task
extends CRM_Core_Task
{
53 public static $objectType = 'contribution';
56 * These tasks are the core set of tasks that the user can perform
57 * on a contact / group of contacts
60 * the set of tasks for a group of contacts
62 public static function tasks() {
63 if (!(self
::$_tasks)) {
65 self
::TASK_DELETE
=> [
66 'title' => ts('Delete contributions'),
67 'class' => 'CRM_Contribute_Form_Task_Delete',
71 'title' => ts('Print selected rows'),
72 'class' => 'CRM_Contribute_Form_Task_Print',
75 self
::TASK_EXPORT
=> [
76 'title' => ts('Export contributions'),
78 'CRM_Export_Form_Select',
79 'CRM_Export_Form_Map',
83 self
::BATCH_UPDATE
=> [
84 'title' => ts('Update multiple contributions'),
86 'CRM_Contribute_Form_Task_PickProfile',
87 'CRM_Contribute_Form_Task_Batch',
92 'title' => ts('Email - send now (to %1 or less)', [
94 ->get('simple_mail_limit'),
96 'class' => 'CRM_Contribute_Form_Task_Email',
99 self
::UPDATE_STATUS
=> [
100 'title' => ts('Update pending contribution status'),
101 'class' => 'CRM_Contribute_Form_Task_Status',
104 self
::PDF_RECEIPT
=> [
105 'title' => ts('Receipts - print or email'),
106 'class' => 'CRM_Contribute_Form_Task_PDF',
109 self
::PDF_THANKYOU
=> [
110 'title' => ts('Thank-you letters - print or email'),
111 'class' => 'CRM_Contribute_Form_Task_PDFLetter',
114 self
::PDF_INVOICE
=> [
115 'title' => ts('Invoices - print or email'),
116 'class' => 'CRM_Contribute_Form_Task_Invoice',
121 //CRM-4418, check for delete
122 if (!CRM_Core_Permission
::check('delete in CiviContribute')) {
123 unset(self
::$_tasks[self
::TASK_DELETE
]);
125 //CRM-12920 - check for edit permission
126 if (!CRM_Core_Permission
::check('edit contributions')) {
127 unset(self
::$_tasks[self
::BATCH_UPDATE
], self
::$_tasks[self
::UPDATE_STATUS
]);
130 // remove action "Invoices - print or email"
131 $invoiceSettings = Civi
::settings()->get('contribution_invoice_settings');
132 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
134 unset(self
::$_tasks[self
::PDF_INVOICE
]);
140 return self
::$_tasks;
144 * Show tasks selectively based on the permission level
147 * @param int $permission
149 * @param array $params
150 * bool softCreditFiltering: derived from CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled
153 * set of tasks that are valid for the user
155 public static function permissionedTaskTitles($permission, $params = []) {
156 if (!isset($params['softCreditFiltering'])) {
157 $params['softCreditFiltering'] = FALSE;
159 if (($permission == CRM_Core_Permission
::EDIT
)
160 || CRM_Core_Permission
::check('edit contributions')
162 $tasks = self
::taskTitles();
166 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
167 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
168 self
::PDF_RECEIPT
=> self
::$_tasks[self
::PDF_RECEIPT
]['title'],
172 if (CRM_Core_Permission
::check('delete in CiviContribute')) {
173 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
176 if ($params['softCreditFiltering']) {
177 unset($tasks[self
::BATCH_UPDATE
], $tasks[self
::PDF_RECEIPT
]);
180 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
185 * These tasks are the core set of tasks that the user can perform
191 * the set of tasks for a group of contributors
193 public static function getTask($value) {
195 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
196 // make the print task by default
197 $value = self
::TASK_PRINT
;
199 return parent
::getTask($value);