Merge pull request #11407 from cividesk/CRM-21553
[civicrm-core.git] / CRM / Member / Page / Tab.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
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 // Display Auto-renew status on page (0=disabled, 1=enabled, 2=enabled, but error
160 if (!empty($membership[$dao->id]['contribution_recur_id'])) {
161 if (CRM_Member_BAO_Membership::isSubscriptionCancelled($membership[$dao->id]['membership_id'])) {
162 $membership[$dao->id]['auto_renew'] = 2;
163 }
164 else {
165 $membership[$dao->id]['auto_renew'] = 1;
166 }
167 }
168 else {
169 $membership[$dao->id]['auto_renew'] = 0;
170 }
171
172 // if relevant--membership is active and type allows inheritance--count related memberships
173 if (CRM_Utils_Array::value('is_current_member', $statusANDType[$dao->id])
174 && CRM_Utils_Array::value('relationship_type_id', $statusANDType[$dao->id])
175 && empty($dao->owner_membership_id)
176 ) {
177 // not an related membership
178 $query = "
179 SELECT COUNT(m.id)
180 FROM civicrm_membership m
181 LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id
182 LEFT JOIN civicrm_contact ct ON ct.id = m.contact_id
183 WHERE m.owner_membership_id = {$dao->id} AND m.is_test = 0 AND ms.is_current_member = 1 AND ct.is_deleted = 0";
184 $num_related = CRM_Core_DAO::singleValueQuery($query);
185 $max_related = CRM_Utils_Array::value('max_related', $membership[$dao->id]);
186 $membership[$dao->id]['related_count'] = ($max_related == '' ? ts('%1 created', array(1 => $num_related)) : ts('%1 out of %2', array(
187 1 => $num_related,
188 2 => $max_related,
189 )));
190 }
191 else {
192 $membership[$dao->id]['related_count'] = ts('N/A');
193 }
194 }
195
196 //Below code gives list of all Membership Types associated
197 //with an Organization(CRM-2016)
198 $membershipTypesResult = civicrm_api3('MembershipType', 'get', array(
199 'member_of_contact_id' => $this->_contactId,
200 'options' => array(
201 'limit' => 0,
202 ),
203 ));
204 $membershipTypes = CRM_Utils_Array::value('values', $membershipTypesResult, NULL);
205
206 foreach ($membershipTypes as $key => $value) {
207 $membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(),
208 $mask,
209 array(
210 'id' => $value['id'],
211 'cid' => $this->_contactId,
212 ),
213 ts('more'),
214 FALSE,
215 'membershipType.organization.action',
216 'MembershipType',
217 $value['id']
218 );
219 }
220
221 $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership);
222 $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive');
223 $this->assign('activeMembers', $activeMembers);
224 $this->assign('inActiveMembers', $inActiveMembers);
225 $this->assign('membershipTypes', $membershipTypes);
226
227 if ($this->_contactId) {
228 $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
229 $this->assign('displayName', $displayName);
230 $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
231 // Refresh other tabs with related data
232 $this->ajaxResponse['updateTabs'] = array(
233 '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId),
234 '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId),
235 );
236 if (CRM_Core_Permission::access('CiviContribute')) {
237 $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
238 }
239 }
240 }
241
242 /**
243 * called when action is view.
244 *
245 * @return null
246 */
247 public function view() {
248 $controller = new CRM_Core_Controller_Simple(
249 'CRM_Member_Form_MembershipView',
250 ts('View Membership'),
251 $this->_action
252 );
253 $controller->setEmbedded(TRUE);
254 $controller->set('id', $this->_id);
255 $controller->set('cid', $this->_contactId);
256
257 return $controller->run();
258 }
259
260 /**
261 * called when action is update or new.
262 *
263 * @return null
264 */
265 public function edit() {
266 // set https for offline cc transaction
267 $mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
268 if ($mode == 'test' || $mode == 'live') {
269 CRM_Utils_System::redirectToSSL();
270 }
271
272 // build associated contributions ( note: this is called to show associated contributions in edit mode )
273 if ($this->_action & CRM_Core_Action::UPDATE) {
274 $this->assign('accessContribution', FALSE);
275 if (CRM_Core_Permission::access('CiviContribute')) {
276 $this->assign('accessContribution', TRUE);
277 CRM_Member_Page_Tab::associatedContribution($this->_contactId, $this->_id);
278
279 //show associated soft credit when contribution payment is paid by different person in edit mode
280 if ($this->_id && $this->_contactId) {
281 $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})";
282 $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter);
283 if (!empty($softCreditList)) {
284 $this->assign('softCredit', TRUE);
285 $this->assign('softCreditRows', $softCreditList);
286 }
287 }
288 }
289 }
290
291 if ($this->_action & CRM_Core_Action::RENEW) {
292 $path = 'CRM_Member_Form_MembershipRenewal';
293 $title = ts('Renew Membership');
294 }
295 else {
296 $path = 'CRM_Member_Form_Membership';
297 $title = ts('Create Membership');
298 }
299
300 $controller = new CRM_Core_Controller_Simple($path, $title, $this->_action);
301 $controller->setEmbedded(TRUE);
302 $controller->set('BAOName', $this->getBAOName());
303 $controller->set('id', $this->_id);
304 $controller->set('cid', $this->_contactId);
305 return $controller->run();
306 }
307
308 public function preProcess() {
309 $context = CRM_Utils_Request::retrieve('context', 'String', $this);
310 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
311 $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
312
313 if ($context == 'standalone') {
314 $this->_action = CRM_Core_Action::ADD;
315 }
316 else {
317 $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
318 $this->assign('contactId', $this->_contactId);
319
320 // check logged in url permission
321 CRM_Contact_Page_View::checkUserPermission($this);
322 }
323
324 $this->assign('action', $this->_action);
325
326 if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit memberships')) {
327 // demote to view since user does not have edit membership rights
328 $this->_permission = CRM_Core_Permission::VIEW;
329 $this->assign('permission', 'view');
330 }
331 }
332
333 /**
334 * the main function that is called when the page loads, it decides the which action has to be taken for the page.
335 *
336 * @return null
337 */
338 public function run() {
339 $this->preProcess();
340
341 // check if we can process credit card membership
342 $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments();
343 $this->assign('newCredit', $newCredit);
344
345 if ($newCredit) {
346 $this->_isPaymentProcessor = TRUE;
347 }
348 else {
349 $this->_isPaymentProcessor = FALSE;
350 }
351
352 // Only show credit card membership signup if user has CiviContribute permission
353 if (CRM_Core_Permission::access('CiviContribute')) {
354 $this->_accessContribution = TRUE;
355 $this->assign('accessContribution', TRUE);
356
357 //show associated soft credit when contribution payment is paid by different person
358 if ($this->_id && $this->_contactId) {
359 $filter = " AND cc.id IN (SELECT contribution_id FROM civicrm_membership_payment WHERE membership_id = {$this->_id})";
360 $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $filter);
361 if (!empty($softCreditList)) {
362 $this->assign('softCredit', TRUE);
363 $this->assign('softCreditRows', $softCreditList);
364 }
365 }
366 }
367 else {
368 $this->_accessContribution = FALSE;
369 $this->assign('accessContribution', FALSE);
370 $this->assign('softCredit', FALSE);
371 }
372
373 if ($this->_action & CRM_Core_Action::VIEW) {
374 $this->view();
375 }
376 elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
377 self::setContext($this);
378 $this->edit();
379 }
380 else {
381 self::setContext($this);
382 $this->browse();
383 }
384
385 return parent::run();
386 }
387
388 /**
389 * @param CRM_Core_Form $form
390 * @param int $contactId
391 */
392 public static function setContext(&$form, $contactId = NULL) {
393 $context = CRM_Utils_Request::retrieve('context', 'String', $form, FALSE, 'search');
394
395 $qfKey = CRM_Utils_Request::retrieve('key', 'String', $form);
396
397 $searchContext = CRM_Utils_Request::retrieve('searchContext', 'String', $form);
398
399 //validate the qfKey
400 if (!CRM_Utils_Rule::qfKey($qfKey)) {
401 $qfKey = NULL;
402 }
403
404 if (!$contactId) {
405 $contactId = $form->_contactId;
406 }
407
408 switch ($context) {
409 case 'dashboard':
410 $url = CRM_Utils_System::url('civicrm/member', 'reset=1');
411 break;
412
413 case 'membership':
414 $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$contactId}&selectedChild=member");
415 break;
416
417 case 'search':
418 $urlParams = 'force=1';
419 if ($qfKey) {
420 $urlParams .= "&qfKey=$qfKey";
421 }
422 $form->assign('searchKey', $qfKey);
423
424 if ($searchContext) {
425 $url = CRM_Utils_System::url("civicrm/$searchContext/search", $urlParams);
426 }
427 else {
428 $url = CRM_Utils_System::url('civicrm/member/search', $urlParams);
429 }
430 break;
431
432 case 'home':
433 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
434 break;
435
436 case 'activity':
437 $url = CRM_Utils_System::url('civicrm/contact/view',
438 "reset=1&force=1&cid={$contactId}&selectedChild=activity"
439 );
440 break;
441
442 case 'standalone':
443 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
444 break;
445
446 case 'fulltext':
447 $action = CRM_Utils_Request::retrieve('action', 'String', $form);
448 $keyName = '&qfKey';
449 $urlParams = 'force=1';
450 $urlString = 'civicrm/contact/search/custom';
451 if ($action == CRM_Core_Action::UPDATE) {
452 if ($form->_contactId) {
453 $urlParams .= '&cid=' . $form->_contactId;
454 }
455 $keyName = '&key';
456 $urlParams .= '&context=fulltext&action=view';
457 $urlString = 'civicrm/contact/view/membership';
458 }
459 if ($qfKey) {
460 $urlParams .= "$keyName=$qfKey";
461 }
462 $form->assign('searchKey', $qfKey);
463 $url = CRM_Utils_System::url($urlString, $urlParams);
464 break;
465
466 default:
467 $cid = NULL;
468 if ($contactId) {
469 $cid = '&cid=' . $contactId;
470 }
471 $url = CRM_Utils_System::url('civicrm/member/search', 'force=1' . $cid);
472 break;
473 }
474
475 $session = CRM_Core_Session::singleton();
476 $session->pushUserContext($url);
477 }
478
479 /**
480 * Get action links.
481 *
482 * @param string $status
483 * @param null $isPaymentProcessor
484 * @param null $accessContribution
485 * @param bool $isCancelSupported
486 * @param bool $isUpdateBilling
487 *
488 * @return array
489 * (reference) of action links
490 */
491 public static function &links(
492 $status = 'all',
493 $isPaymentProcessor = NULL,
494 $accessContribution = NULL,
495 $isCancelSupported = FALSE,
496 $isUpdateBilling = FALSE
497 ) {
498 if (!CRM_Utils_Array::value('view', self::$_links)) {
499 self::$_links['view'] = array(
500 CRM_Core_Action::VIEW => array(
501 'name' => ts('View'),
502 'url' => 'civicrm/contact/view/membership',
503 'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
504 'title' => ts('View Membership'),
505 ),
506 );
507 }
508
509 if (!CRM_Utils_Array::value('all', self::$_links)) {
510 $extraLinks = array(
511 CRM_Core_Action::UPDATE => array(
512 'name' => ts('Edit'),
513 'url' => 'civicrm/contact/view/membership',
514 'qs' => 'action=update&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
515 'title' => ts('Edit Membership'),
516 ),
517 CRM_Core_Action::RENEW => array(
518 'name' => ts('Renew'),
519 'url' => 'civicrm/contact/view/membership',
520 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
521 'title' => ts('Renew Membership'),
522 ),
523 CRM_Core_Action::FOLLOWUP => array(
524 'name' => ts('Renew-Credit Card'),
525 'url' => 'civicrm/contact/view/membership',
526 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member&mode=live',
527 'title' => ts('Renew Membership Using Credit Card'),
528 ),
529 CRM_Core_Action::DELETE => array(
530 'name' => ts('Delete'),
531 'url' => 'civicrm/contact/view/membership',
532 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member',
533 'title' => ts('Delete Membership'),
534 ),
535 );
536 if (!$isPaymentProcessor || !$accessContribution) {
537 //unset the renew with credit card when payment
538 //processor is not available or user is not permitted to create contributions
539 unset($extraLinks[CRM_Core_Action::FOLLOWUP]);
540 }
541 self::$_links['all'] = self::$_links['view'] + $extraLinks;
542 }
543
544 if ($isCancelSupported) {
545 $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.');
546 self::$_links['all'][CRM_Core_Action::DISABLE] = array(
547 'name' => ts('Cancel Auto-renewal'),
548 'url' => 'civicrm/contribute/unsubscribe',
549 'qs' => 'reset=1&cid=%%cid%%&mid=%%id%%&context=membership&selectedChild=member',
550 'title' => ts('Cancel Auto Renew Subscription'),
551 'extra' => 'onclick = "if (confirm(\'' . $cancelMessage . '\') ) { return true; else return false;}"',
552 );
553 }
554 elseif (isset(self::$_links['all'][CRM_Core_Action::DISABLE])) {
555 unset(self::$_links['all'][CRM_Core_Action::DISABLE]);
556 }
557
558 if ($isUpdateBilling) {
559 self::$_links['all'][CRM_Core_Action::MAP] = array(
560 'name' => ts('Change Billing Details'),
561 'url' => 'civicrm/contribute/updatebilling',
562 'qs' => 'reset=1&cid=%%cid%%&mid=%%id%%&context=membership&selectedChild=member',
563 'title' => ts('Change Billing Details'),
564 );
565 }
566 elseif (isset(self::$_links['all'][CRM_Core_Action::MAP])) {
567 unset(self::$_links['all'][CRM_Core_Action::MAP]);
568 }
569 return self::$_links[$status];
570 }
571
572 /**
573 * Define action links for membership types of related organization.
574 *
575 * @return array
576 * self::$_membershipTypesLinks array of action links
577 */
578 public static function &membershipTypesLinks() {
579 if (!self::$_membershipTypesLinks) {
580 self::$_membershipTypesLinks = array(
581 CRM_Core_Action::VIEW => array(
582 'name' => ts('Members'),
583 'url' => 'civicrm/member/search/',
584 'qs' => 'reset=1&force=1&type=%%id%%',
585 'title' => ts('Search'),
586 ),
587 CRM_Core_Action::UPDATE => array(
588 'name' => ts('Edit'),
589 'url' => 'civicrm/admin/member/membershipType',
590 'qs' => 'action=update&id=%%id%%&reset=1',
591 'title' => ts('Edit Membership Type'),
592 ),
593 );
594 }
595 return self::$_membershipTypesLinks;
596 }
597
598 /**
599 * used for the to show the associated.
600 * contribution for the membership
601 *
602 * @param int $contactId
603 * @param int $membershipId
604 */
605 public static function associatedContribution($contactId = NULL, $membershipId = NULL) {
606 $controller = new CRM_Core_Controller_Simple(
607 'CRM_Contribute_Form_Search',
608 ts('Contributions'),
609 NULL,
610 FALSE, FALSE, TRUE
611 );
612 $controller->setEmbedded(TRUE);
613 $controller->reset();
614 $controller->set('force', 1);
615 $controller->set('cid', $contactId);
616 $controller->set('memberId', $membershipId);
617 $controller->set('context', 'contribution');
618 $controller->process();
619 $controller->run();
620 }
621
622 /**
623 * Get BAO Name.
624 *
625 * @return string
626 * Classname of BAO.
627 */
628 public function getBAOName() {
629 return 'CRM_Member_BAO_Membership';
630 }
631
632 /**
633 * Get a list of links based on permissioned FTs.
634 *
635 * @param int $memTypeID
636 * membership type ID
637 * @param int $links
638 * (reference ) action links
639 */
640 public static function getPermissionedLinks($memTypeID, &$links) {
641 if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
642 return FALSE;
643 }
644 $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memTypeID, 'financial_type_id');
645 $finType = CRM_Contribute_PseudoConstant::financialType($finTypeId);
646 if (!CRM_Core_Permission::check('edit contributions of type ' . $finType)) {
647 unset($links[CRM_Core_Action::UPDATE]);
648 unset($links[CRM_Core_Action::RENEW]);
649 unset($links[CRM_Core_Action::FOLLOWUP]);
650 }
651 if (!CRM_Core_Permission::check('delete contributions of type ' . $finType)) {
652 unset($links[CRM_Core_Action::DELETE]);
653 }
654 }
655
656 }