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,8 +402,42 @@ class KTBulkAction extends KTStandardDispatcher {
402 $this->persistParams(array('fListCode', 'fActiveListCode', 'fFolderId', 'fReturnData', 'fReturnAction')); 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 // forms 442 // forms
409 // form to list the entites after checking each one 443 // form to list the entites after checking each one
@@ -411,6 +445,8 @@ class KTBulkAction extends KTStandardDispatcher { @@ -411,6 +445,8 @@ class KTBulkAction extends KTStandardDispatcher {
411 $sListCode = $this->oEntityList->getCode(); 445 $sListCode = $this->oEntityList->getCode();
412 $sActiveListCode = $this->oActiveEntityList->getCode(); 446 $sActiveListCode = $this->oActiveEntityList->getCode();
413 447
  448 + $sTargetUrl = $this->getReturnUrl();
  449 +
414 $oForm = new KTForm; 450 $oForm = new KTForm;
415 $oForm->setOptions(array( 451 $oForm->setOptions(array(
416 'identifier' => 'ktcore.actions.bulk.listing.form', 452 'identifier' => 'ktcore.actions.bulk.listing.form',
@@ -418,7 +454,7 @@ class KTBulkAction extends KTStandardDispatcher { @@ -418,7 +454,7 @@ class KTBulkAction extends KTStandardDispatcher {
418 'targeturl' => $this->getURL(), 454 'targeturl' => $this->getURL(),
419 'action' => 'collectinfo', 455 'action' => 'collectinfo',
420 'fail_action' => 'main', 456 'fail_action' => 'main',
421 - 'cancel_url' => KTBrowseUtil::getUrlForFolder($this->oFolder), 457 + 'cancel_url' => $sTargetUrl,
422 'noframe' => true, 458 'noframe' => true,
423 'extraargs' => array('fListCode' => $sListCode, 459 'extraargs' => array('fListCode' => $sListCode,
424 'fActiveListCode' => $sActiveListCode, 460 'fActiveListCode' => $sActiveListCode,
@@ -437,23 +473,24 @@ class KTBulkAction extends KTStandardDispatcher { @@ -437,23 +473,24 @@ class KTBulkAction extends KTStandardDispatcher {
437 $sReturnData = KTUtil::arrayGet($_REQUEST, 'fReturnData'); 473 $sReturnData = KTUtil::arrayGet($_REQUEST, 'fReturnData');
438 $sAction = 'main'; 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 $oForm = new KTForm; 496 $oForm = new KTForm;
@@ -480,8 +517,8 @@ class KTBulkAction extends KTStandardDispatcher { @@ -480,8 +517,8 @@ class KTBulkAction extends KTStandardDispatcher {
480 // gives us $this->aFailed 517 // gives us $this->aFailed
481 $iActiveCount = $this->check_entities(); 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 $this->store_lists(); 523 $this->store_lists();
487 524
plugins/ktcore/KTBulkActions.php
@@ -65,7 +65,7 @@ class KTBulkDeleteAction extends KTBulkAction { @@ -65,7 +65,7 @@ class KTBulkDeleteAction extends KTBulkAction {
65 } 65 }
66 66
67 function form_collectinfo() { 67 function form_collectinfo() {
68 - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder); 68 + $cancelUrl = $this->getReturnUrl();
69 69
70 $oForm = new KTForm; 70 $oForm = new KTForm;
71 $oForm->setOptions(array( 71 $oForm->setOptions(array(
@@ -200,7 +200,7 @@ class KTBulkMoveAction extends KTBulkAction { @@ -200,7 +200,7 @@ class KTBulkMoveAction extends KTBulkAction {
200 } 200 }
201 201
202 function form_collectinfo() { 202 function form_collectinfo() {
203 - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder); 203 + $cancelUrl = $this->getReturnUrl();
204 204
205 $oForm = new KTForm; 205 $oForm = new KTForm;
206 $oForm->setOptions(array( 206 $oForm->setOptions(array(
@@ -353,7 +353,7 @@ class KTBulkCopyAction extends KTBulkAction { @@ -353,7 +353,7 @@ class KTBulkCopyAction extends KTBulkAction {
353 } 353 }
354 354
355 function form_collectinfo() { 355 function form_collectinfo() {
356 - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder); 356 + $cancelUrl = $this->getReturnUrl();
357 357
358 $oForm = new KTForm; 358 $oForm = new KTForm;
359 $oForm->setOptions(array( 359 $oForm->setOptions(array(
@@ -499,7 +499,7 @@ class KTBulkArchiveAction extends KTBulkAction { @@ -499,7 +499,7 @@ class KTBulkArchiveAction extends KTBulkAction {
499 } 499 }
500 500
501 function form_collectinfo() { 501 function form_collectinfo() {
502 - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder); 502 + $cancelUrl = $this->getReturnUrl();
503 503
504 $oForm = new KTForm; 504 $oForm = new KTForm;
505 $oForm->setOptions(array( 505 $oForm->setOptions(array(
@@ -723,7 +723,7 @@ class KTBrowseBulkExportAction extends KTBulkAction { @@ -723,7 +723,7 @@ class KTBrowseBulkExportAction extends KTBulkAction {
723 $this->oZip = new ZipFolder($folderName); 723 $this->oZip = new ZipFolder($folderName);
724 $res = $this->oZip->checkConvertEncoding(); 724 $res = $this->oZip->checkConvertEncoding();
725 725
726 - $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder); 726 + $folderurl = $this->getReturnUrl();
727 $sReturn = sprintf('<p>' . _kt('Return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl); 727 $sReturn = sprintf('<p>' . _kt('Return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl);
728 728
729 if(PEAR::isError($res)){ 729 if(PEAR::isError($res)){
@@ -757,7 +757,6 @@ class KTBrowseBulkExportAction extends KTBulkAction { @@ -757,7 +757,6 @@ class KTBrowseBulkExportAction extends KTBulkAction {
757 757
758 $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode)); 758 $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode));
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); 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 $str .= sprintf('<p>' . _kt('Once your download is complete, click <a href="%s">here</a> to return to the original folder') . "</p>\n", $folderurl); 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 //$str .= sprintf("</div></div></body></html>\n"); 761 //$str .= sprintf("</div></div></body></html>\n");
763 $str .= sprintf('<script language="JavaScript"> 762 $str .= sprintf('<script language="JavaScript">
@@ -890,7 +889,8 @@ class KTBrowseBulkExportAction extends KTBulkAction { @@ -890,7 +889,8 @@ class KTBrowseBulkExportAction extends KTBulkAction {
890 889
891 if(PEAR::isError($res)){ 890 if(PEAR::isError($res)){
892 $this->addErrorMessage($res->getMessage()); 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 exit(0); 895 exit(0);
896 } 896 }
@@ -940,7 +940,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { @@ -940,7 +940,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
940 } 940 }
941 941
942 function form_collectinfo() { 942 function form_collectinfo() {
943 - $cancelUrl = KTBrowseUtil::getUrlForFolder($this->oFolder); 943 + $cancelUrl = $this->getReturnUrl();
944 944
945 $oForm = new KTForm; 945 $oForm = new KTForm;
946 $oForm->setOptions(array( 946 $oForm->setOptions(array(