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 used by the search forms.
37 class CRM_Contact_Task
extends CRM_Core_Task
{
43 HOUSEHOLD_CONTACTS
= 101,
44 ORGANIZATION_CONTACTS
= 102,
45 RECORD_CONTACTS
= 103,
51 COMMUNICATION_PREFS
= 109,
52 INDIVIDUAL_CONTACTS
= 110,
58 public static $objectType = 'contact';
60 public static function tasks() {
62 self
::$_tasks = array(
63 self
::GROUP_ADD
=> array(
64 'title' => ts('Group - add contacts'),
65 'class' => 'CRM_Contact_Form_Task_AddToGroup',
66 'url' => 'civicrm/task/add-to-group',
68 self
::GROUP_REMOVE
=> array(
69 'title' => ts('Group - remove contacts'),
70 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup',
71 'url' => 'civicrm/task/remove-from-group',
73 self
::TAG_ADD
=> array(
74 'title' => ts('Tag - add to contacts'),
75 'class' => 'CRM_Contact_Form_Task_AddToTag',
76 'url' => 'civicrm/task/add-to-tag',
78 self
::TAG_REMOVE
=> array(
79 'title' => ts('Tag - remove from contacts'),
80 'class' => 'CRM_Contact_Form_Task_RemoveFromTag',
81 'url' => 'civicrm/task/remove-from-tag',
83 self
::TASK_EXPORT
=> array(
84 'title' => ts('Export contacts'),
86 'CRM_Export_Form_Select',
87 'CRM_Export_Form_Map',
91 self
::TASK_EMAIL
=> array(
92 'title' => ts('Email - send now (to %1 or less)', array(
94 ->get('simple_mail_limit'),
96 'class' => 'CRM_Contact_Form_Task_Email',
98 'url' => 'civicrm/task/send-email',
100 self
::TASK_DELETE
=> array(
101 'title' => ts('Delete contacts'),
102 'class' => 'CRM_Contact_Form_Task_Delete',
104 'url' => 'civicrm/task/delete-contact',
106 self
::RECORD_CONTACTS
=> array(
107 'title' => ts('Add activity'),
108 'class' => 'CRM_Activity_Form_Activity',
110 self
::SAVE_SEARCH
=> array(
111 'title' => ts('Group - create smart group'),
112 'class' => 'CRM_Contact_Form_Task_SaveSearch',
115 self
::SAVE_SEARCH_UPDATE
=> array(
116 'title' => ts('Group - update smart group'),
117 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update',
120 self
::TASK_PRINT
=> array(
121 'title' => ts('Print selected rows'),
122 'class' => 'CRM_Contact_Form_Task_Print',
125 self
::LABEL_CONTACTS
=> array(
126 'title' => ts('Mailing labels - print'),
127 'class' => 'CRM_Contact_Form_Task_Label',
129 'url' => 'civicrm/task/make-mailing-label',
131 self
::BATCH_UPDATE
=> array(
132 'title' => ts('Update multiple contacts'),
134 'CRM_Contact_Form_Task_PickProfile',
135 'CRM_Contact_Form_Task_Batch',
138 'url' => 'civicrm/task/pick-profile',
140 self
::PDF_LETTER
=> array(
141 'title' => ts('Print/merge document'),
142 'class' => 'CRM_Contact_Form_Task_PDF',
144 'url' => 'civicrm/task/print-document',
146 self
::EMAIL_UNHOLD
=> array(
147 'title' => ts('Email - unhold addresses'),
148 'class' => 'CRM_Contact_Form_Task_Unhold',
149 'url' => 'civicrm/task/unhold-email',
151 self
::COMMUNICATION_PREFS
=> array(
152 'title' => ts('Communication preferences - alter'),
153 'class' => 'CRM_Contact_Form_Task_AlterPreferences',
154 'url' => 'civicrm/task/alter-contact-preference',
156 self
::RESTORE
=> array(
157 'title' => ts('Restore contacts from trash'),
158 'class' => 'CRM_Contact_Form_Task_Delete',
161 self
::DELETE_PERMANENTLY
=> array(
162 'title' => ts('Delete permanently'),
163 'class' => 'CRM_Contact_Form_Task_Delete',
168 //CRM-16329, if SMS provider is configured show sms action.
169 $providersCount = CRM_SMS_BAO_Provider
::activeProviderCount();
170 if ($providersCount && CRM_Core_Permission
::check('send SMS')) {
171 self
::$_tasks[self
::TASK_SMS
] = array(
172 'title' => ts('SMS - schedule/send'),
173 'class' => 'CRM_Contact_Form_Task_SMS',
178 if (CRM_Contact_BAO_ContactType
::isActive('Individual')) {
179 $label = CRM_Contact_BAO_ContactType
::getLabel('individual');
180 self
::$_tasks[self
::INDIVIDUAL_CONTACTS
] = array(
181 'title' => ts('Add relationship - to %1',
184 'class' => 'CRM_Contact_Form_Task_AddToIndividual',
188 if (CRM_Contact_BAO_ContactType
::isActive('Household')) {
189 $label = CRM_Contact_BAO_ContactType
::getLabel('household');
190 self
::$_tasks[self
::HOUSEHOLD_CONTACTS
] = array(
191 'title' => ts('Add relationship - to %1',
194 'class' => 'CRM_Contact_Form_Task_AddToHousehold',
198 if (CRM_Contact_BAO_ContactType
::isActive('Organization')) {
199 $label = CRM_Contact_BAO_ContactType
::getLabel('organization');
200 self
::$_tasks[self
::ORGANIZATION_CONTACTS
] = array(
201 'title' => ts('Add relationship - to %1',
204 'class' => 'CRM_Contact_Form_Task_AddToOrganization',
208 if (CRM_Core_Permission
::check('merge duplicate contacts')) {
209 self
::$_tasks[self
::MERGE_CONTACTS
] = array(
210 'title' => ts('Merge contacts'),
211 'class' => 'CRM_Contact_Form_Task_Merge',
216 //CRM-4418, check for delete
217 if (!CRM_Core_Permission
::check('delete contacts')) {
218 unset(self
::$_tasks[self
::TASK_DELETE
]);
221 //show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
222 // should fix this to be more flexible as providers are added ??
223 $config = CRM_Core_Config
::singleton();
225 if ($config->mapProvider
&&
226 ($config->mapProvider
== 'Google' ||
227 ($config->mapProvider
== 'OpenStreetMaps' ||
228 $config->geoProvider
== 'Google'
232 self
::$_tasks[self
::MAP_CONTACTS
] = array(
233 'title' => ts('Map contacts'),
234 'class' => 'CRM_Contact_Form_Task_Map',
239 if (CRM_Core_Permission
::access('CiviEvent')) {
240 self
::$_tasks[self
::ADD_EVENT
] = array(
241 'title' => ts('Register participants for event'),
242 'class' => 'CRM_Event_Form_Participant',
246 if (CRM_Core_Permission
::access('CiviMail')
247 ||
(CRM_Mailing_Info
::workflowEnabled() && CRM_Core_Permission
::check('create mailings'))
249 self
::$_tasks[self
::CREATE_MAILING
] = array(
250 'title' => ts('Email - schedule/send via CiviMail'),
251 'class' => 'CRM_Mailing_Form_Task_AdhocMailing',
256 if (CRM_Core_Permission
::access('CiviCase')) {
257 self
::$_tasks[self
::ADD_TO_CASE
] = array(
258 'title' => 'Add to case as role',
259 'class' => 'CRM_Case_Form_AddToCaseAsRole',
267 return self
::$_tasks;
271 * Show tasks selectively based on the permission level
274 * @param int $permission
275 * @param array $params
276 * bool deletedContacts: Are these tasks for operating on deleted contacts?.
279 * set of tasks that are valid for the user
281 public static function permissionedTaskTitles($permission, $params = array()) {
282 if (!isset($params['deletedContacts'])) {
283 $params['deletedContacts'] = FALSE;
287 if ($params['deletedContacts']) {
288 if (CRM_Core_Permission
::check('access deleted contacts')) {
289 $tasks[self
::RESTORE
] = self
::$_tasks[self
::RESTORE
]['title'];
290 if (CRM_Core_Permission
::check('delete contacts')) {
291 $tasks[self
::DELETE_PERMANENTLY
] = self
::$_tasks[self
::DELETE_PERMANENTLY
]['title'];
295 elseif ($permission == CRM_Core_Permission
::EDIT
) {
296 $tasks = self
::taskTitles();
300 self
::TASK_EXPORT
=> self
::$_tasks[self
::TASK_EXPORT
]['title'],
301 self
::TASK_EMAIL
=> self
::$_tasks[self
::TASK_EMAIL
]['title'],
302 self
::LABEL_CONTACTS
=> self
::$_tasks[self
::LABEL_CONTACTS
]['title'],
307 self
::CREATE_MAILING
,
310 if (isset(self
::$_tasks[$task]) &&
311 !empty(self
::$_tasks[$task]['title'])
313 $tasks[$task] = self
::$_tasks[$task]['title'];
318 $tasks = parent
::corePermissionedTaskTitles($tasks, $permission, $params);
327 public static function getTask($value) {
330 if (!CRM_Utils_Array
::value($value, self
::$_tasks)) {
331 // make it the print task by default
332 $value = self
::TASK_PRINT
;
334 return parent
::getTask($value);