Commit b11d71dbef328131f164746b05b1462d8a112d5a
1 parent
381e411c
KTS-1738
"Add version comparison diff" Fixed. Added a check for the doc comparison plugin. If its active, the links to compare content are displayed. Committed By: Megan Watson Reviewed By: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8016 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
89 additions
and
31 deletions
plugins/ktcore/KTDocumentActions.php
| ... | ... | @@ -5,32 +5,32 @@ |
| 5 | 5 | * KnowledgeTree Open Source Edition |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | |
| 8 | + * | |
| 9 | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | 11 | * Free Software Foundation. |
| 12 | - * | |
| 12 | + * | |
| 13 | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | 16 | * details. |
| 17 | - * | |
| 17 | + * | |
| 18 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | - * copyright notice. | |
| 32 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * copyright notice. | |
| 34 | 34 | * Contributor( s): ______________________________________ |
| 35 | 35 | * |
| 36 | 36 | */ |
| ... | ... | @@ -119,6 +119,11 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 119 | 119 | return _kt('Version History'); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | + /** | |
| 123 | + * Display a list of versions for comparing | |
| 124 | + * | |
| 125 | + * @return unknown | |
| 126 | + */ | |
| 122 | 127 | function do_main() { |
| 123 | 128 | $show_version = KTUtil::arrayGet($_REQUEST, 'show'); |
| 124 | 129 | $showall = (isset($show_version) && ($show_version == 'all')) ? true : false; |
| ... | ... | @@ -157,6 +162,26 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 157 | 162 | $bShowDelete = KTUtil::arrayGet($_SESSION, 'adminmode', false); |
| 158 | 163 | } |
| 159 | 164 | |
| 165 | + // Check if the document comparison plugin is installed | |
| 166 | + $isActive = KTPluginUtil::pluginIsActive('document.comparison.plugin'); | |
| 167 | + | |
| 168 | + $bShowCompare = false; | |
| 169 | + $bShowVersionCompare = false; | |
| 170 | + $sUrl = false; | |
| 171 | + | |
| 172 | + if($isActive){ | |
| 173 | + $oRegistry =& KTPluginRegistry::getSingleton(); | |
| 174 | + $oPlugin =& $oRegistry->getPlugin('document.comparison.plugin'); | |
| 175 | + $oPlugin->load(); | |
| 176 | + $sUrl = $oPlugin->getPagePath('DocumentComparison'); | |
| 177 | + $file = $oPlugin->_aPages['document.comparison.plugin/DocumentComparison'][2]; | |
| 178 | + | |
| 179 | + include_once($file); | |
| 180 | + | |
| 181 | + // Check mime type of document for content comparison | |
| 182 | + list($bShowCompare, $bShowVersionCompare) = DocumentComparison::checkMimeType($this->oDocument); | |
| 183 | + } | |
| 184 | + | |
| 160 | 185 | $aTemplateData = array( |
| 161 | 186 | 'context' => $this, |
| 162 | 187 | 'document_id' => $this->oDocument->getId(), |
| ... | ... | @@ -165,10 +190,18 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 165 | 190 | 'downloadaction' => $oAction, |
| 166 | 191 | 'showdelete' => $bShowDelete, |
| 167 | 192 | 'showall' => $showall, |
| 193 | + 'bShowCompare' => $bShowCompare, | |
| 194 | + 'bShowVersionCompare' => $bShowVersionCompare, | |
| 195 | + 'sUrl' => $sUrl | |
| 168 | 196 | ); |
| 169 | 197 | return $oTemplate->render($aTemplateData); |
| 170 | 198 | } |
| 171 | 199 | |
| 200 | + /** | |
| 201 | + * Display list of metadata versions to compare with the selected version | |
| 202 | + * | |
| 203 | + * @return unknown | |
| 204 | + */ | |
| 172 | 205 | function do_startComparison() { |
| 173 | 206 | $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion'); |
| 174 | 207 | |
| ... | ... | @@ -202,6 +235,10 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 202 | 235 | return $oTemplate->render($aTemplateData); |
| 203 | 236 | } |
| 204 | 237 | |
| 238 | + /** | |
| 239 | + * Display the metadata comparison | |
| 240 | + * | |
| 241 | + */ | |
| 205 | 242 | function do_viewComparison() { |
| 206 | 243 | // this is just a redirector |
| 207 | 244 | $QS = array( |
| ... | ... | @@ -225,15 +262,20 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 225 | 262 | if (PEAR::isError($u) || ($u == false)) { return _kt('User no longer exists'); } |
| 226 | 263 | return $u->getName(); |
| 227 | 264 | } |
| 228 | - | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * Confirm the deletion of a version | |
| 268 | + * | |
| 269 | + * @return unknown | |
| 270 | + */ | |
| 229 | 271 | function do_confirmdeleteVersion() { |
| 230 | 272 | $this->oPage->setSecondaryTitle($this->oDocument->getName()); |
| 231 | 273 | $this->oPage->setBreadcrumbDetails(_kt('Delete document version')); |
| 232 | - | |
| 274 | + | |
| 233 | 275 | // Display the version name and number |
| 234 | 276 | $iVersionId = $_REQUEST['version']; |
| 235 | 277 | $oVersion = Document::get($this->oDocument->getId(), $iVersionId); |
| 236 | - | |
| 278 | + | |
| 237 | 279 | $oTemplating =& KTTemplating::getSingleton(); |
| 238 | 280 | $oTemplate = $oTemplating->loadTemplate('ktcore/document/delete_version'); |
| 239 | 281 | $aTemplateData = array( |
| ... | ... | @@ -243,25 +285,29 @@ class KTDocumentVersionHistoryAction extends KTDocumentAction { |
| 243 | 285 | ); |
| 244 | 286 | return $oTemplate->render($aTemplateData); |
| 245 | 287 | } |
| 246 | - | |
| 288 | + | |
| 289 | + /** | |
| 290 | + * Delete a version | |
| 291 | + * | |
| 292 | + */ | |
| 247 | 293 | function do_deleteVersion() { |
| 248 | 294 | $iVersionId = $_REQUEST['versionid']; |
| 249 | 295 | $sReason = $_REQUEST['reason']; |
| 250 | 296 | $oVersion = Document::get($this->oDocument->getId(), $iVersionId); |
| 251 | - | |
| 297 | + | |
| 252 | 298 | $res = KTDocumentUtil::deleteVersion($this->oDocument, $iVersionId, $sReason); |
| 253 | - | |
| 299 | + | |
| 254 | 300 | if(PEAR::isError($res)){ |
| 255 | 301 | $this->addErrorMessage($res->getMessage()); |
| 256 | 302 | redirect(KTDocumentAction::getURL()); |
| 257 | 303 | exit(0); |
| 258 | 304 | } |
| 259 | - | |
| 305 | + | |
| 260 | 306 | // Record the transaction |
| 261 | 307 | $aOptions['version'] = sprintf('%d.%d', $oVersion->getMajorVersionNumber(), $oVersion->getMinorVersionNumber()); |
| 262 | 308 | $oDocumentTransaction = & new DocumentTransaction($this->oDocument, _kt('Document version deleted'), 'ktcore.transactions.delete_version', $aOptions); |
| 263 | 309 | $oDocumentTransaction->create(); |
| 264 | - | |
| 310 | + | |
| 265 | 311 | redirect(KTDocumentAction::getURL()); |
| 266 | 312 | } |
| 267 | 313 | } |
| ... | ... | @@ -1336,7 +1382,7 @@ class KTDocumentArchiveAction extends KTDocumentAction { |
| 1336 | 1382 | $sReason = $data['reason']; |
| 1337 | 1383 | |
| 1338 | 1384 | $res = KTDocumentUtil::archive($this->oDocument, $sReason); |
| 1339 | - | |
| 1385 | + | |
| 1340 | 1386 | if(PEAR::isError($res)){ |
| 1341 | 1387 | $_SESSION['KTErrorMessage'][] = $res->getMessage(); |
| 1342 | 1388 | controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); |
| ... | ... | @@ -1364,7 +1410,7 @@ class KTDocumentWorkflowAction extends KTDocumentAction { |
| 1364 | 1410 | function getDisplayName() { |
| 1365 | 1411 | return _kt('Workflow'); |
| 1366 | 1412 | } |
| 1367 | - | |
| 1413 | + | |
| 1368 | 1414 | function getInfo() { |
| 1369 | 1415 | if ($this->oDocument->getIsCheckedOut()) { |
| 1370 | 1416 | return null; |
| ... | ... | @@ -1381,7 +1427,7 @@ class KTDocumentWorkflowAction extends KTDocumentAction { |
| 1381 | 1427 | $oWorkflowState = KTWorkflowUtil::getWorkflowStateForDocument($oDocument); |
| 1382 | 1428 | |
| 1383 | 1429 | $oUser =& User::get($_SESSION['userID']); |
| 1384 | - | |
| 1430 | + | |
| 1385 | 1431 | // If the document is checked out - set transitions and workflows to empty and set checkedout to true |
| 1386 | 1432 | $bIsCheckedOut = $this->oDocument->getIsCheckedOut(); |
| 1387 | 1433 | if ($bIsCheckedOut){ |
| ... | ... | @@ -1389,28 +1435,28 @@ class KTDocumentWorkflowAction extends KTDocumentAction { |
| 1389 | 1435 | $aWorkflows = array(); |
| 1390 | 1436 | $transition_fields = array(); |
| 1391 | 1437 | $bHasPerm = FALSE; |
| 1392 | - | |
| 1438 | + | |
| 1393 | 1439 | }else{ |
| 1394 | 1440 | $aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($oDocument, $oUser); |
| 1395 | 1441 | |
| 1396 | 1442 | $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1 '); |
| 1397 | - | |
| 1443 | + | |
| 1398 | 1444 | $bHasPerm = false; |
| 1399 | 1445 | if (KTPermissionUtil::userHasPermissionOnItem($oUser, 'ktcore.permissions.workflow', $oDocument)) { |
| 1400 | 1446 | $bHasPerm = true; |
| 1401 | 1447 | } |
| 1402 | - | |
| 1448 | + | |
| 1403 | 1449 | $fieldErrors = null; |
| 1404 | - | |
| 1450 | + | |
| 1405 | 1451 | $transition_fields = array(); |
| 1406 | - | |
| 1452 | + | |
| 1407 | 1453 | if ($aTransitions) { |
| 1408 | 1454 | $aVocab = array(); |
| 1409 | 1455 | foreach ($aTransitions as $oTransition) { |
| 1410 | 1456 | if(is_null($oTransition) || PEAR::isError($oTransition)){ |
| 1411 | 1457 | continue; |
| 1412 | 1458 | } |
| 1413 | - | |
| 1459 | + | |
| 1414 | 1460 | $aVocab[$oTransition->getId()] = $oTransition->showDescription(); |
| 1415 | 1461 | } |
| 1416 | 1462 | $fieldOptions = array('vocab' => $aVocab); |
| ... | ... | @@ -1422,7 +1468,7 @@ class KTDocumentWorkflowAction extends KTDocumentAction { |
| 1422 | 1468 | array('cols' => 80, 'rows' => 4)); |
| 1423 | 1469 | } |
| 1424 | 1470 | } |
| 1425 | - | |
| 1471 | + | |
| 1426 | 1472 | $aTemplateData = array( |
| 1427 | 1473 | 'oDocument' => $oDocument, |
| 1428 | 1474 | 'oWorkflow' => $oWorkflow, |
| ... | ... | @@ -1479,7 +1525,7 @@ class KTDocumentWorkflowAction extends KTDocumentAction { |
| 1479 | 1525 | function form_quicktransition() { |
| 1480 | 1526 | |
| 1481 | 1527 | $oForm = new KTForm; |
| 1482 | - | |
| 1528 | + | |
| 1483 | 1529 | if($this->oDocument->getIsCheckedOut()){ |
| 1484 | 1530 | $this->addErrorMessage(_kt('The workflow cannot be changed while the document is checked out.')); |
| 1485 | 1531 | }else{ | ... | ... |
templates/ktcore/document/metadata_history.smarty
| ... | ... | @@ -37,7 +37,15 @@ |
| 37 | 37 | <strong>{i18n}current version{/i18n}</strong> |
| 38 | 38 | {else} |
| 39 | 39 | {if ($oVersion->getMetadataStatusID() != VERSION_DELETED)} |
| 40 | - <a href="{addQS}action=viewComparison&fDocumentId={$document->getId()}&fBaseVersion={$oVersion->getMetadataVersionId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}compare with current{/i18n}</a></td> | |
| 40 | + <a href="{addQS}action=viewComparison&fDocumentId={$document->getId()}&fBaseVersion={$oVersion->getMetadataVersionId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}Metadata{/i18n}</a> | |
| 41 | + {if ($bShowCompare)} | |
| 42 | + | | |
| 43 | + {if ($document->getMimeTypeID() != $oVersion->getMimeTypeID())} | |
| 44 | + <span class='descriptiveText'>{i18n}mime types do not match{/i18n}</span> | |
| 45 | + {else} | |
| 46 | + <a style="cursor:hand;" onclick='window.open("{$sUrl}&action=downloadComparison&fDocumentId={$document->getId()}&fBaseVersion={$oVersion->getMetadataVersionId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}", "Document_Diffs");'>{i18n}Content{/i18n}</a> | |
| 47 | + {/if} | |
| 48 | + {/if} | |
| 41 | 49 | {else} |
| 42 | 50 | — |
| 43 | 51 | {/if} |
| ... | ... | @@ -48,7 +56,11 @@ |
| 48 | 56 | — |
| 49 | 57 | {else} |
| 50 | 58 | {if ($oVersion->getMetadataStatusID() != VERSION_DELETED)} |
| 51 | - <a href="{addQS}action=startComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}compare with other version{/i18n}</a> | |
| 59 | + <a href="{addQS}action=startComparison&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}{/addQS}">{i18n}Metadata{/i18n}</a> | |
| 60 | + {if ($bShowVersionCompare)} | |
| 61 | + | | |
| 62 | + <a href="{$sUrl}&action=showContentCompare&fDocumentId={$document->getId()}&fComparisonVersion={$oVersion->getCurrentMetadataVersionId()}">{i18n}Content{/i18n}</a> | |
| 63 | + {/if} | |
| 52 | 64 | {else} |
| 53 | 65 | — |
| 54 | 66 | {/if} |
| ... | ... | @@ -73,7 +85,7 @@ |
| 73 | 85 | </tbody> |
| 74 | 86 | |
| 75 | 87 | </table> |
| 76 | - | |
| 88 | + | |
| 77 | 89 | {if ($showdelete && !$showall)} |
| 78 | 90 | <p> |
| 79 | 91 | <a href="{addQS}fDocumentId={$document->getId()}&show=all{/addQS}">{i18n}Show deleted versions{/i18n}</a> | ... | ... |