Commit 95411e798d136d5a551dd540dbb0df503459dbea
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
Showing
3 changed files
with
30 additions
and
0 deletions
config/config.ini
| ... | ... | @@ -113,6 +113,11 @@ phpErrorLogFile = false |
| 113 | 113 | ; browse section |
| 114 | 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 | 121 | [email] |
| 117 | 122 | ; email settings |
| 118 | 123 | emailServer = none | ... | ... |
config/dmsDefaults.php
| ... | ... | @@ -403,10 +403,12 @@ class KTInit { |
| 403 | 403 | $oKTConfig->setdefaultns("KnowledgeTree", "pathInfoSupport", false); |
| 404 | 404 | $oKTConfig->setdefaultns("storage", "manager", 'KTOnDiskHashedStorageManager'); |
| 405 | 405 | $oKTConfig->setdefaultns("config", "useDatabaseConfiguration", false); |
| 406 | + | |
| 406 | 407 | $oKTConfig->setdefaultns("tweaks", "browseToUnitFolder", false); |
| 407 | 408 | $oKTConfig->setdefaultns("tweaks", "genericMetaDataRequired", true); |
| 408 | 409 | $oKTConfig->setdefaultns("tweaks", "phpErrorLogFile", false); |
| 409 | 410 | $oKTConfig->setdefaultns("tweaks", "developmentWindowLog", false); |
| 411 | + $oKTConfig->setdefaultns("tweaks", "noisyBulkOperations", false); | |
| 410 | 412 | |
| 411 | 413 | $oKTConfig->setdefaultns("user_prefs", "passwordLength", 6); |
| 412 | 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 | 30 | require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); |
| 31 | 31 | require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); |
| 32 | 32 | |
| 33 | +require_once(KT_LIB_DIR . '/config/config.inc.php'); | |
| 34 | + | |
| 33 | 35 | class KTBulkExportPlugin extends KTPlugin { |
| 34 | 36 | var $sNamespace = "ktstandard.bulkexport.plugin"; |
| 35 | 37 | |
| ... | ... | @@ -60,6 +62,11 @@ class KTBulkExportAction extends KTFolderAction { |
| 60 | 62 | $aQuery = $this->buildQuery(); |
| 61 | 63 | $this->oValidator->notError($aQuery); |
| 62 | 64 | $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id'); |
| 65 | + | |
| 66 | + $this->startTransaction(); | |
| 67 | + | |
| 68 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 69 | + $bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations"); | |
| 63 | 70 | |
| 64 | 71 | if (empty($aDocumentIds)) { |
| 65 | 72 | $this->addErrorMessage(_kt("No documents found to export")); |
| ... | ... | @@ -79,6 +86,12 @@ class KTBulkExportAction extends KTFolderAction { |
| 79 | 86 | $aPaths = array(); |
| 80 | 87 | foreach ($aDocumentIds as $iId) { |
| 81 | 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 | 95 | $sParentFolder = sprintf('%s/%s', $sTmpPath, $oDocument->getFullPath()); |
| 83 | 96 | $newDir = $this->sTmpPath; |
| 84 | 97 | foreach (split('/', $oDocument->getFullPath()) as $dirPart) { |
| ... | ... | @@ -130,6 +143,14 @@ class KTBulkExportAction extends KTFolderAction { |
| 130 | 143 | } |
| 131 | 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 | 154 | $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode)); |
| 134 | 155 | printf(_kt('Go <a href="%s">here</a> to download the zip file if you are not automatically redirected there'), $url); |
| 135 | 156 | printf("</div></div></body></html>\n"); |
| ... | ... | @@ -140,6 +161,8 @@ class KTBulkExportAction extends KTFolderAction { |
| 140 | 161 | callLater(1, kt_bulkexport_redirect); |
| 141 | 162 | |
| 142 | 163 | </script>', $url); |
| 164 | + | |
| 165 | + $this->commitTransaction(); | |
| 143 | 166 | exit(0); |
| 144 | 167 | } |
| 145 | 168 | ... | ... |