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