Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2022-03-03 09:04:47 +01:00
commit a156932843
2 changed files with 101 additions and 67 deletions

View File

@ -792,7 +792,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* *
* @return bool * @return bool
*/ */
function setDefaultAccess($mode, $noclean="false") { /* {{{ */ function setDefaultAccess($mode, $noclean=false) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if($mode < M_LOWEST_RIGHT || $mode > M_HIGHEST_RIGHT) if($mode < M_LOWEST_RIGHT || $mode > M_HIGHEST_RIGHT)
@ -1328,10 +1328,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
} }
$modeStr = ""; $modeStr = "";
if ($mode!=M_ANY) { if ($mode!=M_ANY) {
$modeStr = " AND mode".$op.(int)$mode; $modeStr = " AND `mode`".$op.(int)$mode;
} }
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_DOCUMENT. $queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_DOCUMENT.
" AND target = " . $this->_id . $modeStr . " ORDER BY `targetType`"; " AND `target` = " . $this->_id . $modeStr . " ORDER BY `targetType`";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr) if (is_bool($resArr) && !$resArr)
return false; return false;
@ -1351,8 +1351,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/** /**
* Add access right to folder * Add access right to folder
* This function may change in the future. Instead of passing the a flag * This function may change in the future. Instead of passing a flag
* and a user/group id a user or group object will be expected. * and a user/group id a user or group object will be expected.
* Starting with version 5.1.25 this method will first check if there
* is already an access right for the user/group.
* *
* @param integer $mode access mode * @param integer $mode access mode
* @param integer $userOrGroupID id of user or group * @param integer $userOrGroupID id of user or group
@ -1368,6 +1370,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`"; $userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
/* Adding a second access right will return false */
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_DOCUMENT.
" AND `target` = " . $this->_id . " AND ". $userOrGroup . " = ".$userOrGroupID;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) || $resArr)
return false;
$queryStr = "INSERT INTO `tblACLs` (`target`, `targetType`, ".$userOrGroup.", `mode`) VALUES $queryStr = "INSERT INTO `tblACLs` (`target`, `targetType`, ".$userOrGroup.", `mode`) VALUES
(".$this->_id.", ".T_DOCUMENT.", " . (int) $userOrGroupID . ", " .(int) $mode. ")"; (".$this->_id.", ".T_DOCUMENT.", " . (int) $userOrGroupID . ", " .(int) $mode. ")";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
@ -2954,7 +2963,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* This function is deprecated. Use * This function is deprecated. Use
* {@see SeedDMS_Core_Document::getReadAccessList()} instead. * {@see SeedDMS_Core_Document::getReadAccessList()} instead.
*/ */
function getApproversList() { /* {{{ */ protected function __getApproversList() { /* {{{ */
return $this->getReadAccessList(0, 0, 0); return $this->getReadAccessList(0, 0, 0);
} /* }}} */ } /* }}} */
@ -7113,9 +7122,18 @@ class SeedDMS_Core_DocumentLink { /* {{{ */
$this->_document = $document; $this->_document = $document;
$this->_target = $target; $this->_target = $target;
$this->_userID = $userID; $this->_userID = $userID;
$this->_public = $public; $this->_public = $public ? true : false;
} }
/**
* Check if this object is of type 'documentlink'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'documentlink';
} /* }}} */
/** /**
* @return int * @return int
*/ */
@ -7288,9 +7306,18 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
$this->_orgFileName = $orgFileName; $this->_orgFileName = $orgFileName;
$this->_name = $name; $this->_name = $name;
$this->_version = $version; $this->_version = $version;
$this->_public = $public; $this->_public = $public ? true : false;
} }
/**
* Check if this object is of type 'documentfile'.
*
* @param string $type type of object
*/
public function isType($type) { /* {{{ */
return $type == 'documentfile';
} /* }}} */
/** /**
* @return int * @return int
*/ */
@ -7339,7 +7366,7 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
* to the current timestamp * to the current timestamp
* @return boolean true on success * @return boolean true on success
*/ */
function setDate($date) { /* {{{ */ function setDate($date=null) { /* {{{ */
$db = $this->_document->getDMS()->getDB(); $db = $this->_document->getDMS()->getDB();
if(!$date) if(!$date)
@ -7454,7 +7481,7 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))
return false; return false;
$this->_public = $newPublic ? 1 : 0; $this->_public = $newPublic ? true : false;
return true; return true;
} /* }}} */ } /* }}} */

View File

@ -1325,7 +1325,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
} }
$modeStr = ""; $modeStr = "";
if ($mode!=M_ANY) { if ($mode!=M_ANY) {
$modeStr = " AND mode".$op.(int)$mode; $modeStr = " AND `mode`".$op.(int)$mode;
} }
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_FOLDER. $queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_FOLDER.
" AND `target` = " . $this->_id . $modeStr . " ORDER BY `targetType`"; " AND `target` = " . $this->_id . $modeStr . " ORDER BY `targetType`";
@ -1386,6 +1386,13 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`"; $userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
/* Adding a second access right will return false */
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_FOLDER.
" AND `target` = " . $this->_id . " AND ". $userOrGroup . " = ".$userOrGroupID;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) || $resArr)
return false;
$queryStr = "INSERT INTO `tblACLs` (`target`, `targetType`, ".$userOrGroup.", `mode`) VALUES $queryStr = "INSERT INTO `tblACLs` (`target`, `targetType`, ".$userOrGroup.", `mode`) VALUES
(".$this->_id.", ".T_FOLDER.", " . (int) $userOrGroupID . ", " .(int) $mode. ")"; (".$this->_id.", ".T_FOLDER.", " . (int) $userOrGroupID . ", " .(int) $mode. ")";
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr))