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
{
48 static $objectType = 'contribution';
51 * These tasks are the core set of tasks that the user can perform
52 * on a contact / group of contacts
55 * the set of tasks for a group of contacts
57 public static function tasks() {
58 if (!(self
::$_tasks)) {
59 self
::$_tasks = array(
60 self
::TASK_DELETE
=> array(
61 'title' => ts('Delete contributions'),
62 'class' => 'CRM_Contribute_Form_Task_Delete',
65 self
::TASK_PRINT
=> array(
66 'title' => ts('Print selected rows'),
67 'class' => 'CRM_Contribute_Form_Task_Print',
70 self
::TASK_EXPORT
=> array(
71 'title' => ts('Export contributions'),
73 'CRM_Export_Form_Select',
74 'CRM_Export_Form_Map',
78 self
::BATCH_UPDATE
=> array(
79 'title' => ts('Update multiple contributions'),
81 'CRM_Contribute_Form_Task_PickProfile',
82 'CRM_Contribute_Form_Task_Batch',
86 self
::TASK_EMAIL
=> array(
87 'title' => ts('Email - send now (to %1 or less)', array(
89 ->get('simple_mail_limit'),
91 'class' => 'CRM_Contribute_Form_Task_Email',
94 self
::UPDATE_STATUS
=> array(
95 'title' => ts('Update pending contribution status'),
96 'class' => 'CRM_Contribute_Form_Task_Status',
99 self
::PDF_RECEIPT
=> array(
100 'title' => ts('Receipts - print or email'),
101 'class' => 'CRM_Contribute_Form_Task_PDF',
104 self
::PDF_THANKYOU
=> array(
105 'title' => ts('Thank-you letters - print or email'),
106 'class' => 'CRM_Contribute_Form_Task_PDFLetter',
109 self
::PDF_INVOICE
=> array(
110 'title' => ts('Invoices - print or email'),
111 'class' => 'CRM_Contribute_Form_Task_Invoice',
116 //CRM-4418, check for delete
117 if (!CRM_Core_Permission
::check('delete in CiviContribute')) {
118 unset(self
::$_tasks[self
::TASK_DELETE
]);
120 //CRM-12920 - check for edit permission
121 if (!CRM_Core_Permission
::check('edit contributions')) {
122 unset(self
::$_tasks[self
::BATCH_UPDATE
], self
::$_tasks[self
::UPDATE_STATUS
]);
125 // remove action "Invoices - print or email"
126 $invoiceSettings = Civi
::settings()->get('contribution_invoice_settings');
127 $invoicing = CRM_Utils_Array
::value('invoicing', $invoiceSettings);
129 unset(self
::$_tasks[self
::PDF_INVOICE
]);
135 return self
::$_tasks;
139 * Show tasks selectively based on the permission level
142 * @param int $permission
144 * @param array $params
145 * bool softCreditFiltering: derived from CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled
148 * set of tasks that are valid for the user
150 public static function permissionedTaskTitles($permission, $params = array()) {
151 if (!isset($params['softCreditFiltering'])) {
152 $params['softCreditFiltering'] = FALSE;
154 if (($permission == CRM_Core_Permission
::EDIT
)
155 || CRM_Core_Permission
::check('edit contributions')
157 $tasks = self
::taskTitles();
161 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
162 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
163 self
::PDF_RECEIPT
=> self
::$_tasks[self
::PDF_RECEIPT
]['title'],
167 if (CRM_Core_Permission
::check('delete in CiviContribute')) {
168 $tasks[self
::TASK_DELETE
] = self
::$_tasks[self
::TASK_DELETE
]['title'];
171 if ($params['softCreditFiltering']) {
172 unset($tasks[self
::BATCH_UPDATE
], $tasks[self
::PDF_RECEIPT
]);
175 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
180 * These tasks are the core set of tasks that the user can perform
186 * the set of tasks for a group of contributors
188 public static function getTask($value) {
190 if (!$value ||
!CRM_Utils_Array
::value($value, self
::$_tasks)) {
191 // make the print task by default
192 $value = self
::TASK_PRINT
;
194 return parent
::getTask($value);