add optional parameter to filterDocumentLinks()

This commit is contained in:
Uwe Steinmann 2017-01-16 12:59:02 +01:00
parent 0fd9c4d340
commit 57498f84a1
2 changed files with 21 additions and 4 deletions

View File

@ -259,13 +259,29 @@ class SeedDMS_Core_DMS {
*
* @param array $links list of objects of type SeedDMS_Core_DocumentLink
* @param object $user user for which access is being checked
* @param string $access set if source or target of link shall be checked
* for sufficient access rights. Set to 'source' if the source document
* of a link is to be checked, set to 'target' for the target document.
* If not set, then access right aren't checked at all.
* @return filtered list of links
*/
static function filterDocumentLinks($user, $links) { /* {{{ */
static function filterDocumentLinks($user, $links, $access='') { /* {{{ */
$tmp = array();
foreach ($links as $link)
if ($link->isPublic() || ($link->getUser()->getID() == $user->getID()) || $user->isAdmin())
array_push($tmp, $link);
foreach ($links as $link) {
if ($link->isPublic() || ($link->getUser()->getID() == $user->getID()) || $user->isAdmin()){
if($access == 'source') {
$obj = $link->getDocument();
if ($obj->getAccessMode($user) >= M_READ)
array_push($tmp, $link);
} elseif($access == 'target') {
$obj = $link->getTarget();
if ($obj->getAccessMode($user) >= M_READ)
array_push($tmp, $link);
} else {
array_push($tmp, $link);
}
}
}
return $tmp;
} /* }}} */

View File

@ -25,6 +25,7 @@
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- order groups by name returned by getReadAccessList()
- add optional parameter to SeedDMS_Core_DMS::filterDocumentLinks()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">