mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-11 20:21:16 +00:00
various minor changes ported back from SeedDMS 6
This commit is contained in:
parent
b8763822d0
commit
007e3faa0a
|
@ -347,9 +347,11 @@ class SeedDMS_Core_DMS {
|
|||
*/
|
||||
static function filterDocumentFiles($user, $files) { /* {{{ */
|
||||
$tmp = array();
|
||||
foreach ($files as $file)
|
||||
if ($file->isPublic() || ($file->getUser()->getID() == $user->getID()) || $user->isAdmin() || ($file->getDocument()->getOwner()->getID() == $user->getID()))
|
||||
array_push($tmp, $file);
|
||||
if($files) {
|
||||
foreach ($files as $file)
|
||||
if ($file->isPublic() || ($file->getUser()->getID() == $user->getID()) || $user->isAdmin() || ($file->getDocument()->getOwner()->getID() == $user->getID()))
|
||||
array_push($tmp, $file);
|
||||
}
|
||||
return $tmp;
|
||||
} /* }}} */
|
||||
|
||||
|
@ -374,6 +376,7 @@ class SeedDMS_Core_DMS {
|
|||
$this->forceRename = false;
|
||||
$this->checkWithinRootDir = false;
|
||||
$this->noReadForStatus = array();
|
||||
$this->user = null;
|
||||
$this->classnames = array();
|
||||
$this->classnames['folder'] = 'SeedDMS_Core_Folder';
|
||||
$this->classnames['document'] = 'SeedDMS_Core_Document';
|
||||
|
@ -589,8 +592,9 @@ class SeedDMS_Core_DMS {
|
|||
/**
|
||||
* Set the logged in user
|
||||
*
|
||||
* If user authentication was done externally, this function can
|
||||
* be used to tell the dms who is currently logged in.
|
||||
* This method tells SeeDMS_Core_DMS the currently logged in user. It must be
|
||||
* called right after instanciating the class, because some methods in
|
||||
* SeedDMS_Core_Document() require the currently logged in user.
|
||||
*
|
||||
* @param object $user this muss not be empty and an instance of SeedDMS_Core_User
|
||||
* @return bool|object returns the old user object or null on success, otherwise false
|
||||
|
@ -613,8 +617,7 @@ class SeedDMS_Core_DMS {
|
|||
/**
|
||||
* Get the logged in user
|
||||
*
|
||||
* If user authentication was done externally, this function can
|
||||
* be used to tell the dms who is currently logged in.
|
||||
* Returns the currently logged in user, as set by setUser()
|
||||
*
|
||||
* @return SeedDMS_Core_User $user
|
||||
*
|
||||
|
@ -685,7 +688,7 @@ class SeedDMS_Core_DMS {
|
|||
if (!$db->createTemporaryTable("ttstatid") || !$db->createTemporaryTable("ttcontentid")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$tsnow = mktime(0, 0, 0); /* Start of today */
|
||||
if(is_int($date)) {
|
||||
$ts = $tsnow + $date * 86400;
|
||||
|
@ -1041,7 +1044,7 @@ class SeedDMS_Core_DMS {
|
|||
$queryStr .= " AND `tblDocumentReviewLog`.`status` = 0 ";
|
||||
if ($orderby=='e') $queryStr .= "ORDER BY `expires`";
|
||||
else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`";
|
||||
else if ($orderby=='s') $queryStr .= "ORDER BY `status`";
|
||||
else if ($orderby=='s') $queryStr .= "ORDER BY `tblDocumentStatusLog`.`status`";
|
||||
else $queryStr .= "ORDER BY `name`";
|
||||
$queryStr .= " ".$orderdir;
|
||||
} else {
|
||||
|
@ -1123,7 +1126,7 @@ class SeedDMS_Core_DMS {
|
|||
$queryStr .= " AND `tblDocumentApproveLog`.`status` = 0 ";
|
||||
if ($orderby=='e') $queryStr .= "ORDER BY `expires`";
|
||||
else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`";
|
||||
else if ($orderby=='s') $queryStr .= "ORDER BY `status`";
|
||||
else if ($orderby=='s') $queryStr .= "ORDER BY `tblDocumentStatusLog`.`status`";
|
||||
else $queryStr .= "ORDER BY `name`";
|
||||
$queryStr .= " ".$orderdir;
|
||||
} else {
|
||||
|
@ -1197,6 +1200,7 @@ class SeedDMS_Core_DMS {
|
|||
$queryStr .= "OR `tblWorkflowTransitionGroups`.`groupid` IN (".implode(',', $groups).")";
|
||||
$queryStr .= ") ";
|
||||
}
|
||||
$queryStr .= "AND `tblDocumentStatusLog`.`status` = ".S_IN_WORKFLOW." ";
|
||||
// echo 'SELECT '.$selectStr." ".$queryStr;
|
||||
if ($orderby=='e') $queryStr .= "ORDER BY `expires`";
|
||||
else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`";
|
||||
|
@ -1264,8 +1268,8 @@ class SeedDMS_Core_DMS {
|
|||
$orderdir = 'DESC';
|
||||
else
|
||||
$orderdir = 'ASC';
|
||||
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ".
|
||||
"AND `tblDocumentStatusLog`.`status` IN (".S_REJECTED.") ";
|
||||
$queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ";
|
||||
$queryStr .= "AND `tblDocumentStatusLog`.`status` IN (".S_REJECTED.") ";
|
||||
//$queryStr .= "ORDER BY `statusDate` DESC";
|
||||
if ($orderby=='e') $queryStr .= "ORDER BY `expires`";
|
||||
else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`";
|
||||
|
|
|
@ -58,6 +58,12 @@ define("S_OBSOLETE", -2);
|
|||
*/
|
||||
define("S_EXPIRED", -3);
|
||||
|
||||
/*
|
||||
* Lowest and highest status that may be set
|
||||
*/
|
||||
define("S_LOWEST_STATUS", -3);
|
||||
define("S_HIGHEST_STATUS", 3);
|
||||
|
||||
/**
|
||||
* The different states a workflow log can be in. This is used in
|
||||
* all tables tblDocumentXXXLog
|
||||
|
@ -2939,7 +2945,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
*
|
||||
* This method may not be called after a negative approval or review to
|
||||
* recalculated the status, because
|
||||
* it doesn't take a defeating approval or review into account. It will
|
||||
* it doesn't take a defeating approval or review into account. This method
|
||||
* does not set the status to S_REJECTED! It will
|
||||
* just check for a pending workflow, approval or review and set the status
|
||||
* accordingly, e.g. after the list of reviewers or appovers has been
|
||||
* modified. If there is not pending workflow, approval or review the
|
||||
|
@ -2966,6 +2973,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
|
||||
/* $pendingReview will be set when there are still open reviews */
|
||||
$pendingReview=false;
|
||||
/* $hasReview will be set if there is at least one positiv review */
|
||||
$hasReview=false;
|
||||
unset($this->_reviewStatus); // force to be reloaded from DB
|
||||
$reviewStatus=$this->getReviewStatus();
|
||||
if (is_array($reviewStatus) && count($reviewStatus)>0) {
|
||||
|
@ -2973,12 +2982,16 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
if ($r["status"]==0){
|
||||
$pendingReview=true;
|
||||
break;
|
||||
} elseif($r["status"]==1){
|
||||
$hasReview=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* $pendingApproval will be set when there are still open approvals */
|
||||
$pendingApproval=false;
|
||||
/* $hasApproval will be set if there is at least one positiv review */
|
||||
$hasApproval=false;
|
||||
unset($this->_approvalStatus); // force to be reloaded from DB
|
||||
$approvalStatus=$this->getApprovalStatus();
|
||||
if (is_array($approvalStatus) && count($approvalStatus)>0) {
|
||||
|
@ -2986,6 +2999,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
if ($a["status"]==0){
|
||||
$pendingApproval=true;
|
||||
break;
|
||||
} elseif($a["status"]==1){
|
||||
$hasApproval=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3233,7 +3248,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
|
||||
// If the supplied value lies outside of the accepted range, return an
|
||||
// error.
|
||||
if ($status < -3 || $status > 3) {
|
||||
if ($status < S_LOWEST_STATUS || $status > S_HIGHEST_STATUS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -4524,6 +4539,9 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
$this->getWorkflow();
|
||||
if($this->_workflow)
|
||||
return false;
|
||||
|
||||
if($workflow && is_object($workflow)) {
|
||||
$db->startTransaction();
|
||||
$initstate = $workflow->getInitState();
|
||||
|
@ -4540,14 +4558,14 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$db->commitTransaction();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get workflow assigned to the document content
|
||||
*
|
||||
* The method returns the last workflow if one was assigned.
|
||||
* If a the document version is in a sub workflow, it will have
|
||||
* If the document version is in a sub workflow, it will have
|
||||
* a never date and therefore will be found first.
|
||||
*
|
||||
* @return object/boolean an object of class SeedDMS_Core_Workflow
|
||||
|
@ -4601,7 +4619,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
$queryStr = "INSERT INTO `tblWorkflowLog` (`document`, `version`, `workflow`, `transition`, `comment`, `date`, `userid`) ".
|
||||
$queryStr = "INSERT INTO `tblWorkflowLog` (`document`, `version`, `workflow`, `transition`, `comment`, `date`, `userid`) ".
|
||||
"VALUES ('".$this->_document->getID() ."', '".(int) $this->_version."', '".(int) $log['workflow']->getID()."', '".(int) $log['transition']->getID()."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".$log['user']->getID().")";
|
||||
if (!$db->getResult($queryStr)) {
|
||||
$db->rollbackTransaction();
|
||||
|
|
|
@ -1051,9 +1051,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
|
||||
$document = $this->_dms->getDocument($db->getInsertID('tblDocuments'));
|
||||
|
||||
// if ($version_comment!="")
|
||||
$res = $document->addContent($version_comment, $owner, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers, $approvers, $reqversion, $version_attributes, $workflow);
|
||||
// else $res = $document->addContent($comment, $owner, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers, $approvers,$reqversion, $version_attributes, $workflow);
|
||||
$res = $document->addContent($version_comment, $owner, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers, $approvers, $reqversion, $version_attributes, $workflow);
|
||||
|
||||
if (is_bool($res) && !$res) {
|
||||
$db->rollbackTransaction();
|
||||
|
@ -1296,9 +1294,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
* has no access list the returned array contains the two elements
|
||||
* 'users' and 'groups' which are than empty. The methode returns false
|
||||
* if the function fails.
|
||||
*
|
||||
* @param int $mode access mode (defaults to M_ANY)
|
||||
* @param int|string $op operation (defaults to O_EQ)
|
||||
*
|
||||
* @param integer $mode access mode (defaults to M_ANY)
|
||||
* @param integer $op operation (defaults to O_EQ)
|
||||
* @return bool|SeedDMS_Core_GroupAccess|SeedDMS_Core_UserAccess
|
||||
*/
|
||||
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
|
||||
|
|
|
@ -232,7 +232,7 @@ class SeedDMS_Core_DatabaseAccess {
|
|||
$this->_ttapproveid = false;
|
||||
$this->_ttstatid = false;
|
||||
$this->_ttcontentid = false;
|
||||
$this->_useviews = false;
|
||||
$this->_useviews = false; // turn off views, because they are much slower then temp. tables
|
||||
$this->_debug = false;
|
||||
} /* }}} */
|
||||
|
||||
|
@ -401,8 +401,10 @@ class SeedDMS_Core_DatabaseAccess {
|
|||
}
|
||||
$res = $this->_conn->query($queryStr);
|
||||
if ($res === false) {
|
||||
if($this->_debug)
|
||||
if($this->_debug) {
|
||||
echo "error: ".$queryStr."<br />";
|
||||
print_r($this->_conn->errorInfo());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$resArr = $res->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
@ -429,8 +431,10 @@ class SeedDMS_Core_DatabaseAccess {
|
|||
}
|
||||
$res = $this->_conn->exec($queryStr);
|
||||
if($res === false) {
|
||||
if($this->_debug)
|
||||
if($this->_debug) {
|
||||
echo "error: ".$queryStr."<br />";
|
||||
print_r($this->_conn->errorInfo());
|
||||
}
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user