- 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:
steinm 2010-11-30 09:27:37 +00:00
parent 56b2211263
commit e3ad95de38

View File

@ -48,7 +48,7 @@ class LetoDMS_Document { /* {{{ */
var $_keywords; var $_keywords;
var $_sequence; var $_sequence;
var $_dms; var $_dms;
function LetoDMS_Document($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */ function LetoDMS_Document($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */
$this->_id = $id; $this->_id = $id;
$this->_name = $name; $this->_name = $name;
@ -110,7 +110,7 @@ class LetoDMS_Document { /* {{{ */
*/ */
function setName($newName) { /* {{{ */ function setName($newName) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "UPDATE tblDocuments SET name = '" . $newName . "' WHERE id = ". $this->_id; $queryStr = "UPDATE tblDocuments SET name = '" . $newName . "' WHERE id = ". $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
@ -146,11 +146,11 @@ class LetoDMS_Document { /* {{{ */
function setKeywords($newKeywords) { /* {{{ */ function setKeywords($newKeywords) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "UPDATE tblDocuments SET keywords = '" . $newKeywords . "' WHERE id = ". $this->_id; $queryStr = "UPDATE tblDocuments SET keywords = '" . $newKeywords . "' WHERE id = ". $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$this->_keywords = $newKeywords; $this->_keywords = $newKeywords;
return true; return true;
} /* }}} */ } /* }}} */
@ -165,9 +165,18 @@ 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();
$queryStr = "UPDATE tblDocuments SET folder = " . $newFolder->getID() . " WHERE id = ". $this->_id; $queryStr = "UPDATE tblDocuments SET folder = " . $newFolder->getID() . " WHERE id = ". $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
@ -219,7 +228,7 @@ class LetoDMS_Document { /* {{{ */
function setDefaultAccess($mode) { /* {{{ */ function setDefaultAccess($mode) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "UPDATE tblDocuments set defaultAccess = " . $mode . " WHERE id = " . $this->_id; $queryStr = "UPDATE tblDocuments set defaultAccess = " . $mode . " WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
@ -246,11 +255,11 @@ class LetoDMS_Document { /* {{{ */
function setInheritAccess($inheritAccess) { /* {{{ */ function setInheritAccess($inheritAccess) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "UPDATE tblDocuments SET inheritAccess = " . ($inheritAccess ? "1" : "0") . " WHERE id = " . $this->_id; $queryStr = "UPDATE tblDocuments SET inheritAccess = " . ($inheritAccess ? "1" : "0") . " WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$this->_inheritAccess = ($inheritAccess ? "1" : "0"); $this->_inheritAccess = ($inheritAccess ? "1" : "0");
// If any of the notification subscribers no longer have read access, // If any of the notification subscribers no longer have read access,
@ -289,7 +298,7 @@ class LetoDMS_Document { /* {{{ */
function setExpires($expires) { /* {{{ */ function setExpires($expires) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$expires = (!$expires) ? 0 : $expires; $expires = (!$expires) ? 0 : $expires;
if ($expires == $this->_expires) { if ($expires == $this->_expires) {
@ -310,12 +319,12 @@ class LetoDMS_Document { /* {{{ */
if (time()>$this->_expires+24*60*60) return true; if (time()>$this->_expires+24*60*60) return true;
return false; return false;
} /* }}} */ } /* }}} */
// return true if status has changed (to reload page) // return true if status has changed (to reload page)
function verifyLastestContentExpriry(){ /* {{{ */ function verifyLastestContentExpriry(){ /* {{{ */
$lc=$this->getLatestContent(); $lc=$this->getLatestContent();
$st=$lc->getStatus(); $st=$lc->getStatus();
if (($st["status"]==S_DRAFT_REV || $st["status"]==S_DRAFT_APP) && $this->hasExpired()){ if (($st["status"]==S_DRAFT_REV || $st["status"]==S_DRAFT_APP) && $this->hasExpired()){
$lc->setStatus(S_EXPIRED,""); $lc->setStatus(S_EXPIRED,"");
return true; return true;
@ -326,12 +335,12 @@ class LetoDMS_Document { /* {{{ */
} }
return false; return false;
} /* }}} */ } /* }}} */
function isLocked() { return $this->_locked != -1; } function isLocked() { return $this->_locked != -1; }
function setLocked($falseOrUser) { /* {{{ */ function setLocked($falseOrUser) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$lockUserID = -1; $lockUserID = -1;
if (is_bool($falseOrUser) && !$falseOrUser) { if (is_bool($falseOrUser) && !$falseOrUser) {
$queryStr = "DELETE FROM tblDocumentLocks WHERE document = ".$this->_id; $queryStr = "DELETE FROM tblDocumentLocks WHERE document = ".$this->_id;
@ -354,7 +363,7 @@ class LetoDMS_Document { /* {{{ */
function getLockingUser() { /* {{{ */ function getLockingUser() { /* {{{ */
if (!$this->isLocked()) if (!$this->isLocked())
return false; return false;
if (!isset($this->_lockingUser)) if (!isset($this->_lockingUser))
$this->_lockingUser = $this->_dms->getUser($this->_locked); $this->_lockingUser = $this->_dms->getUser($this->_locked);
return $this->_lockingUser; return $this->_lockingUser;
@ -364,22 +373,22 @@ class LetoDMS_Document { /* {{{ */
function setSequence($seq) { /* {{{ */ function setSequence($seq) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "UPDATE tblDocuments SET sequence = " . $seq . " WHERE id = " . $this->_id; $queryStr = "UPDATE tblDocuments SET sequence = " . $seq . " WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$this->_sequence = $seq; $this->_sequence = $seq;
return true; return true;
} /* }}} */ } /* }}} */
function clearAccessList() { /* {{{ */ function clearAccessList() { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "DELETE FROM tblACLs WHERE targetType = " . T_DOCUMENT . " AND target = " . $this->_id; $queryStr = "DELETE FROM tblACLs WHERE targetType = " . T_DOCUMENT . " AND target = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
unset($this->_accessList); unset($this->_accessList);
return true; return true;
} /* }}} */ } /* }}} */
@ -390,13 +399,13 @@ class LetoDMS_Document { /* {{{ */
*/ */
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */ function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if ($this->inheritsAccess()) { if ($this->inheritsAccess()) {
$res = $this->getFolder(); $res = $this->getFolder();
if (!$res) return false; if (!$res) return false;
return $this->_folder->getAccessList($mode, $op); return $this->_folder->getAccessList($mode, $op);
} }
if (!isset($this->_accessList[$mode])) { if (!isset($this->_accessList[$mode])) {
if ($op!=O_GTEQ && $op!=O_LTEQ && $op!=O_EQ) { if ($op!=O_GTEQ && $op!=O_LTEQ && $op!=O_EQ) {
return false; return false;
@ -410,7 +419,7 @@ class LetoDMS_Document { /* {{{ */
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr) if (is_bool($resArr) && !$resArr)
return false; return false;
$this->_accessList[$mode] = array("groups" => array(), "users" => array()); $this->_accessList[$mode] = array("groups" => array(), "users" => array());
foreach ($resArr as $row) { foreach ($resArr as $row) {
if ($row["userID"] != -1) if ($row["userID"] != -1)
@ -419,20 +428,20 @@ class LetoDMS_Document { /* {{{ */
array_push($this->_accessList[$mode]["groups"], new LetoDMS_GroupAccess($this->_dms->getGroup($row["groupID"]), $row["mode"])); array_push($this->_accessList[$mode]["groups"], new LetoDMS_GroupAccess($this->_dms->getGroup($row["groupID"]), $row["mode"]));
} }
} }
return $this->_accessList[$mode]; return $this->_accessList[$mode];
} /* }}} */ } /* }}} */
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */ function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$userOrGroup = ($isUser) ? "userID" : "groupID"; $userOrGroup = ($isUser) ? "userID" : "groupID";
$queryStr = "INSERT INTO tblACLs (target, targetType, ".$userOrGroup.", mode) VALUES $queryStr = "INSERT INTO tblACLs (target, targetType, ".$userOrGroup.", mode) VALUES
(".$this->_id.", ".T_DOCUMENT.", " . $userOrGroupID . ", " .$mode. ")"; (".$this->_id.", ".T_DOCUMENT.", " . $userOrGroupID . ", " .$mode. ")";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
unset($this->_accessList); unset($this->_accessList);
// Update the notify list, if necessary. // Update the notify list, if necessary.
@ -498,21 +507,21 @@ class LetoDMS_Document { /* {{{ */
function getAccessMode($user) { /* {{{ */ function getAccessMode($user) { /* {{{ */
/* Administrators have unrestricted access */ /* Administrators have unrestricted access */
if ($user->isAdmin()) return M_ALL; if ($user->isAdmin()) return M_ALL;
/* The owner of the document has unrestricted access */ /* The owner of the document has unrestricted access */
if ($user->getID() == $this->_ownerID) return M_ALL; if ($user->getID() == $this->_ownerID) return M_ALL;
//Gast-Benutzer?? FIXME: //Gast-Benutzer?? FIXME:
if (($user->getID() == $this->_dms->guestID) && ($this->_dms->enableGuestLogin)) { if (($user->getID() == $this->_dms->guestID) && ($this->_dms->enableGuestLogin)) {
$mode = $this->getDefaultAccess(); $mode = $this->getDefaultAccess();
if ($mode >= M_READ) return M_READ; if ($mode >= M_READ) return M_READ;
else return M_NONE; else return M_NONE;
} }
/* Check ACLs */ /* Check ACLs */
$accessList = $this->getAccessList(); $accessList = $this->getAccessList();
if (!$accessList) return false; if (!$accessList) return false;
foreach ($accessList["users"] as $userAccess) { foreach ($accessList["users"] as $userAccess) {
if ($userAccess->getUserID() == $user->getID()) { if ($userAccess->getUserID() == $user->getID()) {
return $userAccess->getMode(); return $userAccess->getMode();
@ -541,13 +550,13 @@ class LetoDMS_Document { /* {{{ */
*/ */
function getGroupAccessMode($group) { /* {{{ */ function getGroupAccessMode($group) { /* {{{ */
$highestPrivileged = M_NONE; $highestPrivileged = M_NONE;
//ACLs durchforsten //ACLs durchforsten
$foundInACL = false; $foundInACL = false;
$accessList = $this->getAccessList(); $accessList = $this->getAccessList();
if (!$accessList) if (!$accessList)
return false; return false;
foreach ($accessList["groups"] as $groupAccess) { foreach ($accessList["groups"] as $groupAccess) {
if ($groupAccess->getGroupID() == $group->getID()) { if ($groupAccess->getGroupID() == $group->getID()) {
$foundInACL = true; $foundInACL = true;
@ -560,7 +569,7 @@ class LetoDMS_Document { /* {{{ */
if ($foundInACL) if ($foundInACL)
return $highestPrivileged; return $highestPrivileged;
//Standard-Berechtigung verwenden //Standard-Berechtigung verwenden
return $this->getDefaultAccess(); return $this->getDefaultAccess();
} /* }}} */ } /* }}} */
@ -577,12 +586,12 @@ class LetoDMS_Document { /* {{{ */
function getNotifyList() { /* {{{ */ function getNotifyList() { /* {{{ */
if (!isset($this->_notifyList)) { if (!isset($this->_notifyList)) {
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr ="SELECT * FROM tblNotify WHERE targetType = " . T_DOCUMENT . " AND target = " . $this->_id; $queryStr ="SELECT * FROM tblNotify WHERE targetType = " . T_DOCUMENT . " AND target = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false) if (is_bool($resArr) && $resArr == false)
return false; return false;
$this->_notifyList = array("groups" => array(), "users" => array()); $this->_notifyList = array("groups" => array(), "users" => array());
foreach ($resArr as $row) foreach ($resArr as $row)
{ {
@ -720,7 +729,7 @@ class LetoDMS_Document { /* {{{ */
*/ */
function removeNotify($userOrGroupID, $isUser) { /* {{{ */ function removeNotify($userOrGroupID, $isUser) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
/* Verify that user / group exists. */ /* Verify that user / group exists. */
$obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID)); $obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID));
if (!is_object($obj)) { if (!is_object($obj)) {
@ -770,34 +779,53 @@ class LetoDMS_Document { /* {{{ */
$queryStr = "DELETE FROM tblNotify WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT . " AND " . $userOrGroup . " = " . $userOrGroupID; $queryStr = "DELETE FROM tblNotify WHERE target = " . $this->_id . " AND targetType = " . T_DOCUMENT . " AND " . $userOrGroup . " = " . $userOrGroupID;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return -4; return -4;
unset($this->_notifyList); unset($this->_notifyList);
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){
$queryStr = "INSERT INTO tblDocumentContent (document, comment, date, createdBy, dir, orgFileName, fileType, mimeType) VALUES ". /* The version field in table tblDocumentContent used to be auto
"(".$this->_id.", '".$comment."', ".$date.", ".$user->getID().", '".$dir."', '".$orgFileName."', '".$fileType."', '" . $mimeType . "')"; * increment but that requires the field to be primary as well if
if (!$db->getResult($queryStr)) return false; * 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;
$version = $db->getInsertID(); $version = $resArr[0]['m']+1;
}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,26 +905,39 @@ 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();
if (!isset($this->_content)) { if (!isset($this->_content)) {
$queryStr = "SELECT * FROM tblDocumentContent WHERE document = ".$this->_id." ORDER BY version"; $queryStr = "SELECT * FROM tblDocumentContent WHERE document = ".$this->_id." ORDER BY version";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$res) if (is_bool($resArr) && !$res)
return false; return false;
$this->_content = array(); $this->_content = array();
foreach ($resArr as $row) foreach ($resArr as $row)
array_push($this->_content, new LetoDMS_DocumentContent($this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"])); array_push($this->_content, new LetoDMS_DocumentContent($this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"]));
} }
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;
if (isset($this->_content)) { if (isset($this->_content)) {
foreach ($this->_content as $revision) { foreach ($this->_content as $revision) {
if ($revision->getVersion() == $version) if ($revision->getVersion() == $version)
@ -904,7 +945,7 @@ class LetoDMS_Document { /* {{{ */
} }
return false; return false;
} }
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "SELECT * FROM tblDocumentContent WHERE document = ".$this->_id." AND version = " . $version; $queryStr = "SELECT * FROM tblDocumentContent WHERE document = ".$this->_id." AND version = " . $version;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
@ -912,7 +953,7 @@ class LetoDMS_Document { /* {{{ */
return false; return false;
if (count($resArr) != 1) if (count($resArr) != 1)
return false; return false;
$resArr = $resArr[0]; $resArr = $resArr[0];
return new LetoDMS_DocumentContent($this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"]); return new LetoDMS_DocumentContent($this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"]);
} /* }}} */ } /* }}} */
@ -926,7 +967,7 @@ class LetoDMS_Document { /* {{{ */
return false; return false;
if (count($resArr) != 1) if (count($resArr) != 1)
return false; return false;
$resArr = $resArr[0]; $resArr = $resArr[0];
$this->_latestContent = new LetoDMS_DocumentContent($this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"]); $this->_latestContent = new LetoDMS_DocumentContent($this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"]);
} }
@ -942,18 +983,18 @@ class LetoDMS_Document { /* {{{ */
if (file_exists( $this->_dms->contentDir.$version->getPath() )) if (file_exists( $this->_dms->contentDir.$version->getPath() ))
if (!LetoDMS_File::removeFile( $this->_dms->contentDir.$version->getPath() )) if (!LetoDMS_File::removeFile( $this->_dms->contentDir.$version->getPath() ))
return false; return false;
$status = $version->getStatus(); $status = $version->getStatus();
$stID = $status["statusID"]; $stID = $status["statusID"];
$queryStr = "DELETE FROM tblDocumentContent WHERE `document` = " . $this->getID() . " AND `version` = " . $version->_version; $queryStr = "DELETE FROM tblDocumentContent WHERE `document` = " . $this->getID() . " AND `version` = " . $version->_version;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$queryStr = "DELETE FROM `tblDocumentStatusLog` WHERE `statusID` = '".$stID."'"; $queryStr = "DELETE FROM `tblDocumentStatusLog` WHERE `statusID` = '".$stID."'";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$queryStr = "DELETE FROM `tblDocumentStatus` WHERE `documentID` = '". $this->getID() ."' AND `version` = '" . $version->_version."'"; $queryStr = "DELETE FROM `tblDocumentStatus` WHERE `documentID` = '". $this->getID() ."' AND `version` = '" . $version->_version."'";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
@ -996,14 +1037,14 @@ class LetoDMS_Document { /* {{{ */
function getDocumentLink($linkID) { /* {{{ */ function getDocumentLink($linkID) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if (!is_numeric($linkID)) return false; if (!is_numeric($linkID)) return false;
$queryStr = "SELECT * FROM tblDocumentLinks WHERE document = " . $this->_id ." AND id = " . $linkID; $queryStr = "SELECT * FROM tblDocumentLinks WHERE document = " . $this->_id ." AND id = " . $linkID;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if ((is_bool($resArr) && !$resArr) || count($resArr)==0) if ((is_bool($resArr) && !$resArr) || count($resArr)==0)
return false; return false;
$resArr = $resArr[0]; $resArr = $resArr[0];
$document = $this->_dms->getDocument($resArr["document"]); $document = $this->_dms->getDocument($resArr["document"]);
$target = $this->_dms->getDocument($resArr["target"]); $target = $this->_dms->getDocument($resArr["target"]);
@ -1013,13 +1054,13 @@ class LetoDMS_Document { /* {{{ */
function getDocumentLinks() { /* {{{ */ function getDocumentLinks() { /* {{{ */
if (!isset($this->_documentLinks)) { if (!isset($this->_documentLinks)) {
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "SELECT * FROM tblDocumentLinks WHERE document = " . $this->_id; $queryStr = "SELECT * FROM tblDocumentLinks WHERE document = " . $this->_id;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr) if (is_bool($resArr) && !$resArr)
return false; return false;
$this->_documentLinks = array(); $this->_documentLinks = array();
foreach ($resArr as $row) { foreach ($resArr as $row) {
$target = $this->_dms->getDocument($row["target"]); $target = $this->_dms->getDocument($row["target"]);
array_push($this->_documentLinks, new LetoDMS_DocumentLink($row["id"], $this, $target, $row["userID"], $row["public"])); array_push($this->_documentLinks, new LetoDMS_DocumentLink($row["id"], $this, $target, $row["userID"], $row["public"]));
@ -1030,35 +1071,35 @@ class LetoDMS_Document { /* {{{ */
function addDocumentLink($targetID, $userID, $public) { /* {{{ */ function addDocumentLink($targetID, $userID, $public) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$public = ($public) ? "1" : "0"; $public = ($public) ? "1" : "0";
$queryStr = "INSERT INTO tblDocumentLinks(document, target, userID, public) VALUES (".$this->_id.", ".$targetID.", ".$userID.", " . $public.")"; $queryStr = "INSERT INTO tblDocumentLinks(document, target, userID, public) VALUES (".$this->_id.", ".$targetID.", ".$userID.", " . $public.")";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
unset($this->_documentLinks); unset($this->_documentLinks);
return true; return true;
} /* }}} */ } /* }}} */
function removeDocumentLink($linkID) { /* {{{ */ function removeDocumentLink($linkID) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "DELETE FROM tblDocumentLinks WHERE document = " . $this->_id ." AND id = " . $linkID; $queryStr = "DELETE FROM tblDocumentLinks WHERE document = " . $this->_id ." AND id = " . $linkID;
if (!$db->getResult($queryStr)) return false; if (!$db->getResult($queryStr)) return false;
unset ($this->_documentLinks); unset ($this->_documentLinks);
return true; return true;
} /* }}} */ } /* }}} */
function getDocumentFile($ID) { /* {{{ */ function getDocumentFile($ID) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if (!is_numeric($ID)) return false; if (!is_numeric($ID)) return false;
$queryStr = "SELECT * FROM tblDocumentFiles WHERE document = " . $this->_id ." AND id = " . $ID; $queryStr = "SELECT * FROM tblDocumentFiles WHERE document = " . $this->_id ." AND id = " . $ID;
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if ((is_bool($resArr) && !$resArr) || count($resArr)==0) return false; if ((is_bool($resArr) && !$resArr) || count($resArr)==0) return false;
$resArr = $resArr[0]; $resArr = $resArr[0];
return new LetoDMS_DocumentFile($resArr["id"], $this, $resArr["userID"], $resArr["comment"], $resArr["date"], $resArr["dir"], $resArr["fileType"], $resArr["mimeType"], $resArr["orgFileName"], $resArr["name"]); return new LetoDMS_DocumentFile($resArr["id"], $this, $resArr["userID"], $resArr["comment"], $resArr["date"], $resArr["dir"], $resArr["fileType"], $resArr["mimeType"], $resArr["orgFileName"], $resArr["name"]);
} /* }}} */ } /* }}} */
@ -1066,67 +1107,67 @@ class LetoDMS_Document { /* {{{ */
function getDocumentFiles() { /* {{{ */ function getDocumentFiles() { /* {{{ */
if (!isset($this->_documentFiles)) { if (!isset($this->_documentFiles)) {
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$queryStr = "SELECT * FROM tblDocumentFiles WHERE document = " . $this->_id." ORDER BY `date` DESC"; $queryStr = "SELECT * FROM tblDocumentFiles WHERE document = " . $this->_id." ORDER BY `date` DESC";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr) return false; if (is_bool($resArr) && !$resArr) return false;
$this->_documentFiles = array(); $this->_documentFiles = array();
foreach ($resArr as $row) { foreach ($resArr as $row) {
array_push($this->_documentFiles, new LetoDMS_DocumentFile($row["id"], $this, $row["userID"], $row["comment"], $row["date"], $row["dir"], $row["fileType"], $row["mimeType"], $row["orgFileName"], $row["name"])); array_push($this->_documentFiles, new LetoDMS_DocumentFile($row["id"], $this, $row["userID"], $row["comment"], $row["date"], $row["dir"], $row["fileType"], $row["mimeType"], $row["orgFileName"], $row["name"]));
} }
} }
return $this->_documentFiles; return $this->_documentFiles;
} /* }}} */ } /* }}} */
function addDocumentFile($name, $comment, $user, $tmpFile, $orgFileName,$fileType, $mimeType ) { /* {{{ */ function addDocumentFile($name, $comment, $user, $tmpFile, $orgFileName,$fileType, $mimeType ) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$dir = $this->getDir(); $dir = $this->getDir();
$queryStr = "INSERT INTO tblDocumentFiles (comment, date, dir, document, fileType, mimeType, orgFileName, userID, name) VALUES ". $queryStr = "INSERT INTO tblDocumentFiles (comment, date, dir, document, fileType, mimeType, orgFileName, userID, name) VALUES ".
"('".$comment."', '".mktime()."', '" . $dir ."', " . $this->_id.", '".$fileType."', '".$mimeType."', '".$orgFileName."',".$user->getID().",'".$name."')"; "('".$comment."', '".mktime()."', '" . $dir ."', " . $this->_id.", '".$fileType."', '".$mimeType."', '".$orgFileName."',".$user->getID().",'".$name."')";
if (!$db->getResult($queryStr)) return false; if (!$db->getResult($queryStr)) return false;
$id = $db->getInsertID(); $id = $db->getInsertID();
$file = $this->getDocumentFile($id); $file = $this->getDocumentFile($id);
if (is_bool($file) && !$file) return false; if (is_bool($file) && !$file) 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 . $file->getPath() )) return false; if (!LetoDMS_File::copyFile($tmpFile, $this->_dms->contentDir . $file->getPath() )) return false;
return true; return true;
} /* }}} */ } /* }}} */
function removeDocumentFile($ID) { /* {{{ */ function removeDocumentFile($ID) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$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() )){ if (file_exists( $this->_dms->contentDir . $file->getPath() )){
if (!LetoDMS_File::removeFile( $this->_dms->contentDir . $file->getPath() )) if (!LetoDMS_File::removeFile( $this->_dms->contentDir . $file->getPath() ))
return false; return false;
} }
$name=$file->getName(); $name=$file->getName();
$comment=$file->getcomment(); $comment=$file->getcomment();
$queryStr = "DELETE FROM tblDocumentFiles WHERE document = " . $this->getID() . " AND id = " . $ID; $queryStr = "DELETE FROM tblDocumentFiles WHERE document = " . $this->getID() . " AND id = " . $ID;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
unset ($this->_documentFiles); unset ($this->_documentFiles);
return true; return true;
} /* }}} */ } /* }}} */
function remove() { /* {{{ */ function remove() { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$res = $this->getContent(); $res = $this->getContent();
if (is_bool($res) && !$res) return false; if (is_bool($res) && !$res) return false;
@ -1138,17 +1179,17 @@ class LetoDMS_Document { /* {{{ */
// remove document file // remove document file
$res = $this->getDocumentFiles(); $res = $this->getDocumentFiles();
if (is_bool($res) && !$res) return false; if (is_bool($res) && !$res) return false;
foreach ($res as $documentfile) foreach ($res as $documentfile)
if(!$this->removeDocumentFile($documentfile->getId())) if(!$this->removeDocumentFile($documentfile->getId()))
return false; return false;
// TODO: versioning file? // TODO: versioning file?
if (file_exists( $this->_dms->contentDir . $this->getDir() )) if (file_exists( $this->_dms->contentDir . $this->getDir() ))
if (!LetoDMS_File::removeDir( $this->_dms->contentDir . $this->getDir() )) if (!LetoDMS_File::removeDir( $this->_dms->contentDir . $this->getDir() ))
return false; return false;
$queryStr = "DELETE FROM tblDocuments WHERE id = " . $this->_id; $queryStr = "DELETE FROM tblDocuments WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
@ -1177,7 +1218,7 @@ class LetoDMS_Document { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if (!isset($this->_approversList)) { if (!isset($this->_approversList)) {
$this->_approversList = array("groups" => array(), "users" => array()); $this->_approversList = array("groups" => array(), "users" => array());
$userIDs = ""; $userIDs = "";
$groupIDs = ""; $groupIDs = "";
@ -1197,7 +1238,7 @@ class LetoDMS_Document { /* {{{ */
$groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $group->getGroupID(); $groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $group->getGroupID();
} }
foreach ($tmpList["users"] as $c_user) { foreach ($tmpList["users"] as $c_user) {
if (!$this->_dms->enableAdminRevApp && $c_user->isAdmin()) continue; if (!$this->_dms->enableAdminRevApp && $c_user->isAdmin()) continue;
$userIDs .= (strlen($userIDs)==0 ? "" : ", ") . $c_user->getUserID(); $userIDs .= (strlen($userIDs)==0 ? "" : ", ") . $c_user->getUserID();
} }
@ -1244,7 +1285,7 @@ class LetoDMS_Document { /* {{{ */
if (!is_bool($resArr)) { if (!is_bool($resArr)) {
foreach ($resArr as $row) { foreach ($resArr as $row) {
$user = $this->_dms->getUser($row['id']); $user = $this->_dms->getUser($row['id']);
if (!$this->_dms->enableAdminRevApp && $user->isAdmin()) continue; if (!$this->_dms->enableAdminRevApp && $user->isAdmin()) continue;
$this->_approversList["users"][] = $user; $this->_approversList["users"][] = $user;
} }
} }
@ -1288,32 +1329,32 @@ class LetoDMS_Document { /* {{{ */
* deutschen Umlauten, während Windows wiederum den Doppelpunkt in Dateinamen nicht verwenden kann. * deutschen Umlauten, während Windows wiederum den Doppelpunkt in Dateinamen nicht verwenden kann.
* Der ursprüngliche Dateiname wird nur zum Download verwendet (siehe op.Download.pgp) * Der ursprüngliche Dateiname wird nur zum Download verwendet (siehe op.Download.pgp)
*/ */
// these are the version information // these are the version information
class LetoDMS_DocumentContent { /* {{{ */ class LetoDMS_DocumentContent { /* {{{ */
// if status is released and there are reviewers set status draft_rev // if status is released and there are reviewers set status draft_rev
// if status is released or draft_rev and there are approves set status draft_app // if status is released or draft_rev and there are approves set status draft_app
// if status is draft and there are no approver and no reviewers set status to release // if status is draft and there are no approver and no reviewers set status to release
function verifyStatus($ignorecurrentstatus=false,$user=null) { /* {{{ */ function verifyStatus($ignorecurrentstatus=false,$user=null) { /* {{{ */
unset($this->_status); unset($this->_status);
$st=$this->getStatus(); $st=$this->getStatus();
if (!$ignorecurrentstatus && ($st["status"]==S_OBSOLETE || $st["status"]==S_REJECTED || $st["status"]==S_EXPIRED )) return; if (!$ignorecurrentstatus && ($st["status"]==S_OBSOLETE || $st["status"]==S_REJECTED || $st["status"]==S_EXPIRED )) return;
$pendingReview=false; $pendingReview=false;
unset($this->_reviewStatus); // force to be reloaded from DB unset($this->_reviewStatus); // force to be reloaded from DB
$reviewStatus=$this->getReviewStatus(true); $reviewStatus=$this->getReviewStatus(true);
if (is_array($reviewStatus) && count($reviewStatus)>0) { if (is_array($reviewStatus) && count($reviewStatus)>0) {
foreach ($reviewStatus as $r){ foreach ($reviewStatus as $r){
if ($r["status"]==0){ if ($r["status"]==0){
$pendingReview=true; $pendingReview=true;
break; break;
} }
} }
} }
$pendingApproval=false; $pendingApproval=false;
unset($this->_approvalStatus); // force to be reloaded from DB unset($this->_approvalStatus); // force to be reloaded from DB
$approvalStatus=$this->getApprovalStatus(true); $approvalStatus=$this->getApprovalStatus(true);
if (is_array($approvalStatus) && count($approvalStatus)>0) { if (is_array($approvalStatus) && count($approvalStatus)>0) {
@ -1355,7 +1396,7 @@ class LetoDMS_DocumentContent { /* {{{ */
return $this->_user; return $this->_user;
} /* }}} */ } /* }}} */
function getPath() { return $this->_dir . $this->_version . $this->_fileType; } function getPath() { return $this->_dir . $this->_version . $this->_fileType; }
function setComment($newComment) { /* {{{ */ function setComment($newComment) { /* {{{ */
$db = $this->_document->_dms->getDB(); $db = $this->_document->_dms->getDB();
@ -1364,30 +1405,30 @@ class LetoDMS_DocumentContent { /* {{{ */
return false; return false;
$this->_comment = $newComment; $this->_comment = $newComment;
return true; return true;
} /* }}} */ } /* }}} */
function convert() { /* {{{ */ function convert() { /* {{{ */
if (file_exists($this->_document->_dms->contentDir . $this->_dir . "index.html")) if (file_exists($this->_document->_dms->contentDir . $this->_dir . "index.html"))
return true; return true;
if (!in_array($this->_fileType, array_keys($this->_document->_dms->convertFileTypes))) if (!in_array($this->_fileType, array_keys($this->_document->_dms->convertFileTypes)))
return false; return false;
$source = $this->_document->_dms->contentDir . $this->_dir . $this->getFileName(); $source = $this->_document->_dms->contentDir . $this->_dir . $this->getFileName();
$target = $this->_document->_dms->contentDir . $this->_dir . "index.html"; $target = $this->_document->_dms->contentDir . $this->_dir . "index.html";
// $source = str_replace("/", "\\", $source); // $source = str_replace("/", "\\", $source);
// $target = str_replace("/", "\\", $target); // $target = str_replace("/", "\\", $target);
$command = $this->_document->_dms->convertFileTypes[$this->_fileType]; $command = $this->_document->_dms->convertFileTypes[$this->_fileType];
$command = str_replace("{SOURCE}", "\"$source\"", $command); $command = str_replace("{SOURCE}", "\"$source\"", $command);
$command = str_replace("{TARGET}", "\"$target\"", $command); $command = str_replace("{TARGET}", "\"$target\"", $command);
$output = array(); $output = array();
$res = 0; $res = 0;
exec($command, $output, $res); exec($command, $output, $res);
if ($res != 0) { if ($res != 0) {
print (implode("\n", $output)); print (implode("\n", $output));
return false; return false;
@ -1405,10 +1446,10 @@ class LetoDMS_DocumentContent { /* {{{ */
if (in_array(strtolower($this->_fileType), $this->_document->_dms->_viewOnlineFileTypes)) if (in_array(strtolower($this->_fileType), $this->_document->_dms->_viewOnlineFileTypes))
return true; return true;
if ($this->_document->_dms->enableConverting && in_array($this->_fileType, array_keys($this->_document->_dms->convertFileTypes))) if ($this->_document->_dms->enableConverting && in_array($this->_fileType, array_keys($this->_document->_dms->convertFileTypes)))
if ($this->wasConverted()) return true; if ($this->wasConverted()) return true;
return false; return false;
} /* }}} */ } /* }}} */
@ -1418,14 +1459,14 @@ class LetoDMS_DocumentContent { /* {{{ */
function getURL() { /* {{{ */ function getURL() { /* {{{ */
if (!$this->viewOnline())return false; if (!$this->viewOnline())return false;
if (in_array(strtolower($this->_fileType), $this->_document->_dms->_viewOnlineFileTypes)) if (in_array(strtolower($this->_fileType), $this->_document->_dms->_viewOnlineFileTypes))
return "/" . $this->_document->getID() . "/" . $this->_version . "/" . $this->getOriginalFileName(); return "/" . $this->_document->getID() . "/" . $this->_version . "/" . $this->getOriginalFileName();
else else
return "/" . $this->_document->getID() . "/" . $this->_version . "/index.html"; return "/" . $this->_document->getID() . "/" . $this->_version . "/index.html";
} /* }}} */ } /* }}} */
// $send_email=FALSE is used when removing entire document // $send_email=FALSE is used when removing entire document
// to avoid one email for every version // to avoid one email for every version
// This function is deprecated. It was replaced by LetoDMS_Document::removeContent() // This function is deprecated. It was replaced by LetoDMS_Document::removeContent()
function __remove($send_email=TRUE) { /* {{{ */ function __remove($send_email=TRUE) { /* {{{ */
@ -1438,18 +1479,18 @@ class LetoDMS_DocumentContent { /* {{{ */
if (file_exists( $this->_document->_dms->contentDir.$version->getPath() )) if (file_exists( $this->_document->_dms->contentDir.$version->getPath() ))
if (!LetoDMS_File::removeFile( $this->_document->_dms->contentDir.$version->getPath() )) if (!LetoDMS_File::removeFile( $this->_document->_dms->contentDir.$version->getPath() ))
return false; return false;
$status = $this->getStatus(); $status = $this->getStatus();
$stID = $status["statusID"]; $stID = $status["statusID"];
$queryStr = "DELETE FROM tblDocumentContent WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version; $queryStr = "DELETE FROM tblDocumentContent WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$queryStr = "DELETE FROM `tblDocumentStatusLog` WHERE `statusID` = '".$stID."'"; $queryStr = "DELETE FROM `tblDocumentStatusLog` WHERE `statusID` = '".$stID."'";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$queryStr = "DELETE FROM `tblDocumentStatus` WHERE `documentID` = '". $this->_document->getID() ."' AND `version` = '" . $this->_version."'"; $queryStr = "DELETE FROM `tblDocumentStatus` WHERE `documentID` = '". $this->_document->getID() ."' AND `version` = '" . $this->_version."'";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
@ -1489,7 +1530,7 @@ class LetoDMS_DocumentContent { /* {{{ */
// Notify affected users. // Notify affected users.
if ($send_email && $this->_notifier){ if ($send_email && $this->_notifier){
$recipients = array(); $recipients = array();
foreach ($emailList as $eID) { foreach ($emailList as $eID) {
$eU = $this->_document->_dms->getUser($eID); $eU = $this->_document->_dms->getUser($eID);
@ -1497,7 +1538,7 @@ class LetoDMS_DocumentContent { /* {{{ */
} }
$subject = "###SITENAME###: ".$this->_document->getName().", v.".$this->_version." - ".getMLText("version_deleted_email"); $subject = "###SITENAME###: ".$this->_document->getName().", v.".$this->_version." - ".getMLText("version_deleted_email");
$message = getMLText("version_deleted_email")."\r\n"; $message = getMLText("version_deleted_email")."\r\n";
$message .= $message .=
getMLText("document").": ".$this->_document->getName()."\r\n". getMLText("document").": ".$this->_document->getName()."\r\n".
getMLText("version").": ".$this->_version."\r\n". getMLText("version").": ".$this->_version."\r\n".
getMLText("comment").": ".$this->getComment()."\r\n". getMLText("comment").": ".$this->getComment()."\r\n".
@ -1505,9 +1546,9 @@ class LetoDMS_DocumentContent { /* {{{ */
$subject=mydmsDecodeString($subject); $subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message); $message=mydmsDecodeString($message);
LetoDMS_Email::toList($user, $recipients, $subject, $message); LetoDMS_Email::toList($user, $recipients, $subject, $message);
// Send notification to subscribers. // Send notification to subscribers.
$nl=$this->_document->getNotifyList(); $nl=$this->_document->getNotifyList();
LetoDMS_Email::toList($user, $nl["users"], $subject, $message); LetoDMS_Email::toList($user, $nl["users"], $subject, $message);
@ -1678,7 +1719,7 @@ class LetoDMS_DocumentContent { /* {{{ */
else { else {
$reviewID = isset($reviewStatus["indstatus"][0]["reviewID"])?$reviewStatus["indstatus"][0]["reviewID"]:NULL; $reviewID = isset($reviewStatus["indstatus"][0]["reviewID"])?$reviewStatus["indstatus"][0]["reviewID"]:NULL;
} }
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewID ."', '0', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $reviewID ."', '0', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -1736,7 +1777,7 @@ class LetoDMS_DocumentContent { /* {{{ */
else { else {
$reviewID = isset($reviewStatus[0]["reviewID"])?$reviewStatus[0]["reviewID"]:NULL; $reviewID = isset($reviewStatus[0]["reviewID"])?$reviewStatus[0]["reviewID"]:NULL;
} }
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewID ."', '0', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $reviewID ."', '0', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -1849,7 +1890,7 @@ class LetoDMS_DocumentContent { /* {{{ */
else { else {
$approveID = isset($approvalStatus[0]["approveID"])?$approvalStatus[0]["approveID"]:NULL; $approveID = isset($approvalStatus[0]["approveID"])?$approvalStatus[0]["approveID"]:NULL;
} }
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $approveID ."', '0', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $approveID ."', '0', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -1883,7 +1924,7 @@ class LetoDMS_DocumentContent { /* {{{ */
// return an error. // return an error.
return -3; return -3;
} }
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewStatus["indstatus"][0]["reviewID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $reviewStatus["indstatus"][0]["reviewID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -1914,7 +1955,7 @@ class LetoDMS_DocumentContent { /* {{{ */
// return an error. // return an error.
return -3; return -3;
} }
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewStatus[0]["reviewID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $reviewStatus[0]["reviewID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -1945,7 +1986,7 @@ class LetoDMS_DocumentContent { /* {{{ */
// return an error. // return an error.
return -3; return -3;
} }
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $approvalStatus["indstatus"][0]["approveID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $approvalStatus["indstatus"][0]["approveID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -1976,7 +2017,7 @@ class LetoDMS_DocumentContent { /* {{{ */
// return an error. // return an error.
return -3; return -3;
} }
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $approvalStatus[0]["approveID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')"; "VALUES ('". $approvalStatus[0]["approveID"] ."', '-2', '', NOW(), '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
@ -2026,11 +2067,11 @@ class LetoDMS_DocumentLink { /* {{{ */
function __remove() { // Do not use anymore function __remove() { // Do not use anymore
$db = $this->_document->_dms->getDB(); $db = $this->_document->_dms->getDB();
$queryStr = "DELETE FROM tblDocumentLinks WHERE id = " . $this->_id; $queryStr = "DELETE FROM tblDocumentLinks WHERE id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
return true; return true;
} }
} /* }}} */ } /* }}} */
@ -2072,13 +2113,13 @@ class LetoDMS_DocumentFile { /* {{{ */
function getMimeType() { return $this->_mimeType; } function getMimeType() { return $this->_mimeType; }
function getOriginalFileName() { return $this->_orgFileName; } function getOriginalFileName() { return $this->_orgFileName; }
function getName() { return $this->_name; } function getName() { return $this->_name; }
function getUser() { function getUser() {
if (!isset($this->_user)) if (!isset($this->_user))
$this->_user = $this->_document->_dms->getUser($this->_userID); $this->_user = $this->_document->_dms->getUser($this->_userID);
return $this->_user; return $this->_user;
} }
function getPath() { function getPath() {
return $this->_dir . "f" .$this->_id . $this->_fileType; return $this->_dir . "f" .$this->_id . $this->_fileType;
} }
@ -2086,16 +2127,16 @@ class LetoDMS_DocumentFile { /* {{{ */
function __remove() // do not use anymore, will be called from document->removeDocumentFile function __remove() // do not use anymore, will be called from document->removeDocumentFile
{ {
$db = $this->_document->_dms->getDB(); $db = $this->_document->_dms->getDB();
if (file_exists( $this->_document->_dms->contentDir.$this->getPath() )) if (file_exists( $this->_document->_dms->contentDir.$this->getPath() ))
if (!LetoDMS_File::removeFile( $this->_document->_dms->contentDir.$this->getPath() )) if (!LetoDMS_File::removeFile( $this->_document->_dms->contentDir.$this->getPath() ))
return false; return false;
$queryStr = "DELETE FROM tblDocumentFiles WHERE document = " . $this->_document->getID() . " AND id = " . $this->_id; $queryStr = "DELETE FROM tblDocumentFiles WHERE document = " . $this->_document->getID() . " AND id = " . $this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
return true; return true;
} }
} /* }}} */ } /* }}} */
@ -2107,7 +2148,7 @@ class LetoDMS_DocumentFile { /* {{{ */
// reviewers and approvers and the status. // reviewers and approvers and the status.
// //
class LetoDMS_AddContentResultSet { /* {{{ */ class LetoDMS_AddContentResultSet { /* {{{ */
var $_indReviewers; var $_indReviewers;
var $_grpReviewers; var $_grpReviewers;
var $_indApprovers; var $_indApprovers;
@ -2126,7 +2167,7 @@ class LetoDMS_AddContentResultSet { /* {{{ */
} }
function addReviewer($reviewer, $type, $status) { function addReviewer($reviewer, $type, $status) {
if (!is_object($reviewer) || (strcasecmp($type, "i") && strcasecmp($type, "g")) && !is_integer($status)){ if (!is_object($reviewer) || (strcasecmp($type, "i") && strcasecmp($type, "g")) && !is_integer($status)){
return false; return false;
} }
@ -2152,7 +2193,7 @@ class LetoDMS_AddContentResultSet { /* {{{ */
} }
function addApprover($approver, $type, $status) { function addApprover($approver, $type, $status) {
if (!is_object($approver) || (strcasecmp($type, "i") && strcasecmp($type, "g")) && !is_integer($status)){ if (!is_object($approver) || (strcasecmp($type, "i") && strcasecmp($type, "g")) && !is_integer($status)){
return false; return false;
} }