From bc9e8d33a25f29e4691af5c11ffa257a62651a3b Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Wed, 13 Feb 2008 10:30:18 +0000 Subject: [PATCH] Merged in from DEV trunk... --- plugins/ktcore/KTBulkActions.php | 53 ++++++++++++++++++++++++++++++++++++++--------------- sql/mysql/install/data.sql | 38 ++++---------------------------------- sql/mysql/install/structure.sql | 33 +++------------------------------ 3 files changed, 45 insertions(+), 79 deletions(-) diff --git a/plugins/ktcore/KTBulkActions.php b/plugins/ktcore/KTBulkActions.php index ecca7d0..ba957ac 100644 --- a/plugins/ktcore/KTBulkActions.php +++ b/plugins/ktcore/KTBulkActions.php @@ -49,6 +49,16 @@ class KTBulkDeleteAction extends KTBulkAction { function getDisplayName() { return _kt('Delete'); } + + function check_entity($oEntity) { + if(is_a($oEntity, 'Document')) { + if($oEntity->getImmutable()) + { + return PEAR::raiseError(_kt('Document cannot be deleted as it is immutable')); + } + } + return parent::check_entity($oEntity); + } function form_collectinfo() { $oForm = new KTForm; @@ -732,6 +742,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { function check_entity($oEntity) { if(is_a($oEntity, 'Document')) { + // Check that the document isn't already checked out if ($oEntity->getIsCheckedOut()) { $checkedOutUser = $oEntity->getCheckedOutUserID(); $sUserId = $_SESSION['userID']; @@ -741,6 +752,11 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { return PEAR::raiseError($oEntity->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName()); } } + + // Check that the checkout action isn't restricted for the document + if(!KTWorkflowUtil::actionEnabledForDocument($oEntity, 'ktcore.actions.document.checkout')){ + return PEAR::raiseError($oEntity->getName().': '._kt('Checkout is restricted by the workflow state.')); + } }else if(!is_a($oEntity, 'Folder')) { return PEAR::raiseError(_kt('Document cannot be checked out')); } @@ -944,22 +960,29 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { continue; } - // Checkout document - if it is already checked out, check the owner. + // Check if the action is restricted by workflow on the document + if(!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.checkout')){ + $this->addErrorMessage($oDocument->getName().': '._kt('Checkout is restricted by the workflow state.')); + continue; + } + + // Check if document is already checked out, check the owner. // If the current user is the owner, then include to the download, otherwise ignore. - $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser); - if(PEAR::isError($res)) { - if($oDocument->getIsCheckedOut()){ - $checkedOutUser = $oDocument->getCheckedOutUserID(); - $sUserId = $_SESSION['userID']; - - if($checkedOutUser != $sUserId){ - $oCheckedOutUser = User::get($checkedOutUser); - $this->addErrorMessage($oDocument->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName()); - continue; - } - } + if($oDocument->getIsCheckedOut()){ + $checkedOutUser = $oDocument->getCheckedOutUserID(); + $sUserId = $_SESSION['userID']; + if($checkedOutUser != $sUserId){ - $this->addErrorMessage($oDocument->getName().': '.$res->getMessage()); + $oCheckedOutUser = User::get($checkedOutUser); + $this->addErrorMessage($oDocument->getName().': '._kt('Document has already been checked out by ').$oCheckedOutUser->getName()); + continue; + } + }else{ + // Check out document + $res = KTDocumentUtil::checkout($oDocument, $sReason, $this->oUser); + + if(PEAR::isError($res)) { + $this->addErrorMessage($oDocument->getName().': '._kt('Document could not be checked out. ').$res->getMessage()); continue; } } @@ -967,7 +990,7 @@ class KTBrowseBulkCheckoutAction extends KTBulkAction { // Add document to the zip file if($this->bDownload){ if ($this->bNoisy) { - $oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk checkout", 'ktstandard.transactions.check_out', array()); + $oDocumentTransaction = new DocumentTransaction($oDocument, 'Document part of bulk checkout', 'ktstandard.transactions.check_out', array()); $oDocumentTransaction->create(); } $sDocFolderId = $oDocument->getFolderID(); diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index 79c8c1f..345aee1 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -1169,16 +1169,6 @@ INSERT INTO `zseq_authentication_sources` VALUES (1); UNLOCK TABLES; -- --- Dumping data for table `zseq_browse_criteria` --- - -LOCK TABLES `zseq_browse_criteria` WRITE; -/*!40000 ALTER TABLE `zseq_browse_criteria` DISABLE KEYS */; -INSERT INTO `zseq_browse_criteria` VALUES (5); -/*!40000 ALTER TABLE `zseq_browse_criteria` ENABLE KEYS */; -UNLOCK TABLES; - --- -- Dumping data for table `zseq_column_entries` -- @@ -1209,26 +1199,6 @@ INSERT INTO `zseq_data_types` VALUES (5); UNLOCK TABLES; -- --- Dumping data for table `zseq_dependant_document_instance` --- - -LOCK TABLES `zseq_dependant_document_instance` WRITE; -/*!40000 ALTER TABLE `zseq_dependant_document_instance` DISABLE KEYS */; -INSERT INTO `zseq_dependant_document_instance` VALUES (1); -/*!40000 ALTER TABLE `zseq_dependant_document_instance` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `zseq_dependant_document_template` --- - -LOCK TABLES `zseq_dependant_document_template` WRITE; -/*!40000 ALTER TABLE `zseq_dependant_document_template` DISABLE KEYS */; -INSERT INTO `zseq_dependant_document_template` VALUES (1); -/*!40000 ALTER TABLE `zseq_dependant_document_template` ENABLE KEYS */; -UNLOCK TABLES; - --- -- Dumping data for table `zseq_discussion_comments` -- @@ -1353,7 +1323,7 @@ UNLOCK TABLES; LOCK TABLES `zseq_document_transaction_types_lookup` WRITE; /*!40000 ALTER TABLE `zseq_document_transaction_types_lookup` DISABLE KEYS */; -INSERT INTO `zseq_document_transaction_types_lookup` VALUES (20); +INSERT INTO `zseq_document_transaction_types_lookup` VALUES (21); /*!40000 ALTER TABLE `zseq_document_transaction_types_lookup` ENABLE KEYS */; UNLOCK TABLES; @@ -1512,7 +1482,7 @@ UNLOCK TABLES; LOCK TABLES `zseq_help` WRITE; /*!40000 ALTER TABLE `zseq_help` DISABLE KEYS */; -INSERT INTO `zseq_help` VALUES (98); +INSERT INTO `zseq_help` VALUES (100); /*!40000 ALTER TABLE `zseq_help` ENABLE KEYS */; UNLOCK TABLES; @@ -1750,7 +1720,7 @@ UNLOCK TABLES; LOCK TABLES `zseq_scheduler_tasks` WRITE; /*!40000 ALTER TABLE `zseq_scheduler_tasks` DISABLE KEYS */; -INSERT INTO `zseq_scheduler_tasks` VALUES (3); +INSERT INTO `zseq_scheduler_tasks` VALUES (5); /*!40000 ALTER TABLE `zseq_scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; @@ -1769,7 +1739,7 @@ UNLOCK TABLES; LOCK TABLES `zseq_status_lookup` WRITE; /*!40000 ALTER TABLE `zseq_status_lookup` DISABLE KEYS */; -INSERT INTO `zseq_status_lookup` VALUES (5); +INSERT INTO `zseq_status_lookup` VALUES (6); /*!40000 ALTER TABLE `zseq_status_lookup` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/mysql/install/structure.sql b/sql/mysql/install/structure.sql index 9b2f8fc..777c6fe 100644 --- a/sql/mysql/install/structure.sql +++ b/sql/mysql/install/structure.sql @@ -1799,15 +1799,6 @@ CREATE TABLE `zseq_authentication_sources` ( ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; -- --- Table structure for table `zseq_browse_criteria` --- - -CREATE TABLE `zseq_browse_criteria` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; - --- -- Table structure for table `zseq_column_entries` -- @@ -1835,24 +1826,6 @@ CREATE TABLE `zseq_data_types` ( ) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; -- --- Table structure for table `zseq_dependant_document_instance` --- - -CREATE TABLE `zseq_dependant_document_instance` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; - --- --- Table structure for table `zseq_dependant_document_template` --- - -CREATE TABLE `zseq_dependant_document_template` ( - `id` int(10) unsigned NOT NULL auto_increment, - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; - --- -- Table structure for table `zseq_discussion_comments` -- @@ -1967,7 +1940,7 @@ CREATE TABLE `zseq_document_tags` ( CREATE TABLE `zseq_document_transaction_types_lookup` ( `id` int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1; +) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=latin1; -- -- Table structure for table `zseq_document_transactions` @@ -2111,7 +2084,7 @@ CREATE TABLE `zseq_groups_lookup` ( CREATE TABLE `zseq_help` ( `id` int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=99 DEFAULT CHARSET=latin1; +) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=latin1; -- -- Table structure for table `zseq_help_replacement` @@ -2353,7 +2326,7 @@ CREATE TABLE `zseq_search_saved` ( CREATE TABLE `zseq_status_lookup` ( `id` int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; +) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; -- -- Table structure for table `zseq_system_settings` -- libgit2 0.21.4