mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
- addContent() determines a new version number itself and doesn't relay
on the auto_increment of the database anymore - some mor documentation
This commit is contained in:
parent
56b2211263
commit
e3ad95de38
|
@ -165,6 +165,15 @@ class LetoDMS_Document { /* {{{ */
|
||||||
return $this->_folder;
|
return $this->_folder;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set folder of a document
|
||||||
|
*
|
||||||
|
* This function basically moves a document from a folder to another
|
||||||
|
* folder.
|
||||||
|
*
|
||||||
|
* @param object $newFolder
|
||||||
|
* @return boolean false in case of an error, otherwise true
|
||||||
|
*/
|
||||||
function setFolder($newFolder) { /* {{{ */
|
function setFolder($newFolder) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -775,29 +784,48 @@ class LetoDMS_Document { /* {{{ */
|
||||||
return 0;
|
return 0;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function addContent($comment, $user, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers=array(), $approvers=array(),$version=0,$send_email=TRUE) { /* {{{ */
|
/**
|
||||||
|
* Add content to a document
|
||||||
|
*
|
||||||
|
* Each document may have any number of content elements attached to it.
|
||||||
|
* Each content element has a version number. Newer versions (greater
|
||||||
|
* version number) replace older versions.
|
||||||
|
*
|
||||||
|
* @param string $comment comment
|
||||||
|
* @param object $user user who shall be the owner of this content
|
||||||
|
* @param string $tmpFile file containing the actuall content
|
||||||
|
* @param string $orgFileName original file name
|
||||||
|
* @param string $mimeType MimeType of the content
|
||||||
|
* @param array $reviewers list of reviewers
|
||||||
|
* @param array $approvers list of approvers
|
||||||
|
* @param integer $version version number of content or 0 if next higher version shall be used.
|
||||||
|
* @return bool/array false in case of an error or a result set
|
||||||
|
*/
|
||||||
|
function addContent($comment, $user, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers=array(), $approvers=array(), $version=0) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
// the doc path is id/version.filetype
|
// the doc path is id/version.filetype
|
||||||
$dir = $this->getDir();
|
$dir = $this->getDir();
|
||||||
|
|
||||||
//Eintrag in tblDocumentContent
|
|
||||||
$date = mktime();
|
$date = mktime();
|
||||||
|
|
||||||
if ((int)$version<1){
|
/* The version field in table tblDocumentContent used to be auto
|
||||||
|
* increment but that requires the field to be primary as well if
|
||||||
|
* innodb is used. That's why the version is now determined here.
|
||||||
|
*/
|
||||||
|
if ((int)$version<1) {
|
||||||
|
$queryStr = "SELECT MAX(version) as m from tblDocumentContent where document = ".$this->_id;
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && !$res)
|
||||||
|
return false;
|
||||||
|
|
||||||
$queryStr = "INSERT INTO tblDocumentContent (document, comment, date, createdBy, dir, orgFileName, fileType, mimeType) VALUES ".
|
$version = $resArr[0]['m']+1;
|
||||||
"(".$this->_id.", '".$comment."', ".$date.", ".$user->getID().", '".$dir."', '".$orgFileName."', '".$fileType."', '" . $mimeType . "')";
|
|
||||||
if (!$db->getResult($queryStr)) return false;
|
|
||||||
|
|
||||||
$version = $db->getInsertID();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
$queryStr = "INSERT INTO tblDocumentContent (document, version, comment, date, createdBy, dir, orgFileName, fileType, mimeType) VALUES ".
|
|
||||||
"(".$this->_id.", ".(int)$version.",'".$comment."', ".$date.", ".$user->getID().", '".$dir."', '".$orgFileName."', '".$fileType."', '" . $mimeType . "')";
|
|
||||||
if (!$db->getResult($queryStr)) return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$queryStr = "INSERT INTO tblDocumentContent (document, version, comment, date, createdBy, dir, orgFileName, fileType, mimeType) VALUES ".
|
||||||
|
"(".$this->_id.", ".(int)$version.",'".$comment."', ".$date.", ".$user->getID().", '".$dir."', '".$orgFileName."', '".$fileType."', '" . $mimeType . "')";
|
||||||
|
if (!$db->getResult($queryStr)) return false;
|
||||||
|
|
||||||
// copy file
|
// copy file
|
||||||
if (!LetoDMS_File::makeDir($this->_dms->contentDir . $dir)) return false;
|
if (!LetoDMS_File::makeDir($this->_dms->contentDir . $dir)) return false;
|
||||||
if (!LetoDMS_File::copyFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType)) return false;
|
if (!LetoDMS_File::copyFile($tmpFile, $this->_dms->contentDir . $dir . $version . $fileType)) return false;
|
||||||
|
@ -877,6 +905,13 @@ class LetoDMS_Document { /* {{{ */
|
||||||
return $docResultSet;
|
return $docResultSet;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all content elements of a document
|
||||||
|
*
|
||||||
|
* This functions returns an array of content elements ordered by version
|
||||||
|
*
|
||||||
|
* @return array list of objects of class LetoDMS_DocumentContent
|
||||||
|
*/
|
||||||
function getContent() { /* {{{ */
|
function getContent() { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -894,6 +929,12 @@ class LetoDMS_Document { /* {{{ */
|
||||||
return $this->_content;
|
return $this->_content;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the content element of a document with a given version number
|
||||||
|
*
|
||||||
|
* @param integer $version version number of content element
|
||||||
|
* @return object object of class LetoDMS_DocumentContent
|
||||||
|
*/
|
||||||
function getContentByVersion($version) { /* {{{ */
|
function getContentByVersion($version) { /* {{{ */
|
||||||
if (!is_numeric($version)) return false;
|
if (!is_numeric($version)) return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user