mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 23:42:11 +00:00
$dms->noReadForStatus no longer needed
SeedDMS_Core_DocumentContent::getAccessMode() retrieves the role based access restrictions from the role of the given user
This commit is contained in:
parent
2a38d713b8
commit
1326f825d3
|
@ -1792,7 +1792,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
*
|
||||
* This functions returns an array of content elements ordered by version.
|
||||
* Version which are not accessible because of its status, will be filtered
|
||||
* out.
|
||||
* out. Access rights based on the document status are calculated for the
|
||||
* currently logged in user.
|
||||
*
|
||||
* @return array list of objects of class SeedDMS_Core_DocumentContent
|
||||
*/
|
||||
|
@ -1826,7 +1827,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
* Return the content element of a document with a given version number
|
||||
*
|
||||
* This function will check if the version is accessible and return false
|
||||
* if not.
|
||||
* if not. Access rights based on the document status are calculated for the
|
||||
* currently logged in user.
|
||||
*
|
||||
* @param integer $version version number of content element
|
||||
* @return object/boolean object of class {@link SeedDMS_Core_DocumentContent}
|
||||
|
@ -1890,6 +1892,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
* {@link SeedDMS_Core_DMS::noReadForStatus} the function will go
|
||||
* backwards in history until an accessible version is found. If none
|
||||
* is found null will be returned.
|
||||
* Access rights based on the document status are calculated for the
|
||||
* currently logged in user.
|
||||
*
|
||||
* @return object object of class {@link SeedDMS_Core_DocumentContent}
|
||||
*/
|
||||
|
@ -3213,7 +3217,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
* like a virtual access mode, derived from the status of the document
|
||||
* content. The function checks if {@link SeedDMS_Core_DMS::noReadForStatus}
|
||||
* contains the status of the version and returns M_NONE if it exists and
|
||||
* the user is not involved in a workflow or review/approval.
|
||||
* the user is not involved in a workflow or review/approval/revision.
|
||||
* This method is called by all functions that returns the content e.g.
|
||||
* {@link SeedDMS_Core_Document::getLatestContent()}
|
||||
* It is also used by {@link SeedDMS_Core_Document::getAccessMode()} to
|
||||
|
@ -3221,6 +3225,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
*
|
||||
* FIXME: This function only works propperly if $u is the currently logged in
|
||||
* user, because noReadForStatus will be set for this user.
|
||||
* FIXED: instead of using $dms->noReadForStatus it is take from the user's role
|
||||
*
|
||||
* @param object $u user
|
||||
* @return integer either M_NONE or M_READ
|
||||
|
@ -3229,12 +3234,21 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$dms = $this->_document->_dms;
|
||||
$db = $dms->getDB();
|
||||
|
||||
if(!$u)
|
||||
return M_NONE;
|
||||
|
||||
/* If read access isn't further restricted by status, than grant read access */
|
||||
/* Old code
|
||||
if(!$dms->noReadForStatus)
|
||||
return M_READ;
|
||||
$noReadForStatus = $dms->noReadForStatus;
|
||||
*/
|
||||
$noReadForStatus = $u->getRole()->getNoAccess();
|
||||
if(!$noReadForStatus)
|
||||
return M_READ;
|
||||
|
||||
/* If the current status is not in list of status without read access, then grant read access */
|
||||
if(!in_array($this->getStatus()['status'], $dms->noReadForStatus))
|
||||
if(!in_array($this->getStatus()['status'], $noReadForStatus))
|
||||
return M_READ;
|
||||
|
||||
/* Administrators have unrestricted access */
|
||||
|
@ -3304,6 +3318,21 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
}
|
||||
break;
|
||||
case S_IN_REVISION:
|
||||
$status = $this->getRevisionStatus();
|
||||
foreach ($status as $r) {
|
||||
if($r['status'] != -2) // Check if reviewer was removed
|
||||
switch ($r["type"]) {
|
||||
case 0: // Revisor is an individual.
|
||||
if($u->getId() == $r["required"])
|
||||
return M_READ;
|
||||
break;
|
||||
case 1: // Revisor is a group.
|
||||
$required = $dms->getGroup($r["required"]);
|
||||
if (is_object($required) && $required->isMember($u))
|
||||
return M_READ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case S_REJECTED:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue
Block a user