mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-01 06:27:15 +00:00
- use database transactions
This commit is contained in:
parent
aeec43c5fb
commit
1c82746c64
|
@ -240,16 +240,22 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
function setCategories($newCategories) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$db->startTransaction();
|
||||
$queryStr = "DELETE from tblDocumentCategory WHERE documentID = ". $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($newCategories as $cat) {
|
||||
$queryStr = "INSERT INTO tblDocumentCategory (categoryID, documentID) VALUES (". $cat->getId() .", ". $this->_id .")";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
$this->_categories = $newCategories;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
@ -1067,15 +1073,26 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
$version = $resArr[0]['m']+1;
|
||||
}
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
$queryStr = "INSERT INTO tblDocumentContent (document, version, comment, date, createdBy, dir, orgFileName, fileType, mimeType) VALUES ".
|
||||
"(".$this->_id.", ".(int)$version.",".$db->qstr($comment).", ".$date.", ".$user->getID().", ".$db->qstr($dir).", ".$db->qstr($orgFileName).", ".$db->qstr($fileType).", ".$db->qstr($mimeType).")";
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$contentID = $db->getInsertID();
|
||||
|
||||
// copy file
|
||||
if (!LetoDMS_Core_File::makeDir($this->_dms->contentDir . $dir)) return false;
|
||||
if (!LetoDMS_Core_File::copyFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType)) return false;
|
||||
if (!LetoDMS_Core_File::makeDir($this->_dms->contentDir . $dir)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
if (!LetoDMS_Core_File::copyFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->_content);
|
||||
unset($this->_latestContent);
|
||||
|
@ -1087,6 +1104,7 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
if(trim($attribute))
|
||||
if(!$content->setAttributeValue($this->_dms->getAttributeDefinition($attrdefid), $attribute)) {
|
||||
$this->removeContent($content);
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1098,8 +1116,11 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
|
||||
$queryStr = "INSERT INTO `tblDocumentStatus` (`documentID`, `version`) ".
|
||||
"VALUES (". $this->_id .", ". (int) $version .")";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$this->removeContent($content);
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$statusID = $db->getInsertID();
|
||||
|
||||
|
@ -1155,11 +1176,14 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
}
|
||||
$queryStr = "INSERT INTO `tblDocumentStatusLog` (`statusID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $statusID ."', '". $status."', 'New document content submitted". $comment ."', CURRENT_TIMESTAMP, '". $user->getID() ."')";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$docResultSet->setStatus($status,$comment,$user);
|
||||
|
||||
$db->commitTransaction();
|
||||
return $docResultSet;
|
||||
} /* }}} */
|
||||
|
||||
|
@ -1242,24 +1266,34 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
if (!LetoDMS_Core_File::removeFile( $this->_dms->contentDir.$version->getPath() ))
|
||||
return false;
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
$status = $version->getStatus();
|
||||
$stID = $status["statusID"];
|
||||
|
||||
$queryStr = "DELETE FROM tblDocumentContent WHERE `document` = " . $this->getID() . " AND `version` = " . $version->_version;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblDocumentContentAttributes WHERE content = " . $version->getId();
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM `tblDocumentStatusLog` WHERE `statusID` = '".$stID."'";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM `tblDocumentStatus` WHERE `documentID` = '". $this->getID() ."' AND `version` = '" . $version->_version."'";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$status = $version->getReviewStatus();
|
||||
$stList = "";
|
||||
|
@ -1272,12 +1306,16 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
|
||||
if (strlen($stList)>0) {
|
||||
$queryStr = "DELETE FROM `tblDocumentReviewLog` WHERE `tblDocumentReviewLog`.`reviewID` IN (".$stList.")";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$queryStr = "DELETE FROM `tblDocumentReviewers` WHERE `documentID` = '". $this->getID() ."' AND `version` = '" . $version->_version."'";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$status = $version->getApprovalStatus();
|
||||
$stList = "";
|
||||
foreach ($status as $st) {
|
||||
|
@ -1288,13 +1326,18 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
}
|
||||
if (strlen($stList)>0) {
|
||||
$queryStr = "DELETE FROM `tblDocumentApproveLog` WHERE `tblDocumentApproveLog`.`approveID` IN (".$stList.")";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$queryStr = "DELETE FROM `tblDocumentApprovers` WHERE `documentID` = '". $this->getID() ."' AND `version` = '" . $version->_version."'";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
|
@ -1432,58 +1475,92 @@ class LetoDMS_Core_Document extends LetoDMS_Core_Object { /* {{{ */
|
|||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Remove a document completly
|
||||
*
|
||||
* @return boolean true on success, otherwise false
|
||||
*/
|
||||
function remove() { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$res = $this->getContent();
|
||||
if (is_bool($res) && !$res) return false;
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
// FIXME: call a new function removeContent instead
|
||||
foreach ($this->_content as $version)
|
||||
if (!$this->removeContent($version))
|
||||
foreach ($this->_content as $version) {
|
||||
if (!$this->removeContent($version)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// remove document file
|
||||
$res = $this->getDocumentFiles();
|
||||
if (is_bool($res) && !$res) return false;
|
||||
if (is_bool($res) && !$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($res as $documentfile)
|
||||
if(!$this->removeDocumentFile($documentfile->getId()))
|
||||
if(!$this->removeDocumentFile($documentfile->getId())) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: versioning file?
|
||||
|
||||
if (file_exists( $this->_dms->contentDir . $this->getDir() ))
|
||||
if (!LetoDMS_Core_File::removeDir( $this->_dms->contentDir . $this->getDir() ))
|
||||
if (!LetoDMS_Core_File::removeDir( $this->_dms->contentDir . $this->getDir() )) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblDocuments WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblDocumentAttributes WHERE document = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblACLs WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblDocumentLinks WHERE document = " . $this->_id . " OR target = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblDocumentLocks WHERE document = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblDocumentFiles WHERE document = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblDocumentCategory WHERE documentID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the notification list.
|
||||
$queryStr = "DELETE FROM tblNotify WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
|
|
|
@ -371,11 +371,16 @@ class LetoDMS_Core_Folder extends LetoDMS_Core_Object {
|
|||
if (strlen($pathPrefix)>1) {
|
||||
$pathPrefix .= ":";
|
||||
}
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
//inheritAccess = true, defaultAccess = M_READ
|
||||
$queryStr = "INSERT INTO tblFolders (name, parent, folderList, comment, date, owner, inheritAccess, defaultAccess, sequence) ".
|
||||
"VALUES (".$db->qstr($name).", ".$this->_id.", ".$db->qstr($pathPrefix).", ".$db->qstr($comment).", ".time().", ".$owner->getID().", 1, ".M_READ.", ". $sequence.")";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$newFolder = $this->_dms->getFolder($db->getInsertID());
|
||||
unset($this->_subFolders);
|
||||
|
||||
|
@ -383,12 +388,13 @@ class LetoDMS_Core_Folder extends LetoDMS_Core_Object {
|
|||
foreach($attributes as $attrdefid=>$attribute) {
|
||||
if(trim($attribute))
|
||||
if(!$newFolder->setAttributeValue($this->_dms->getAttributeDefinition($attrdefid), $attribute)) {
|
||||
$newFolder->remove();
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return $newFolder;
|
||||
} /* }}} */
|
||||
|
||||
|
@ -525,10 +531,14 @@ class LetoDMS_Core_Folder extends LetoDMS_Core_Object {
|
|||
$pathPrefix .= ":";
|
||||
}
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
$queryStr = "INSERT INTO tblDocuments (name, comment, date, expires, owner, folder, folderList, inheritAccess, defaultAccess, locked, keywords, sequence) VALUES ".
|
||||
"(".$db->qstr($name).", ".$db->qstr($comment).", " . time().", ".(int) $expires.", ".$owner->getID().", ".$this->_id.",".$db->qstr($pathPrefix).", 1, ".M_READ.", -1, ".$db->qstr($keywords).", " . $sequence . ")";
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$document = $this->_dms->getDocument($db->getInsertID());
|
||||
|
||||
|
@ -537,8 +547,7 @@ class LetoDMS_Core_Folder extends LetoDMS_Core_Object {
|
|||
else $res = $document->addContent($comment, $owner, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers, $approvers,$reqversion, $version_attributes);
|
||||
|
||||
if (is_bool($res) && !$res) {
|
||||
$queryStr = "DELETE FROM tblDocuments WHERE id = " . $document->getID();
|
||||
$db->getResult($queryStr);
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -551,11 +560,13 @@ class LetoDMS_Core_Folder extends LetoDMS_Core_Object {
|
|||
if(trim($attribute))
|
||||
if(!$document->setAttributeValue($this->_dms->getAttributeDefinition($attrdefid), $attribute)) {
|
||||
$document->remove();
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return array($document, $res);
|
||||
} /* }}} */
|
||||
|
||||
|
@ -575,28 +586,42 @@ class LetoDMS_Core_Folder extends LetoDMS_Core_Object {
|
|||
|
||||
foreach ($this->_subFolders as $subFolder) {
|
||||
$res = $subFolder->remove();
|
||||
if (!$res) return false;
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->_documents as $document) {
|
||||
$res = $document->remove();
|
||||
if (!$res) return false;
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Entfernen der Datenbankeinträge
|
||||
$db->rollbackTransaction();
|
||||
$queryStr = "DELETE FROM tblFolders WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblFolderAttributes WHERE folder = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblACLs WHERE target = ". $this->_id. " AND targetType = " . T_FOLDER;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblNotify WHERE target = ". $this->_id. " AND targetType = " . T_FOLDER;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$db->commitTransaction();
|
||||
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
|
|
@ -191,24 +191,38 @@ class LetoDMS_Core_Group {
|
|||
function remove($user) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$queryStr = "DELETE FROM tblGroups WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
return false;
|
||||
$db->startTransaction();
|
||||
|
||||
$queryStr = "DELETE FROM tblGroupMembers WHERE groupID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblACLs WHERE groupID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblNotify WHERE groupID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblMandatoryReviewers WHERE reviewerGroupID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblMandatoryApprovers WHERE approverGroupID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "DELETE FROM tblGroups WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO : update document status if reviewer/approver has been deleted
|
||||
|
||||
|
@ -218,6 +232,10 @@ class LetoDMS_Core_Group {
|
|||
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $r["reviewID"] ."', '-2', 'Review group removed from process', NOW(), '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$approvalStatus = $this->getApprovalStatus();
|
||||
|
@ -225,8 +243,14 @@ class LetoDMS_Core_Group {
|
|||
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $a["approveID"] ."', '-2', 'Approval group removed from process', NOW(), '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
|
|
|
@ -122,14 +122,20 @@ class LetoDMS_Core_KeywordCategory {
|
|||
function remove() {
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$db->startTransaction();
|
||||
$queryStr = "DELETE FROM tblKeywords WHERE category = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblKeywordCategories WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr))
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,6 +376,8 @@ class LetoDMS_Core_User {
|
|||
return;
|
||||
$assignTo = $assignToUser->getID();
|
||||
|
||||
$db->startTransaction();
|
||||
|
||||
// delete private keyword lists
|
||||
$queryStr = "SELECT tblKeywords.id FROM tblKeywords, tblKeywordCategories WHERE tblKeywords.category = tblKeywordCategories.id AND tblKeywordCategories.owner = " . $this->_id;
|
||||
$resultArr = $db->getResultArray($queryStr);
|
||||
|
@ -386,83 +388,145 @@ class LetoDMS_Core_User {
|
|||
if ($i + 1 < count($resultArr))
|
||||
$queryStr .= " OR ";
|
||||
}
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblKeywordCategories WHERE owner = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
//Benachrichtigungen entfernen
|
||||
$queryStr = "DELETE FROM tblNotify WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Assign documents of the removed user to the given user */
|
||||
$queryStr = "UPDATE tblFolders SET owner = " . $assignTo . " WHERE owner = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "UPDATE tblDocuments SET owner = " . $assignTo . " WHERE owner = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "UPDATE tblDocumentContent SET createdBy = " . $assignTo . " WHERE createdBy = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove private links on documents ...
|
||||
$queryStr = "DELETE FROM tblDocumentLinks WHERE userID = " . $this->_id . " AND public = 0";
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// ... but keep public links
|
||||
$queryStr = "UPDATE tblDocumentLinks SET userID = " . $assignTo . " WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// set administrator for deleted user's attachments
|
||||
$queryStr = "UPDATE tblDocumentFiles SET userID = " . $assignTo . " WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
//Evtl. von diesem Benutzer gelockte Dokumente werden freigegeben
|
||||
$queryStr = "DELETE FROM tblDocumentLocks WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete user from all groups
|
||||
$queryStr = "DELETE FROM tblGroupMembers WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// User aus allen ACLs streichen
|
||||
$queryStr = "DELETE FROM tblACLs WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete image of user
|
||||
$queryStr = "DELETE FROM tblUserImages WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete entries in password history
|
||||
$queryStr = "DELETE FROM tblUserPasswordHistory WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete entries in password request
|
||||
$queryStr = "DELETE FROM tblUserPasswordRequest WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
|
||||
// Delete user itself
|
||||
$queryStr = "DELETE FROM tblUsers WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// mandatory review/approve
|
||||
$queryStr = "DELETE FROM tblMandatoryReviewers WHERE reviewerUserID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblMandatoryApprovers WHERE approverUserID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblMandatoryReviewers WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "DELETE FROM tblMandatoryApprovers WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// set administrator for deleted user's events
|
||||
$queryStr = "UPDATE tblEvents SET userID = " . $assignTo . " WHERE userID = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete user itself
|
||||
$queryStr = "DELETE FROM tblUsers WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO : update document status if reviewer/approver has been deleted
|
||||
// "DELETE FROM tblDocumentApproveLog WHERE userID = " . $this->_id;
|
||||
|
@ -474,6 +538,10 @@ class LetoDMS_Core_User {
|
|||
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $ri["reviewID"] ."', '-2', 'Reviewer removed from process', NOW(), '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$approvalStatus = $this->getApprovalStatus();
|
||||
|
@ -481,8 +549,13 @@ class LetoDMS_Core_User {
|
|||
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $ai["approveID"] ."', '-2', 'Approver removed from process', NOW(), '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
// unset($this);
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
|
Loading…
Reference in New Issue
Block a user