mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-08 20:46:05 +00:00
addDocumentFiles() clears internal list, make removeDocumentFile() more robust
This commit is contained in:
parent
08887fcbd9
commit
233e464692
|
@ -2358,29 +2358,37 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->commitTransaction();
|
$db->commitTransaction();
|
||||||
|
unset ($this->_documentFiles);
|
||||||
return $file;
|
return $file;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function removeDocumentFile($ID) { /* {{{ */
|
function removeDocumentFile($ID) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if (!is_numeric($ID)) return false;
|
if (!is_numeric($ID) || $ID < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
$file = $this->getDocumentFile($ID);
|
$file = $this->getDocumentFile($ID);
|
||||||
if (is_bool($file) && !$file) return false;
|
if (is_bool($file) && !$file) return false;
|
||||||
|
|
||||||
if (file_exists( $this->_dms->contentDir . $file->getPath() )){
|
$db->startTransaction();
|
||||||
if (!SeedDMS_Core_File::removeFile( $this->_dms->contentDir . $file->getPath() ))
|
/* First delete the database record, because that can be undone
|
||||||
return false;
|
* if deletion of the file fails.
|
||||||
|
*/
|
||||||
|
$queryStr = "DELETE FROM `tblDocumentFiles` WHERE `document` = " . $this->getID() . " AND `id` = " . (int) $ID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name=$file->getName();
|
if (file_exists( $this->_dms->contentDir . $file->getPath() )){
|
||||||
$comment=$file->getcomment();
|
if (!SeedDMS_Core_File::removeFile( $this->_dms->contentDir . $file->getPath() )) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
$queryStr = "DELETE FROM `tblDocumentFiles` WHERE `document` = " . $this->getID() . " AND `id` = " . (int) $ID;
|
return false;
|
||||||
if (!$db->getResult($queryStr))
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
$db->commitTransaction();
|
||||||
unset ($this->_documentFiles);
|
unset ($this->_documentFiles);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user