mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-15 06:01:19 +00:00
add optional parameter to filterDocumentLinks()
This commit is contained in:
parent
0fd9c4d340
commit
57498f84a1
|
@ -259,13 +259,29 @@ class SeedDMS_Core_DMS {
|
||||||
*
|
*
|
||||||
* @param array $links list of objects of type SeedDMS_Core_DocumentLink
|
* @param array $links list of objects of type SeedDMS_Core_DocumentLink
|
||||||
* @param object $user user for which access is being checked
|
* @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
|
* @return filtered list of links
|
||||||
*/
|
*/
|
||||||
static function filterDocumentLinks($user, $links) { /* {{{ */
|
static function filterDocumentLinks($user, $links, $access='') { /* {{{ */
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
foreach ($links as $link)
|
foreach ($links as $link) {
|
||||||
if ($link->isPublic() || ($link->getUser()->getID() == $user->getID()) || $user->isAdmin())
|
if ($link->isPublic() || ($link->getUser()->getID() == $user->getID()) || $user->isAdmin()){
|
||||||
array_push($tmp, $link);
|
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;
|
return $tmp;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
|
||||||
<notes>
|
<notes>
|
||||||
- order groups by name returned by getReadAccessList()
|
- order groups by name returned by getReadAccessList()
|
||||||
|
- add optional parameter to SeedDMS_Core_DMS::filterDocumentLinks()
|
||||||
</notes>
|
</notes>
|
||||||
<contents>
|
<contents>
|
||||||
<dir baseinstalldir="SeedDMS" name="/">
|
<dir baseinstalldir="SeedDMS" name="/">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user