Merge pull request #15666 from revati90/shared_address
[civicrm-core.git] / CRM / Case / Selector / Search.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
f299f7db 6 | Copyright CiviCRM LLC (c) 2004-2020 |
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
f299f7db 31 * @copyright CiviCRM LLC (c) 2004-2020
6a488035
TO
32 */
33
34/**
67d19299 35 * This class is used to retrieve and display a range of contacts that match the given criteria.
6a488035
TO
36 */
37class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
38
39 /**
40 * This defines two actions- View and Edit.
41 *
42 * @var array
6a488035 43 */
f157740d 44 public static $_links = NULL;
6a488035 45
620d09f0
MWMC
46 /**
47 * The action links that we need to display for the browse screen.
48 *
49 * @var array
50 */
51 private static $_actionLinks;
52
6a488035 53 /**
100fef9d 54 * We use desc to remind us what that column is, name is used in the tpl
6a488035
TO
55 *
56 * @var array
6a488035 57 */
f157740d 58 public static $_columnHeaders;
6a488035
TO
59
60 /**
61 * Properties of contact we're interested in displaying
62 * @var array
6a488035 63 */
f157740d 64 public static $_properties = [
6a488035
TO
65 'contact_id',
66 'contact_type',
67 'sort_name',
68 'display_name',
69 'case_id',
70 'case_subject',
71 'case_status_id',
72 'case_status',
73 'case_type_id',
74 'case_type',
75 'case_role',
76 'phone',
be2fb01f 77 ];
6a488035
TO
78
79 /**
100fef9d 80 * Are we restricting ourselves to a single contact
6a488035 81 *
b67daa72 82 * @var bool
6a488035
TO
83 */
84 protected $_single = FALSE;
85
86 /**
100fef9d 87 * Are we restricting ourselves to a single contact
6a488035 88 *
b67daa72 89 * @var bool
6a488035
TO
90 */
91 protected $_limit = NULL;
92
93 /**
100fef9d 94 * What context are we being invoked from
6a488035 95 *
6a488035
TO
96 * @var string
97 */
98 protected $_context = NULL;
99
100 /**
100fef9d 101 * QueryParams is the array returned by exportValues called on
6a488035
TO
102 * the HTML_QuickForm_Controller for that page.
103 *
104 * @var array
6a488035
TO
105 */
106 public $_queryParams;
107
108 /**
100fef9d 109 * Represent the type of selector
6a488035
TO
110 *
111 * @var int
6a488035
TO
112 */
113 protected $_action;
114
115 /**
116 * The additional clause that we restrict the search with
117 *
118 * @var string
119 */
120 protected $_additionalClause = NULL;
121
122 /**
123 * The query object
124 *
125 * @var string
126 */
127 protected $_query;
128
129 /**
fe482240 130 * Class constructor.
6a488035 131 *
64bd5a0e
TO
132 * @param array $queryParams
133 * Array of parameters for query.
dd244018 134 * @param \const|int $action - action of search basic or advanced.
64bd5a0e
TO
135 * @param string $additionalClause
136 * If the caller wants to further restrict the search (used in participations).
137 * @param bool $single
138 * Are we dealing only with one contact?.
139 * @param int $limit
140 * How many signers do we want returned.
6a488035 141 *
dd244018
EM
142 * @param string $context
143 *
144 * @return \CRM_Case_Selector_Search
dd244018 145 */
8d7a9d07 146 public function __construct(
28d4d481 147 &$queryParams,
e547f744 148 $action = CRM_Core_Action::NONE,
6a488035 149 $additionalClause = NULL,
e547f744
TO
150 $single = FALSE,
151 $limit = NULL,
152 $context = 'search'
6a488035
TO
153 ) {
154 // submitted form values
155 $this->_queryParams = &$queryParams;
156
353ffa53
TO
157 $this->_single = $single;
158 $this->_limit = $limit;
6a488035
TO
159 $this->_context = $context;
160
161 $this->_additionalClause = $additionalClause;
162
163 // type of selector
164 $this->_action = $action;
165
166 $this->_query = new CRM_Contact_BAO_Query($this->_queryParams,
167 CRM_Case_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CASE,
168 FALSE
169 ),
170 NULL, FALSE, FALSE,
171 CRM_Contact_BAO_Query::MODE_CASE
172 );
173
174 $this->_query->_distinctComponentClause = " civicrm_case.id ";
175 $this->_query->_groupByComponentClause = " GROUP BY civicrm_case.id ";
176 }
6a488035
TO
177
178 /**
179 * This method returns the links that are given for each search row.
180 * currently the links added for each row are
181 *
182 * - View
183 * - Edit
184 *
da6b46f4
EM
185 * @param bool $isDeleted
186 * @param null $key
187 *
6a488035 188 * @return array
6a488035 189 */
f157740d 190 public static function &links($isDeleted = FALSE, $key = NULL) {
6a488035
TO
191 $extraParams = ($key) ? "&key={$key}" : NULL;
192
193 if ($isDeleted) {
be2fb01f
CW
194 self::$_links = [
195 CRM_Core_Action::RENEW => [
6a488035
TO
196 'name' => ts('Restore'),
197 'url' => 'civicrm/contact/view/case',
198 'qs' => 'reset=1&action=renew&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams,
199 'ref' => 'restore-case',
200 'title' => ts('Restore Case'),
be2fb01f
CW
201 ],
202 ];
6a488035
TO
203 }
204 else {
be2fb01f
CW
205 self::$_links = [
206 CRM_Core_Action::VIEW => [
6a488035
TO
207 'name' => ts('Manage'),
208 'url' => 'civicrm/contact/view/case',
209 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=case' . $extraParams,
210 'ref' => 'manage-case',
47f03411 211 'class' => 'no-popup',
6a488035 212 'title' => ts('Manage Case'),
be2fb01f
CW
213 ],
214 CRM_Core_Action::DELETE => [
6a488035
TO
215 'name' => ts('Delete'),
216 'url' => 'civicrm/contact/view/case',
217 'qs' => 'reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams,
218 'ref' => 'delete-case',
219 'title' => ts('Delete Case'),
be2fb01f
CW
220 ],
221 CRM_Core_Action::UPDATE => [
6a488035
TO
222 'name' => ts('Assign to Another Client'),
223 'url' => 'civicrm/contact/view/case/editClient',
224 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams,
225 'ref' => 'reassign',
a4400196 226 'class' => 'medium-popup',
6a488035 227 'title' => ts('Assign to Another Client'),
be2fb01f
CW
228 ],
229 ];
6a488035
TO
230 }
231
be2fb01f 232 $actionLinks = [];
6a488035 233 foreach (self::$_links as $key => $value) {
f6f26d03 234 $actionLinks['primaryActions'][$key] = $value;
6a488035
TO
235 }
236
237 return $actionLinks;
238 }
6a488035
TO
239
240 /**
100fef9d 241 * Getter for array of the parameters required for creating pager.
6a488035 242 *
fd31fa4c 243 * @param $action
c490a46a 244 * @param array $params
6a488035 245 */
00be9182 246 public function getPagerParams($action, &$params) {
6a488035
TO
247 $params['status'] = ts('Case') . ' %%StatusMessage%%';
248 $params['csvString'] = NULL;
249 if ($this->_limit) {
250 $params['rowCount'] = $this->_limit;
251 }
252 else {
253 $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
254 }
255
256 $params['buttonTop'] = 'PagerTopButton';
257 $params['buttonBottom'] = 'PagerBottomButton';
258 }
6a488035
TO
259
260 /**
261 * Returns total number of rows for the query.
262 *
263 * @param
264 *
a6c01b45
CW
265 * @return int
266 * Total number of rows
6a488035 267 */
00be9182 268 public function getTotalCount($action) {
6a488035
TO
269 return $this->_query->searchQuery(0, 0, NULL,
270 TRUE, FALSE,
271 FALSE, FALSE,
272 FALSE,
273 $this->_additionalClause
274 );
275 }
276
277 /**
fe482240 278 * Returns all the rows in the given offset and rowCount.
6a488035 279 *
3f8d2862 280 * @param string $action
64bd5a0e
TO
281 * The action being performed.
282 * @param int $offset
283 * The row number to start from.
284 * @param int $rowCount
285 * The number of rows to return.
286 * @param string $sort
287 * The sql string that describes the sort order.
3f8d2862 288 * @param string $output
64bd5a0e 289 * What should the result set include (web/email/csv).
6a488035 290 *
a6c01b45
CW
291 * @return int
292 * the total number of rows for this action
6a488035 293 */
00be9182 294 public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
6a488035
TO
295 $result = $this->_query->searchQuery($offset, $rowCount, $sort,
296 FALSE, FALSE,
297 FALSE, FALSE,
298 FALSE,
299 $this->_additionalClause
300 );
301 // process the result of the query
be2fb01f 302 $rows = [];
6a488035
TO
303
304 //CRM-4418 check for view, edit, delete
be2fb01f 305 $permissions = [CRM_Core_Permission::VIEW];
6a488035
TO
306 if (CRM_Core_Permission::check('access all cases and activities')
307 || CRM_Core_Permission::check('access my cases and activities')
308 ) {
309 $permissions[] = CRM_Core_Permission::EDIT;
310 }
311 if (CRM_Core_Permission::check('delete in CiviCase')) {
312 $permissions[] = CRM_Core_Permission::DELETE;
313 }
314 $mask = CRM_Core_Action::mask($permissions);
315
316 $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND v.name = 'Urgent' ");
317
be2fb01f 318 $scheduledInfo = [];
6a488035
TO
319
320 while ($result->fetch()) {
be2fb01f 321 $row = [];
6a488035
TO
322 // the columns we are interested in
323 foreach (self::$_properties as $property) {
324 if (isset($result->$property)) {
325 $row[$property] = $result->$property;
326 }
327 }
328
329 $isDeleted = FALSE;
330 if ($result->case_deleted) {
331 $isDeleted = TRUE;
c1c1b937 332 $row['case_status_id'] = empty($row['case_status_id']) ? "" : $row['case_status_id'] . '<br />' . ts('(deleted)');
6a488035
TO
333 }
334
335 $scheduledInfo['case_id'][] = $result->case_id;
336 $scheduledInfo['contact_id'][] = $result->contact_id;
337 $scheduledInfo['case_deleted'] = $result->case_deleted;
338 $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->case_id;
339
340 $links = self::links($isDeleted, $this->_key);
341 $row['action'] = CRM_Core_Action::formLink($links['primaryActions'],
be2fb01f 342 $mask, [
6a488035
TO
343 'id' => $result->case_id,
344 'cid' => $result->contact_id,
345 'cxt' => $this->_context,
be2fb01f 346 ],
87dab4a4
AH
347 ts('more'),
348 FALSE,
349 'case.selector.actions',
350 'Case',
351 $result->case_id
6a488035 352 );
6a488035 353
e547f744 354 $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type
6a488035
TO
355 );
356
357 //adding case manager to case selector.CRM-4510.
358 $caseType = CRM_Case_BAO_Case::getCaseType($result->case_id, 'name');
5757b086 359 $row['casemanager'] = CRM_Case_BAO_Case::getCaseManagerContact($caseType, $result->case_id);
6a488035
TO
360
361 if (isset($result->case_status_id) &&
362 array_key_exists($result->case_status_id, $caseStatus)
363 ) {
364 $row['class'] = "status-urgent";
365 }
366 else {
367 $row['class'] = "status-normal";
368 }
369
370 $rows[$result->case_id] = $row;
371 }
372
373 //retrive the scheduled & recent Activity type and date for selector
374 if (!empty($scheduledInfo)) {
375 $schdeduledActivity = CRM_Case_BAO_Case::getNextScheduledActivity($scheduledInfo, 'upcoming');
376 foreach ($schdeduledActivity as $key => $value) {
377 $rows[$key]['case_scheduled_activity_date'] = $value['date'];
378 $rows[$key]['case_scheduled_activity_type'] = $value['type'];
379 }
380 $recentActivity = CRM_Case_BAO_Case::getNextScheduledActivity($scheduledInfo, 'recent');
381 foreach ($recentActivity as $key => $value) {
382 $rows[$key]['case_recent_activity_date'] = $value['date'];
383 $rows[$key]['case_recent_activity_type'] = $value['type'];
384 }
385 }
386 return $rows;
387 }
388
389 /**
1054415f 390 * @inheritDoc
6a488035 391 */
6a488035
TO
392 public function getQILL() {
393 return $this->_query->qill();
394 }
395
396 /**
100fef9d 397 * Returns the column headers as an array of tuples:
6a488035
TO
398 * (name, sortName (key to the sort array))
399 *
64bd5a0e
TO
400 * @param string $action
401 * The action being performed.
3f8d2862 402 * @param string $output
64bd5a0e 403 * What should the result set include (web/email/csv).
6a488035 404 *
a6c01b45
CW
405 * @return array
406 * the column headers that need to be displayed
6a488035
TO
407 */
408 public function &getColumnHeaders($action = NULL, $output = NULL) {
409 if (!isset(self::$_columnHeaders)) {
be2fb01f
CW
410 self::$_columnHeaders = [
411 [
6a488035
TO
412 'name' => ts('Subject'),
413 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
414 ],
415 [
6a488035
TO
416 'name' => ts('Status'),
417 'sort' => 'case_status',
418 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
419 ],
420 [
6a488035 421 'name' => ts('Case Type'),
33a5a53d 422 'sort' => 'case_type',
6a488035 423 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
424 ],
425 [
6a488035
TO
426 'name' => ts('My Role'),
427 'sort' => 'case_role',
428 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
429 ],
430 [
6a488035
TO
431 'name' => ts('Case Manager'),
432 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
433 ],
434 [
6a488035
TO
435 'name' => ts('Most Recent'),
436 'sort' => 'case_recent_activity_date',
437 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
438 ],
439 [
6a488035
TO
440 'name' => ts('Next Sched.'),
441 'sort' => 'case_scheduled_activity_date',
442 'direction' => CRM_Utils_Sort::DONTCARE,
be2fb01f
CW
443 ],
444 ['name' => ts('Actions')],
445 ];
6a488035
TO
446
447 if (!$this->_single) {
be2fb01f
CW
448 $pre = [
449 [
6a488035
TO
450 'name' => ts('Client'),
451 'sort' => 'sort_name',
452 'direction' => CRM_Utils_Sort::ASCENDING,
be2fb01f
CW
453 ],
454 ];
6a488035
TO
455
456 self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
457 }
458 }
459 return self::$_columnHeaders;
460 }
461
4c6ce474
EM
462 /**
463 * @return mixed
464 */
00be9182 465 public function alphabetQuery() {
52cda5dc 466 return $this->_query->alphabetQuery();
6a488035
TO
467 }
468
4c6ce474
EM
469 /**
470 * @return string
471 */
00be9182 472 public function &getQuery() {
6a488035
TO
473 return $this->_query;
474 }
475
476 /**
100fef9d 477 * Name of export file.
6a488035 478 *
64bd5a0e
TO
479 * @param string $output
480 * Type of output.
6a488035 481 *
a6c01b45
CW
482 * @return string
483 * name of the file
6a488035 484 */
00be9182 485 public function getExportFileName($output = 'csv') {
6a488035
TO
486 return ts('Case Search');
487 }
96025800 488
d059df45
AH
489 /**
490 * Add the set of "actionLinks" to the case activity
491 *
492 * @param int $caseID
493 * @param int $contactID
494 * @param int $userID
495 * @param string $context
7bf3b68c
MWMC
496 * @param \CRM_Activity_BAO_Activity $dao
497 * @param bool $allowView
d059df45 498 *
7bf3b68c 499 * @return string $linksMarkup
d059df45 500 */
7bf3b68c 501 public static function addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao, $allowView = TRUE) {
d059df45 502 $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
7bf3b68c
MWMC
503 $actionLinks = self::actionLinks();
504 // Check logged in user for permission.
505 if (CRM_Case_BAO_Case::checkPermission($dao->id, 'view', $dao->activity_type_id, $userID)) {
506 $permissions[] = CRM_Core_Permission::VIEW;
507 }
508 if (!$allowView) {
509 unset($actionLinks[CRM_Core_Action::VIEW]);
d059df45 510 }
d059df45 511 if (!$dao->deleted) {
7bf3b68c
MWMC
512 // Activity is not deleted, allow user to edit/delete if they have permission
513 // hide Edit link if:
514 // 1. User does not have edit permission.
515 // 2. Activity type is NOT editable (special case activities).CRM-5871
516 if (CRM_Case_BAO_Case::checkPermission($dao->id, 'edit', $dao->activity_type_id, $userID)) {
517 $permissions[] = CRM_Core_Permission::EDIT;
d059df45 518 }
7bf3b68c
MWMC
519 if (in_array($dao->activity_type_id, CRM_Activity_BAO_Activity::getViewOnlyActivityTypeIDs())) {
520 unset($actionLinks[CRM_Core_Action::UPDATE]);
d059df45 521 }
7bf3b68c
MWMC
522 if (CRM_Case_BAO_Case::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID)) {
523 $permissions[] = CRM_Core_Permission::DELETE;
524 }
525 unset($actionLinks[CRM_Core_Action::RENEW]);
d059df45 526 }
7bf3b68c
MWMC
527 $extraMask = 0;
528 if ($dao->deleted && !$caseDeleted
529 && (CRM_Case_BAO_Case::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID))) {
530 // Case is not deleted but activity is.
531 // Allow user to restore activity if they have delete permissions
532 unset($actionLinks[CRM_Core_Action::DELETE]);
533 $extraMask = CRM_Core_Action::RENEW;
d059df45 534 }
7bf3b68c
MWMC
535 if (!CRM_Case_BAO_Case::checkPermission($dao->id, 'Move To Case', $dao->activity_type_id)) {
536 unset($actionLinks[CRM_Core_Action::DETACH]);
d059df45 537 }
7bf3b68c
MWMC
538 if (!CRM_Case_BAO_Case::checkPermission($dao->id, 'Copy To Case', $dao->activity_type_id)) {
539 unset($actionLinks[CRM_Core_Action::COPY]);
d059df45 540 }
7bf3b68c
MWMC
541 $actionMask = CRM_Core_Action::mask($permissions) | $extraMask;
542 $values = [
543 'aid' => $dao->id,
544 'cid' => $contactID,
545 'cxt' => empty($context) ? '' : "&context={$context}",
546 'caseid' => $caseID,
547 ];
548 $linksMarkup = CRM_Core_Action::formLink($actionLinks,
549 $actionMask,
550 $values,
551 ts('more'),
552 FALSE,
553 'case.tab.row',
554 'Activity',
555 $dao->id
556 );
d059df45
AH
557 // if there are file attachments we will return how many and, if only one, add a link to it
558 if (!empty($dao->attachment_ids)) {
7bf3b68c 559 $linksMarkup .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $dao->id));
d059df45 560 }
7bf3b68c
MWMC
561 return $linksMarkup;
562 }
d059df45 563
7bf3b68c
MWMC
564 /**
565 * @param int $caseID
566 * @param int $contactID
567 * @param int $userID
568 * @param string $context
569 * @param int $activityTypeID
570 * @param int $activityDeleted
571 * @param int $activityID
572 * @param bool $allowView
573 *
574 * @return array|null
575 */
576 public static function permissionedActionLinks($caseID, $contactID, $userID, $context, $activityTypeID, $activityDeleted, $activityID, $allowView = TRUE) {
577 $caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
578 $values = [
579 'aid' => $activityID,
580 'cid' => $contactID,
581 'cxt' => empty($context) ? '' : "&context={$context}",
582 'caseid' => $caseID,
583 ];
584 $actionLinks = self::actionLinks();
585
586 // Check logged in user for permission.
587 if (CRM_Case_BAO_Case::checkPermission($activityID, 'view', $activityTypeID, $userID)) {
588 $permissions[] = CRM_Core_Permission::VIEW;
589 }
590 if (!$allowView) {
591 unset($actionLinks[CRM_Core_Action::VIEW]);
592 }
593 if (!$activityDeleted) {
594 // Activity is not deleted, allow user to edit/delete if they have permission
595
596 // hide Edit link if:
597 // 1. User does not have edit permission.
598 // 2. Activity type is NOT editable (special case activities).CRM-5871
599 if (CRM_Case_BAO_Case::checkPermission($activityID, 'edit', $activityTypeID, $userID)) {
600 $permissions[] = CRM_Core_Permission::EDIT;
601 }
602 if (in_array($activityTypeID, CRM_Activity_BAO_Activity::getViewOnlyActivityTypeIDs())) {
603 unset($actionLinks[CRM_Core_Action::UPDATE]);
604 }
605 if (CRM_Case_BAO_Case::checkPermission($activityID, 'delete', $activityTypeID, $userID)) {
606 $permissions[] = CRM_Core_Permission::DELETE;
607 }
608 unset($actionLinks[CRM_Core_Action::RENEW]);
609 }
610 $extraMask = 0;
611 if ($activityDeleted && !$caseDeleted
612 && (CRM_Case_BAO_Case::checkPermission($activityID, 'delete', $activityTypeID, $userID))) {
613 // Case is not deleted but activity is.
614 // Allow user to restore activity if they have delete permissions
615 unset($actionLinks[CRM_Core_Action::DELETE]);
616 $extraMask = CRM_Core_Action::RENEW;
617 }
618 if (!CRM_Case_BAO_Case::checkPermission($activityID, 'Move To Case', $activityTypeID)) {
619 unset($actionLinks[CRM_Core_Action::DETACH]);
620 }
621 if (!CRM_Case_BAO_Case::checkPermission($activityID, 'Copy To Case', $activityTypeID)) {
622 unset($actionLinks[CRM_Core_Action::COPY]);
623 }
624
625 $actionMask = CRM_Core_Action::mask($permissions) | $extraMask;
626 return CRM_Core_Action::filterLinks($actionLinks, $actionMask, $values, 'case.activity', 'Activity', $activityID);
627 }
628
629 /**
630 * Get the action links for this page.
631 *
632 * @return array
633 */
634 public static function actionLinks() {
635 // check if variable _actionsLinks is populated
636 if (!isset(self::$_actionLinks)) {
637 self::$_actionLinks = [
638 CRM_Core_Action::VIEW => [
639 'name' => ts('View'),
640 'url' => 'civicrm/case/activity/view',
641 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&aid=%%aid%%',
642 'title' => ts('View'),
643 ],
644 CRM_Core_Action::UPDATE => [
645 'name' => ts('Edit'),
646 'url' => 'civicrm/case/activity',
647 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&id=%%aid%%&action=update%%cxt%%',
648 'title' => ts('Edit'),
649 'icon' => 'fa-pencil',
650 ],
651 CRM_Core_Action::DELETE => [
652 'name' => ts('Delete'),
653 'url' => 'civicrm/case/activity',
654 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&id=%%aid%%&action=delete%%cxt%%',
655 'title' => ts('Delete'),
656 'icon' => 'fa-trash',
657 ],
658 CRM_Core_Action::RENEW => [
659 'name' => ts('Restore'),
660 'url' => 'civicrm/case/activity',
661 'qs' => 'reset=1&cid=%%cid%%&caseid=%%caseid%%&id=%%aid%%&action=renew%%cxt%%',
662 'title' => ts('Restore'),
663 'icon' => 'fa-undo',
664 ],
665 CRM_Core_Action::DETACH => [
666 'name' => ts('Move To Case'),
667 'ref' => 'move_to_case_action',
668 'title' => ts('Move To Case'),
669 'extra' => 'onclick = "Javascript:fileOnCase( \'move\', %%aid%%, %%caseid%%, this ); return false;"',
670 'icon' => 'fa-clipboard',
671 ],
672 CRM_Core_Action::COPY => [
673 'name' => ts('Copy To Case'),
674 'ref' => 'copy_to_case_action',
675 'title' => ts('Copy To Case'),
676 'extra' => 'onclick = "Javascript:fileOnCase( \'copy\', %%aid%%, %%caseid%%, this ); return false;"',
677 'icon' => 'fa-files-o',
678 ],
679 ];
680 }
681 return self::$_actionLinks;
d059df45
AH
682 }
683
6a488035 684}