Commit c2624275ca75a2c678a1bae5df33a4310aba7f99

Authored by kevin_fourie
1 parent 2e1bf60b

Merged in...

KTS-3760
"When cancelling any of the Bulk Actions in process the user is returned to the Root folder view and not to the Search where the action originated."
Fixed. Set the cancel action to the return action.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.4-Release-Branch@9456 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/actions/bulkaction.php
... ... @@ -402,8 +402,42 @@ class KTBulkAction extends KTStandardDispatcher {
402 402 $this->persistParams(array('fListCode', 'fActiveListCode', 'fFolderId', 'fReturnData', 'fReturnAction'));
403 403 }
404 404  
  405 + /**
  406 + * Get the return url based on the return action and data
  407 + */
  408 + function getReturnUrl()
  409 + {
  410 + $sReturnAction = $_REQUEST['fReturnAction'];
  411 + $sReturnData = $_REQUEST['fReturnData'];
  412 + $sAction = 'main';
  413 + $qs = '';
  414 +
  415 + switch ($sReturnAction){
  416 + case 'browse':
  417 + $sReturnData = (empty($sReturnData)) ? $_REQUEST['fFolderId'] : $sReturnData;
  418 + $sTargetUrl = KTBrowseUtil::getUrlForFolder(Folder::get($sReturnData));
  419 + break;
  420 + case 'simpleSearch':
  421 + $sTargetUrl = KTBrowseUtil::getSimpleSearchBaseUrl();
  422 + $extra = 'fSearchableText='.$sReturnData;
  423 + break;
  424 + case 'booleanSearch':
  425 + $sTargetUrl = KTBrowseUtil::getBooleanSearchBaseUrl();
  426 + $sAction = 'performSearch';
  427 + $extra = 'boolean_search_id='.$sReturnData;
  428 + break;
  429 + case 'search2':
  430 + $sTargetUrl = KTBrowseUtil::getSearchResultURL();
  431 + $sAction = 'searchResults';
  432 + break;
  433 + }
405 434  
  435 + $qs = 'action='.$sAction;
  436 + $qs .= (!empty($extra))? '&'.$extra : '';
  437 + $sTargetUrl = KTUtil::addQueryString($sTargetUrl, $qs);
406 438  
  439 + return $sTargetUrl;
  440 + }
407 441  
408 442 // forms
409 443 // form to list the entites after checking each one
... ... @@ -411,6 +445,8 @@ class KTBulkAction extends KTStandardDispatcher {
411 445 $sListCode = $this->oEntityList->getCode();
412 446 $sActiveListCode = $this->oActiveEntityList->getCode();
413 447  
  448 + $sTargetUrl = $this->getReturnUrl();
  449 +
414 450 $oForm = new KTForm;
415 451 $oForm->setOptions(array(
416 452 'identifier' => 'ktcore.actions.bulk.listing.form',
... ... @@ -418,7 +454,7 @@ class KTBulkAction extends KTStandardDispatcher {
418 454 'targeturl' => $this->getURL(),
419 455 'action' => 'collectinfo',
420 456 'fail_action' => 'main',
421   - 'cancel_url' => KTBrowseUtil::getUrlForFolder($this->oFolder),
  457 + 'cancel_url' => $sTargetUrl,
422 458 'noframe' => true,
423 459 'extraargs' => array('fListCode' => $sListCode,
424 460 'fActiveListCode' => $sActiveListCode,
... ... @@ -437,23 +473,24 @@ class KTBulkAction extends KTStandardDispatcher {
437 473 $sReturnData = KTUtil::arrayGet($_REQUEST, 'fReturnData');
438 474 $sAction = 'main';
439 475  
440   - if($sReturnAction == 'browse') {
441   - if ($sReturnData == '')
442   - {
443   - $sReturnData = KTUtil::arrayGet($_REQUEST, 'fFolderId');
444   - }
445   - $sTargetUrl = KTBrowseUtil::getUrlForFolder(Folder::get($sReturnData));
446   - } elseif($sReturnAction == 'simpleSearch') {
447   - $sTargetUrl = KTBrowseUtil::getSimpleSearchBaseUrl();
448   - $extraargs = array('fSearchableText'=>$sReturnData);
449   - } elseif($sReturnAction == 'booleanSearch') {
450   - $sTargetUrl = KTBrowseUtil::getBooleanSearchBaseUrl();
451   - $sAction = 'performSearch';
452   - $extraargs = array('boolean_search_id'=>$sReturnData);
453   - }
454   - elseif($sReturnAction == 'search2') {
455   - $sTargetUrl = KTBrowseUtil::getSearchResultURL();
456   - $sAction = 'searchResults';
  476 + switch ($sReturnAction){
  477 + case 'browse':
  478 + $sReturnData = (empty($sReturnData)) ? $_REQUEST['fFolderId'] : $sReturnData;
  479 + $sTargetUrl = KTBrowseUtil::getUrlForFolder(Folder::get($sReturnData));
  480 + break;
  481 + case 'simpleSearch': // do we use this?
  482 + $sTargetUrl = KTBrowseUtil::getSimpleSearchBaseUrl();
  483 + $extraargs = array('fSearchableText'=>$sReturnData);
  484 + break;
  485 + case 'booleanSearch': // do we use this?
  486 + $sTargetUrl = KTBrowseUtil::getBooleanSearchBaseUrl();
  487 + $sAction = 'performSearch';
  488 + $extraargs = array('boolean_search_id'=>$sReturnData);
  489 + break;
  490 + case 'search2':
  491 + $sTargetUrl = KTBrowseUtil::getSearchResultURL();
  492 + $sAction = 'searchResults';
  493 + break;
457 494 }
458 495  
459 496 $oForm = new KTForm;
... ... @@ -480,8 +517,8 @@ class KTBulkAction extends KTStandardDispatcher {
480 517 // gives us $this->aFailed
481 518 $iActiveCount = $this->check_entities();
482 519  
483   - $oTemplating =& KTTemplating::getSingleton();
484   - $oTemplate = $oTemplating->loadTemplate('ktcore/bulk_action_listing');
  520 + $oTemplating =& KTTemplating::getSingleton();
  521 + $oTemplate = $oTemplating->loadTemplate('ktcore/bulk_action_listing');
485 522  
486 523 $this->store_lists();
487 524  
... ...
plugins/ktcore/KTBulkActions.php
... ... @@ -65,7 +65,7 @@ class KTBulkDeleteAction extends KTBulkAction {
65 65 }
66 66  
67 67 function form_collectinfo() {
68   - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder);
  68 + $cancelUrl = $this->getReturnUrl();
69 69  
70 70 $oForm = new KTForm;
71 71 $oForm->setOptions(array(
... ... @@ -200,7 +200,7 @@ class KTBulkMoveAction extends KTBulkAction {
200 200 }
201 201  
202 202 function form_collectinfo() {
203   - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder);
  203 + $cancelUrl = $this->getReturnUrl();
204 204  
205 205 $oForm = new KTForm;
206 206 $oForm->setOptions(array(
... ... @@ -353,7 +353,7 @@ class KTBulkCopyAction extends KTBulkAction {
353 353 }
354 354  
355 355 function form_collectinfo() {
356   - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder);
  356 + $cancelUrl = $this->getReturnUrl();
357 357  
358 358 $oForm = new KTForm;
359 359 $oForm->setOptions(array(
... ... @@ -499,7 +499,7 @@ class KTBulkArchiveAction extends KTBulkAction {
499 499 }
500 500  
501 501 function form_collectinfo() {
502   - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder);
  502 + $cancelUrl = $this->getReturnUrl();
503 503  
504 504 $oForm = new KTForm;
505 505 $oForm->setOptions(array(
... ... @@ -723,7 +723,7 @@ class KTBrowseBulkExportAction extends KTBulkAction {
723 723 $this->oZip = new ZipFolder($folderName);
724 724 $res = $this->oZip->checkConvertEncoding();
725 725  
726   - $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder);
  726 + $folderurl = $this->getReturnUrl();
727 727 $sReturn = sprintf('<p>' . _kt('Return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl);
728 728  
729 729 if(PEAR::isError($res)){
... ... @@ -757,7 +757,6 @@ class KTBrowseBulkExportAction extends KTBulkAction {
757 757  
758 758 $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode));
759 759 $str = sprintf('<p>' . _kt('Your download will begin shortly. If you are not automatically redirected to your download, please click <a href="%s">here</a> ') . "</p>\n", $url);
760   - $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder);
761 760 $str .= sprintf('<p>' . _kt('Once your download is complete, click <a href="%s">here</a> to return to the original folder') . "</p>\n", $folderurl);
762 761 //$str .= sprintf("</div></div></body></html>\n");
763 762 $str .= sprintf('<script language="JavaScript">
... ... @@ -890,7 +889,8 @@ class KTBrowseBulkExportAction extends KTBulkAction {
890 889  
891 890 if(PEAR::isError($res)){
892 891 $this->addErrorMessage($res->getMessage());
893   - redirect(generateControllerUrl("browse", "fBrowseType=folder&fFolderId=" . $this->oFolder->getId()));
  892 + $redirectUrl = $this->getReturnUrl();
  893 + redirect($redirectUrl);
894 894 }
895 895 exit(0);
896 896 }
... ... @@ -940,7 +940,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
940 940 }
941 941  
942 942 function form_collectinfo() {
943   - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder);
  943 + $cancelUrl = $this->getReturnUrl();
944 944  
945 945 $oForm = new KTForm;
946 946 $oForm->setOptions(array(
... ...