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