Commit b11d71dbef328131f164746b05b1462d8a112d5a

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