diff --git a/CHANGELOG b/CHANGELOG
index 052f21366..522563cc0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -216,6 +216,8 @@
- more settings to disable import and download of extensions
- add new configuration for excluding sequence and comment when creating
a folder
+- get zendframework from pkgist
+- auto generate path if not set in settings.xml
--------------------------------------------------------------------------------
Changes in version 5.1.23
diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php
index 48ad52122..b9c5e8f18 100644
--- a/SeedDMS_Core/Core/inc.ClassDMS.php
+++ b/SeedDMS_Core/Core/inc.ClassDMS.php
@@ -1241,7 +1241,7 @@ class SeedDMS_Core_DMS {
$selectStr .= ", `tblDocumentReviewLog`.`date` as `duedate` ";
$queryStr .=
- "LEFT JOIN `tblDocumentReviewers` on `ttcontentid`.`document`=`tblDocumentReviewers`.`documentID` AND `ttcontentid`.`maxVersion`=`tblDocumentReviewers`.`version` ".
+ "LEFT JOIN `tblDocumentReviewers` ON `ttcontentid`.`document`=`tblDocumentReviewers`.`documentID` AND `ttcontentid`.`maxVersion`=`tblDocumentReviewers`.`version` ".
"LEFT JOIN `ttreviewid` ON `ttreviewid`.`reviewID` = `tblDocumentReviewers`.`reviewID` ".
"LEFT JOIN `tblDocumentReviewLog` ON `tblDocumentReviewLog`.`reviewLogID`=`ttreviewid`.`maxLogID` ";
@@ -1323,7 +1323,7 @@ class SeedDMS_Core_DMS {
$selectStr .= ", `tblDocumentApproveLog`.`date` as `duedate` ";
$queryStr .=
- "LEFT JOIN `tblDocumentApprovers` on `ttcontentid`.`document`=`tblDocumentApprovers`.`documentID` AND `ttcontentid`.`maxVersion`=`tblDocumentApprovers`.`version` ".
+ "LEFT JOIN `tblDocumentApprovers` ON `ttcontentid`.`document`=`tblDocumentApprovers`.`documentID` AND `ttcontentid`.`maxVersion`=`tblDocumentApprovers`.`version` ".
"LEFT JOIN `ttapproveid` ON `ttapproveid`.`approveID` = `tblDocumentApprovers`.`approveID` ".
"LEFT JOIN `tblDocumentApproveLog` ON `tblDocumentApproveLog`.`approveLogID`=`ttapproveid`.`maxLogID` ";
@@ -1620,10 +1620,10 @@ class SeedDMS_Core_DMS {
}
$selectStr = 'distinct '.$selectStr;
$queryStr .=
- "LEFT JOIN `tblWorkflowDocumentContent` on `ttcontentid`.`document`=`tblWorkflowDocumentContent`.`document` AND `ttcontentid`.`maxVersion`=`tblWorkflowDocumentContent`.`version` ".
- "LEFT JOIN `tblWorkflowTransitions` on `tblWorkflowDocumentContent`.`workflow`=`tblWorkflowTransitions`.`workflow` AND `tblWorkflowDocumentContent`.`state`=`tblWorkflowTransitions`.`state` ".
- "LEFT JOIN `tblWorkflowTransitionUsers` on `tblWorkflowTransitionUsers`.`transition` = `tblWorkflowTransitions`.`id` ".
- "LEFT JOIN `tblWorkflowTransitionGroups` on `tblWorkflowTransitionGroups`.`transition` = `tblWorkflowTransitions`.`id` ";
+ "LEFT JOIN `tblWorkflowDocumentContent` ON `ttcontentid`.`document`=`tblWorkflowDocumentContent`.`document` AND `ttcontentid`.`maxVersion`=`tblWorkflowDocumentContent`.`version` ".
+ "LEFT JOIN `tblWorkflowTransitions` ON `tblWorkflowDocumentContent`.`workflow`=`tblWorkflowTransitions`.`workflow` AND `tblWorkflowDocumentContent`.`state`=`tblWorkflowTransitions`.`state` ".
+ "LEFT JOIN `tblWorkflowTransitionUsers` ON `tblWorkflowTransitionUsers`.`transition` = `tblWorkflowTransitions`.`id` ".
+ "LEFT JOIN `tblWorkflowTransitionGroups` ON `tblWorkflowTransitionGroups`.`transition` = `tblWorkflowTransitions`.`id` ";
if($user) {
$queryStr .= "WHERE (`tblWorkflowTransitionUsers`.`userid` = ".$user->getID()." ";
@@ -3151,8 +3151,10 @@ class SeedDMS_Core_DMS {
$queryStr = "SELECT * FROM `tblCategory` WHERE `id` = " . (int) $id;
$resArr = $this->db->getResultArray($queryStr);
- if ((is_bool($resArr) && !$resArr) || (count($resArr) != 1))
+ if (is_bool($resArr) && !$resArr)
return false;
+ if (count($resArr) != 1)
+ return null;
$resArr = $resArr[0];
$cat = new SeedDMS_Core_DocumentCategory($resArr["id"], $resArr["name"]);
@@ -3189,7 +3191,7 @@ class SeedDMS_Core_DMS {
$name = trim($name);
if (!$name) return false;
- $queryStr = "SELECT * FROM `tblCategory` where `name`=".$this->db->qstr($name);
+ $queryStr = "SELECT * FROM `tblCategory` WHERE `name`=".$this->db->qstr($name);
$resArr = $this->db->getResultArray($queryStr);
if (!$resArr)
return false;
@@ -3279,7 +3281,7 @@ class SeedDMS_Core_DMS {
*/
function checkPasswordRequest($hash) { /* {{{ */
/* Get the password request from the database */
- $queryStr = "SELECT * FROM `tblUserPasswordRequest` where `hash`=".$this->db->qstr($hash);
+ $queryStr = "SELECT * FROM `tblUserPasswordRequest` WHERE `hash`=".$this->db->qstr($hash);
$resArr = $this->db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
@@ -3316,14 +3318,16 @@ class SeedDMS_Core_DMS {
* @return bool|SeedDMS_Core_AttributeDefinition or false
*/
function getAttributeDefinition($id) { /* {{{ */
- if (!is_numeric($id))
+ if (!is_numeric($id) || $id < 1)
return false;
$queryStr = "SELECT * FROM `tblAttributeDefinitions` WHERE `id` = " . (int) $id;
$resArr = $this->db->getResultArray($queryStr);
- if (is_bool($resArr) && $resArr == false) return false;
- if (count($resArr) != 1) return false;
+ if (is_bool($resArr) && $resArr == false)
+ return false;
+ if (count($resArr) != 1)
+ return null;
$resArr = $resArr[0];
@@ -3347,8 +3351,10 @@ class SeedDMS_Core_DMS {
$queryStr = "SELECT * FROM `tblAttributeDefinitions` WHERE `name` = " . $this->db->qstr($name);
$resArr = $this->db->getResultArray($queryStr);
- if (is_bool($resArr) && $resArr == false) return false;
- if (count($resArr) != 1) return false;
+ if (is_bool($resArr) && $resArr == false)
+ return false;
+ if (count($resArr) != 1)
+ return null;
$resArr = $resArr[0];
@@ -3469,7 +3475,7 @@ class SeedDMS_Core_DMS {
* @return SeedDMS_Core_Workflow|bool of instances of {@link SeedDMS_Core_Workflow}, null if no workflow was found or false
*/
function getWorkflow($id) { /* {{{ */
- if (!is_numeric($id))
+ if (!is_numeric($id) || $id < 1)
return false;
$queryStr = "SELECT * FROM `tblWorkflows` WHERE `id`=".intval($id);
@@ -3548,7 +3554,7 @@ class SeedDMS_Core_DMS {
* @return bool|SeedDMS_Core_Workflow_State or false
*/
function getWorkflowState($id) { /* {{{ */
- if (!is_numeric($id))
+ if (!is_numeric($id) || $id < 1)
return false;
$queryStr = "SELECT * FROM `tblWorkflowStates` WHERE `id` = " . (int) $id;
@@ -3648,7 +3654,7 @@ class SeedDMS_Core_DMS {
* @return SeedDMS_Core_Workflow_Action|bool instance of {@link SeedDMS_Core_Workflow_Action} or false
*/
function getWorkflowAction($id) { /* {{{ */
- if (!is_numeric($id))
+ if (!is_numeric($id) || $id < 1)
return false;
$queryStr = "SELECT * FROM `tblWorkflowActions` WHERE `id` = " . (int) $id;
@@ -3942,7 +3948,7 @@ class SeedDMS_Core_DMS {
* @return array|bool
*/
function getDuplicateDocumentContent() { /* {{{ */
- $queryStr = "SELECT a.*, b.`id` as dupid FROM `tblDocumentContent` a LEFT JOIN `tblDocumentContent` b ON a.`checksum`=b.`checksum` where a.`id`!=b.`id` ORDER by a.`id` LIMIT 1000";
+ $queryStr = "SELECT a.*, b.`id` as dupid FROM `tblDocumentContent` a LEFT JOIN `tblDocumentContent` b ON a.`checksum`=b.`checksum` WHERE a.`id`!=b.`id` ORDER by a.`id` LIMIT 1000";
$resArr = $this->db->getResultArray($queryStr);
if ($resArr === false)
return false;
diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php
index 0953db9a1..f136b2adf 100644
--- a/SeedDMS_Core/Core/inc.ClassDocument.php
+++ b/SeedDMS_Core/Core/inc.ClassDocument.php
@@ -247,6 +247,27 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$this->_notifyList = array();
$this->_latestContent = null;
$this->_content = null;
+ /* 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.
+ *
+ */
+ public function clearCache() { /* {{{ */
+ $this->_parent = null;
+ $this->_owner = null;
+ $this->_documentLinks = null;
+ $this->_documentFiles = null;
+ $this->_content = null;
+ $this->_accessList = null;
+ $this->_notifyList = null;
} /* }}} */
/**
@@ -330,30 +351,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return null;
$resArr = $resArr[0];
- // New Locking mechanism uses a separate table to track the lock.
- /*
- $queryStr = "SELECT * FROM `tblDocumentLocks` WHERE `document` = " . (int) $id;
- $lockArr = $db->getResultArray($queryStr);
- if ((is_bool($lockArr) && $lockArr==false) || (count($lockArr)==0)) {
- // Could not find a lock on the selected document.
- $resArr['lock'] = -1;
- }
- else {
- // A lock has been identified for this document.
- $resArr['lock'] = $lockArr[0]["userID"];
- }
-*/
$resArr['lock'] = !$resArr['lock'] ? -1 : $resArr['lock'];
-// print_r($resArr);exit;
return self::getInstanceByData($resArr, $dms);
-
- $classname = $dms->getClassname('document');
- /** @var SeedDMS_Core_Document $document */
- $document = new $classname($resArr["id"], $resArr["name"], $resArr["comment"], $resArr["date"], $resArr["expires"], $resArr["owner"], $resArr["folder"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr['lock'], $resArr["keywords"], $resArr["sequence"]);
- $document->setDMS($dms);
- $document = $document->applyDecorators();
- return $document;
} /* }}} */
/**
@@ -1331,6 +1331,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
$db = $this->_dms->getDB();
+ if($mode < M_NONE || $mode > M_ALL)
+ return false;
+
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
$queryStr = "INSERT INTO `tblACLs` (`target`, `targetType`, ".$userOrGroup.", `mode`) VALUES
@@ -2112,8 +2115,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* currently logged in user.
*
* @param integer $version version number of content element
- * @return SeedDMS_Core_DocumentContent|boolean object of class {@link SeedDMS_Core_DocumentContent}
- * or false
+ * @return SeedDMS_Core_DocumentContent|null|boolean object of class
+ * {@link SeedDMS_Core_DocumentContent}, null if not content was found,
+ * false in case of an error
*/
function getContentByVersion($version) { /* {{{ */
if (!is_numeric($version)) return false;
@@ -2123,7 +2127,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if ($revision->getVersion() == $version)
return $revision;
}
- return false;
+ return null;
}
$db = $this->_dms->getDB();
@@ -2132,7 +2136,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($resArr) && !$resArr)
return false;
if (count($resArr) != 1)
- return false;
+ return null;
$resArr = $resArr[0];
$classname = $this->_dms->getClassname('documentcontent');
@@ -2141,7 +2145,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$user = $this->_dms->getLoggedInUser();
/* A user with write access on the document may always see the version */
if($user && $content->getAccessMode($user) == M_NONE)
- return false;
+ return null;
else
return $content;
} else {
@@ -2475,8 +2479,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$queryStr = "SELECT * FROM `tblDocumentLinks` WHERE `document` = " . $this->_id ." AND `id` = " . (int) $linkID;
$resArr = $db->getResultArray($queryStr);
- if ((is_bool($resArr) && !$resArr) || count($resArr)==0)
+ if (is_bool($resArr) && !$resArr)
return false;
+ if (count($resArr)==0)
+ return null;
$resArr = $resArr[0];
$document = $this->_dms->getDocument($resArr["document"]);
@@ -2494,12 +2500,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)) {
@@ -2540,39 +2556,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;
} /* }}} */
@@ -2580,20 +2598,39 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
function addDocumentLink($targetID, $userID, $public) { /* {{{ */
$db = $this->_dms->getDB();
- $public = ($public) ? "1" : "0";
+ $public = ($public) ? 1 : 0;
- $queryStr = "INSERT INTO `tblDocumentLinks` (`document`, `target`, `userID`, `public`) VALUES (".$this->_id.", ".(int)$targetID.", ".(int)$userID.", ".(int)$public.")";
+ if (!is_numeric($targetID) || $targetID < 1)
+ return false;
+
+ if ($targetID == $this->_id)
+ return false;
+
+ if (!is_numeric($userID) || $userID < 1)
+ return false;
+
+ if(!($target = $this->_dms->getDocument($targetID)))
+ return false;
+
+ if(!($user = $this->_dms->getUser($userID)))
+ return false;
+
+ $queryStr = "INSERT INTO `tblDocumentLinks` (`document`, `target`, `userID`, `public`) VALUES (".$this->_id.", ".(int)$targetID.", ".(int)$userID.", ".$public.")";
if (!$db->getResult($queryStr))
return false;
unset($this->_documentLinks);
- return true;
+
+ $id = $db->getInsertID('tblDocumentLinks');
+ $link = new SeedDMS_Core_DocumentLink($id, $this, $target, $user->getId(), $public);
+ return $link;
} /* }}} */
function removeDocumentLink($linkID) { /* {{{ */
$db = $this->_dms->getDB();
- if (!is_numeric($linkID)) return false;
+ if (!is_numeric($linkID) || $linkID < 1)
+ return false;
$queryStr = "DELETE FROM `tblDocumentLinks` WHERE `document` = " . $this->_id ." AND `id` = " . (int) $linkID;
if (!$db->getResult($queryStr)) return false;
@@ -2627,8 +2664,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/**
* Get list of files attached to document
*
- * @param integer $version get only attachments for this version
- *@param boolean $incnoversion include attachments without a version
+ * @param integer $version get only attachments for this version
+ * @param boolean $incnoversion include attachments without a version
+ *
* @return array list of files, false in case of an sql error
*/
function getDocumentFiles($version=0, $incnoversion=true) { /* {{{ */
@@ -2666,7 +2704,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return $this->_documentFiles[$hash];
} /* }}} */
- function addDocumentFile($name, $comment, $user, $tmpFile, $orgFileName,$fileType, $mimeType,$version=0,$public=1) { /* {{{ */
+ function addDocumentFile($name, $comment, $user, $tmpFile, $orgFileName, $fileType, $mimeType, $version=0, $public=1) { /* {{{ */
$db = $this->_dms->getDB();
$dir = $this->getDir();
@@ -2699,29 +2737,37 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
}
$db->commitTransaction();
+ unset ($this->_documentFiles);
return $file;
} /* }}} */
function removeDocumentFile($ID) { /* {{{ */
$db = $this->_dms->getDB();
- if (!is_numeric($ID)) return false;
+ if (!is_numeric($ID) || $ID < 1)
+ return false;
$file = $this->getDocumentFile($ID);
if (is_bool($file) && !$file) return false;
- if (file_exists( $this->_dms->contentDir . $file->getPath() )){
- if (!SeedDMS_Core_File::removeFile( $this->_dms->contentDir . $file->getPath() ))
- return false;
+ $db->startTransaction();
+ /* First delete the database record, because that can be undone
+ * if deletion of the file fails.
+ */
+ $queryStr = "DELETE FROM `tblDocumentFiles` WHERE `document` = " . $this->getID() . " AND `id` = " . (int) $ID;
+ if (!$db->getResult($queryStr)) {
+ $db->rollbackTransaction();
+ return false;
}
- $name=$file->getName();
- $comment=$file->getcomment();
-
- $queryStr = "DELETE FROM `tblDocumentFiles` WHERE `document` = " . $this->getID() . " AND `id` = " . (int) $ID;
- if (!$db->getResult($queryStr))
- return false;
+ if (file_exists( $this->_dms->contentDir . $file->getPath() )){
+ if (!SeedDMS_Core_File::removeFile( $this->_dms->contentDir . $file->getPath() )) {
+ $db->rollbackTransaction();
+ return false;
+ }
+ }
+ $db->commitTransaction();
unset ($this->_documentFiles);
return true;
@@ -2840,7 +2886,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/* Check if 'onPostRemoveDocument' callback is set */
if(isset($this->_dms->callbacks['onPostRemoveDocument'])) {
foreach($this->_dms->callbacks['onPostRemoveDocument'] as $callback) {
- if(!call_user_func($callback[0], $callback[1], $this->_id)) {
+ if(!call_user_func($callback[0], $callback[1], $this)) {
}
}
}
diff --git a/SeedDMS_Core/Core/inc.ClassDocumentCategory.php b/SeedDMS_Core/Core/inc.ClassDocumentCategory.php
index 6d5451664..f7aa2fb64 100644
--- a/SeedDMS_Core/Core/inc.ClassDocumentCategory.php
+++ b/SeedDMS_Core/Core/inc.ClassDocumentCategory.php
@@ -53,7 +53,11 @@ class SeedDMS_Core_DocumentCategory {
function getName() { return $this->_name; }
- function setName($newName) { /* {{{ */
+ function setName($newName) { /* {{{ */
+ $newName = trim($newName);
+ if(!$name)
+ return false;
+
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblCategory` SET `name` = ".$db->qstr($newName)." WHERE `id` = ". $this->_id;
diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php
index a99c746e0..5156826c8 100644
--- a/SeedDMS_Core/Core/inc.ClassFolder.php
+++ b/SeedDMS_Core/Core/inc.ClassFolder.php
@@ -146,6 +146,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
$this->_subFolders = null;
$this->_documents = null;
$this->_accessList = null;
+ $this->_notifyList = null;
} /* }}} */
/**
@@ -389,6 +390,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
* 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
* @return bool true if passed folder is a subfolder, otherwise false
@@ -794,15 +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()}
+ *
* @param object $folder parent folder
* @return boolean true if folder is a subfolder
*/
- function isDescendant($folder) { /* {{{ */
+ function isDescendant($folder) { /* {{{ */
+ /* If the current folder has no parent it cannot be a descendant */
if(!$this->getParent())
- return false;
+ 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;
+ return true;
+ /* Recursively go up to the root folder */
return $this->getParent()->isDescendant($folder);
} /* }}} */
@@ -814,11 +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();
+ $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)) {
- /** @noinspection PhpUndefinedFieldInspection */
return count($this->_documents);
- }
+ }
+ */
$queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
@@ -1307,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;
- }
+ }
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_FOLDER.
" AND `target` = " . $this->_id . $modeStr . " ORDER BY `targetType`";
$resArr = $db->getResultArray($queryStr);
@@ -1328,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]);
@@ -1369,6 +1381,9 @@ 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;
+
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
$queryStr = "INSERT INTO `tblACLs` (`target`, `targetType`, ".$userOrGroup.", `mode`) VALUES
@@ -1443,32 +1458,32 @@ 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
+ *
* 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 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
- * recursive check for access rights of parent folders if access rights
+ * recursively check for access rights of parent folders if access rights
* are inherited.
*
- * 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 other users have access rights according
- * to the access control lists or the default access. This function will
- * recursive check for access rights of parent folders if access rights
- * are inherited.
- *
- * Before checking the access in the method itself a callback 'onCheckAccessFolder'
+ * Before checking the access itself a callback 'onCheckAccessFolder'
* is called. If it returns a value > 0, then this will be returned by this
* method without any further checks. The optional paramater $context
* 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.
+ * permission on deleting a document. This callback could be used to
+ * override any existing access mode in a certain context.
*
- * @param object $user user for which access shall be checked
+ * @param SeedDMS_Core_User $user user for which access shall be checked
* @param string $context context in which the access mode is requested
* @return integer access mode
*/
diff --git a/SeedDMS_Core/Core/inc.ClassGroup.php b/SeedDMS_Core/Core/inc.ClassGroup.php
index b171e6cc2..3a6eb4a68 100644
--- a/SeedDMS_Core/Core/inc.ClassGroup.php
+++ b/SeedDMS_Core/Core/inc.ClassGroup.php
@@ -162,6 +162,10 @@ class SeedDMS_Core_Group { /* {{{ */
* @return bool
*/
function setName($newName) { /* {{{ */
+ $newName = trim($newName);
+ if(!$newName)
+ return false;
+
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblGroups` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
diff --git a/SeedDMS_Core/Core/inc.ClassKeywords.php b/SeedDMS_Core/Core/inc.ClassKeywords.php
index 0981023d3..aa11c9dc3 100644
--- a/SeedDMS_Core/Core/inc.ClassKeywords.php
+++ b/SeedDMS_Core/Core/inc.ClassKeywords.php
@@ -91,6 +91,10 @@ class SeedDMS_Core_KeywordCategory {
* @return bool
*/
function setName($newName) {
+ $newName = trim($newName);
+ if(!$newName)
+ return false;
+
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblKeywordCategories` SET `name` = ".$db->qstr($newName)." WHERE `id` = ". $this->_id;
@@ -105,10 +109,13 @@ class SeedDMS_Core_KeywordCategory {
* @param SeedDMS_Core_User $user
* @return bool
*/
- function setOwner($user) {
+ function setOwner($user) {
+ if(!$user || !$user->isType('user'))
+ return false;
+
$db = $this->_dms->getDB();
- $queryStr = "UPDATE `tblKeywordCategories` SET `owner` = " . $user->getID() . " WHERE = `id` = " . $this->_id;
+ $queryStr = "UPDATE `tblKeywordCategories` SET `owner` = " . $user->getID() . " WHERE `id` = " . $this->_id;
if (!$db->getResult($queryStr))
return false;
diff --git a/SeedDMS_Core/Core/inc.ClassUser.php b/SeedDMS_Core/Core/inc.ClassUser.php
index c70e3779c..e89025f29 100644
--- a/SeedDMS_Core/Core/inc.ClassUser.php
+++ b/SeedDMS_Core/Core/inc.ClassUser.php
@@ -655,7 +655,7 @@ class SeedDMS_Core_User { /* {{{ */
function setEmail($newEmail) { /* {{{ */
$db = $this->_dms->getDB();
- $queryStr = "UPDATE `tblUsers` SET `email` =".$db->qstr($newEmail)." WHERE `id` = " . $this->_id;
+ $queryStr = "UPDATE `tblUsers` SET `email` =".$db->qstr(trim($newEmail))." WHERE `id` = " . $this->_id;
$res = $db->getResult($queryStr);
if (!$res)
return false;
@@ -676,7 +676,7 @@ class SeedDMS_Core_User { /* {{{ */
function setLanguage($newLanguage) { /* {{{ */
$db = $this->_dms->getDB();
- $queryStr = "UPDATE `tblUsers` SET `language` =".$db->qstr($newLanguage)." WHERE `id` = " . $this->_id;
+ $queryStr = "UPDATE `tblUsers` SET `language` =".$db->qstr(trim($newLanguage))." WHERE `id` = " . $this->_id;
$res = $db->getResult($queryStr);
if (!$res)
return false;
@@ -697,7 +697,7 @@ class SeedDMS_Core_User { /* {{{ */
function setTheme($newTheme) { /* {{{ */
$db = $this->_dms->getDB();
- $queryStr = "UPDATE `tblUsers` SET `theme` =".$db->qstr($newTheme)." WHERE `id` = " . $this->_id;
+ $queryStr = "UPDATE `tblUsers` SET `theme` =".$db->qstr(trim($newTheme))." WHERE `id` = " . $this->_id;
$res = $db->getResult($queryStr);
if (!$res)
return false;
@@ -718,7 +718,7 @@ class SeedDMS_Core_User { /* {{{ */
function setComment($newComment) { /* {{{ */
$db = $this->_dms->getDB();
- $queryStr = "UPDATE `tblUsers` SET `comment` =".$db->qstr($newComment)." WHERE `id` = " . $this->_id;
+ $queryStr = "UPDATE `tblUsers` SET `comment` =".$db->qstr(trim($newComment))." WHERE `id` = " . $this->_id;
$res = $db->getResult($queryStr);
if (!$res)
return false;
diff --git a/SeedDMS_Core/Core/inc.DBAccessPDO.php b/SeedDMS_Core/Core/inc.DBAccessPDO.php
index 17c453afc..ba033b392 100644
--- a/SeedDMS_Core/Core/inc.DBAccessPDO.php
+++ b/SeedDMS_Core/Core/inc.DBAccessPDO.php
@@ -257,6 +257,15 @@ class SeedDMS_Core_DatabaseAccess {
return $this->_driver;
} /* }}} */
+ /**
+ * Turn on views instead of temp. tables
+ *
+ * @param bool $onoff turn use of views instead of temp. table on/off
+ */
+ function useViews($onoff) { /* {{{ */
+ $this->_useviews = $onoff;
+ } /* }}} */
+
/**
* Destructor of SeedDMS_Core_DatabaseAccess
*/
@@ -1105,7 +1114,9 @@ class SeedDMS_Core_DatabaseAccess {
*/
function createDump($fp) { /* {{{ */
$tables = $this->TableList('TABLES');
- foreach($tables as $table) {
+ foreach($tables as $table) {
+ if($table == 'sqlite_sequence')
+ continue;
$query = "SELECT * FROM `".$table."`";
$records = $this->getResultArray($query);
fwrite($fp,"\n-- TABLE: ".$table."--\n\n");
diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml
index 9e1ad2727..b79aaeea1 100644
--- a/SeedDMS_Core/package.xml
+++ b/SeedDMS_Core/package.xml
@@ -44,9 +44,6 @@
-
-
-
@@ -88,8 +85,17 @@