CRM-20312 regenerated DAOS with indexes
[civicrm-core.git] / CRM / Campaign / Task.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7e9e8871 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
0f03f337 6 | Copyright CiviCRM LLC (c) 2004-2017 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
0f03f337 31 * @copyright CiviCRM LLC (c) 2004-2017
6a488035
TO
32 */
33
34/**
df371444 35 * class to represent the actions that can be performed on a group of voters.
6a488035 36 *
df371444 37 * Used by the search forms.
6a488035
TO
38 */
39class CRM_Campaign_Task {
7da04cde 40 const INTERVIEW = 1, RESERVE = 2, RELEASE = 3, PRINT_VOTERS = 4;
6a488035
TO
41
42 /**
100fef9d 43 * The task array
6a488035
TO
44 *
45 * @var array
6a488035
TO
46 */
47 static $_tasks = NULL;
48
49 /**
100fef9d 50 * The optional task array
6a488035
TO
51 *
52 * @var array
6a488035
TO
53 */
54 static $_optionalTasks = NULL;
55
56 /**
57 * These tasks are the core set of tasks that the user can perform
58 * on a voter / group of voters
59 *
a6c01b45
CW
60 * @return array
61 * the set of tasks for a group of voters.
6a488035 62 */
00be9182 63 public static function &tasks() {
6a488035 64 if (!(self::$_tasks)) {
94880218 65 self::$_tasks = array(
353ffa53
TO
66 1 => array(
67 'title' => ts('Record Respondents Interview'),
6a488035
TO
68 'class' => array(
69 'CRM_Campaign_Form_Task_Interview',
70 'CRM_Campaign_Form_Task_Release',
71 ),
72 'result' => FALSE,
73 ),
23546577
CW
74 2 => array(
75 'title' => ts('Reserve Respondents'),
6a488035
TO
76 'class' => array(
77 'CRM_Campaign_Form_Task_Reserve',
78 'CRM_Campaign_Form_Task_Interview',
79 'CRM_Campaign_Form_Task_Release',
80 ),
81 'result' => FALSE,
82 ),
23546577
CW
83 3 => array(
84 'title' => ts('Release Respondents'),
6a488035
TO
85 'class' => 'CRM_Campaign_Form_Task_Release',
86 'result' => FALSE,
87 ),
23546577
CW
88 4 => array(
89 'title' => ts('Print Respondents'),
6a488035
TO
90 'class' => 'CRM_Campaign_Form_Task_Print',
91 'result' => FALSE,
92 ),
93 );
6a488035 94
4d73a5a7 95 CRM_Utils_Hook::searchTasks('campaign', self::$_tasks);
96 asort(self::$_tasks);
97 }
6a488035
TO
98
99 return self::$_tasks;
100 }
101
102 /**
103 * These tasks are the core set of task titles
104 * on voters.
105 *
a6c01b45
CW
106 * @return array
107 * the set of task titles
6a488035 108 */
00be9182 109 public static function &taskTitles() {
6a488035
TO
110 self::tasks();
111 $titles = array();
112 foreach (self::$_tasks as $id => $value) {
113 $titles[$id] = $value['title'];
114 }
115
116 return $titles;
117 }
118
119 /**
100fef9d 120 * Show tasks selectively based on the permission level
6a488035
TO
121 * of the user
122 *
123 * @param int $permission
124 *
a6c01b45
CW
125 * @return array
126 * set of tasks that are valid for the user
6a488035 127 */
00be9182 128 public static function &permissionedTaskTitles($permission) {
6a488035
TO
129 $tasks = self::taskTitles();
130
131 return $tasks;
132 }
133
134 /**
135 * These tasks are the core set of tasks that the user can perform
136 * on voters.
137 *
138 * @param int $value
139 *
a6c01b45
CW
140 * @return array
141 * the set of tasks for a group of voters.
6a488035 142 */
00be9182 143 public static function getTask($value) {
6a488035
TO
144 self::tasks();
145 if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
146 // make the interview task by default
147 $value = 1;
148 }
149
150 return array(
151 self::$_tasks[$value]['class'],
152 self::$_tasks[$value]['result'],
153 );
154 }
96025800 155
6a488035 156}