dev/financial#6 exclude template contributions from the contact summary and add a...
[civicrm-core.git] / CRM / Contribute / Page / Tab.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17class CRM_Contribute_Page_Tab extends CRM_Core_Page {
18
19 /**
04d15518 20 * The permission we have on this contact
6a488035 21 *
04d15518 22 * @var string
6a488035 23 */
6a488035 24 public $_permission = NULL;
04d15518
MWMC
25
26 /**
27 * The contact ID for the contributions we are acting on
28 * @var int
29 */
6a488035 30 public $_contactId = NULL;
04d15518
MWMC
31
32 /**
33 * The recurring contribution ID (if any)
34 * @var int
35 */
6a488035
TO
36 public $_crid = NULL;
37
6a488035
TO
38 /**
39 * This method returns the links that are given for recur search row.
40 * currently the links added for each row are:
41 * - View
42 * - Edit
43 * - Cancel
44 *
57ee0d9b 45 * @param int $recurID
6c8f6e67
EM
46 * @param string $context
47 *
6a488035 48 * @return array
6a488035 49 */
57ee0d9b 50 public static function recurLinks(int $recurID, $context = 'contribution') {
2a7f3ed7 51 $paymentProcessorObj = Civi\Payment\System::singleton()->getById(CRM_Contribute_BAO_ContributionRecur::getPaymentProcessorID($recurID));
f35ca929 52 $templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($recurID);
04d15518
MWMC
53 $links = [
54 CRM_Core_Action::VIEW => [
55 'name' => ts('View'),
56 'title' => ts('View Recurring Payment'),
57 'url' => 'civicrm/contact/view/contributionrecur',
58 'qs' => "reset=1&id=%%crid%%&cid=%%cid%%&context={$context}",
59 ],
2a7f3ed7 60 ];
f35ca929
JJ
61 if (!empty($templateContribution['id'])) {
62 // Use constant CRM_Core_Action::PREVIEW as there is no such thing as view template.
63 // And reusing view will mangle the actions.
64 $links[CRM_Core_Action::PREVIEW] = [
65 'name' => ts('View Template'),
66 'title' => ts('View Template Contribution'),
67 'url' => 'civicrm/contact/view/contribution',
68 'qs' => "reset=1&id={$templateContribution['id']}&cid=%%cid%%&action=view&context={$context}",
69 ];
70 }
2a7f3ed7 71 if (
72 (CRM_Core_Permission::check('edit contributions') || $context !== 'contribution') &&
73 ($paymentProcessorObj->supports('ChangeSubscriptionAmount')
74 || $paymentProcessorObj->supports('EditRecurringContribution')
75 )) {
76 $links[CRM_Core_Action::UPDATE] = [
04d15518
MWMC
77 'name' => ts('Edit'),
78 'title' => ts('Edit Recurring Payment'),
79 'url' => 'civicrm/contribute/updaterecur',
80 'qs' => "reset=1&action=update&crid=%%crid%%&cid=%%cid%%&context={$context}",
2a7f3ed7 81 ];
82 }
83
84 $links[CRM_Core_Action::DISABLE] = [
85 'name' => ts('Cancel'),
86 'title' => ts('Cancel'),
87 'ref' => 'crm-enable-disable',
04d15518 88 ];
6a488035 89
57ee0d9b 90 if ($paymentProcessorObj->supports('cancelRecurring')) {
91 unset($links[CRM_Core_Action::DISABLE]['extra'], $links[CRM_Core_Action::DISABLE]['ref']);
92 $links[CRM_Core_Action::DISABLE]['url'] = "civicrm/contribute/unsubscribe";
93 $links[CRM_Core_Action::DISABLE]['qs'] = "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}";
94 }
04d15518 95
57ee0d9b 96 if ($paymentProcessorObj->supports('UpdateSubscriptionBillingInfo')) {
97 $links[CRM_Core_Action::RENEW] = [
98 'name' => ts('Change Billing Details'),
99 'title' => ts('Change Billing Details'),
100 'url' => 'civicrm/contribute/updatebilling',
101 'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}",
102 ];
103 }
f68ea0a7 104
04d15518 105 return $links;
6a488035 106 }
6a488035 107
2d852c61 108 /**
109 * Get the recur links to return for self service.
110 *
111 * These are the links to present to a logged in user wishing
112 * to service their own
113 *
114 * @param int $recurID
115 *
116 * @return array|array[]
117 * @throws \CRM_Core_Exception
118 * @throws \CiviCRM_API3_Exception
119 */
120 public static function selfServiceRecurLinks(int $recurID): array {
121 $links = [];
122 $paymentProcessorObj = Civi\Payment\System::singleton()->getById(CRM_Contribute_BAO_ContributionRecur::getPaymentProcessorID($recurID));
123 if ($paymentProcessorObj->supports('cancelRecurring')
124 && $paymentProcessorObj->subscriptionURL($recurID, 'recur', 'cancel')
125 ) {
126 $url = $paymentProcessorObj->subscriptionURL($recurID, 'recur', 'cancel');
127 $links[CRM_Core_Action::DISABLE] = [
128 'url' => $url,
129 'name' => ts('Cancel'),
130 'title' => ts('Cancel'),
131 // Only display on-site links in a popup.
132 'class' => (stripos($url, 'http') !== FALSE) ? 'no-popup' : '',
133 ];
134 }
135
136 if ($paymentProcessorObj->supports('UpdateSubscriptionBillingInfo')
137 && $paymentProcessorObj->subscriptionURL($recurID, 'recur', 'billing')
138 ) {
139 $url = $paymentProcessorObj->subscriptionURL($recurID, 'recur', 'billing');
140 $links[CRM_Core_Action::RENEW] = [
141 'name' => ts('Change Billing Details'),
142 'title' => ts('Change Billing Details'),
143 'url' => $url,
144 // Only display on-site links in a popup.
145 'class' => (stripos($url, 'http') !== FALSE) ? 'no-popup' : '',
146 ];
147 }
148
149 if (($paymentProcessorObj->supports('ChangeSubscriptionAmount')
150 || $paymentProcessorObj->supports('EditRecurringContribution'))
151 && $paymentProcessorObj->subscriptionURL($recurID, 'recur', 'update')
152 ) {
153 $url = $paymentProcessorObj->subscriptionURL($recurID, 'recur', 'update');
154 $links[CRM_Core_Action::UPDATE] = [
155 'name' => ts('Edit'),
156 'title' => ts('Edit Recurring Payment'),
157 'url' => $url,
158 // Only display on-site links in a popup.
159 'class' => (stripos($url, 'http') !== FALSE) ? 'no-popup' : '',
160 ];
161 }
162 return $links;
163 }
164
165 /**
166 * Get recurring links appropriate to viewing a user dashboard.
167 *
168 * A contact should be able to see links appropriate to them (e.g
169 * payment processor cancel page) if viewing their own dashboard and
170 * links appropriate to the contact they are viewing, if they have
171 * permission, if viewing another user.
172 *
173 * @param int $recurID
174 * @param int $contactID
175 *
176 * @return array|array[]
177 * @throws \CRM_Core_Exception
178 * @throws \CiviCRM_API3_Exception
179 */
180 public static function dashboardRecurLinks(int $recurID, int $contactID): array {
181 $links = [];
182 if ($contactID && $contactID === CRM_Core_Session::getLoggedInContactID()) {
183 $links = self::selfServiceRecurLinks($recurID);
184 }
185 $links += self::recurLinks($recurID, 'dashboard');
186 return $links;
187 }
188
6a488035 189 /**
fe482240 190 * called when action is browse.
6a488035 191 *
6a488035 192 */
00be9182 193 public function browse() {
6a488035 194 // add annual contribution
be2fb01f 195 $annual = [];
2a7f3ed7 196 [$annual['count'], $annual['amount'], $annual['avg']] = CRM_Contribute_BAO_Contribution::annual($this->_contactId);
6a488035
TO
197 $this->assign('annual', $annual);
198
199 $controller = new CRM_Core_Controller_Simple(
200 'CRM_Contribute_Form_Search',
201 ts('Contributions'),
202 $this->_action,
203 FALSE, FALSE, TRUE
204 );
205 $controller->setEmbedded(TRUE);
206 $controller->reset();
207 $controller->set('cid', $this->_contactId);
208 $controller->set('crid', $this->_crid);
7a49693c 209 $controller->set('context', 'contribution');
c2874d9c 210 $controller->set('limit', 50);
6a488035
TO
211 $controller->process();
212 $controller->run();
213
214 // add recurring block
46097c9c
MW
215 $this->addRecurringContributionsBlock();
216
217 // enable/disable soft credit records for test contribution
218 $isTest = 0;
219 if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) {
220 $isTest = 1;
221 }
222 $this->assign('isTest', $isTest);
223
224 $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest);
225
226 if (!empty($softCreditList)) {
be2fb01f 227 $softCreditTotals = [];
46097c9c 228
d9c8c3c8
PF
229 list($softCreditTotals['count'],
230 $softCreditTotals['cancel']['count'],
231 $softCreditTotals['amount'],
46097c9c 232 $softCreditTotals['avg'],
1330f57a
SL
233 // to get cancel amount
234 $softCreditTotals['cancel']['amount']
46097c9c
MW
235 ) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest);
236
237 $this->assign('softCredit', TRUE);
238 $this->assign('softCreditRows', $softCreditList);
239 $this->assign('softCreditTotals', $softCreditTotals);
240 }
241
242 if ($this->_contactId) {
243 $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
244 $this->assign('displayName', $displayName);
7255972e
MWMC
245 $tabCount = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
246 $this->assign('tabCount', $tabCount);
247 $this->ajaxResponse['tabCount'] = $tabCount;
46097c9c
MW
248 }
249 }
250
251 /**
252 * Get all the recurring contribution information and assign to the template
253 */
254 private function addRecurringContributionsBlock() {
2a7f3ed7 255 [$activeContributions, $activeContributionsCount] = $this->getActiveRecurringContributions();
256 [$inactiveRecurringContributions, $inactiveContributionsCount] = $this->getInactiveRecurringContributions();
5963b706
CR
257
258 if (!empty($activeContributions) || !empty($inactiveRecurringContributions)) {
259 // assign vars to templates
260 $this->assign('action', $this->_action);
261 $this->assign('activeRecurRows', $activeContributions);
51e31e45 262 $this->assign('contributionRecurCount', $activeContributionsCount + $inactiveContributionsCount);
5963b706
CR
263 $this->assign('inactiveRecurRows', $inactiveRecurringContributions);
264 $this->assign('recur', TRUE);
265 }
266 }
267
268 /**
269 * Loads active recurring contributions for the current contact and formats
270 * them to be used on the form.
271 *
04d15518 272 * @return array
5963b706
CR
273 */
274 private function getActiveRecurringContributions() {
9e475c2d 275 try {
be2fb01f 276 $contributionRecurResult = civicrm_api3('ContributionRecur', 'get', [
9e475c2d 277 'contact_id' => $this->_contactId,
be2fb01f 278 'contribution_status_id' => ['NOT IN' => CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses()],
0b3146b3 279 'options' => ['limit' => 0, 'sort' => 'is_test, start_date DESC'],
be2fb01f 280 ]);
9c1bc317 281 $recurContributions = $contributionRecurResult['values'] ?? NULL;
5963b706
CR
282 }
283 catch (Exception $e) {
be2fb01f 284 $recurContributions = [];
5963b706
CR
285 }
286
287 return $this->buildRecurringContributionsArray($recurContributions);
288 }
289
290 /**
291 * Loads inactive recurring contributions for the current contact and formats
292 * them to be used on the form.
293 *
04d15518 294 * @return array
5963b706
CR
295 */
296 private function getInactiveRecurringContributions() {
9e475c2d 297 try {
be2fb01f 298 $contributionRecurResult = civicrm_api3('ContributionRecur', 'get', [
9e475c2d 299 'contact_id' => $this->_contactId,
be2fb01f 300 'contribution_status_id' => ['IN' => CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses()],
0b3146b3 301 'options' => ['limit' => 0, 'sort' => 'is_test, start_date DESC'],
be2fb01f 302 ]);
9c1bc317 303 $recurContributions = $contributionRecurResult['values'] ?? NULL;
9e475c2d
MW
304 }
305 catch (Exception $e) {
306 $recurContributions = NULL;
307 }
6a488035 308
5963b706
CR
309 return $this->buildRecurringContributionsArray($recurContributions);
310 }
6a488035 311
5963b706
CR
312 /**
313 * @param $recurContributions
314 *
04d15518 315 * @return array
5963b706
CR
316 */
317 private function buildRecurringContributionsArray($recurContributions) {
e2ef9c65 318 $liveRecurringContributionCount = 0;
5963b706 319 foreach ($recurContributions as $recurId => $recurDetail) {
44c118da
MWMC
320 // Is recurring contribution active?
321 $recurContributions[$recurId]['is_active'] = !in_array(CRM_Contribute_PseudoConstant::contributionStatus($recurDetail['contribution_status_id'], 'name'), CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses());
322 if ($recurContributions[$recurId]['is_active']) {
57ee0d9b 323 $actionMask = array_sum(array_keys(self::recurLinks((int) $recurId)));
44c118da
MWMC
324 }
325 else {
326 $actionMask = CRM_Core_Action::mask([CRM_Core_Permission::VIEW]);
327 }
46097c9c 328
e2ef9c65
PN
329 if (empty($recurDetail['is_test'])) {
330 $liveRecurringContributionCount++;
331 }
332
5963b706
CR
333 // Get the name of the payment processor
334 if (!empty($recurDetail['payment_processor_id'])) {
335 $recurContributions[$recurId]['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName($recurDetail['payment_processor_id']);
336 }
337 // Get the label for the contribution status
338 if (!empty($recurDetail['contribution_status_id'])) {
339 $recurContributions[$recurId]['contribution_status'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', $recurDetail['contribution_status_id']);
340 }
6a488035 341
57ee0d9b 342 $recurContributions[$recurId]['action'] = CRM_Core_Action::formLink(self::recurLinks((int) $recurId), $actionMask,
be2fb01f 343 [
44c118da
MWMC
344 'cid' => $this->_contactId,
345 'crid' => $recurId,
346 'cxt' => 'contribution',
be2fb01f 347 ],
44c118da
MWMC
348 ts('more'),
349 FALSE,
350 'contribution.selector.recurring',
351 'Contribution',
352 $recurId
353 );
6a488035 354 }
5963b706 355
e2ef9c65 356 return [$recurContributions, $liveRecurringContributionCount];
6a488035
TO
357 }
358
359 /**
fe482240 360 * called when action is view.
6a488035 361 *
9e475c2d 362 * @return mixed
6a488035 363 */
00be9182 364 public function view() {
6a488035
TO
365 $controller = new CRM_Core_Controller_Simple(
366 'CRM_Contribute_Form_ContributionView',
367 ts('View Contribution'),
368 $this->_action
369 );
370 $controller->setEmbedded(TRUE);
371 $controller->set('id', $this->_id);
372 $controller->set('cid', $this->_contactId);
373
374 return $controller->run();
375 }
376
377 /**
fe482240 378 * called when action is update or new.
6a488035 379 *
9e475c2d
MW
380 * @return mixed
381 * @throws \CRM_Core_Exception
382 * @throws \Exception
6a488035 383 */
00be9182 384 public function edit() {
6a488035 385 // set https for offline cc transaction
19046166 386 $mode = CRM_Utils_Request::retrieve('mode', 'Alphanumeric', $this);
6a488035
TO
387 if ($mode == 'test' || $mode == 'live') {
388 CRM_Utils_System::redirectToSSL();
389 }
390
391 $controller = new CRM_Core_Controller_Simple(
392 'CRM_Contribute_Form_Contribution',
393 'Create Contribution',
394 $this->_action
395 );
396 $controller->setEmbedded(TRUE);
397 $controller->set('id', $this->_id);
398 $controller->set('cid', $this->_contactId);
399
400 return $controller->run();
401 }
402
04d15518
MWMC
403 /**
404 * @throws \CRM_Core_Exception
405 * @throws \CiviCRM_API3_Exception
406 */
00be9182 407 public function preProcess() {
edc80cda 408 $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
6a488035 409 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
353ffa53 410 $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
6a488035
TO
411
412 if ($context == 'standalone') {
413 $this->_action = CRM_Core_Action::ADD;
414 }
415 else {
f9009fe0
EM
416 $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, empty($this->_id));
417 if (empty($this->_contactId)) {
be2fb01f 418 $this->_contactId = civicrm_api3('contribution', 'getvalue', [
1330f57a
SL
419 'id' => $this->_id,
420 'return' => 'contact_id',
421 ]);
f9009fe0 422 }
6a488035
TO
423 $this->assign('contactId', $this->_contactId);
424
425 // check logged in url permission
426 CRM_Contact_Page_View::checkUserPermission($this);
6a488035
TO
427 }
428 $this->assign('action', $this->_action);
429
430 if ($this->_permission == CRM_Core_Permission::EDIT && !CRM_Core_Permission::check('edit contributions')) {
431 // demote to view since user does not have edit contrib rights
432 $this->_permission = CRM_Core_Permission::VIEW;
433 $this->assign('permission', 'view');
434 }
435 }
436
437 /**
dc195289 438 * the main function that is called when the page
6a488035
TO
439 * loads, it decides the which action has to be taken for the page.
440 *
04d15518
MWMC
441 * @throws \CRM_Core_Exception
442 * @throws \CiviCRM_API3_Exception
6a488035 443 */
00be9182 444 public function run() {
6a488035
TO
445 $this->preProcess();
446
447 // check if we can process credit card contribs
9be1374d 448 $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
6a488035
TO
449
450 $this->setContext();
451
452 if ($this->_action & CRM_Core_Action::VIEW) {
453 $this->view();
454 }
455 elseif ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
456 $this->edit();
457 }
458 else {
459 $this->browse();
460 }
461
04d15518 462 parent::run();
6a488035
TO
463 }
464
04d15518
MWMC
465 /**
466 * @throws \CRM_Core_Exception
467 */
00be9182 468 public function setContext() {
6a488035 469 $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
edc80cda 470 $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric',
6a488035
TO
471 $this, FALSE, 'search'
472 );
473 $compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
474
29571f63
AS
475 $searchContext = CRM_Utils_Request::retrieve('searchContext', 'String', $this);
476
6a488035
TO
477 //swap the context.
478 if ($context == 'search' && $compContext) {
479 $context = $compContext;
480 }
481 else {
482 $compContext = NULL;
483 }
484
485 // make sure we dont get tricked with a bad key
486 // so check format
487 if (!CRM_Core_Key::valid($qfKey)) {
488 $qfKey = NULL;
489 }
490
6a488035
TO
491 switch ($context) {
492 case 'user':
493 $url = CRM_Utils_System::url('civicrm/user', 'reset=1');
494 break;
495
496 case 'dashboard':
497 $url = CRM_Utils_System::url('civicrm/contribute',
498 'reset=1'
499 );
500 break;
501
502 case 'pledgeDashboard':
503 $url = CRM_Utils_System::url('civicrm/pledge',
504 'reset=1'
505 );
506 break;
507
508 case 'contribution':
6a488035 509 $url = CRM_Utils_System::url('civicrm/contact/view',
8381af80 510 "reset=1&force=1&cid={$this->_contactId}&selectedChild=contribute"
6a488035
TO
511 );
512 break;
513
514 case 'search':
515 case 'advanced':
516 $extraParams = "force=1";
517 if ($qfKey) {
518 $extraParams .= "&qfKey=$qfKey";
519 }
520
521 $this->assign('searchKey', $qfKey);
522 if ($context == 'advanced') {
523 $url = CRM_Utils_System::url('civicrm/contact/search/advanced', $extraParams);
524 }
4c9b6178 525 elseif ($searchContext) {
29571f63
AS
526 $url = CRM_Utils_System::url("civicrm/$searchContext/search", $extraParams);
527 }
6a488035
TO
528 else {
529 $url = CRM_Utils_System::url('civicrm/contribute/search', $extraParams);
530 }
531 break;
532
533 case 'home':
534 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
535 break;
536
537 case 'activity':
538 $url = CRM_Utils_System::url('civicrm/contact/view',
539 "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity"
540 );
541 break;
542
543 case 'member':
544 case 'membership':
545 $componentId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
546 $componentAction = CRM_Utils_Request::retrieve('compAction', 'Integer', $this);
547
548 $context = 'membership';
549 $searchKey = NULL;
550 if ($compContext) {
551 $context = 'search';
552 if ($qfKey) {
553 $searchKey = "&key=$qfKey";
554 }
555 $compContext = "&compContext={$compContext}";
556 }
557 if ($componentAction & CRM_Core_Action::VIEW) {
558 $action = 'view';
559 }
560 else {
561 $action = 'update';
562 }
563 $url = CRM_Utils_System::url('civicrm/contact/view/membership',
564 "reset=1&action={$action}&id={$componentId}&cid={$this->_contactId}&context={$context}&selectedChild=member{$searchKey}{$compContext}"
565 );
566 break;
567
568 case 'participant':
569 $componentId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
570 $componentAction = CRM_Utils_Request::retrieve('compAction', 'Integer', $this);
571
572 $context = 'participant';
573 $searchKey = NULL;
574 if ($compContext) {
575 $context = 'search';
576 if ($qfKey) {
577 $searchKey = "&key=$qfKey";
578 }
579 $compContext = "&compContext={$compContext}";
580 }
581 if ($componentAction == CRM_Core_Action::VIEW) {
582 $action = 'view';
583 }
584 else {
585 $action = 'update';
586 }
587 $url = CRM_Utils_System::url('civicrm/contact/view/participant',
588 "reset=1&action={$action}&id={$componentId}&cid={$this->_contactId}&context={$context}&selectedChild=event{$searchKey}{$compContext}"
589 );
590 break;
591
592 case 'pledge':
593 $url = CRM_Utils_System::url('civicrm/contact/view',
594 "reset=1&force=1&cid={$this->_contactId}&selectedChild=pledge"
595 );
596 break;
597
598 case 'standalone':
599 $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
600 break;
601
602 case 'fulltext':
353ffa53 603 $keyName = '&qfKey';
6a488035
TO
604 $urlParams = 'force=1';
605 $urlString = 'civicrm/contact/search/custom';
606 if ($this->_action == CRM_Core_Action::UPDATE) {
607 if ($this->_contactId) {
608 $urlParams .= '&cid=' . $this->_contactId;
609 }
610 $keyName = '&key';
611 $urlParams .= '&context=fulltext&action=view';
612 $urlString = 'civicrm/contact/view/contribution';
613 }
614 if ($qfKey) {
615 $urlParams .= "$keyName=$qfKey";
616 }
617 $this->assign('searchKey', $qfKey);
618 $url = CRM_Utils_System::url($urlString, $urlParams);
619 break;
620
621 default:
622 $cid = NULL;
623 if ($this->_contactId) {
624 $cid = '&cid=' . $this->_contactId;
625 }
626 $url = CRM_Utils_System::url('civicrm/contribute/search',
627 'reset=1&force=1' . $cid
628 );
629 break;
630 }
631
632 $session = CRM_Core_Session::singleton();
633 $session->pushUserContext($url);
634 }
96025800 635
6a488035 636}