Commit 95411e798d136d5a551dd540dbb0df503459dbea

Authored by bshuttle
1 parent 56038441

- add a folder transaction for export

- add an option to have a document-transaction on bulk export
fixes KTS-1074


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5654 c91229c3-7414-0410-bfa2-8a42b809f60b
config/config.ini
@@ -113,6 +113,11 @@ phpErrorLogFile = false @@ -113,6 +113,11 @@ phpErrorLogFile = false
113 ; browse section 113 ; browse section
114 browseToUnitFolder = default 114 browseToUnitFolder = default
115 115
  116 +; Whether bulk operations should generate a transaction notice on each
  117 +; item, or only on the folder. Default of "false" indicates that only
  118 +; the folder transaction should occur.
  119 +noisyBulkOperations = false
  120 +
116 [email] 121 [email]
117 ; email settings 122 ; email settings
118 emailServer = none 123 emailServer = none
config/dmsDefaults.php
@@ -403,10 +403,12 @@ class KTInit { @@ -403,10 +403,12 @@ class KTInit {
403 $oKTConfig->setdefaultns("KnowledgeTree", "pathInfoSupport", false); 403 $oKTConfig->setdefaultns("KnowledgeTree", "pathInfoSupport", false);
404 $oKTConfig->setdefaultns("storage", "manager", 'KTOnDiskHashedStorageManager'); 404 $oKTConfig->setdefaultns("storage", "manager", 'KTOnDiskHashedStorageManager');
405 $oKTConfig->setdefaultns("config", "useDatabaseConfiguration", false); 405 $oKTConfig->setdefaultns("config", "useDatabaseConfiguration", false);
  406 +
406 $oKTConfig->setdefaultns("tweaks", "browseToUnitFolder", false); 407 $oKTConfig->setdefaultns("tweaks", "browseToUnitFolder", false);
407 $oKTConfig->setdefaultns("tweaks", "genericMetaDataRequired", true); 408 $oKTConfig->setdefaultns("tweaks", "genericMetaDataRequired", true);
408 $oKTConfig->setdefaultns("tweaks", "phpErrorLogFile", false); 409 $oKTConfig->setdefaultns("tweaks", "phpErrorLogFile", false);
409 $oKTConfig->setdefaultns("tweaks", "developmentWindowLog", false); 410 $oKTConfig->setdefaultns("tweaks", "developmentWindowLog", false);
  411 + $oKTConfig->setdefaultns("tweaks", "noisyBulkOperations", false);
410 412
411 $oKTConfig->setdefaultns("user_prefs", "passwordLength", 6); 413 $oKTConfig->setdefaultns("user_prefs", "passwordLength", 6);
412 $oKTConfig->setdefaultns("user_prefs", "restrictAdminPasswords", false); 414 $oKTConfig->setdefaultns("user_prefs", "restrictAdminPasswords", false);
plugins/ktstandard/KTBulkExportPlugin.php
@@ -30,6 +30,8 @@ require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); @@ -30,6 +30,8 @@ require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
30 require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); 30 require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
31 require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); 31 require_once(KT_LIB_DIR . '/browse/browseutil.inc.php');
32 32
  33 +require_once(KT_LIB_DIR . '/config/config.inc.php');
  34 +
33 class KTBulkExportPlugin extends KTPlugin { 35 class KTBulkExportPlugin extends KTPlugin {
34 var $sNamespace = "ktstandard.bulkexport.plugin"; 36 var $sNamespace = "ktstandard.bulkexport.plugin";
35 37
@@ -60,6 +62,11 @@ class KTBulkExportAction extends KTFolderAction { @@ -60,6 +62,11 @@ class KTBulkExportAction extends KTFolderAction {
60 $aQuery = $this->buildQuery(); 62 $aQuery = $this->buildQuery();
61 $this->oValidator->notError($aQuery); 63 $this->oValidator->notError($aQuery);
62 $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id'); 64 $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id');
  65 +
  66 + $this->startTransaction();
  67 +
  68 + $oKTConfig =& KTConfig::getSingleton();
  69 + $bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations");
63 70
64 if (empty($aDocumentIds)) { 71 if (empty($aDocumentIds)) {
65 $this->addErrorMessage(_kt("No documents found to export")); 72 $this->addErrorMessage(_kt("No documents found to export"));
@@ -79,6 +86,12 @@ class KTBulkExportAction extends KTFolderAction { @@ -79,6 +86,12 @@ class KTBulkExportAction extends KTFolderAction {
79 $aPaths = array(); 86 $aPaths = array();
80 foreach ($aDocumentIds as $iId) { 87 foreach ($aDocumentIds as $iId) {
81 $oDocument = Document::get($iId); 88 $oDocument = Document::get($iId);
  89 +
  90 + if ($bNoisy) {
  91 + $oDocumentTransaction = & new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array());
  92 + $oDocumentTransaction->create();
  93 + }
  94 +
82 $sParentFolder = sprintf('%s/%s', $sTmpPath, $oDocument->getFullPath()); 95 $sParentFolder = sprintf('%s/%s', $sTmpPath, $oDocument->getFullPath());
83 $newDir = $this->sTmpPath; 96 $newDir = $this->sTmpPath;
84 foreach (split('/', $oDocument->getFullPath()) as $dirPart) { 97 foreach (split('/', $oDocument->getFullPath()) as $dirPart) {
@@ -130,6 +143,14 @@ class KTBulkExportAction extends KTFolderAction { @@ -130,6 +143,14 @@ class KTBulkExportAction extends KTFolderAction {
130 } 143 }
131 pclose($fh); 144 pclose($fh);
132 145
  146 + $oTransaction = KTFolderTransaction::createFromArray(array(
  147 + 'folderid' => $this->oFolder->getId(),
  148 + 'comment' => "Bulk export",
  149 + 'transactionNS' => 'ktstandard.transactions.bulk_export',
  150 + 'userid' => $_SESSION['userID'],
  151 + 'ip' => Session::getClientIP(),
  152 + ));
  153 +
133 $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode)); 154 $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode));
134 printf(_kt('Go <a href="%s">here</a> to download the zip file if you are not automatically redirected there'), $url); 155 printf(_kt('Go <a href="%s">here</a> to download the zip file if you are not automatically redirected there'), $url);
135 printf("</div></div></body></html>\n"); 156 printf("</div></div></body></html>\n");
@@ -140,6 +161,8 @@ class KTBulkExportAction extends KTFolderAction { @@ -140,6 +161,8 @@ class KTBulkExportAction extends KTFolderAction {
140 callLater(1, kt_bulkexport_redirect); 161 callLater(1, kt_bulkexport_redirect);
141 162
142 </script>', $url); 163 </script>', $url);
  164 +
  165 + $this->commitTransaction();
143 exit(0); 166 exit(0);
144 } 167 }
145 168