Merge pull request #19023 from eileenmcnaughton/tt
[civicrm-core.git] / CRM / Campaign / Task.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
df371444 19 * class to represent the actions that can be performed on a group of voters.
6a488035 20 *
df371444 21 * Used by the search forms.
6a488035 22 */
5da76dbe 23class CRM_Campaign_Task extends CRM_Core_Task {
6a488035 24
f157740d
SL
25 /**
26 * Campaign tasks
27 */
5da76dbe 28 const
5da76dbe
MW
29 INTERVIEW = 601,
30 RESERVE = 602,
31 RELEASE = 603;
6a488035 32
f157740d
SL
33 /**
34 * @var string
35 */
36 public static $objectType = 'campaign';
6a488035
TO
37
38 /**
39 * These tasks are the core set of tasks that the user can perform
40 * on a voter / group of voters
41 *
a6c01b45
CW
42 * @return array
43 * the set of tasks for a group of voters.
6a488035 44 */
5da76dbe 45 public static function tasks() {
6a488035 46 if (!(self::$_tasks)) {
be2fb01f
CW
47 self::$_tasks = [
48 self::INTERVIEW => [
353ffa53 49 'title' => ts('Record Respondents Interview'),
be2fb01f 50 'class' => [
6a488035
TO
51 'CRM_Campaign_Form_Task_Interview',
52 'CRM_Campaign_Form_Task_Release',
be2fb01f 53 ],
6a488035 54 'result' => FALSE,
be2fb01f
CW
55 ],
56 self::RESERVE => [
23546577 57 'title' => ts('Reserve Respondents'),
be2fb01f 58 'class' => [
6a488035
TO
59 'CRM_Campaign_Form_Task_Reserve',
60 'CRM_Campaign_Form_Task_Interview',
61 'CRM_Campaign_Form_Task_Release',
be2fb01f 62 ],
6a488035 63 'result' => FALSE,
be2fb01f
CW
64 ],
65 self::RELEASE => [
23546577 66 'title' => ts('Release Respondents'),
6a488035
TO
67 'class' => 'CRM_Campaign_Form_Task_Release',
68 'result' => FALSE,
be2fb01f
CW
69 ],
70 self::TASK_PRINT => [
23546577 71 'title' => ts('Print Respondents'),
6a488035
TO
72 'class' => 'CRM_Campaign_Form_Task_Print',
73 'result' => FALSE,
be2fb01f
CW
74 ],
75 ];
6a488035 76
5da76dbe 77 parent::tasks();
4d73a5a7 78 }
6a488035
TO
79
80 return self::$_tasks;
81 }
82
6a488035 83 /**
100fef9d 84 * Show tasks selectively based on the permission level
6a488035
TO
85 * of the user
86 *
87 * @param int $permission
5da76dbe 88 * @param array $params
6a488035 89 *
a6c01b45
CW
90 * @return array
91 * set of tasks that are valid for the user
6a488035 92 */
be2fb01f 93 public static function permissionedTaskTitles($permission, $params = []) {
6a488035
TO
94 $tasks = self::taskTitles();
95
5da76dbe 96 $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params);
6a488035
TO
97 return $tasks;
98 }
99
100 /**
101 * These tasks are the core set of tasks that the user can perform
102 * on voters.
103 *
104 * @param int $value
105 *
a6c01b45
CW
106 * @return array
107 * the set of tasks for a group of voters.
6a488035 108 */
00be9182 109 public static function getTask($value) {
6a488035 110 self::tasks();
b99f3e96 111 if (!$value || empty(self::$_tasks[$value])) {
5da76dbe
MW
112 // Set the interview task as default
113 $value = self::INTERVIEW;
6a488035
TO
114 }
115
be2fb01f 116 return [
6a488035
TO
117 self::$_tasks[$value]['class'],
118 self::$_tasks[$value]['result'],
be2fb01f 119 ];
6a488035 120 }
96025800 121
6a488035 122}