better documentation of getReverseDocumentLinks() and getDocumentLinks()

This commit is contained in:
Uwe Steinmann 2021-09-24 10:11:13 +02:00
parent 2f9148e5b9
commit 77de9bfaae

View File

@ -2121,12 +2121,22 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* The list may contain all links to other documents, even those which
* may not be visible by certain users, unless you pass appropriate
* parameters to filter out public links and those created by
* the given user. The application may call
* SeedDMS_Core_DMS::filterDocumentLinks() afterwards.
* the given user. The two parameters are or'ed. If $publiconly
* is set the method will return all public links disregarding the
* user. If $publiconly is not set but a user is set, the method
* will return all links of that user (public and none public).
* Setting a user and $publiconly to true will *not* return the
* public links of that user but all links which are public or
* owned by that user.
*
* @param boolean $publiconly return on publically visible links
* @param object $user return also private links of this user
* @return array list of objects of class SeedDMS_Core_DocumentLink
* The application must call
* SeedDMS_Core_DMS::filterDocumentLinks() afterwards to filter out
* those links pointing to a document not accessible by a given user.
*
* @param boolean $publiconly return all publically visible links
* @param SeedDMS_Core_User $user return also private links of this user
*
* @return array list of objects of class {@see SeedDMS_Core_DocumentLink}
*/
function getDocumentLinks($publiconly=false, $user=null) { /* {{{ */
if (!isset($this->_documentLinks)) {
@ -2167,39 +2177,41 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* parameters to filter out public links and those created by
* the given user.
* This functions is basically the reverse of
* SeedDMS_Core_Document::getDocumentLinks()
* {@see SeedDMS_Core_Document::getDocumentLinks()}
*
* The application may call
* SeedDMS_Core_DMS::filterDocumentLinks() afterwards.
* The application must call
* SeedDMS_Core_DMS::filterDocumentLinks() afterwards to filter out
* those links pointing to a document not accessible by a given user.
*
* @param boolean $publiconly return all publically visible links
* @param SeedDMS_Core_User $user return also private links of this user
*
* @param boolean $publiconly return on publically visible links
* @param object $user return also private links of this user
* @return array list of objects of class SeedDMS_Core_DocumentLink
*/
function getReverseDocumentLinks($publiconly=false, $user=null) { /* {{{ */
$db = $this->_dms->getDB();
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblDocumentLinks` WHERE `target` = " . $this->_id;
$tmp = array();
if($publiconly)
$tmp[] = "`public`=1";
if($user)
$tmp[] = "`userID`=".$user->getID();
if($tmp) {
$queryStr .= " AND (".implode(" OR ", $tmp).")";
}
$queryStr = "SELECT * FROM `tblDocumentLinks` WHERE `target` = " . $this->_id;
$tmp = array();
if($publiconly)
$tmp[] = "`public`=1";
if($user)
$tmp[] = "`userID`=".$user->getID();
if($tmp) {
$queryStr .= " AND (".implode(" OR ", $tmp).")";
}
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
$links = array();
foreach ($resArr as $row) {
$document = $this->_dms->getDocument($row["document"]);
$link = new SeedDMS_Core_DocumentLink($row["id"], $document, $this, $row["userID"], $row["public"]);
if($link->getAccessMode($user, $document, $this) >= M_READ)
array_push($links, $link);
}
$links = array();
foreach ($resArr as $row) {
$document = $this->_dms->getDocument($row["document"]);
$link = new SeedDMS_Core_DocumentLink($row["id"], $document, $this, $row["userID"], $row["public"]);
if($link->getAccessMode($user, $document, $this) >= M_READ)
array_push($links, $link);
}
return $links;
} /* }}} */