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
This commit is contained in:
Uwe Steinmann 2015-04-17 20:05:34 +02:00
parent 2d7e511bb8
commit 7bc0b8947f

View File

@ -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;