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