| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 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 | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * |
| 14 | * @package CRM |
| 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * class to represent the actions that can be performed on a group of contacts |
| 20 | * used by the search forms. |
| 21 | * |
| 22 | */ |
| 23 | class CRM_Mailing_Task extends CRM_Core_Task { |
| 24 | |
| 25 | public static $objectType = 'mailing'; |
| 26 | |
| 27 | /** |
| 28 | * These tasks are the core set of tasks that the user can perform |
| 29 | * on a contact / group of contacts. |
| 30 | * |
| 31 | * @return array |
| 32 | * the set of tasks for a group of contacts. |
| 33 | */ |
| 34 | public static function tasks() { |
| 35 | if (!(self::$_tasks)) { |
| 36 | self::$_tasks = [ |
| 37 | self::TASK_PRINT => [ |
| 38 | 'title' => ts('Print Mailing Recipients'), |
| 39 | 'class' => 'CRM_Mailing_Form_Task_Print', |
| 40 | 'result' => FALSE, |
| 41 | ], |
| 42 | ]; |
| 43 | |
| 44 | parent::tasks(); |
| 45 | } |
| 46 | |
| 47 | return self::$_tasks; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Show tasks selectively based on the permission level |
| 52 | * of the user. |
| 53 | * |
| 54 | * @param int $permission |
| 55 | * @param array $params |
| 56 | * |
| 57 | * @return array |
| 58 | * set of tasks that are valid for the user |
| 59 | */ |
| 60 | public static function permissionedTaskTitles($permission, $params = []) { |
| 61 | $tasks = []; |
| 62 | |
| 63 | $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); |
| 64 | return $tasks; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * These tasks are the core set of tasks that the user can perform. |
| 69 | * on mailing recipients. |
| 70 | * |
| 71 | * @param int $value |
| 72 | * |
| 73 | * @return array |
| 74 | * the set of tasks for a group of mailing recipients |
| 75 | */ |
| 76 | public static function getTask($value) { |
| 77 | self::tasks(); |
| 78 | if (!$value || empty(self::$_tasks[$value])) { |
| 79 | // make the print task by default |
| 80 | $value = self::TASK_PRINT; |
| 81 | } |
| 82 | |
| 83 | if (isset(self::$_tasks[$value])) { |
| 84 | return [[self::$_tasks[$value]['class']], self::$_tasks[$value]['result']]; |
| 85 | } |
| 86 | return [[], NULL]; |
| 87 | } |
| 88 | |
| 89 | } |