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