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