Commit | Line | Data |
---|---|---|
2cc569f2 PJ |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
2cc569f2 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
2cc569f2 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
2cc569f2 PJ |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
2cc569f2 PJ |
16 | */ |
17 | ||
18 | /** | |
19 | * class to represent the actions that can be performed on a group of contacts | |
25606795 | 20 | * used by the search forms. |
2cc569f2 PJ |
21 | * |
22 | */ | |
12009fb4 | 23 | class CRM_Mailing_Task extends CRM_Core_Task { |
2cc569f2 | 24 | |
7e8c8317 | 25 | public static $objectType = 'mailing'; |
2cc569f2 PJ |
26 | |
27 | /** | |
28 | * These tasks are the core set of tasks that the user can perform | |
25606795 | 29 | * on a contact / group of contacts. |
2cc569f2 | 30 | * |
a6c01b45 | 31 | * @return array |
25606795 | 32 | * the set of tasks for a group of contacts. |
2cc569f2 | 33 | */ |
12009fb4 | 34 | public static function tasks() { |
2cc569f2 | 35 | if (!(self::$_tasks)) { |
be2fb01f CW |
36 | self::$_tasks = [ |
37 | self::TASK_PRINT => [ | |
23546577 | 38 | 'title' => ts('Print Mailing Recipients'), |
2cc569f2 PJ |
39 | 'class' => 'CRM_Mailing_Form_Task_Print', |
40 | 'result' => FALSE, | |
be2fb01f CW |
41 | ], |
42 | ]; | |
2cc569f2 | 43 | |
12009fb4 | 44 | parent::tasks(); |
2cc569f2 PJ |
45 | } |
46 | ||
47 | return self::$_tasks; | |
48 | } | |
49 | ||
2cc569f2 | 50 | /** |
100fef9d | 51 | * Show tasks selectively based on the permission level |
25606795 | 52 | * of the user. |
2cc569f2 PJ |
53 | * |
54 | * @param int $permission | |
12009fb4 | 55 | * @param array $params |
2cc569f2 | 56 | * |
a6c01b45 CW |
57 | * @return array |
58 | * set of tasks that are valid for the user | |
2cc569f2 | 59 | */ |
be2fb01f CW |
60 | public static function permissionedTaskTitles($permission, $params = []) { |
61 | $tasks = []; | |
12009fb4 MW |
62 | |
63 | $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); | |
64 | return $tasks; | |
2cc569f2 PJ |
65 | } |
66 | ||
67 | /** | |
fe482240 | 68 | * These tasks are the core set of tasks that the user can perform. |
25606795 | 69 | * on mailing recipients. |
2cc569f2 PJ |
70 | * |
71 | * @param int $value | |
72 | * | |
a6c01b45 CW |
73 | * @return array |
74 | * the set of tasks for a group of mailing recipients | |
2cc569f2 | 75 | */ |
00be9182 | 76 | public static function getTask($value) { |
2cc569f2 | 77 | self::tasks(); |
b99f3e96 | 78 | if (!$value || empty(self::$_tasks[$value])) { |
2cc569f2 | 79 | // make the print task by default |
12009fb4 | 80 | $value = self::TASK_PRINT; |
2cc569f2 | 81 | } |
12009fb4 | 82 | |
be2fb01f | 83 | return [ |
2cc569f2 PJ |
84 | self::$_tasks[$value]['class'], |
85 | self::$_tasks[$value]['result'], | |
be2fb01f | 86 | ]; |
2cc569f2 | 87 | } |
96025800 | 88 | |
bf765334 | 89 | } |