mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-11 00:15:34 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
a156932843
|
@ -792,7 +792,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
function setDefaultAccess($mode, $noclean="false") { /* {{{ */
|
||||
function setDefaultAccess($mode, $noclean=false) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if($mode < M_LOWEST_RIGHT || $mode > M_HIGHEST_RIGHT)
|
||||
|
@ -1328,10 +1328,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
}
|
||||
$modeStr = "";
|
||||
if ($mode!=M_ANY) {
|
||||
$modeStr = " AND mode".$op.(int)$mode;
|
||||
$modeStr = " AND `mode`".$op.(int)$mode;
|
||||
}
|
||||
$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);
|
||||
if (is_bool($resArr) && !$resArr)
|
||||
return false;
|
||||
|
@ -1351,8 +1351,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* 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 $userOrGroupID id of user or group
|
||||
|
@ -1368,6 +1370,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
|
||||
$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
|
||||
(".$this->_id.", ".T_DOCUMENT.", " . (int) $userOrGroupID . ", " .(int) $mode. ")";
|
||||
if (!$db->getResult($queryStr))
|
||||
|
@ -2954,7 +2963,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
|||
* This function is deprecated. Use
|
||||
* {@see SeedDMS_Core_Document::getReadAccessList()} instead.
|
||||
*/
|
||||
function getApproversList() { /* {{{ */
|
||||
protected function __getApproversList() { /* {{{ */
|
||||
return $this->getReadAccessList(0, 0, 0);
|
||||
} /* }}} */
|
||||
|
||||
|
@ -7113,9 +7122,18 @@ class SeedDMS_Core_DocumentLink { /* {{{ */
|
|||
$this->_document = $document;
|
||||
$this->_target = $target;
|
||||
$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
|
||||
*/
|
||||
|
@ -7288,9 +7306,18 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
|
|||
$this->_orgFileName = $orgFileName;
|
||||
$this->_name = $name;
|
||||
$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
|
||||
*/
|
||||
|
@ -7339,7 +7366,7 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
|
|||
* to the current timestamp
|
||||
* @return boolean true on success
|
||||
*/
|
||||
function setDate($date) { /* {{{ */
|
||||
function setDate($date=null) { /* {{{ */
|
||||
$db = $this->_document->getDMS()->getDB();
|
||||
|
||||
if(!$date)
|
||||
|
@ -7454,7 +7481,7 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
|
|||
if (!$db->getResult($queryStr))
|
||||
return false;
|
||||
|
||||
$this->_public = $newPublic ? 1 : 0;
|
||||
$this->_public = $newPublic ? true : false;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
|
|
|
@ -126,27 +126,27 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
$this->_inheritAccess = $inheritAccess;
|
||||
$this->_defaultAccess = $defaultAccess;
|
||||
$this->_sequence = $sequence;
|
||||
$this->_notifyList = array();
|
||||
/* Cache */
|
||||
$this->clearCache();
|
||||
$this->_notifyList = array();
|
||||
/* Cache */
|
||||
$this->clearCache();
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Clear cache of this instance.
|
||||
*
|
||||
* The result of some expensive database actions (e.g. get all subfolders
|
||||
* or documents) will be saved in a class variable to speed up consecutive
|
||||
* calls of the same method. If a second call of the same method shall not
|
||||
* use the cache, then it must be cleared.
|
||||
*
|
||||
* Clear cache of this instance.
|
||||
*
|
||||
* The result of some expensive database actions (e.g. get all subfolders
|
||||
* or documents) will be saved in a class variable to speed up consecutive
|
||||
* calls of the same method. If a second call of the same method shall not
|
||||
* use the cache, then it must be cleared.
|
||||
*
|
||||
*/
|
||||
public function clearCache() { /* {{{ */
|
||||
$this->_parent = null;
|
||||
$this->_owner = null;
|
||||
$this->_subFolders = null;
|
||||
$this->_documents = null;
|
||||
$this->_accessList = null;
|
||||
$this->_notifyList = null;
|
||||
$this->_parent = null;
|
||||
$this->_owner = null;
|
||||
$this->_subFolders = null;
|
||||
$this->_documents = null;
|
||||
$this->_accessList = null;
|
||||
$this->_notifyList = null;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
@ -384,16 +384,16 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
/**
|
||||
* Check if the folder is subfolder
|
||||
*
|
||||
* This method checks if the current folder is in the path of the
|
||||
* passed subfolder. In that case the current folder is a parent,
|
||||
* grant parent, grant grant parent, etc. of the subfolder or
|
||||
* to say it differently the passed folder is somewhere below the
|
||||
* current folder.
|
||||
* This method checks if the current folder is in the path of the
|
||||
* passed subfolder. In that case the current folder is a parent,
|
||||
* grant parent, grant grant parent, etc. of the subfolder or
|
||||
* to say it differently the passed folder is somewhere below the
|
||||
* current folder.
|
||||
*
|
||||
* This is basically the opposite of {@see SeedDMS_Core_Folder::isDescendant()}
|
||||
*
|
||||
* @param SeedDMS_Core_Folder $subfolder folder to be checked if it is
|
||||
* a subfolder on any level of the current folder
|
||||
* This is basically the opposite of {@see SeedDMS_Core_Folder::isDescendant()}
|
||||
*
|
||||
* @param SeedDMS_Core_Folder $subfolder folder to be checked if it is
|
||||
* a subfolder on any level of the current folder
|
||||
* @return bool true if passed folder is a subfolder, otherwise false
|
||||
*/
|
||||
function isSubFolder($subfolder) { /* {{{ */
|
||||
|
@ -797,22 +797,22 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
|
||||
/**
|
||||
* Check, if this folder is a subfolder of a given folder
|
||||
*
|
||||
* This is basically the opposite of {@see SeedDMS_Core_Folder::isSubFolder()}
|
||||
*
|
||||
*
|
||||
* This is basically the opposite of {@see SeedDMS_Core_Folder::isSubFolder()}
|
||||
*
|
||||
* @param object $folder parent folder
|
||||
* @return boolean true if folder is a subfolder
|
||||
*/
|
||||
function isDescendant($folder) { /* {{{ */
|
||||
/* If the current folder has no parent it cannot be a descendant */
|
||||
function isDescendant($folder) { /* {{{ */
|
||||
/* If the current folder has no parent it cannot be a descendant */
|
||||
if(!$this->getParent())
|
||||
return false;
|
||||
/* Check if the passed folder is the parent of the current folder.
|
||||
* In that case the current folder is a subfolder of the passed folder.
|
||||
*/
|
||||
return false;
|
||||
/* Check if the passed folder is the parent of the current folder.
|
||||
* In that case the current folder is a subfolder of the passed folder.
|
||||
*/
|
||||
if($this->getParent()->getID() == $folder->getID())
|
||||
return true;
|
||||
/* Recursively go up to the root folder */
|
||||
return true;
|
||||
/* Recursively go up to the root folder */
|
||||
return $this->getParent()->isDescendant($folder);
|
||||
} /* }}} */
|
||||
|
||||
|
@ -824,13 +824,13 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
* @return int number of documents or false in case of an error
|
||||
*/
|
||||
function hasDocuments() { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
/* Do not use the cache because it may not contain all documents if
|
||||
* the former call getDocuments() limited the number of documents
|
||||
$db = $this->_dms->getDB();
|
||||
/* Do not use the cache because it may not contain all documents if
|
||||
* the former call getDocuments() limited the number of documents
|
||||
if (isset($this->_documents)) {
|
||||
return count($this->_documents);
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id;
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && !$resArr)
|
||||
|
@ -1319,14 +1319,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
$pacl = array("groups" => array(), "users" => array());
|
||||
}
|
||||
|
||||
if (!isset($this->_accessList[$mode])) {
|
||||
if (!isset($this->_accessList[$mode])) {
|
||||
if ($op!=O_GTEQ && $op!=O_LTEQ && $op!=O_EQ) {
|
||||
return false;
|
||||
}
|
||||
$modeStr = "";
|
||||
if ($mode!=M_ANY) {
|
||||
$modeStr = " AND mode".$op.(int)$mode;
|
||||
}
|
||||
$modeStr = " AND `mode`".$op.(int)$mode;
|
||||
}
|
||||
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_FOLDER.
|
||||
" AND `target` = " . $this->_id . $modeStr . " ORDER BY `targetType`";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
|
@ -1340,7 +1340,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
else //if ($row["groupID"] != -1)
|
||||
array_push($this->_accessList[$mode]["groups"], new SeedDMS_Core_GroupAccess($this->_dms->getGroup($row["groupID"]), (int) $row["mode"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_accessList[$mode];
|
||||
return SeedDMS_Core_DMS::mergeAccessLists($pacl, $this->_accessList[$mode]);
|
||||
|
@ -1381,11 +1381,18 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if($mode < M_NONE || $mode > M_ALL)
|
||||
return false;
|
||||
if($mode < M_NONE || $mode > M_ALL)
|
||||
return false;
|
||||
|
||||
$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
|
||||
(".$this->_id.", ".T_FOLDER.", " . (int) $userOrGroupID . ", " .(int) $mode. ")";
|
||||
if (!$db->getResult($queryStr))
|
||||
|
@ -1458,18 +1465,18 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
|
||||
/**
|
||||
* Get the access mode of a user on the folder
|
||||
*
|
||||
* The access mode is either M_READ, M_READWRITE, M_ALL, or M_NONE.
|
||||
* It is determined
|
||||
* - by the user (admins and owners have always access mode M_ALL)
|
||||
* - by the access list for the user (possibly inherited)
|
||||
* - by the default access mode
|
||||
*
|
||||
*
|
||||
* The access mode is either M_READ, M_READWRITE, M_ALL, or M_NONE.
|
||||
* It is determined
|
||||
* - by the user (admins and owners have always access mode M_ALL)
|
||||
* - by the access list for the user (possibly inherited)
|
||||
* - by the default access mode
|
||||
*
|
||||
* This function returns the access mode for a given user. An administrator
|
||||
* and the owner of the folder has unrestricted access. A guest user has
|
||||
* read only access or no access if access rights are further limited
|
||||
* by access control lists all the default access.
|
||||
* All other users have access rights according
|
||||
* by access control lists all the default access.
|
||||
* All other users have access rights according
|
||||
* to the access control lists or the default access. This function will
|
||||
* recursively check for access rights of parent folders if access rights
|
||||
* are inherited.
|
||||
|
@ -1480,8 +1487,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
|
|||
* will be passed as a third parameter to the callback. It contains
|
||||
* the operation for which the access mode is retrieved. It is for example
|
||||
* set to 'removeDocument' if the access mode is used to check for sufficient
|
||||
* permission on deleting a document. This callback could be used to
|
||||
* override any existing access mode in a certain context.
|
||||
* permission on deleting a document. This callback could be used to
|
||||
* override any existing access mode in a certain context.
|
||||
*
|
||||
* @param SeedDMS_Core_User $user user for which access shall be checked
|
||||
* @param string $context context in which the access mode is requested
|
||||
|
|
Loading…
Reference in New Issue
Block a user