From 7bc0b8947f9753f65e3a8b62854fd0c64ea9e9e5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 17 Apr 2015 20:05:34 +0200 Subject: [PATCH] add sql statements to setOwner() for moving locks and checkouts still commented out, but the idea is, that the user of a lock and checkout of a document should also be changed if the document owner changes --- SeedDMS_Core/Core/inc.ClassDocument.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index db6f696e4..441d3c870 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -397,9 +397,31 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ function setOwner($newOwner) { /* {{{ */ $db = $this->_dms->getDB(); + $oldOwner = self::getOwner(); + + $db->startTransaction(); $queryStr = "UPDATE tblDocuments set owner = " . $newOwner->getID() . " WHERE id = " . $this->_id; - if (!$db->getResult($queryStr)) + if (!$db->getResult($queryStr)) { + $db->rollbackTransaction(); return false; + } + + /* FIXME: Update also all locks and checkouts done by the previous owner */ + /* + $queryStr = "UPDATE tblDocumentLocks set userID = " . $newOwner->getID() . " WHERE document = " . $this->_id . " AND userID = " . $oldOwner->getID(); + if (!$db->getResult($queryStr)) { + $db->rollbackTransaction(); + return false; + } + + $queryStr = "UPDATE tblDocumentCheckOuts set userID = " . $newOwner->getID() . " WHERE document = " . $this->_id . " AND userID = " . $oldOwner->getID(); + if (!$db->getResult($queryStr)) { + $db->rollbackTransaction(); + return false; + } + */ + + $db->commitTransaction(); $this->_ownerID = $newOwner->getID(); $this->_owner = $newOwner;