check if latest content exists

This commit is contained in:
Uwe Steinmann 2021-06-25 09:02:39 +02:00
parent ff9385bf1e
commit 61a5dbc2b9

View File

@ -107,12 +107,13 @@ class SeedDMS_AccessOperation {
*/ */
function mayOverwriteStatus() { /* {{{ */ function mayOverwriteStatus() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
if ((($this->settings->_enableVersionModification && ($this->obj->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && ($status["status"]==S_RELEASED || $status["status"]==S_OBSOLETE )) { if ((($this->settings->_enableVersionModification && ($this->obj->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && ($status["status"]==S_RELEASED || $status["status"]==S_OBSOLETE )) {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -128,7 +129,7 @@ class SeedDMS_AccessOperation {
*/ */
function maySetReviewersApprovers() { /* {{{ */ function maySetReviewersApprovers() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
$reviewstatus = $latestContent->getReviewStatus(); $reviewstatus = $latestContent->getReviewStatus();
$hasreview = false; $hasreview = false;
@ -146,6 +147,7 @@ class SeedDMS_AccessOperation {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -160,13 +162,14 @@ class SeedDMS_AccessOperation {
*/ */
function maySetWorkflow() { /* {{{ */ function maySetWorkflow() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$workflow = $latestContent->getWorkflow(); $workflow = $latestContent->getWorkflow();
$workflowstate = $latestContent->getWorkflowState(); $workflowstate = $latestContent->getWorkflowState();
if ((($this->settings->_enableVersionModification && ($this->obj->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && (!$workflow || ($workflowstate && ($workflow->getInitState()->getID() == $workflowstate->getID())))) { if ((($this->settings->_enableVersionModification && ($this->obj->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && (!$workflow || ($workflowstate && ($workflow->getInitState()->getID() == $workflowstate->getID())))) {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -178,12 +181,13 @@ class SeedDMS_AccessOperation {
*/ */
function maySetExpires() { /* {{{ */ function maySetExpires() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
if ((($this->obj->getAccessMode($this->user) == M_ALL) || $this->user->isAdmin()) && ($status["status"]!=S_OBSOLETE)) { if ((($this->obj->getAccessMode($this->user) == M_ALL) || $this->user->isAdmin()) && ($status["status"]!=S_OBSOLETE)) {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -206,12 +210,13 @@ class SeedDMS_AccessOperation {
return false; return false;
} }
} }
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
if (($this->settings->_enableVersionModification || $this->user->isAdmin()) && !in_array($status["status"], array(S_OBSOLETE, S_EXPIRED))) { if (($this->settings->_enableVersionModification || $this->user->isAdmin()) && !in_array($status["status"], array(S_OBSOLETE, S_EXPIRED))) {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -225,7 +230,7 @@ class SeedDMS_AccessOperation {
*/ */
function mayEditAttributes() { /* {{{ */ function mayEditAttributes() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
$workflow = $latestContent->getWorkflow(); $workflow = $latestContent->getWorkflow();
$workflowstate = $latestContent->getWorkflowState(); $workflowstate = $latestContent->getWorkflowState();
@ -235,6 +240,7 @@ class SeedDMS_AccessOperation {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -247,12 +253,13 @@ class SeedDMS_AccessOperation {
*/ */
function mayReview() { /* {{{ */ function mayReview() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
if ($status["status"]==S_DRAFT_REV) { if ($status["status"]==S_DRAFT_REV) {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */
@ -282,12 +289,13 @@ class SeedDMS_AccessOperation {
*/ */
function mayApprove() { /* {{{ */ function mayApprove() { /* {{{ */
if($this->obj->isType('document')) { if($this->obj->isType('document')) {
$latestContent = $this->obj->getLatestContent(); if($latestContent = $this->obj->getLatestContent()) {
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
if ($status["status"]==S_DRAFT_APP) { if ($status["status"]==S_DRAFT_APP) {
return true; return true;
} }
} }
}
return false; return false;
} /* }}} */ } /* }}} */