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