mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 20:51:30 +00:00
inc.ClassFolder.php
This commit is contained in:
parent
ab73fe5298
commit
3f2e24f80d
|
@ -561,7 +561,7 @@ class SeedDMS_Core_DMS {
|
||||||
* If user authentication was done externally, this function can
|
* If user authentication was done externally, this function can
|
||||||
* be used to tell the dms who is currently logged in.
|
* be used to tell the dms who is currently logged in.
|
||||||
*
|
*
|
||||||
* @return object $user
|
* @return SeedDMS_Core_User $user
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function getLoggedInUser() { /* {{{ */
|
function getLoggedInUser() { /* {{{ */
|
||||||
|
|
|
@ -186,7 +186,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
protected $_sequence;
|
protected $_sequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var object temp. storage for latestcontent
|
* @var SeedDMS_Core_DocumentContent temp. storage for latestcontent
|
||||||
*/
|
*/
|
||||||
protected $_latestContent;
|
protected $_latestContent;
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
*/
|
*/
|
||||||
protected $_folder;
|
protected $_folder;
|
||||||
|
|
||||||
/** @var SeedDMS_Core_UserAccess[] */
|
/** @var array of SeedDMS_Core_UserAccess and SeedDMS_Core_GroupAccess */
|
||||||
protected $_accessList;
|
protected $_accessList;
|
||||||
|
|
||||||
function __construct($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */
|
function __construct($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */
|
||||||
|
@ -557,7 +557,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* will not have read access anymore.
|
* will not have read access anymore.
|
||||||
*
|
*
|
||||||
* @param integer $mode access mode
|
* @param integer $mode access mode
|
||||||
* @param boolean $noclean set to true if notifier list shall not be clean up
|
* @param bool|string $noclean set to true if notifier list shall not be clean up
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function setDefaultAccess($mode, $noclean="false") { /* {{{ */
|
function setDefaultAccess($mode, $noclean="false") { /* {{{ */
|
||||||
|
@ -802,7 +802,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
*
|
*
|
||||||
* @param int $mode access mode (defaults to M_ANY)
|
* @param int $mode access mode (defaults to M_ANY)
|
||||||
* @param int|string $op operation (defaults to O_EQ)
|
* @param int|string $op operation (defaults to O_EQ)
|
||||||
* @return bool|SeedDMS_Core_UserAccess[]
|
* @return bool|array
|
||||||
*/
|
*/
|
||||||
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
|
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -970,6 +970,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$accessList = $this->getAccessList();
|
$accessList = $this->getAccessList();
|
||||||
if (!$accessList) return false;
|
if (!$accessList) return false;
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_UserAccess $userAccess */
|
||||||
foreach ($accessList["users"] as $userAccess) {
|
foreach ($accessList["users"] as $userAccess) {
|
||||||
if ($userAccess->getUserID() == $user->getID()) {
|
if ($userAccess->getUserID() == $user->getID()) {
|
||||||
$mode = $userAccess->getMode();
|
$mode = $userAccess->getMode();
|
||||||
|
@ -983,6 +984,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
/* Get the highest right defined by a group */
|
/* Get the highest right defined by a group */
|
||||||
if($accessList['groups']) {
|
if($accessList['groups']) {
|
||||||
$mode = 0;
|
$mode = 0;
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $groupAccess */
|
||||||
foreach ($accessList["groups"] as $groupAccess) {
|
foreach ($accessList["groups"] as $groupAccess) {
|
||||||
if ($user->isMemberOfGroup($groupAccess->getGroup())) {
|
if ($user->isMemberOfGroup($groupAccess->getGroup())) {
|
||||||
if ($groupAccess->getMode() > $mode)
|
if ($groupAccess->getMode() > $mode)
|
||||||
|
@ -1014,7 +1016,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* The function takes inherited access rights into account.
|
* The function takes inherited access rights into account.
|
||||||
* For a list of possible access rights see @file inc.AccessUtils.php
|
* For a list of possible access rights see @file inc.AccessUtils.php
|
||||||
*
|
*
|
||||||
* @param $group object instance of class SeedDMS_Core_Group
|
* @param SeedDMS_Core_Group $group object instance of class SeedDMS_Core_Group
|
||||||
* @return integer access mode
|
* @return integer access mode
|
||||||
*/
|
*/
|
||||||
function getGroupAccessMode($group) { /* {{{ */
|
function getGroupAccessMode($group) { /* {{{ */
|
||||||
|
@ -1026,6 +1028,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
if (!$accessList)
|
if (!$accessList)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $groupAccess */
|
||||||
foreach ($accessList["groups"] as $groupAccess) {
|
foreach ($accessList["groups"] as $groupAccess) {
|
||||||
if ($groupAccess->getGroupID() == $group->getID()) {
|
if ($groupAccess->getGroupID() == $group->getID()) {
|
||||||
$foundInACL = true;
|
$foundInACL = true;
|
||||||
|
@ -1051,7 +1054,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* SeedDMS_Core_Group.
|
* SeedDMS_Core_Group.
|
||||||
*
|
*
|
||||||
* @param integer $type type of notification (not yet used)
|
* @param integer $type type of notification (not yet used)
|
||||||
* @return array list of notifications
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function getNotifyList($type=0) { /* {{{ */
|
function getNotifyList($type=0) { /* {{{ */
|
||||||
if (empty($this->_notifyList)) {
|
if (empty($this->_notifyList)) {
|
||||||
|
@ -1092,7 +1095,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
/* Make a copy of both notifier lists because removeNotify will empty
|
/* Make a copy of both notifier lists because removeNotify will empty
|
||||||
* $this->_notifyList and the second foreach will not work anymore.
|
* $this->_notifyList and the second foreach will not work anymore.
|
||||||
*/
|
*/
|
||||||
|
/** @var SeedDMS_Core_User[] $nusers */
|
||||||
$nusers = $this->_notifyList["users"];
|
$nusers = $this->_notifyList["users"];
|
||||||
|
/** @var SeedDMS_Core_Group[] $ngroups */
|
||||||
$ngroups = $this->_notifyList["groups"];
|
$ngroups = $this->_notifyList["groups"];
|
||||||
foreach ($nusers as $u) {
|
foreach ($nusers as $u) {
|
||||||
if ($this->getAccessMode($u) < M_READ) {
|
if ($this->getAccessMode($u) < M_READ) {
|
||||||
|
@ -1172,6 +1177,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
// that the current group has not been explicitly excluded.
|
// that the current group has not been explicitly excluded.
|
||||||
$acl = $this->getAccessList(M_NONE, O_EQ);
|
$acl = $this->getAccessList(M_NONE, O_EQ);
|
||||||
$found = false;
|
$found = false;
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $group */
|
||||||
foreach ($acl["groups"] as $group) {
|
foreach ($acl["groups"] as $group) {
|
||||||
if ($group->getGroupID() == $userOrGroupID) {
|
if ($group->getGroupID() == $userOrGroupID) {
|
||||||
$found = true;
|
$found = true;
|
||||||
|
@ -1190,6 +1196,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
$found = false;
|
$found = false;
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $group */
|
||||||
foreach ($acl["groups"] as $group) {
|
foreach ($acl["groups"] as $group) {
|
||||||
if ($group->getGroupID() == $userOrGroupID) {
|
if ($group->getGroupID() == $userOrGroupID) {
|
||||||
$found = true;
|
$found = true;
|
||||||
|
@ -1240,6 +1247,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
/* Verify that user / group exists. */
|
/* Verify that user / group exists. */
|
||||||
|
/** @var SeedDMS_Core_Group|SeedDMS_Core_User $obj */
|
||||||
$obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID));
|
$obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID));
|
||||||
if (!is_object($obj)) {
|
if (!is_object($obj)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1315,7 +1323,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* @param array $attributes list of version attributes. The element key
|
* @param array $attributes list of version attributes. The element key
|
||||||
* must be the id of the attribute definition.
|
* must be the id of the attribute definition.
|
||||||
* @param object $workflow
|
* @param object $workflow
|
||||||
* @return bool/array false in case of an error or a result set
|
* @return bool|SeedDMS_Core_AddContentResultSet
|
||||||
*/
|
*/
|
||||||
function addContent($comment, $user, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers=array(), $approvers=array(), $version=0, $attributes=array(), $workflow=null) { /* {{{ */
|
function addContent($comment, $user, $tmpFile, $orgFileName, $fileType, $mimeType, $reviewers=array(), $approvers=array(), $version=0, $attributes=array(), $workflow=null) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -1365,7 +1373,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$this->_content = null;
|
$this->_content = null;
|
||||||
$this->_latestContent = null;
|
$this->_latestContent = null;
|
||||||
$content = $this->getLatestContent($contentID);
|
$content = $this->getLatestContent($contentID); /** @todo: Parameter not defined in Funktion */
|
||||||
$docResultSet = new SeedDMS_Core_AddContentResultSet($content);
|
$docResultSet = new SeedDMS_Core_AddContentResultSet($content);
|
||||||
$docResultSet->setDMS($this->_dms);
|
$docResultSet->setDMS($this->_dms);
|
||||||
|
|
||||||
|
@ -1402,7 +1410,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
// and submit comments, if appropriate. Reviewers can also recommend that
|
// and submit comments, if appropriate. Reviewers can also recommend that
|
||||||
// a document be rejected.
|
// a document be rejected.
|
||||||
$pendingReview=false;
|
$pendingReview=false;
|
||||||
$reviewRes = array();
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
|
$reviewRes = array(); /** @todo unused variable */
|
||||||
foreach (array("i", "g") as $i){
|
foreach (array("i", "g") as $i){
|
||||||
if (isset($reviewers[$i])) {
|
if (isset($reviewers[$i])) {
|
||||||
foreach ($reviewers[$i] as $reviewerID) {
|
foreach ($reviewers[$i] as $reviewerID) {
|
||||||
|
@ -1420,7 +1429,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
// Add approvers to the database. Approvers must also review the document
|
// Add approvers to the database. Approvers must also review the document
|
||||||
// and make a recommendation on its release as an approved version.
|
// and make a recommendation on its release as an approved version.
|
||||||
$pendingApproval=false;
|
$pendingApproval=false;
|
||||||
$approveRes = array();
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
|
$approveRes = array(); /** @todo unused variable */
|
||||||
foreach (array("i", "g") as $i){
|
foreach (array("i", "g") as $i){
|
||||||
if (isset($approvers[$i])) {
|
if (isset($approvers[$i])) {
|
||||||
foreach ($approvers[$i] as $approverID) {
|
foreach ($approvers[$i] as $approverID) {
|
||||||
|
@ -1458,7 +1468,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$docResultSet->setStatus($status,$comment,$user);
|
/** @noinspection PhpMethodParametersCountMismatchInspection */
|
||||||
|
$docResultSet->setStatus($status,$comment,$user); /** @todo parameter count wrong */
|
||||||
|
|
||||||
$db->commitTransaction();
|
$db->commitTransaction();
|
||||||
return $docResultSet;
|
return $docResultSet;
|
||||||
|
@ -1496,7 +1507,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
if ((int) $version<1) {
|
if ((int) $version<1) {
|
||||||
$queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id;
|
$queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$res)
|
if (is_bool($resArr) && !$res) /** @todo undefined variable */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$version = $resArr[0]['m'];
|
$version = $resArr[0]['m'];
|
||||||
|
@ -1551,7 +1562,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* out. Access rights based on the document status are calculated for the
|
* out. Access rights based on the document status are calculated for the
|
||||||
* currently logged in user.
|
* currently logged in user.
|
||||||
*
|
*
|
||||||
* @return array list of objects of class SeedDMS_Core_DocumentContent
|
* @return bool|SeedDMS_Core_DocumentContent[]
|
||||||
*/
|
*/
|
||||||
function getContent() { /* {{{ */
|
function getContent() { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -1559,13 +1570,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
if (!isset($this->_content)) {
|
if (!isset($this->_content)) {
|
||||||
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version`";
|
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version`";
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$res)
|
if (is_bool($resArr) && !$res) /** @todo undefined variable */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$this->_content = array();
|
$this->_content = array();
|
||||||
$classname = $this->_dms->getClassname('documentcontent');
|
$classname = $this->_dms->getClassname('documentcontent');
|
||||||
$user = $this->_dms->getLoggedInUser();
|
$user = $this->_dms->getLoggedInUser();
|
||||||
foreach ($resArr as $row) {
|
foreach ($resArr as $row) {
|
||||||
|
/** @var SeedDMS_Core_DocumentContent $content */
|
||||||
$content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']);
|
$content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']);
|
||||||
if($user) {
|
if($user) {
|
||||||
if($content->getAccessMode($user) >= M_READ)
|
if($content->getAccessMode($user) >= M_READ)
|
||||||
|
@ -1587,7 +1599,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* currently logged in user.
|
* currently logged in user.
|
||||||
*
|
*
|
||||||
* @param integer $version version number of content element
|
* @param integer $version version number of content element
|
||||||
* @return object/boolean object of class {@link SeedDMS_Core_DocumentContent}
|
* @return SeedDMS_Core_DocumentContent|boolean object of class {@link SeedDMS_Core_DocumentContent}
|
||||||
* or false
|
* or false
|
||||||
*/
|
*/
|
||||||
function getContentByVersion($version) { /* {{{ */
|
function getContentByVersion($version) { /* {{{ */
|
||||||
|
@ -1604,13 +1616,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." AND `version` = " . (int) $version;
|
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." AND `version` = " . (int) $version;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$res)
|
if (is_bool($resArr) && !$res) /** @todo undefined variable */
|
||||||
return false;
|
return false;
|
||||||
if (count($resArr) != 1)
|
if (count($resArr) != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$resArr = $resArr[0];
|
$resArr = $resArr[0];
|
||||||
$classname = $this->_dms->getClassname('documentcontent');
|
$classname = $this->_dms->getClassname('documentcontent');
|
||||||
|
/** @var SeedDMS_Core_DocumentContent $content */
|
||||||
if($content = new $classname($resArr["id"], $this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"], $resArr['fileSize'], $resArr['checksum'])) {
|
if($content = new $classname($resArr["id"], $this, $resArr["version"], $resArr["comment"], $resArr["date"], $resArr["createdBy"], $resArr["dir"], $resArr["orgFileName"], $resArr["fileType"], $resArr["mimeType"], $resArr['fileSize'], $resArr['checksum'])) {
|
||||||
$user = $this->_dms->getLoggedInUser();
|
$user = $this->_dms->getLoggedInUser();
|
||||||
/* A user with write access on the document may always see the version */
|
/* A user with write access on the document may always see the version */
|
||||||
|
@ -1623,6 +1636,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool|null|SeedDMS_Core_DocumentContent
|
||||||
|
*/
|
||||||
function __getLatestContent() { /* {{{ */
|
function __getLatestContent() { /* {{{ */
|
||||||
if (!$this->_latestContent) {
|
if (!$this->_latestContent) {
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -1651,20 +1667,21 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* Access rights based on the document status are calculated for the
|
* Access rights based on the document status are calculated for the
|
||||||
* currently logged in user.
|
* currently logged in user.
|
||||||
*
|
*
|
||||||
* @return object object of class {@link SeedDMS_Core_DocumentContent}
|
* @return bool|SeedDMS_Core_DocumentContent object of class {@link SeedDMS_Core_DocumentContent}
|
||||||
*/
|
*/
|
||||||
function getLatestContent() { /* {{{ */
|
function getLatestContent() { /* {{{ */
|
||||||
if (!$this->_latestContent) {
|
if (!$this->_latestContent) {
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC";
|
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC";
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$res)
|
if (is_bool($resArr) && !$res) /** @todo: $res not defined */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$classname = $this->_dms->getClassname('documentcontent');
|
$classname = $this->_dms->getClassname('documentcontent');
|
||||||
$user = $this->_dms->getLoggedInUser();
|
$user = $this->_dms->getLoggedInUser();
|
||||||
foreach ($resArr as $row) {
|
foreach ($resArr as $row) {
|
||||||
if (!$this->_latestContent) {
|
if (!$this->_latestContent) {
|
||||||
|
/** @var SeedDMS_Core_DocumentContent $content */
|
||||||
$content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']);
|
$content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']);
|
||||||
if($user) {
|
if($user) {
|
||||||
/* If the user may even write the document, then also allow to see all content.
|
/* If the user may even write the document, then also allow to see all content.
|
||||||
|
@ -1686,7 +1703,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
/**
|
/**
|
||||||
* Remove version of document
|
* Remove version of document
|
||||||
*
|
*
|
||||||
* @param interger $version version number of content
|
* @param SeedDMS_Core_DocumentContent $version version number of content
|
||||||
* @return boolean true if successful, otherwise false
|
* @return boolean true if successful, otherwise false
|
||||||
*/
|
*/
|
||||||
private function _removeContent($version) { /* {{{ */
|
private function _removeContent($version) { /* {{{ */
|
||||||
|
@ -1816,7 +1833,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
/**
|
/**
|
||||||
* Call callback onPreRemoveDocument before deleting content
|
* Call callback onPreRemoveDocument before deleting content
|
||||||
*
|
*
|
||||||
* @param integer $version version number of content
|
* @param SeedDMS_Core_DocumentContent $version version number of content
|
||||||
|
* @return bool|mixed
|
||||||
*/
|
*/
|
||||||
function removeContent($version) { /* {{{ */
|
function removeContent($version) { /* {{{ */
|
||||||
/* Check if 'onPreRemoveDocument' callback is set */
|
/* Check if 'onPreRemoveDocument' callback is set */
|
||||||
|
@ -1847,7 +1865,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* Return a certain document link
|
* Return a certain document link
|
||||||
*
|
*
|
||||||
* @param integer $linkID id of link
|
* @param integer $linkID id of link
|
||||||
* @return object instance of SeedDMS_Core_DocumentLink or false in case of
|
* @return SeedDMS_Core_DocumentLink|bool of SeedDMS_Core_DocumentLink or false in case of
|
||||||
* an error.
|
* an error.
|
||||||
*/
|
*/
|
||||||
function getDocumentLink($linkID) { /* {{{ */
|
function getDocumentLink($linkID) { /* {{{ */
|
||||||
|
@ -1866,7 +1884,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$link = new SeedDMS_Core_DocumentLink($resArr["id"], $document, $target, $resArr["userID"], $resArr["public"]);
|
$link = new SeedDMS_Core_DocumentLink($resArr["id"], $document, $target, $resArr["userID"], $resArr["public"]);
|
||||||
$user = $this->_dms->getLoggedInUser();
|
$user = $this->_dms->getLoggedInUser();
|
||||||
if($link->getAccessMode($user, $document, $target) >= M_READ)
|
if($link->getAccessMode($user, $document, $target) >= M_READ)
|
||||||
return $file;
|
/** @noinspection PhpUndefinedVariableInspection */
|
||||||
|
return $file; /** @todo variable not defined */
|
||||||
return null;
|
return null;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,48 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
*/
|
*/
|
||||||
protected $_sequence;
|
protected $_sequence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
protected $_date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SeedDMS_Core_Folder
|
||||||
|
*/
|
||||||
|
protected $_parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SeedDMS_Core_User
|
||||||
|
*/
|
||||||
|
protected $_owner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SeedDMS_Core_Folder[]
|
||||||
|
*/
|
||||||
|
protected $_subFolders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SeedDMS_Core_Document[]
|
||||||
|
*/
|
||||||
|
protected $_documents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SeedDMS_Core_UserAccess[]|SeedDMS_Core_GroupAccess[]
|
||||||
|
*/
|
||||||
|
protected $_accessList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SeedDMS_Core_Folder constructor.
|
||||||
|
* @param $id
|
||||||
|
* @param $name
|
||||||
|
* @param $parentID
|
||||||
|
* @param $comment
|
||||||
|
* @param $date
|
||||||
|
* @param $ownerID
|
||||||
|
* @param $inheritAccess
|
||||||
|
* @param $defaultAccess
|
||||||
|
* @param $sequence
|
||||||
|
*/
|
||||||
function __construct($id, $name, $parentID, $comment, $date, $ownerID, $inheritAccess, $defaultAccess, $sequence) { /* {{{ */
|
function __construct($id, $name, $parentID, $comment, $date, $ownerID, $inheritAccess, $defaultAccess, $sequence) { /* {{{ */
|
||||||
parent::__construct($id);
|
parent::__construct($id);
|
||||||
$this->_id = $id;
|
$this->_id = $id;
|
||||||
|
@ -91,6 +133,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* Return an array of database fields which used for searching
|
* Return an array of database fields which used for searching
|
||||||
* a term entered in the database search form
|
* a term entered in the database search form
|
||||||
*
|
*
|
||||||
|
* @param SeedDMS_Core_DMS $dms
|
||||||
* @param array $searchin integer list of search scopes (2=name, 3=comment,
|
* @param array $searchin integer list of search scopes (2=name, 3=comment,
|
||||||
* 4=attributes)
|
* 4=attributes)
|
||||||
* @return array list of database fields
|
* @return array list of database fields
|
||||||
|
@ -125,6 +168,11 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return $sql;
|
return $sql;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @param SeedDMS_Core_DMS $dms
|
||||||
|
* @return bool|SeedDMS_Core_Folder
|
||||||
|
*/
|
||||||
public static function getInstance($id, $dms) { /* {{{ */
|
public static function getInstance($id, $dms) { /* {{{ */
|
||||||
$db = $dms->getDB();
|
$db = $dms->getDB();
|
||||||
|
|
||||||
|
@ -137,22 +185,24 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
|
|
||||||
$resArr = $resArr[0];
|
$resArr = $resArr[0];
|
||||||
$classname = $dms->getClassname('folder');
|
$classname = $dms->getClassname('folder');
|
||||||
|
/** @var SeedDMS_Core_Folder $folder */
|
||||||
$folder = new $classname($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["date"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]);
|
$folder = new $classname($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["date"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]);
|
||||||
$folder->setDMS($dms);
|
$folder->setDMS($dms);
|
||||||
return $folder;
|
return $folder;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Get the name of the folder.
|
* Get the name of the folder.
|
||||||
*
|
*
|
||||||
* @return string name of folder
|
* @return string name of folder
|
||||||
*/
|
*/
|
||||||
public function getName() { return $this->_name; }
|
public function getName() { return $this->_name; }
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Set the name of the folder.
|
* Set the name of the folder.
|
||||||
*
|
*
|
||||||
* @param string $newName set a new name of the folder
|
* @param string $newName set a new name of the folder
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setName($newName) { /* {{{ */
|
public function setName($newName) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -166,8 +216,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getComment() { return $this->_comment; }
|
public function getComment() { return $this->_comment; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $newComment
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function setComment($newComment) { /* {{{ */
|
public function setComment($newComment) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -215,7 +272,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/**
|
/**
|
||||||
* Returns the parent
|
* Returns the parent
|
||||||
*
|
*
|
||||||
* @return object parent folder or false if there is no parent folder
|
* @return bool|SeedDMS_Core_Folder
|
||||||
*/
|
*/
|
||||||
public function getParent() { /* {{{ */
|
public function getParent() { /* {{{ */
|
||||||
if ($this->_id == $this->_dms->rootFolderID || empty($this->_parentID)) {
|
if ($this->_id == $this->_dms->rootFolderID || empty($this->_parentID)) {
|
||||||
|
@ -234,8 +291,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* This function checks if the passed folder is a subfolder of the current
|
* This function checks if the passed folder is a subfolder of the current
|
||||||
* folder.
|
* folder.
|
||||||
*
|
*
|
||||||
* @param object $subFolder potential sub folder
|
* @param SeedDMS_Core_Folder $subfolder
|
||||||
* @return boolean true if passes folder is a subfolder
|
* @return bool true if passes folder is a subfolder
|
||||||
*/
|
*/
|
||||||
function isSubFolder($subfolder) { /* {{{ */
|
function isSubFolder($subfolder) { /* {{{ */
|
||||||
$target_path = $subfolder->getPath();
|
$target_path = $subfolder->getPath();
|
||||||
|
@ -252,7 +309,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* This function moves a folder from one parent folder into another parent
|
* This function moves a folder from one parent folder into another parent
|
||||||
* folder. It will fail if the root folder is moved.
|
* folder. It will fail if the root folder is moved.
|
||||||
*
|
*
|
||||||
* @param object $newParent new parent folder
|
* @param SeedDMS_Core_Folder $newParent new parent folder
|
||||||
* @return boolean true if operation was successful otherwise false
|
* @return boolean true if operation was successful otherwise false
|
||||||
*/
|
*/
|
||||||
public function setParent($newParent) { /* {{{ */
|
public function setParent($newParent) { /* {{{ */
|
||||||
|
@ -306,6 +363,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
foreach ($resArr as $row) {
|
foreach ($resArr as $row) {
|
||||||
$newPath = preg_replace("/^.*:".$this->_id.":(.*$)/", $pathPrefix."\\1", $row["folderList"]);
|
$newPath = preg_replace("/^.*:".$this->_id.":(.*$)/", $pathPrefix."\\1", $row["folderList"]);
|
||||||
$queryStr="UPDATE `tblDocuments` SET `folderList` = '".$newPath."' WHERE `tblDocuments`.`id` = '".$row["id"]."'";
|
$queryStr="UPDATE `tblDocuments` SET `folderList` = '".$newPath."' WHERE `tblDocuments`.`id` = '".$row["id"]."'";
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$res = $db->getResult($queryStr);
|
$res = $db->getResult($queryStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +376,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
foreach ($resArr as $row) {
|
foreach ($resArr as $row) {
|
||||||
$newPath = preg_replace("/^.*:".$this->_id.":(.*$)/", $pathPrefix."\\1", $row["folderList"]);
|
$newPath = preg_replace("/^.*:".$this->_id.":(.*$)/", $pathPrefix."\\1", $row["folderList"]);
|
||||||
$queryStr="UPDATE `tblFolders` SET `folderList` = '".$newPath."' WHERE `tblFolders`.`id` = '".$row["id"]."'";
|
$queryStr="UPDATE `tblFolders` SET `folderList` = '".$newPath."' WHERE `tblFolders`.`id` = '".$row["id"]."'";
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$res = $db->getResult($queryStr);
|
$res = $db->getResult($queryStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +397,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/**
|
/**
|
||||||
* Set the owner
|
* Set the owner
|
||||||
*
|
*
|
||||||
* @param object new owner of the folder
|
* @param SeedDMS_Core_User $newOwner of the folder
|
||||||
* @return boolean true if successful otherwise false
|
* @return boolean true if successful otherwise false
|
||||||
*/
|
*/
|
||||||
function setOwner($newOwner) { /* {{{ */
|
function setOwner($newOwner) { /* {{{ */
|
||||||
|
@ -353,6 +412,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool|int
|
||||||
|
*/
|
||||||
function getDefaultAccess() { /* {{{ */
|
function getDefaultAccess() { /* {{{ */
|
||||||
if ($this->inheritsAccess()) {
|
if ($this->inheritsAccess()) {
|
||||||
$res = $this->getParent();
|
$res = $this->getParent();
|
||||||
|
@ -371,6 +433,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
*
|
*
|
||||||
* @param integer $mode access mode
|
* @param integer $mode access mode
|
||||||
* @param boolean $noclean set to true if notifier list shall not be clean up
|
* @param boolean $noclean set to true if notifier list shall not be clean up
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function setDefaultAccess($mode, $noclean=false) { /* {{{ */
|
function setDefaultAccess($mode, $noclean=false) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -443,7 +506,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
function hasSubFolders() { /* {{{ */
|
function hasSubFolders() { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
if (isset($this->_subFolders)) {
|
if (isset($this->_subFolders)) {
|
||||||
return count($this->subFolders);
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
return count($this->subFolders); /** @todo not $this->_subFolders? */
|
||||||
}
|
}
|
||||||
$queryStr = "SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this->_id;
|
$queryStr = "SELECT count(*) as c FROM `tblFolders` WHERE `parent` = " . $this->_id;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
@ -462,7 +526,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param string $orderby if set to 'n' the list is ordered by name, otherwise
|
* @param string $orderby if set to 'n' the list is ordered by name, otherwise
|
||||||
* it will be ordered by sequence
|
* it will be ordered by sequence
|
||||||
* @param string $dir direction of sorting (asc or desc)
|
* @param string $dir direction of sorting (asc or desc)
|
||||||
* @return array list of folder objects or false in case of an error
|
* @return SeedDMS_Core_Folder[]|bool
|
||||||
*/
|
*/
|
||||||
function getSubFolders($orderby="", $dir="asc") { /* {{{ */
|
function getSubFolders($orderby="", $dir="asc") { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -497,7 +561,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param integer $sequence position of folder in list of sub folders.
|
* @param integer $sequence position of folder in list of sub folders.
|
||||||
* @param array $attributes list of document attributes. The element key
|
* @param array $attributes list of document attributes. The element key
|
||||||
* must be the id of the attribute definition.
|
* must be the id of the attribute definition.
|
||||||
* @return object object of type SeedDMS_Core_Folder or false in case of
|
* @return bool|SeedDMS_Core_Folder
|
||||||
* an error.
|
* an error.
|
||||||
*/
|
*/
|
||||||
function addSubFolder($name, $comment, $owner, $sequence, $attributes=array()) { /* {{{ */
|
function addSubFolder($name, $comment, $owner, $sequence, $attributes=array()) { /* {{{ */
|
||||||
|
@ -540,6 +604,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/* Check if 'onPostAddSubFolder' callback is set */
|
/* Check if 'onPostAddSubFolder' callback is set */
|
||||||
if(isset($this->_dms->callbacks['onPostAddSubFolder'])) {
|
if(isset($this->_dms->callbacks['onPostAddSubFolder'])) {
|
||||||
foreach($this->_dms->callbacks['onPostAddSubFolder'] as $callback) {
|
foreach($this->_dms->callbacks['onPostAddSubFolder'] as $callback) {
|
||||||
|
/** @noinspection PhpStatementHasEmptyBodyInspection */
|
||||||
if(!call_user_func($callback[0], $callback[1], $newFolder)) {
|
if(!call_user_func($callback[0], $callback[1], $newFolder)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,7 +683,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
function hasDocuments() { /* {{{ */
|
function hasDocuments() { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
if (isset($this->_documents)) {
|
if (isset($this->_documents)) {
|
||||||
return count($this->documents);
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
return count($this->documents); /** @todo not $this->_documents? */
|
||||||
}
|
}
|
||||||
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id;
|
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
@ -631,12 +697,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/**
|
/**
|
||||||
* Check if folder has document with given name
|
* Check if folder has document with given name
|
||||||
*
|
*
|
||||||
* @return boolean true if document exists, false if not or in case
|
* @param string $name
|
||||||
|
* @return bool true if document exists, false if not or in case
|
||||||
* of an error
|
* of an error
|
||||||
*/
|
*/
|
||||||
function hasDocumentByName($name) { /* {{{ */
|
function hasDocumentByName($name) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
if (isset($this->_documents)) {
|
if (isset($this->_documents)) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */ /** @todo not $this->_documents? */
|
||||||
return count($this->documents);
|
return count($this->documents);
|
||||||
}
|
}
|
||||||
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id . " AND `name` = ".$db->qstr($name);
|
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id . " AND `name` = ".$db->qstr($name);
|
||||||
|
@ -656,7 +724,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param string $orderby if set to 'n' the list is ordered by name, otherwise
|
* @param string $orderby if set to 'n' the list is ordered by name, otherwise
|
||||||
* it will be ordered by sequence
|
* it will be ordered by sequence
|
||||||
* @param string $dir direction of sorting (asc or desc)
|
* @param string $dir direction of sorting (asc or desc)
|
||||||
* @return array list of documents or false in case of an error
|
* @return SeedDMS_Core_Document[]|bool
|
||||||
*/
|
*/
|
||||||
function getDocuments($orderby="", $dir="asc") { /* {{{ */
|
function getDocuments($orderby="", $dir="asc") { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -697,13 +765,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* Setting the parameter $limit to 0 will turn off access right checking
|
* Setting the parameter $limit to 0 will turn off access right checking
|
||||||
* which is reasonable if the $user is an administrator.
|
* which is reasonable if the $user is an administrator.
|
||||||
*
|
*
|
||||||
* @param string $orderby if set to 'n' the list is ordered by name, otherwise
|
* @param SeedDMS_Core_User $user
|
||||||
* it will be ordered by sequence
|
|
||||||
* @param integer $limit maximum number of folders and documents that will
|
* @param integer $limit maximum number of folders and documents that will
|
||||||
* be precisly counted by taken the access rights into account
|
* be precisly counted by taken the access rights into account
|
||||||
* @return array array with four elements 'document_count', 'folder_count'
|
* @return array|bool with four elements 'document_count', 'folder_count'
|
||||||
* 'document_precise', 'folder_precise' holding
|
* 'document_precise', 'folder_precise' holding
|
||||||
* the counted number and a flag if the number is precise.
|
* the counted number and a flag if the number is precise.
|
||||||
|
* @internal param string $orderby if set to 'n' the list is ordered by name, otherwise
|
||||||
|
* it will be ordered by sequence
|
||||||
*/
|
*/
|
||||||
function countChildren($user, $limit=10000) { /* {{{ */
|
function countChildren($user, $limit=10000) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -782,7 +851,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param integer $expires expiration date as a unix timestamp or 0 for no
|
* @param integer $expires expiration date as a unix timestamp or 0 for no
|
||||||
* expiration date
|
* expiration date
|
||||||
* @param object $owner owner of the new document
|
* @param object $owner owner of the new document
|
||||||
* @param string $keywords keywords of new document
|
* @param SeedDMS_Core_User $keywords keywords of new document
|
||||||
* @param array $categories list of category ids
|
* @param array $categories list of category ids
|
||||||
* @param string $tmpFile the path of the file containing the content
|
* @param string $tmpFile the path of the file containing the content
|
||||||
* @param string $orgFileName the original file name
|
* @param string $orgFileName the original file name
|
||||||
|
@ -791,15 +860,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param float $sequence position of new document within the folder
|
* @param float $sequence position of new document within the folder
|
||||||
* @param array $reviewers list of users who must review this document
|
* @param array $reviewers list of users who must review this document
|
||||||
* @param array $approvers list of users who must approve this document
|
* @param array $approvers list of users who must approve this document
|
||||||
* @param string $reqversion version number of the content
|
* @param int|string $reqversion version number of the content
|
||||||
* @param string $version_comment comment of the content. If left empty
|
* @param string $version_comment comment of the content. If left empty
|
||||||
* the $comment will be used.
|
* the $comment will be used.
|
||||||
* @param array $attributes list of document attributes. The element key
|
* @param array $attributes list of document attributes. The element key
|
||||||
* must be the id of the attribute definition.
|
* must be the id of the attribute definition.
|
||||||
* @param array $version_attributes list of document version attributes.
|
* @param array $version_attributes list of document version attributes.
|
||||||
* The element key must be the id of the attribute definition.
|
* The element key must be the id of the attribute definition.
|
||||||
* @param object $workflow
|
* @param SeedDMS_Core_Workflow $workflow
|
||||||
* @return array/boolean false in case of error, otherwise an array
|
* @return array|bool false in case of error, otherwise an array
|
||||||
* containing two elements. The first one is the new document, the
|
* containing two elements. The first one is the new document, the
|
||||||
* second one is the result set returned when inserting the content.
|
* second one is the result set returned when inserting the content.
|
||||||
*/
|
*/
|
||||||
|
@ -859,6 +928,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/* Check if 'onPostAddDocument' callback is set */
|
/* Check if 'onPostAddDocument' callback is set */
|
||||||
if(isset($this->_dms->callbacks['onPostAddDocument'])) {
|
if(isset($this->_dms->callbacks['onPostAddDocument'])) {
|
||||||
foreach($this->_dms->callbacks['onPostAddDocument'] as $callback) {
|
foreach($this->_dms->callbacks['onPostAddDocument'] as $callback) {
|
||||||
|
/** @noinspection PhpStatementHasEmptyBodyInspection */
|
||||||
if(!call_user_func($callback[0], $callback[1], $document)) {
|
if(!call_user_func($callback[0], $callback[1], $document)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -923,6 +993,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/* Check if 'onPostRemoveFolder' callback is set */
|
/* Check if 'onPostRemoveFolder' callback is set */
|
||||||
if(isset($this->_dms->callbacks['onPostRemoveFolder'])) {
|
if(isset($this->_dms->callbacks['onPostRemoveFolder'])) {
|
||||||
foreach($this->_dms->callbacks['onPostRemoveFolder'] as $callback) {
|
foreach($this->_dms->callbacks['onPostRemoveFolder'] as $callback) {
|
||||||
|
/** @noinspection PhpStatementHasEmptyBodyInspection */
|
||||||
if(!call_user_func($callback[0], $callback[1], $this->_id)) {
|
if(!call_user_func($callback[0], $callback[1], $this->_id)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -939,6 +1010,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @return boolean true on success, false in case of an error
|
* @return boolean true on success, false in case of an error
|
||||||
*/
|
*/
|
||||||
function remove() { /* {{{ */
|
function remove() { /* {{{ */
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
// Do not delete the root folder.
|
// Do not delete the root folder.
|
||||||
|
@ -983,9 +1055,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* 'users' and 'groups' which are than empty. The methode returns false
|
* 'users' and 'groups' which are than empty. The methode returns false
|
||||||
* if the function fails.
|
* if the function fails.
|
||||||
*
|
*
|
||||||
* @param integer $mode access mode (defaults to M_ANY)
|
* @param int $mode access mode (defaults to M_ANY)
|
||||||
* @param integer $op operation (defaults to O_EQ)
|
* @param int|string $op operation (defaults to O_EQ)
|
||||||
* @return array multi dimensional array
|
* @return bool|SeedDMS_Core_GroupAccess|SeedDMS_Core_UserAccess
|
||||||
*/
|
*/
|
||||||
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
|
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -1052,6 +1124,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param integer $userOrGroupID id of user or group
|
* @param integer $userOrGroupID id of user or group
|
||||||
* @param integer $isUser set to 1 if $userOrGroupID is the id of a
|
* @param integer $isUser set to 1 if $userOrGroupID is the id of a
|
||||||
* user
|
* user
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
|
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -1082,6 +1155,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* @param integer $userOrGroupID id of user or group
|
* @param integer $userOrGroupID id of user or group
|
||||||
* @param integer $isUser set to 1 if $userOrGroupID is the id of a
|
* @param integer $isUser set to 1 if $userOrGroupID is the id of a
|
||||||
* user
|
* user
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function changeAccess($newMode, $userOrGroupID, $isUser) { /* {{{ */
|
function changeAccess($newMode, $userOrGroupID, $isUser) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
@ -1102,6 +1176,11 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userOrGroupID
|
||||||
|
* @param $isUser
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
function removeAccess($userOrGroupID, $isUser) { /* {{{ */
|
function removeAccess($userOrGroupID, $isUser) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
@ -1158,6 +1237,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
$accessList = $this->getAccessList();
|
$accessList = $this->getAccessList();
|
||||||
if (!$accessList) return false;
|
if (!$accessList) return false;
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_UserAccess $userAccess */
|
||||||
foreach ($accessList["users"] as $userAccess) {
|
foreach ($accessList["users"] as $userAccess) {
|
||||||
if ($userAccess->getUserID() == $user->getID()) {
|
if ($userAccess->getUserID() == $user->getID()) {
|
||||||
$mode = $userAccess->getMode();
|
$mode = $userAccess->getMode();
|
||||||
|
@ -1171,6 +1251,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/* Get the highest right defined by a group */
|
/* Get the highest right defined by a group */
|
||||||
if($accessList['groups']) {
|
if($accessList['groups']) {
|
||||||
$mode = 0;
|
$mode = 0;
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $groupAccess */
|
||||||
foreach ($accessList["groups"] as $groupAccess) {
|
foreach ($accessList["groups"] as $groupAccess) {
|
||||||
if ($user->isMemberOfGroup($groupAccess->getGroup())) {
|
if ($user->isMemberOfGroup($groupAccess->getGroup())) {
|
||||||
if ($groupAccess->getMode() > $mode)
|
if ($groupAccess->getMode() > $mode)
|
||||||
|
@ -1198,7 +1279,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* applied to get the access mode is the same as describe at
|
* applied to get the access mode is the same as describe at
|
||||||
* {@link getAccessMode}
|
* {@link getAccessMode}
|
||||||
*
|
*
|
||||||
* @param object $group group for which access shall be checked
|
* @param SeedDMS_Core_Group $group group for which access shall be checked
|
||||||
* @return integer access mode
|
* @return integer access mode
|
||||||
*/
|
*/
|
||||||
function getGroupAccessMode($group) { /* {{{ */
|
function getGroupAccessMode($group) { /* {{{ */
|
||||||
|
@ -1208,6 +1289,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
if (!$accessList)
|
if (!$accessList)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $groupAccess */
|
||||||
foreach ($accessList["groups"] as $groupAccess) {
|
foreach ($accessList["groups"] as $groupAccess) {
|
||||||
if ($groupAccess->getGroupID() == $group->getID()) {
|
if ($groupAccess->getGroupID() == $group->getID()) {
|
||||||
$foundInACL = true;
|
$foundInACL = true;
|
||||||
|
@ -1224,13 +1306,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return $this->getDefaultAccess();
|
return $this->getDefaultAccess();
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/** @noinspection PhpUnusedParameterInspection */
|
||||||
/**
|
/**
|
||||||
* Get a list of all notification
|
* Get a list of all notification
|
||||||
* This function returns all users and groups that have registerd a
|
* This function returns all users and groups that have registerd a
|
||||||
* notification for the folder
|
* notification for the folder
|
||||||
*
|
*
|
||||||
* @param integer $type type of notification (not yet used)
|
* @param integer $type type of notification (not yet used)
|
||||||
* @return array array with a the elements 'users' and 'groups' which
|
* @return SeedDMS_Core_User[]|SeedDMS_Core_Group[]|bool array with a the elements 'users' and 'groups' which
|
||||||
* contain a list of users and groups.
|
* contain a list of users and groups.
|
||||||
*/
|
*/
|
||||||
function getNotifyList($type=0) { /* {{{ */
|
function getNotifyList($type=0) { /* {{{ */
|
||||||
|
@ -1272,6 +1355,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
/* Make a copy of both notifier lists because removeNotify will empty
|
/* Make a copy of both notifier lists because removeNotify will empty
|
||||||
* $this->_notifyList and the second foreach will not work anymore.
|
* $this->_notifyList and the second foreach will not work anymore.
|
||||||
*/
|
*/
|
||||||
|
/** @var SeedDMS_Core_User[] $nusers */
|
||||||
$nusers = $this->_notifyList["users"];
|
$nusers = $this->_notifyList["users"];
|
||||||
$ngroups = $this->_notifyList["groups"];
|
$ngroups = $this->_notifyList["groups"];
|
||||||
foreach ($nusers as $u) {
|
foreach ($nusers as $u) {
|
||||||
|
@ -1279,6 +1363,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
$this->removeNotify($u->getID(), true);
|
$this->removeNotify($u->getID(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_Group[] $ngroups */
|
||||||
foreach ($ngroups as $g) {
|
foreach ($ngroups as $g) {
|
||||||
if ($this->getGroupAccessMode($g) < M_READ) {
|
if ($this->getGroupAccessMode($g) < M_READ) {
|
||||||
$this->removeNotify($g->getID(), false);
|
$this->removeNotify($g->getID(), false);
|
||||||
|
@ -1286,7 +1372,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Add a user/group to the notification list
|
* Add a user/group to the notification list
|
||||||
* This function does not check if the currently logged in user
|
* This function does not check if the currently logged in user
|
||||||
* is allowed to add a notification. This must be checked by the calling
|
* is allowed to add a notification. This must be checked by the calling
|
||||||
|
@ -1307,6 +1393,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
|
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
|
||||||
|
|
||||||
/* Verify that user / group exists */
|
/* Verify that user / group exists */
|
||||||
|
/** @var SeedDMS_Core_User|SeedDMS_Core_Group $obj */
|
||||||
$obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID));
|
$obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID));
|
||||||
if (!is_object($obj)) {
|
if (!is_object($obj)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1356,6 +1443,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
// that the current group has not been explicitly excluded.
|
// that the current group has not been explicitly excluded.
|
||||||
$acl = $this->getAccessList(M_NONE, O_EQ);
|
$acl = $this->getAccessList(M_NONE, O_EQ);
|
||||||
$found = false;
|
$found = false;
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $group */
|
||||||
foreach ($acl["groups"] as $group) {
|
foreach ($acl["groups"] as $group) {
|
||||||
if ($group->getGroupID() == $userOrGroupID) {
|
if ($group->getGroupID() == $userOrGroupID) {
|
||||||
$found = true;
|
$found = true;
|
||||||
|
@ -1374,6 +1462,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
$found = false;
|
$found = false;
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $group */
|
||||||
foreach ($acl["groups"] as $group) {
|
foreach ($acl["groups"] as $group) {
|
||||||
if ($group->getGroupID() == $userOrGroupID) {
|
if ($group->getGroupID() == $userOrGroupID) {
|
||||||
$found = true;
|
$found = true;
|
||||||
|
@ -1407,7 +1496,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
return 0;
|
return 0;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Removes notify for a user or group to folder
|
* Removes notify for a user or group to folder
|
||||||
* This function does not check if the currently logged in user
|
* This function does not check if the currently logged in user
|
||||||
* is allowed to remove a notification. This must be checked by the calling
|
* is allowed to remove a notification. This must be checked by the calling
|
||||||
|
@ -1415,8 +1504,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
*
|
*
|
||||||
* @param integer $userOrGroupID
|
* @param integer $userOrGroupID
|
||||||
* @param boolean $isUser true if $userOrGroupID is a user id otherwise false
|
* @param boolean $isUser true if $userOrGroupID is a user id otherwise false
|
||||||
* @param $type type of notification (0 will delete all) Not used yet!
|
* @param int $type type of notification (0 will delete all) Not used yet!
|
||||||
* @return integer error code
|
* @return int error code
|
||||||
* -1: Invalid User/Group ID.
|
* -1: Invalid User/Group ID.
|
||||||
* -3: User is not subscribed.
|
* -3: User is not subscribed.
|
||||||
* -4: Database / internal error.
|
* -4: Database / internal error.
|
||||||
|
@ -1500,9 +1589,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
* administrators and the owner of the folder unless $listadmin resp.
|
* administrators and the owner of the folder unless $listadmin resp.
|
||||||
* $listowner is set to true.
|
* $listowner is set to true.
|
||||||
*
|
*
|
||||||
* @param boolean $listadmin if set to true any admin will be listed too
|
* @param bool|int $listadmin if set to true any admin will be listed too
|
||||||
* @param boolean $listowner if set to true the owner will be listed too
|
* @param bool|int $listowner if set to true the owner will be listed too
|
||||||
*
|
|
||||||
* @return array list of users and groups
|
* @return array list of users and groups
|
||||||
*/
|
*/
|
||||||
function getReadAccessList($listadmin=0, $listowner=0) { /* {{{ */
|
function getReadAccessList($listadmin=0, $listowner=0) { /* {{{ */
|
||||||
|
@ -1530,9 +1618,12 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
// to the folder.
|
// to the folder.
|
||||||
$tmpList = $this->getAccessList(M_NONE, O_LTEQ);
|
$tmpList = $this->getAccessList(M_NONE, O_LTEQ);
|
||||||
}
|
}
|
||||||
|
/** @var SeedDMS_Core_GroupAccess $groupAccess */
|
||||||
foreach ($tmpList["groups"] as $groupAccess) {
|
foreach ($tmpList["groups"] as $groupAccess) {
|
||||||
$groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $groupAccess->getGroupID();
|
$groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $groupAccess->getGroupID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var SeedDMS_Core_UserAccess $userAccess */
|
||||||
foreach ($tmpList["users"] as $userAccess) {
|
foreach ($tmpList["users"] as $userAccess) {
|
||||||
$user = $userAccess->getUser();
|
$user = $userAccess->getUser();
|
||||||
if (!$listadmin && $user->isAdmin()) continue;
|
if (!$listadmin && $user->isAdmin()) continue;
|
||||||
|
@ -1672,5 +1763,3 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user