Commit bc9e8d33a25f29e4691af5c11ffa257a62651a3b

Authored by kevin_fourie
1 parent db2a68d3

Merged in from DEV trunk...

KTS-2813
"Folder view's checkout function should not apply to documents where workflow configuration blocks checkout"
Fixed. Added a check on the WF disabled actions.

Committed by: Megan Watson
Reviewed by: Jonathan Byrne

KTS-2869
"User with Delete permission can Delete an Immutable document."

Fixed. Added a check for immutable documents in bulk delete.

Committed By: Jonathan Byrne
Reviewed By: Megan Watson

KTC-379
"Fix zseq tables"
Updated. Fixed "ZSEQ SHOULD NOT BE EMPTY ON" and "DB ERROR ON" issues.

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@8042 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/KTBulkActions.php
... ... @@ -49,6 +49,16 @@ class KTBulkDeleteAction extends KTBulkAction {
49 49 function getDisplayName() {
50 50 return _kt('Delete');
51 51 }
  52 +
  53 + function check_entity($oEntity) {
  54 + if(is_a($oEntity, 'Document')) {
  55 + if($oEntity->getImmutable())
  56 + {
  57 + return PEAR::raiseError(_kt('Document cannot be deleted as it is immutable'));
  58 + }
  59 + }
  60 + return parent::check_entity($oEntity);
  61 + }
52 62  
53 63 function form_collectinfo() {
54 64 $oForm = new KTForm;
... ... @@ -732,6 +742,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
732 742  
733 743 function check_entity($oEntity) {
734 744 if(is_a($oEntity, 'Document')) {
  745 + // Check that the document isn't already checked out
735 746 if ($oEntity->getIsCheckedOut()) {
736 747 $checkedOutUser = $oEntity->getCheckedOutUserID();
737 748 $sUserId = $_SESSION['userID'];
... ... @@ -741,6 +752,11 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
741 752 return PEAR::raiseError($oEntity->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName());
742 753 }
743 754 }
  755 +
  756 + // Check that the checkout action isn't restricted for the document
  757 + if(!KTWorkflowUtil::actionEnabledForDocument($oEntity, 'ktcore.actions.document.checkout')){
  758 + return PEAR::raiseError($oEntity->getName().': '._kt('Checkout is restricted by the workflow state.'));
  759 + }
744 760 }else if(!is_a($oEntity, 'Folder')) {
745 761 return PEAR::raiseError(_kt('Document cannot be checked out'));
746 762 }
... ... @@ -944,22 +960,29 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
944 960 continue;
945 961 }
946 962  
947   - // Checkout document - if it is already checked out, check the owner.
  963 + // Check if the action is restricted by workflow on the document
  964 + if(!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.checkout')){
  965 + $this->addErrorMessage($oDocument->getName().': '._kt('Checkout is restricted by the workflow state.'));
  966 + continue;
  967 + }
  968 +
  969 + // Check if document is already checked out, check the owner.
948 970 // If the current user is the owner, then include to the download, otherwise ignore.
949   - $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser);
950   - if(PEAR::isError($res)) {
951   - if($oDocument->getIsCheckedOut()){
952   - $checkedOutUser = $oDocument->getCheckedOutUserID();
953   - $sUserId = $_SESSION['userID'];
954   -
955   - if($checkedOutUser != $sUserId){
956   - $oCheckedOutUser = User::get($checkedOutUser);
957   - $this->addErrorMessage($oDocument->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName());
958   - continue;
959   - }
960   - }
  971 + if($oDocument->getIsCheckedOut()){
  972 + $checkedOutUser = $oDocument->getCheckedOutUserID();
  973 + $sUserId = $_SESSION['userID'];
  974 +
961 975 if($checkedOutUser != $sUserId){
962   - $this->addErrorMessage($oDocument->getName().': '.$res->getMessage());
  976 + $oCheckedOutUser = User::get($checkedOutUser);
  977 + $this->addErrorMessage($oDocument->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName());
  978 + continue;
  979 + }
  980 + }else{
  981 + // Check out document
  982 + $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser);
  983 +
  984 + if(PEAR::isError($res)) {
  985 + $this->addErrorMessage($oDocument->getName().': '._kt('Document could not be checked out. ').$res->getMessage());
963 986 continue;
964 987 }
965 988 }
... ... @@ -967,7 +990,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction {
967 990 // Add document to the zip file
968 991 if($this->bDownload){
969 992 if ($this->bNoisy) {
970   - $oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk checkout", 'ktstandard.transactions.check_out', array());
  993 + $oDocumentTransaction = new DocumentTransaction($oDocument, 'Document part of bulk checkout', 'ktstandard.transactions.check_out', array());
971 994 $oDocumentTransaction->create();
972 995 }
973 996 $sDocFolderId = $oDocument->getFolderID();
... ...
sql/mysql/install/data.sql
... ... @@ -1169,16 +1169,6 @@ INSERT INTO `zseq_authentication_sources` VALUES (1);
1169 1169 UNLOCK TABLES;
1170 1170  
1171 1171 --
1172   --- Dumping data for table `zseq_browse_criteria`
1173   ---
1174   -
1175   -LOCK TABLES `zseq_browse_criteria` WRITE;
1176   -/*!40000 ALTER TABLE `zseq_browse_criteria` DISABLE KEYS */;
1177   -INSERT INTO `zseq_browse_criteria` VALUES (5);
1178   -/*!40000 ALTER TABLE `zseq_browse_criteria` ENABLE KEYS */;
1179   -UNLOCK TABLES;
1180   -
1181   ---
1182 1172 -- Dumping data for table `zseq_column_entries`
1183 1173 --
1184 1174  
... ... @@ -1209,26 +1199,6 @@ INSERT INTO `zseq_data_types` VALUES (5);
1209 1199 UNLOCK TABLES;
1210 1200  
1211 1201 --
1212   --- Dumping data for table `zseq_dependant_document_instance`
1213   ---
1214   -
1215   -LOCK TABLES `zseq_dependant_document_instance` WRITE;
1216   -/*!40000 ALTER TABLE `zseq_dependant_document_instance` DISABLE KEYS */;
1217   -INSERT INTO `zseq_dependant_document_instance` VALUES (1);
1218   -/*!40000 ALTER TABLE `zseq_dependant_document_instance` ENABLE KEYS */;
1219   -UNLOCK TABLES;
1220   -
1221   ---
1222   --- Dumping data for table `zseq_dependant_document_template`
1223   ---
1224   -
1225   -LOCK TABLES `zseq_dependant_document_template` WRITE;
1226   -/*!40000 ALTER TABLE `zseq_dependant_document_template` DISABLE KEYS */;
1227   -INSERT INTO `zseq_dependant_document_template` VALUES (1);
1228   -/*!40000 ALTER TABLE `zseq_dependant_document_template` ENABLE KEYS */;
1229   -UNLOCK TABLES;
1230   -
1231   ---
1232 1202 -- Dumping data for table `zseq_discussion_comments`
1233 1203 --
1234 1204  
... ... @@ -1353,7 +1323,7 @@ UNLOCK TABLES;
1353 1323  
1354 1324 LOCK TABLES `zseq_document_transaction_types_lookup` WRITE;
1355 1325 /*!40000 ALTER TABLE `zseq_document_transaction_types_lookup` DISABLE KEYS */;
1356   -INSERT INTO `zseq_document_transaction_types_lookup` VALUES (20);
  1326 +INSERT INTO `zseq_document_transaction_types_lookup` VALUES (21);
1357 1327 /*!40000 ALTER TABLE `zseq_document_transaction_types_lookup` ENABLE KEYS */;
1358 1328 UNLOCK TABLES;
1359 1329  
... ... @@ -1512,7 +1482,7 @@ UNLOCK TABLES;
1512 1482  
1513 1483 LOCK TABLES `zseq_help` WRITE;
1514 1484 /*!40000 ALTER TABLE `zseq_help` DISABLE KEYS */;
1515   -INSERT INTO `zseq_help` VALUES (98);
  1485 +INSERT INTO `zseq_help` VALUES (100);
1516 1486 /*!40000 ALTER TABLE `zseq_help` ENABLE KEYS */;
1517 1487 UNLOCK TABLES;
1518 1488  
... ... @@ -1750,7 +1720,7 @@ UNLOCK TABLES;
1750 1720  
1751 1721 LOCK TABLES `zseq_scheduler_tasks` WRITE;
1752 1722 /*!40000 ALTER TABLE `zseq_scheduler_tasks` DISABLE KEYS */;
1753   -INSERT INTO `zseq_scheduler_tasks` VALUES (3);
  1723 +INSERT INTO `zseq_scheduler_tasks` VALUES (5);
1754 1724 /*!40000 ALTER TABLE `zseq_scheduler_tasks` ENABLE KEYS */;
1755 1725 UNLOCK TABLES;
1756 1726  
... ... @@ -1769,7 +1739,7 @@ UNLOCK TABLES;
1769 1739  
1770 1740 LOCK TABLES `zseq_status_lookup` WRITE;
1771 1741 /*!40000 ALTER TABLE `zseq_status_lookup` DISABLE KEYS */;
1772   -INSERT INTO `zseq_status_lookup` VALUES (5);
  1742 +INSERT INTO `zseq_status_lookup` VALUES (6);
1773 1743 /*!40000 ALTER TABLE `zseq_status_lookup` ENABLE KEYS */;
1774 1744 UNLOCK TABLES;
1775 1745  
... ...
sql/mysql/install/structure.sql
... ... @@ -1799,15 +1799,6 @@ CREATE TABLE `zseq_authentication_sources` (
1799 1799 ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
1800 1800  
1801 1801 --
1802   --- Table structure for table `zseq_browse_criteria`
1803   ---
1804   -
1805   -CREATE TABLE `zseq_browse_criteria` (
1806   - `id` int(10) unsigned NOT NULL auto_increment,
1807   - PRIMARY KEY (`id`)
1808   -) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
1809   -
1810   ---
1811 1802 -- Table structure for table `zseq_column_entries`
1812 1803 --
1813 1804  
... ... @@ -1835,24 +1826,6 @@ CREATE TABLE `zseq_data_types` (
1835 1826 ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
1836 1827  
1837 1828 --
1838   --- Table structure for table `zseq_dependant_document_instance`
1839   ---
1840   -
1841   -CREATE TABLE `zseq_dependant_document_instance` (
1842   - `id` int(10) unsigned NOT NULL auto_increment,
1843   - PRIMARY KEY (`id`)
1844   -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
1845   -
1846   ---
1847   --- Table structure for table `zseq_dependant_document_template`
1848   ---
1849   -
1850   -CREATE TABLE `zseq_dependant_document_template` (
1851   - `id` int(10) unsigned NOT NULL auto_increment,
1852   - PRIMARY KEY (`id`)
1853   -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
1854   -
1855   ---
1856 1829 -- Table structure for table `zseq_discussion_comments`
1857 1830 --
1858 1831  
... ... @@ -1967,7 +1940,7 @@ CREATE TABLE `zseq_document_tags` (
1967 1940 CREATE TABLE `zseq_document_transaction_types_lookup` (
1968 1941 `id` int(10) unsigned NOT NULL auto_increment,
1969 1942 PRIMARY KEY (`id`)
1970   -) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1;
  1943 +) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=latin1;
1971 1944  
1972 1945 --
1973 1946 -- Table structure for table `zseq_document_transactions`
... ... @@ -2111,7 +2084,7 @@ CREATE TABLE `zseq_groups_lookup` (
2111 2084 CREATE TABLE `zseq_help` (
2112 2085 `id` int(10) unsigned NOT NULL auto_increment,
2113 2086 PRIMARY KEY (`id`)
2114   -) ENGINE=MyISAM AUTO_INCREMENT=99 DEFAULT CHARSET=latin1;
  2087 +) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=latin1;
2115 2088  
2116 2089 --
2117 2090 -- Table structure for table `zseq_help_replacement`
... ... @@ -2353,7 +2326,7 @@ CREATE TABLE `zseq_search_saved` (
2353 2326 CREATE TABLE `zseq_status_lookup` (
2354 2327 `id` int(10) unsigned NOT NULL auto_increment,
2355 2328 PRIMARY KEY (`id`)
2356   -) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
  2329 +) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;
2357 2330  
2358 2331 --
2359 2332 -- Table structure for table `zseq_system_settings`
... ...