Merge pull request #9648 from MegaphoneJon/CRM-19608
[civicrm-core.git] / CRM / Member / Page / Tab.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
31 * @copyright CiviCRM LLC (c) 2004-2017
32 * $Id$
33 *
34 */
35 class CRM_Member_Page_Tab extends CRM_Core_Page {
36
37 /**
38 * The action links that we need to display for the browse screen.
39 *
40 * @var array
41 */
42 static $_links = NULL;
43 static $_membershipTypesLinks = NULL;
44
45 public $_permission = NULL;
46 public $_contactId = NULL;
47
48 /**
49 * called when action is browse.
50 */
51 public function browse() {
52 $links = self::links('all', $this->_isPaymentProcessor, $this->_accessContribution);
53 CRM_Financial_BAO_FinancialType::getAvailableMembershipTypes($membershipTypes);
54 $addWhere = "membership_type_id IN (0)";
55 if (!empty($membershipTypes)) {
56 $addWhere = "membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")";
57 }
58
59 $membership = array();
60 $dao = new CRM_Member_DAO_Membership();
61 $dao->contact_id = $this->_contactId;
62 $dao->is_test = 0;
63 $dao->whereAdd($addWhere);
64 //$dao->orderBy('name');
65 $dao->find();
66
67 //CRM--4418, check for view, edit, delete
68 $permissions = array(CRM_Core_Permission::VIEW);
69 if (CRM_Core_Permission::check('edit memberships')) {
70 $permissions[] = CRM_Core_Permission::EDIT;
71 }
72 if (CRM_Core_Permission::check('delete in CiviMember')) {
73 $permissions[] = CRM_Core_Permission::DELETE;
74 }
75 $mask = CRM_Core_Action::mask($permissions);
76
77 // get deceased status id
78 $allStatus = CRM_Member_PseudoConstant::membershipStatus();
79 $deceasedStatusId = array_search('Deceased', $allStatus);
80
81 //get all campaigns.
82 $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
83
84 //checks membership of contact itself
85 while ($dao->fetch()) {
86 $membership[$dao->id] = array();
87 CRM_Core_DAO::storeValues($dao, $membership[$dao->id]);
88
89 //carry campaign.
90 $membership[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns);
91
92 //get the membership status and type values.
93 $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id);
94 foreach (array('status', 'membership_type') as $fld) {
95 $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]);
96 }
97 if (!empty($statusANDType[$dao->id]['is_current_member'])) {
98 $membership[$dao->id]['active'] = TRUE;
99 }
100 if (empty($dao->owner_membership_id)) {
101 // unset renew and followup link for deceased membership
102 $currentMask = $mask;
103 if ($dao->status_id == $deceasedStatusId) {
104 $currentMask = $currentMask & ~CRM_Core_Action::RENEW & ~CRM_Core_Action::FOLLOWUP;
105 }
106
107 $isUpdateBilling = FALSE;
108 // It would be better to determine if there is a recurring contribution &
109 // is so get the entity for the recurring contribution (& skip if not).
110 $paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity(
111 $membership[$dao->id]['membership_id'], 'membership', 'obj');
112 if (!empty($paymentObject)) {
113 // @todo - get this working with syntax style $paymentObject->supports(array
114 //('updateSubscriptionBillingInfo'));
115 $isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
116 }
117
118 // @todo - get this working with syntax style $paymentObject->supports(array
119 //('CancelSubscriptionSupported'));
120 $isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported(
121 $membership[$dao->id]['membership_id']);
122 $links = self::links('all',
123 NULL,
124 NULL,
125 $isCancelSupported,
126 $isUpdateBilling
127 );
128 self::getPermissionedLinks($dao->membership_type_id, $links);
129 $membership[$dao->id]['action'] = CRM_Core_Action::formLink($links,
130 $currentMask,
131 array(
132 'id' => $dao->id,
133 'cid' => $this->_contactId,
134 ),
135 ts('Renew') . '...',
136 FALSE,
137 'membership.tab.row',
138 'Membership',
139 $dao->id
140 );
141 }
142 else {
143 $links = self::links('view');
144 self::getPermissionedLinks($dao->membership_type_id, $links);
145 $membership[$dao->id]['action'] = CRM_Core_Action::formLink($links,
146 $mask,
147 array(
148 'id' => $dao->id,
149 'cid' => $this->_contactId,
150 ),
151 ts('more'),
152 FALSE,
153 'membership.tab.row',
154 'Membership',
155 $dao->id
156 );
157 }
158
159 //does membership have auto renew CRM-7137.
160 if (!empty($membership[$dao->id]['contribution_recur_id']) &&
161 !CRM_Member_BAO_Membership::isSubscriptionCancelled($membership[$dao->id]['membership_id'])
162 ) {
163 $membership[$dao->id]['auto_renew'] = 1;
164 }
165 else {
166 $membership[$dao->id]['auto_renew'] = 0;
167 }
168
169 // if relevant--membership is active and type allows inheritance--count related memberships
170 if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id])
171 && CRM_Utils_Array::value('relationship_type_id', $statusANDType[$dao->id])
172 && empty($dao->owner_membership_id)
173 ) {
174 // not an related membership
175 $query = "
176 SELECT COUNT(m.id)
177 FROM civicrm_membership m
178 LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id
179 LEFT JOIN civicrm_contact ct ON ct.id = m.contact_id
180 WHERE m.owner_membership_id = {$dao->id} AND m.is_test = 0 AND ms.is_current_member = 1 AND ct.is_deleted = 0";
181 $num_related = CRM_Core_DAO::singleValueQuery($query);
182 $max_related = CRM_Utils_Array::value('max_related', $membership[$dao->id]);
183 $membership[$dao->id]['related_count'] = ($max_related == '' ? ts('%1 created', array(1 => $num_related)) : ts('%1 out of %2', array(
184 1 => $num_related,
185 2 => $max_related,
186 )));
187 }
188 else {
189 $membership[$dao->id]['related_count'] = ts('N/A');
190 }
191 }
192
193 //Below code gives list of all Membership Types associated
194 //with an Organization(CRM-2016)
195 $membershipTypesResult = civicrm_api3('MembershipType', 'get', array(
196 'member_of_contact_id' => $this->_contactId,
197 'options' => array(
198 'limit' => 0,
199 ),
200 ));
201 $membershipTypes = CRM_Utils_Array::value('values', $membershipTypesResult, NULL);
202
203 foreach ($membershipTypes as $key => $value) {
204 $membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(),
205 $mask,
206 array(
207 'id' => $value['id'],
208 'cid' => $this->_contactId,
209 ),
210 ts('more'),
211 FALSE,
212 'membershipType.organization.action',
213 'MembershipType',
214 $value['id']
215 );
216 }
217
218 $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
219 $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
220 $this->assign('activeMembers', $activeMembers);
221 $this->assign('inActiveMembers', $inActiveMembers);
222 $this->assign('membershipTypes', $membershipTypes);
223
224 if ($this->_contactId) {
225 $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
226 $this->assign('displayName', $displayName);
227 $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
228 // Refresh other tabs with related data
229 $this->ajaxResponse['updateTabs'] = array(
230 '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId),
231 '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId),
232 );
233 if (CRM_Core_Permission::access('CiviContribute')) {
234 $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
235 }
236 }
237 }
238
239 /**
240 * called when action is view.
241 *
242 * @return null
243 */
244 public function view() {
245 $controller = new CRM_Core_Controller_Simple(
246 'CRM_Member_Form_MembershipView',
247 ts('View Membership'),
248 $this->_action
249 );
250 $controller->setEmbedded(TRUE);
251 $controller->set('id', $this->_id);
252 $controller->set('cid', $this->_contactId);
253
254 return $controller->run();
255 }
256
257 /**
258 * called when action is update or new.
259 *
260 * @return null
261 */
262 public function edit() {
263 // set https for offline cc transaction
264 $mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
265 if ($mode == 'test' || $mode == 'live') {
266 CRM_Utils_System::redirectToSSL();
267 }
268
269 // build associated contributions ( note: this is called to show associated contributions in edit mode )
270 if ($this->_action & CRM_Core_Action::UPDATE) {
271 $this->assign('accessContribution', FALSE);
272 if (CRM_Core_Permission::access('CiviContribute')) {
273 $this->assign('accessContribution', TRUE);
274 CRM_Member_Page_Tab::associatedContribution($this->_contactId, $this->_id);
275
276 //show associated soft credit when contribution payment is paid by different person in edit mode
277 if ($this->_id && $this->_contactId) {
278 $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})";
279 $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter);
280 if (!empty($softCreditList)) {
281 $this->assign('softCredit', TRUE);
282 $this->assign('softCreditRows', $softCreditList);
283 }
284 }
285 }
286 }
287
288 if ($this->_action & CRM_Core_Action::RENEW) {
289 $path = 'CRM_Member_Form_MembershipRenewal';
290 $title = ts('Renew Membership');
291 }
292 else {
293 $path = 'CRM_Member_Form_Membership';
294 $title = ts('Create Membership');
295 }
296
297 $controller = new CRM_Core_Controller_Simple($path, $title, $this->_action);
298 $controller->setEmbedded(TRUE);
299 $controller->set('BAOName', $this->getBAOName());
300 $controller->set('id', $this->_id);
301 $controller->set('cid', $this->_contactId);
302 return $controller->run();
303 }
304
305 public function preProcess() {
306 $context = CRM_Utils_Request::retrieve('context', 'String', $this);
307 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
308 $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
309
310 if ($context == 'standalone') {
311 $this->_action = CRM_Core_Action::ADD;
312 }
313 else {
314 $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
315 $this->assign('contactId', $this->_contactId);
316
317 // check logged in url permission
318 CRM_Contact_Page_View::checkUserPermission($this);
319 }
320
321 $this->assign('action', $this->_action);
322
323 if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit memberships')) {
324 // demote to view since user does not have edit membership rights
325 $this->_permission = CRM_Core_Permission::VIEW;
326 $this->assign('permission', 'view');
327 }
328 }
329
330 /**
331 * the main function that is called when the page loads, it decides the which action has to be taken for the page.
332 *
333 * @return null
334 */
335 public function run() {
336 $this->preProcess();
337
338 // check if we can process credit card membership
339 $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments();
340 $this->assign('newCredit', $newCredit);
341
342 if ($newCredit) {
343 $this->_isPaymentProcessor = TRUE;
344 }
345 else {
346 $this->_isPaymentProcessor = FALSE;
347 }
348
349 // Only show credit card membership signup if user has CiviContribute permission
350 if (CRM_Core_Permission::access('CiviContribute')) {
351 $this->_accessContribution = TRUE;
352 $this->assign('accessContribution', TRUE);
353
354 //show associated soft credit when contribution payment is paid by different person
355 if ($this->_id && $this->_contactId) {
356 $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})";
357 $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter);
358 if (!empty($softCreditList)) {
359 $this->assign('softCredit', TRUE);
360 $this->assign('softCreditRows', $softCreditList);
361 }
362 }
363 }
364 else {
365 $this->_accessContribution = FALSE;
366 $this->assign('accessContribution', FALSE);
367 $this->assign('softCredit', FALSE);
368 }
369
370 if ($this->_action & CRM_Core_Action::VIEW) {
371 $this->view();
372 }
373 elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
374 self::setContext($this);
375 $this->edit();
376 }
377 else {
378 self::setContext($this);
379 $this->browse();
380 }
381
382 return parent::run();
383 }
384
385 /**
386 * @param CRM_Core_Form $form
387 * @param int $contactId
388 */
389 public static function setContext(&$form, $contactId = NULL) {
390 $context = CRM_Utils_Request::retrieve('context', 'String', $form, FALSE, 'search');
391
392 $qfKey = CRM_Utils_Request::retrieve('key', 'String', $form);
393
394 $searchContext = CRM_Utils_Request::retrieve('searchContext', 'String', $form);
395
396 //validate the qfKey
397 if (!CRM_Utils_Rule::qfKey($qfKey)) {
398 $qfKey = NULL;
399 }
400
401 if (!$contactId) {
402 $contactId = $form->_contactId;
403 }
404
405 switch ($context) {
406 case 'dashboard':
407 $url = CRM_Utils_System::url('civicrm/member', 'reset=1');
408 break;
409
410 case 'membership':
411 $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$contactId}&selectedChild=member");
412 break;
413
414 case 'search':
415 $urlParams = 'force=1';
416 if ($qfKey) {
417 $urlParams .= "&qfKey=$qfKey";
418 }
419 $form->assign('searchKey', $qfKey);
420
421 if ($searchContext) {
422 $url = CRM_Utils_System::url("civicrm/$searchContext/search", $urlParams);
423 }
424 else {
425 $url = CRM_Utils_System::url('civicrm/member/search', $urlParams);
426 }
427 break;
428
429 case 'home':
430 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
431 break;
432
433 case 'activity':
434 $url = CRM_Utils_System::url('civicrm/contact/view',
435 "reset=1&force=1&cid={$contactId}&selectedChild=activity"
436 );
437 break;
438
439 case 'standalone':
440 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
441 break;
442
443 case 'fulltext':
444 $action = CRM_Utils_Request::retrieve('action', 'String', $form);
445 $keyName = '&qfKey';
446 $urlParams = 'force=1';
447 $urlString = 'civicrm/contact/search/custom';
448 if ($action == CRM_Core_Action::UPDATE) {
449 if ($form->_contactId) {
450 $urlParams .= '&cid=' . $form->_contactId;
451 }
452 $keyName = '&key';
453 $urlParams .= '&context=fulltext&action=view';
454 $urlString = 'civicrm/contact/view/membership';
455 }
456 if ($qfKey) {
457 $urlParams .= "$keyName=$qfKey";
458 }
459 $form->assign('searchKey', $qfKey);
460 $url = CRM_Utils_System::url($urlString, $urlParams);
461 break;
462
463 default:
464 $cid = NULL;
465 if ($contactId) {
466 $cid = '&cid=' . $contactId;
467 }
468 $url = CRM_Utils_System::url('civicrm/member/search', 'force=1' . $cid);
469 break;
470 }
471
472 $session = CRM_Core_Session::singleton();
473 $session->pushUserContext($url);
474 }
475
476 /**
477 * Get action links.
478 *
479 * @param string $status
480 * @param null $isPaymentProcessor
481 * @param null $accessContribution
482 * @param bool $isCancelSupported
483 * @param bool $isUpdateBilling
484 *
485 * @return array
486 * (reference) of action links
487 */
488 public static function &links(
489 $status = 'all',
490 $isPaymentProcessor = NULL,
491 $accessContribution = NULL,
492 $isCancelSupported = FALSE,
493 $isUpdateBilling = FALSE
494 ) {
495 if (!CRM_Utils_Array::value('view', self::$_links)) {
496 self::$_links['view'] = array(
497 CRM_Core_Action::VIEW => array(
498 'name' => ts('View'),
499 'url' => 'civicrm/contact/view/membership',
500 'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
501 'title' => ts('View Membership'),
502 ),
503 );
504 }
505
506 if (!CRM_Utils_Array::value('all', self::$_links)) {
507 $extraLinks = array(
508 CRM_Core_Action::UPDATE => array(
509 'name' => ts('Edit'),
510 'url' => 'civicrm/contact/view/membership',
511 'qs' => 'action=update&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
512 'title' => ts('Edit Membership'),
513 ),
514 CRM_Core_Action::RENEW => array(
515 'name' => ts('Renew'),
516 'url' => 'civicrm/contact/view/membership',
517 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
518 'title' => ts('Renew Membership'),
519 ),
520 CRM_Core_Action::FOLLOWUP => array(
521 'name' => ts('Renew-Credit Card'),
522 'url' => 'civicrm/contact/view/membership',
523 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member&mode=live',
524 'title' => ts('Renew Membership Using Credit Card'),
525 ),
526 CRM_Core_Action::DELETE => array(
527 'name' => ts('Delete'),
528 'url' => 'civicrm/contact/view/membership',
529 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
530 'title' => ts('Delete Membership'),
531 ),
532 );
533 if (!$isPaymentProcessor || !$accessContribution) {
534 //unset the renew with credit card when payment
535 //processor is not available or user is not permitted to create contributions
536 unset($extraLinks[CRM_Core_Action::FOLLOWUP]);
537 }
538 self::$_links['all'] = self::$_links['view'] + $extraLinks;
539 }
540
541 if ($isCancelSupported) {
542 $cancelMessage = ts('WARNING: If you cancel the recurring contribution associated with this membership, the membership will no longer be renewed automatically. However, the current membership status will not be affected.');
543 self::$_links['all'][CRM_Core_Action::DISABLE] = array(
544 'name' => ts('Cancel Auto-renewal'),
545 'url' => 'civicrm/contribute/unsubscribe',
546 'qs' => 'reset=1&cid=%%cid%%&mid=%%id%%&context=membership&selectedChild=member',
547 'title' => ts('Cancel Auto Renew Subscription'),
548 'extra' => 'onclick = "if (confirm(\'' . $cancelMessage . '\') ) { return true; else return false;}"',
549 );
550 }
551 elseif (isset(self::$_links['all'][CRM_Core_Action::DISABLE])) {
552 unset(self::$_links['all'][CRM_Core_Action::DISABLE]);
553 }
554
555 if ($isUpdateBilling) {
556 self::$_links['all'][CRM_Core_Action::MAP] = array(
557 'name' => ts('Change Billing Details'),
558 'url' => 'civicrm/contribute/updatebilling',
559 'qs' => 'reset=1&cid=%%cid%%&mid=%%id%%&context=membership&selectedChild=member',
560 'title' => ts('Change Billing Details'),
561 );
562 }
563 elseif (isset(self::$_links['all'][CRM_Core_Action::MAP])) {
564 unset(self::$_links['all'][CRM_Core_Action::MAP]);
565 }
566 return self::$_links[$status];
567 }
568
569 /**
570 * Define action links for membership types of related organization.
571 *
572 * @return array
573 * self::$_membershipTypesLinks array of action links
574 */
575 public static function &membershipTypesLinks() {
576 if (!self::$_membershipTypesLinks) {
577 self::$_membershipTypesLinks = array(
578 CRM_Core_Action::VIEW => array(
579 'name' => ts('Members'),
580 'url' => 'civicrm/member/search/',
581 'qs' => 'reset=1&force=1&type=%%id%%',
582 'title' => ts('Search'),
583 ),
584 CRM_Core_Action::UPDATE => array(
585 'name' => ts('Edit'),
586 'url' => 'civicrm/admin/member/membershipType',
587 'qs' => 'action=update&id=%%id%%&reset=1',
588 'title' => ts('Edit Membership Type'),
589 ),
590 );
591 }
592 return self::$_membershipTypesLinks;
593 }
594
595 /**
596 * used for the to show the associated.
597 * contribution for the membership
598 *
599 * @param int $contactId
600 * @param int $membershipId
601 */
602 public static function associatedContribution($contactId = NULL, $membershipId = NULL) {
603 $controller = new CRM_Core_Controller_Simple(
604 'CRM_Contribute_Form_Search',
605 ts('Contributions'),
606 NULL,
607 FALSE, FALSE, TRUE
608 );
609 $controller->setEmbedded(TRUE);
610 $controller->reset();
611 $controller->set('force', 1);
612 $controller->set('cid', $contactId);
613 $controller->set('memberId', $membershipId);
614 $controller->set('context', 'contribution');
615 $controller->process();
616 $controller->run();
617 }
618
619 /**
620 * Get BAO Name.
621 *
622 * @return string
623 * Classname of BAO.
624 */
625 public function getBAOName() {
626 return 'CRM_Member_BAO_Membership';
627 }
628
629 /**
630 * Get a list of links based on permissioned FTs.
631 *
632 * @param int $memTypeID
633 * membership type ID
634 * @param int $links
635 * (reference ) action links
636 */
637 public static function getPermissionedLinks($memTypeID, &$links) {
638 if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
639 return FALSE;
640 }
641 $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memTypeID, 'financial_type_id');
642 $finType = CRM_Contribute_PseudoConstant::financialType($finTypeId);
643 if (!CRM_Core_Permission::check('edit contributions of type ' . $finType)) {
644 unset($links[CRM_Core_Action::UPDATE]);
645 unset($links[CRM_Core_Action::RENEW]);
646 unset($links[CRM_Core_Action::FOLLOWUP]);
647 }
648 if (!CRM_Core_Permission::check('delete contributions of type ' . $finType)) {
649 unset($links[CRM_Core_Action::DELETE]);
650 }
651 }
652
653 }