more api comment fixes
[civicrm-core.git] / CRM / Activity / Task.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
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. |
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 along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
d25dd0ee 25 */
6a488035
TO
26
27/**
28 *
29 * @package CRM
06b69b18 30 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
31 * $Id$
32 *
33 */
34
35/**
36 * class to represent the actions that can be performed on a group of contacts
37 * used by the search forms
38 *
39 */
40class CRM_Activity_Task {
7da04cde 41 const
6a488035
TO
42 DELETE_ACTIVITIES = 1,
43 PRINT_ACTIVITIES = 2,
44 EXPORT_ACTIVITIES = 3,
45 BATCH_ACTIVITIES = 4,
46 EMAIL_CONTACTS = 5,
47 EMAIL_SMS = 6;
48
49 /**
100fef9d 50 * The task array
6a488035
TO
51 *
52 * @var array
6a488035
TO
53 */
54 static $_tasks = NULL;
55
56 /**
100fef9d 57 * The optional task array
6a488035
TO
58 *
59 * @var array
6a488035
TO
60 */
61 static $_optionalTasks = NULL;
62
63 /**
64 * These tasks are the core set of tasks that the user can perform
65 * on a contact / group of contacts
66 *
a6c01b45
CW
67 * @return array
68 * the set of tasks for a group of contacts
6a488035 69 */
00be9182 70 public static function &tasks() {
6a488035
TO
71 if (!(self::$_tasks)) {
72 self::$_tasks = array(
23546577
CW
73 1 => array(
74 'title' => ts('Delete Activities'),
6a488035
TO
75 'class' => 'CRM_Activity_Form_Task_Delete',
76 'result' => FALSE,
77 ),
23546577
CW
78 2 => array(
79 'title' => ts('Print Selected Rows'),
6a488035
TO
80 'class' => 'CRM_Activity_Form_Task_Print',
81 'result' => FALSE,
82 ),
23546577
CW
83 3 => array(
84 'title' => ts('Export Activities'),
6a488035
TO
85 'class' => array(
86 'CRM_Export_Form_Select',
87 'CRM_Export_Form_Map',
88 ),
89 'result' => FALSE,
90 ),
23546577
CW
91 4 => array(
92 'title' => ts('Batch Update Activities Via Profile'),
6a488035
TO
93 'class' => array(
94 'CRM_Activity_Form_Task_PickProfile',
95 'CRM_Activity_Form_Task_Batch',
96 ),
97 'result' => FALSE,
98 ),
23546577
CW
99 5 => array(
100 'title' => ts('Send Email to Contacts'),
6a488035
TO
101 'class' => array(
102 'CRM_Activity_Form_Task_PickOption',
103 'CRM_Activity_Form_Task_Email',
104 ),
105 'result' => FALSE,
106 ),
23546577
CW
107 6 => array(
108 'title' => ts('Send Reply SMS To Contacts'),
6a488035
TO
109 'class' => 'CRM_Activity_Form_Task_SMS',
110 'result' => FALSE,
111 ),
f70ca446
PN
112 7 => array(
113 'title' => ts('Tag Activities (assign tags)'),
114 'class' => 'CRM_Activity_Form_Task_AddToTag',
115 'result' => FALSE,
116 ),
117 8 => array(
118 'title' => ts('Untag Activities (remove tags)'),
119 'class' => 'CRM_Activity_Form_Task_RemoveFromTag',
120 'result' => FALSE,
121 ),
6a488035
TO
122 );
123
124 $config = CRM_Core_Config::singleton();
125 if (in_array('CiviCase', $config->enableComponents)) {
481a74f4 126 if (CRM_Core_Permission::check('access all cases and activities') ||
353ffa53
TO
127 CRM_Core_Permission::check('access my cases and activities')
128 ) {
23546577
CW
129 self::$_tasks[6] = array(
130 'title' => ts('File on Case'),
bbfeec41
BS
131 'class' => 'CRM_Activity_Form_Task_FileOnCase',
132 'result' => FALSE,
133 );
134 }
6a488035
TO
135 }
136
137 //CRM-4418, check for delete
138 if (!CRM_Core_Permission::check('delete activities')) {
139 unset(self::$_tasks[1]);
140 }
141 }
142 CRM_Utils_Hook::searchTasks('activity', self::$_tasks);
143 asort(self::$_tasks);
144 return self::$_tasks;
145 }
146
147 /**
148 * These tasks are the core set of task titles
149 * on activity
150 *
a6c01b45
CW
151 * @return array
152 * the set of task titles
6a488035 153 */
00be9182 154 public static function &taskTitles() {
6a488035
TO
155 self::tasks();
156 $titles = array();
157 foreach (self::$_tasks as $id => $value) {
e341bbee 158 $titles[$id] = $value['title'];
6a488035
TO
159 }
160 return $titles;
161 }
162
163 /**
100fef9d 164 * Show tasks selectively based on the permission level
6a488035
TO
165 * of the user
166 *
167 * @param int $permission
168 *
a6c01b45
CW
169 * @return array
170 * set of tasks that are valid for the user
6a488035 171 */
00be9182 172 public static function &permissionedTaskTitles($permission) {
6a488035
TO
173 $tasks = array();
174 if ($permission == CRM_Core_Permission::EDIT) {
175 $tasks = self::taskTitles();
176 }
177 else {
178 $tasks = array(
179 3 => self::$_tasks[3]['title'],
180 );
181
182 //CRM-4418,
183 if (CRM_Core_Permission::check('delete activities')) {
184 $tasks[1] = self::$_tasks[1]['title'];
185 }
186 }
187 return $tasks;
188 }
189
190 /**
191 * These tasks are the core set of tasks that the user can perform
192 * on activity
193 *
194 * @param int $value
195 *
a6c01b45
CW
196 * @return array
197 * the set of tasks for a group of activity
6a488035 198 */
00be9182 199 public static function getTask($value) {
6a488035
TO
200 self::tasks();
201 if (!$value || !CRM_Utils_Array::value($value, self::$_tasks)) {
202 // make the print task by default
203 $value = 2;
204 }
205 return array(
206 self::$_tasks[$value]['class'],
207 self::$_tasks[$value]['result'],
208 );
209 }
96025800 210
6a488035 211}