From db678e08da0c66a7c06b8d1d8a3f2ab57c914487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Tue, 24 Oct 2017 11:10:41 +0200 Subject: [PATCH 01/81] =?UTF-8?q?Einf=C3=BCgen=20DocBlock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SeedDMS_Core/Core/inc.ClassAccess.php | 50 +++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassAccess.php b/SeedDMS_Core/Core/inc.ClassAccess.php index 560358451..3d355e21e 100644 --- a/SeedDMS_Core/Core/inc.ClassAccess.php +++ b/SeedDMS_Core/Core/inc.ClassAccess.php @@ -24,22 +24,47 @@ * @version Release: @package_version@ */ class SeedDMS_Core_UserAccess { /* {{{ */ + + /** + * @var SeedDMS_Core_User + */ var $_user; + + /** + * @var + */ var $_mode; + /** + * SeedDMS_Core_UserAccess constructor. + * @param $user + * @param $mode + */ function __construct($user, $mode) { $this->_user = $user; $this->_mode = $mode; } + /** + * @return int + */ function getUserID() { return $this->_user->getID(); } + /** + * @return mixed + */ function getMode() { return $this->_mode; } + /** + * @return bool + */ function isAdmin() { return ($this->_mode == SeedDMS_Core_User::role_admin); } + /** + * @return SeedDMS_Core_User + */ function getUser() { return $this->_user; } @@ -57,20 +82,41 @@ class SeedDMS_Core_UserAccess { /* {{{ */ * @version Release: @package_version@ */ class SeedDMS_Core_GroupAccess { /* {{{ */ + + /** + * @var SeedDMS_Core_Group + */ var $_group; + + /** + * @var + */ var $_mode; + /** + * SeedDMS_Core_GroupAccess constructor. + * @param $group + * @param $mode + */ function __construct($group, $mode) { $this->_group = $group; $this->_mode = $mode; } + /** + * @return int + */ function getGroupID() { return $this->_group->getID(); } + /** + * @return mixed + */ function getMode() { return $this->_mode; } + /** + * @return SeedDMS_Core_Group + */ function getGroup() { return $this->_group; } -} /* }}} */ -?> +} /* }}} */ \ No newline at end of file From b34b936b2479c535d18edda182fa67df0d30496c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Tue, 24 Oct 2017 11:53:31 +0200 Subject: [PATCH 02/81] =?UTF-8?q?Einf=C3=BCgen=20DocBlock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SeedDMS_Core/Core/inc.ClassDMS.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 26a196243..626e3431e 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -74,7 +74,7 @@ require_once("inc.ClassAttribute.php"); */ class SeedDMS_Core_DMS { /** - * @var object $db reference to database object. This must be an instance + * @var SeedDMS_Core_DMS $db reference to database object. This must be an instance * of {@link SeedDMS_Core_DatabaseAccess}. * @access protected */ @@ -88,7 +88,7 @@ class SeedDMS_Core_DMS { protected $classnames; /** - * @var object $user reference to currently logged in user. This must be + * @var SeedDMS_Core_User $user reference to currently logged in user. This must be * an instance of {@link SeedDMS_Core_User}. This variable is currently not * used. It is set by {@link setUser}. * @access private @@ -214,7 +214,7 @@ class SeedDMS_Core_DMS { * The result of the function can be 0 which happens if the first element * of an indexed array matches. * - * @param object $object1 object to look for (needle) + * @param object $object object to look for (needle) * @param array $list list of objects (haystack) * @return boolean/integer index in array if object was found, otherwise false */ From 2ab5db0c6ddb99616f50cf08d14039e95b919978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Tue, 24 Oct 2017 12:12:38 +0200 Subject: [PATCH 03/81] inc.ClassObject.php --- SeedDMS_Core/Core/inc.ClassDMS.php | 6 +- SeedDMS_Core/Core/inc.ClassDocument.php | 181 +++++++++++++++++++++--- SeedDMS_Core/Core/inc.ClassObject.php | 49 ++++--- 3 files changed, 193 insertions(+), 43 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 626e3431e..71097e64d 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -294,7 +294,7 @@ class SeedDMS_Core_DMS { * given user. A link is only accessible, if it is publically visible, * owned by the user, or the accessing user is an administrator. * - * @param array $links list of objects of type SeedDMS_Core_DocumentLink + * @param SeedDMS_Core_DocumentLink[] $links list of objects of type SeedDMS_Core_DocumentLink * @param object $user user for which access is being checked * @param string $access set if source or target of link shall be checked * for sufficient access rights. Set to 'source' if the source document @@ -1691,7 +1691,7 @@ class SeedDMS_Core_DMS { * This function retrieves a user from the database by its id. * * @param integer $id internal id of user - * @return object instance of {@link SeedDMS_Core_User} or false + * @return SeedDMS_Core_User|boolean instance of {@link SeedDMS_Core_User} or false */ function getUser($id) { /* {{{ */ $classname = $this->classnames['user']; @@ -2095,7 +2095,7 @@ class SeedDMS_Core_DMS { * its id. * * @param integer $id internal id of attribute defintion - * @return object instance of {@link SeedDMS_Core_AttributeDefinition} or false + * @return bool|SeedDMS_Core_AttributeDefinition or false */ function getAttributeDefinition($id) { /* {{{ */ if (!is_numeric($id)) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 3359ab1a8..90758cf97 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -4552,7 +4552,7 @@ class SeedDMS_Core_DocumentLink { /* {{{ */ protected $_id; /** - * @var object reference to document this link belongs to + * @var SeedDMS_Core_Document reference to document this link belongs to */ protected $_document; @@ -4571,6 +4571,14 @@ class SeedDMS_Core_DocumentLink { /* {{{ */ */ protected $_public; + /** + * SeedDMS_Core_DocumentLink constructor. + * @param $id + * @param $document + * @param $target + * @param $userID + * @param $public + */ function __construct($id, $document, $target, $userID, $public) { $this->_id = $id; $this->_document = $document; @@ -4579,35 +4587,52 @@ class SeedDMS_Core_DocumentLink { /* {{{ */ $this->_public = $public; } + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return SeedDMS_Core_Document + */ function getDocument() { return $this->_document; } + /** + * @return object + */ function getTarget() { return $this->_target; } + /** + * @return bool|SeedDMS_Core_User + */ function getUser() { if (!isset($this->_user)) $this->_user = $this->_document->_dms->getUser($this->_userID); return $this->_user; } + /** + * @return int + */ function isPublic() { return $this->_public; } - /** - * Returns the access mode similar to a document - * - * There is no real access mode for document links, so this is just - * another way to add more access restrictions than the default restrictions. - * It is only called for public document links, not accessed by the owner - * or the administrator. - * - * @param object $u user - * @return integer either M_NONE or M_READ - */ + /** + * Returns the access mode similar to a document + * + * There is no real access mode for document links, so this is just + * another way to add more access restrictions than the default restrictions. + * It is only called for public document links, not accessed by the owner + * or the administrator. + * + * @param SeedDMS_Core_User $u user + * @param $source + * @param $target + * @return int either M_NONE or M_READ + */ function getAccessMode($u, $source, $target) { /* {{{ */ $dms = $this->_document->_dms; @@ -4649,7 +4674,7 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ protected $_id; /** - * @var object reference to document this file belongs to + * @var SeedDMS_Core_Document reference to document this file belongs to */ protected $_document; @@ -4706,6 +4731,21 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ */ protected $_name; + /** + * SeedDMS_Core_DocumentFile constructor. + * @param $id + * @param $document + * @param $userID + * @param $comment + * @param $date + * @param $dir + * @param $fileType + * @param $mimeType + * @param $orgFileName + * @param $name + * @param $version + * @param $public + */ function __construct($id, $document, $userID, $comment, $date, $dir, $fileType, $mimeType, $orgFileName,$name,$version,$public) { $this->_id = $id; $this->_document = $document; @@ -4721,29 +4761,80 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ $this->_public = $public; } + /** + * @return int + */ function getID() { return $this->_id; } + + /** + * @return SeedDMS_Core_Document + */ function getDocument() { return $this->_document; } + + /** + * @return int + */ function getUserID() { return $this->_userID; } + + /** + * @return string + */ function getComment() { return $this->_comment; } + + /** + * @return string + */ function getDate() { return $this->_date; } + + /** + * @return string + */ function getDir() { return $this->_dir; } + + /** + * @return string + */ function getFileType() { return $this->_fileType; } + + /** + * @return string + */ function getMimeType() { return $this->_mimeType; } + + /** + * @return string + */ function getOriginalFileName() { return $this->_orgFileName; } + + /** + * @return string + */ function getName() { return $this->_name; } + /** + * @return bool|SeedDMS_Core_User + */ function getUser() { if (!isset($this->_user)) $this->_user = $this->_document->_dms->getUser($this->_userID); return $this->_user; } + /** + * @return string + */ function getPath() { return $this->_document->getDir() . "f" .$this->_id . $this->_fileType; } + /** + * @return int + */ function getVersion() { return $this->_version; } + /** + * @return int + */ function isPublic() { return $this->_public; } /** @@ -4794,18 +4885,45 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ */ class SeedDMS_Core_AddContentResultSet { /* {{{ */ + /** + * @var null + */ protected $_indReviewers; + + /** + * @var null + */ protected $_grpReviewers; + + /** + * @var null + */ protected $_indApprovers; + + /** + * @var null + */ protected $_grpApprovers; + + /** + * @var + */ protected $_content; + + /** + * @var null + */ protected $_status; /** - * @var object back reference to document management system + * @var SeedDMS_Core_DMS back reference to document management system */ protected $_dms; + /** + * SeedDMS_Core_AddContentResultSet constructor. + * @param $content + */ function __construct($content) { /* {{{ */ $this->_content = $content; $this->_indReviewers = null; @@ -4816,7 +4934,7 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ $this->_dms = null; } /* }}} */ - /* + /** * Set dms this object belongs to. * * Each object needs a reference to the dms it belongs to. It will be @@ -4824,12 +4942,18 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ * The dms has a references to the currently logged in user * and the database connection. * - * @param object $dms reference to dms + * @param SeedDMS_Core_DMS $dms reference to dms */ function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ + /** + * @param $reviewer + * @param $type + * @param $status + * @return bool + */ function addReviewer($reviewer, $type, $status) { /* {{{ */ $dms = $this->_dms; @@ -4857,6 +4981,12 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ return true; } /* }}} */ + /** + * @param $approver + * @param $type + * @param $status + * @return bool + */ function addApprover($approver, $type, $status) { /* {{{ */ $dms = $this->_dms; @@ -4884,6 +5014,10 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ return true; } /* }}} */ + /** + * @param $status + * @return bool + */ function setStatus($status) { /* {{{ */ if (!is_integer($status)) { return false; @@ -4895,14 +5029,24 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ return true; } /* }}} */ + /** + * @return null + */ function getStatus() { /* {{{ */ return $this->_status; } /* }}} */ + /** + * @return mixed + */ function getContent() { /* {{{ */ return $this->_content; } /* }}} */ + /** + * @param $type + * @return array|bool|null + */ function getReviewers($type) { /* {{{ */ if (strcasecmp($type, "i") && strcasecmp($type, "g")) { return false; @@ -4915,6 +5059,10 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ } } /* }}} */ + /** + * @param $type + * @return array|bool|null + */ function getApprovers($type) { /* {{{ */ if (strcasecmp($type, "i") && strcasecmp($type, "g")) { return false; @@ -4927,4 +5075,3 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ } } /* }}} */ } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassObject.php b/SeedDMS_Core/Core/inc.ClassObject.php index 4a9df2a30..3fbe48cf8 100644 --- a/SeedDMS_Core/Core/inc.ClassObject.php +++ b/SeedDMS_Core/Core/inc.ClassObject.php @@ -34,7 +34,7 @@ class SeedDMS_Core_Object { /* {{{ */ protected $_attributes; /** - * @var object back reference to document management system + * @var SeedDMS_Core_DMS back reference to document management system */ public $_dms; @@ -67,8 +67,8 @@ class SeedDMS_Core_Object { /* {{{ */ /** * Returns all attributes set for the object * - * @return array list of objects of class SeedDMS_Core_Attribute - */ + * @return array|bool + */ function getAttributes() { /* {{{ */ if (!$this->_attributes) { $db = $this->_dms->getDB(); @@ -102,12 +102,13 @@ class SeedDMS_Core_Object { /* {{{ */ } /* }}} */ - /** - * Returns an attribute of the object for the given attribute definition - * - * @return array|string value of attritbute or false. The value is an array - * if the attribute is defined as multi value - */ + /** + * Returns an attribute of the object for the given attribute definition + * + * @param SeedDMS_Core_AttributeDefinition $attrdef + * @return array|string value of attritbute or false. The value is an array + * if the attribute is defined as multi value + */ function getAttribute($attrdef) { /* {{{ */ if (!$this->_attributes) { $this->getAttributes(); @@ -124,6 +125,7 @@ class SeedDMS_Core_Object { /* {{{ */ /** * Returns an attribute value of the object for the given attribute definition * + * @param SeedDMS_Core_AttributeDefinition $attrdef * @return array|string value of attritbute or false. The value is an array * if the attribute is defined as multi value */ @@ -154,16 +156,17 @@ class SeedDMS_Core_Object { /* {{{ */ } /* }}} */ - /** - * Returns an attribute value of the object for the given attribute definition - * - * This is a short cut for getAttribute($attrdef)->getValueAsArray() but - * first checks if the object has an attribute for the given attribute - * definition. - * - * @return array value of attritbute or false. The value is always an array - * even if the attribute is not defined as multi value - */ + /** + * Returns an attribute value of the object for the given attribute definition + * + * This is a short cut for getAttribute($attrdef)->getValueAsArray() but + * first checks if the object has an attribute for the given attribute + * definition. + * + * @param SeedDMS_Core_AttributeDefinition $attrdef + * @return array|bool + * even if the attribute is not defined as multi value + */ function getAttributeValueAsArray($attrdef) { /* {{{ */ if (!$this->_attributes) { $this->getAttributes(); @@ -183,6 +186,7 @@ class SeedDMS_Core_Object { /* {{{ */ * first checks if the object has an attribute for the given attribute * definition. * + * @param SeedDMS_Core_AttributeDefinition $attrdef * @return string value of attritbute or false. The value is always a string * even if the attribute is defined as multi value */ @@ -201,8 +205,8 @@ class SeedDMS_Core_Object { /* {{{ */ /** * Set an attribute of the object for the given attribute definition * - * @param object $attrdef definition of attribute - * @param array|sting $value value of attribute, for multiple values this + * @param SeedDMS_Core_AttributeDefinition $attrdef definition of attribute + * @param array|string $value value of attribute, for multiple values this * must be an array * @return boolean true if operation was successful, otherwise false */ @@ -254,7 +258,7 @@ class SeedDMS_Core_Object { /* {{{ */ /** * Remove an attribute of the object for the given attribute definition - * + * @param SeedDMS_Core_AttributeDefinition $attrdef * @return boolean true if operation was successful, otherwise false */ function removeAttribute($attrdef) { /* {{{ */ @@ -285,4 +289,3 @@ class SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ } /* }}} */ -?> From 61382afc7b4f0efafbf68e29936b77842a39ee57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Tue, 24 Oct 2017 12:44:22 +0200 Subject: [PATCH 04/81] inc.ClassAttribute.php --- SeedDMS_Core/Core/inc.AccessUtils.php | 4 +- SeedDMS_Core/Core/inc.ClassAttribute.php | 153 ++++++++++++----------- 2 files changed, 81 insertions(+), 76 deletions(-) diff --git a/SeedDMS_Core/Core/inc.AccessUtils.php b/SeedDMS_Core/Core/inc.AccessUtils.php index 823f3f7b7..ccb087db7 100644 --- a/SeedDMS_Core/Core/inc.AccessUtils.php +++ b/SeedDMS_Core/Core/inc.AccessUtils.php @@ -85,6 +85,4 @@ define("N_DELETE_VERSION", 5); /** * Notify when version of document was deleted */ -define("N_ADD_DOCUMENT", 6); - -?> +define("N_ADD_DOCUMENT", 6); \ No newline at end of file diff --git a/SeedDMS_Core/Core/inc.ClassAttribute.php b/SeedDMS_Core/Core/inc.ClassAttribute.php index 58bb5b027..ddacf055a 100644 --- a/SeedDMS_Core/Core/inc.ClassAttribute.php +++ b/SeedDMS_Core/Core/inc.ClassAttribute.php @@ -36,7 +36,7 @@ class SeedDMS_Core_Attribute { /* {{{ */ protected $_id; /** - * @var object SeedDMS_Core_Object folder, document or document content + * @var SeedDMS_Core_Folder|SeedDMS_Core_Document|SeedDMS_Core_DocumentContent SeedDMS_Core_Object folder, document or document content * this attribute belongs to * * @access protected @@ -44,7 +44,7 @@ class SeedDMS_Core_Attribute { /* {{{ */ protected $_obj; /** - * @var object SeedDMS_Core_AttributeDefinition definition of this attribute + * @var SeedDMS_Core_AttributeDefinition definition of this attribute * * @access protected */ @@ -65,20 +65,19 @@ class SeedDMS_Core_Attribute { /* {{{ */ protected $_validation_error; /** - * @var object SeedDMS_Core_DMS reference to the dms instance this attribute belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to * * @access protected */ protected $_dms; - /** - * Constructor - * - * @param integer $id internal id of attribute - * @param SeedDMS_Core_Object $obj object this attribute is attached to - * @param SeedDMS_Core_AttributeDefinition $attrdef reference to the attribute definition - * @param string $value value of the attribute - */ + /** + * SeedDMS_Core_Attribute constructor. + * @param $id + * @param $obj + * @param $attrdef + * @param $value + */ function __construct($id, $obj, $attrdef, $value) { /* {{{ */ $this->_id = $id; $this->_obj = $obj; @@ -242,10 +241,11 @@ class SeedDMS_Core_Attribute { /* {{{ */ * If the validation fails the validation error will be set which * can be requested by SeedDMS_Core_Attribute::getValidationError() * - * @return boolean true if validation succeds, otherwise false + * @return boolean true if validation succeeds, otherwise false */ function validate() { /* {{{ */ - $attrdef = $this->_attrdef(); + /** @var SeedDMS_Core_AttributeDefinition $attrdef */ + $attrdef = $this->_attrdef(); /** @todo check this out, this method is not existing */ $result = $attrdef->validate($this->_value); $this->_validation_error = $attrdef->getValidationError(); return $result; @@ -373,12 +373,17 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ protected $_validation_error; /** - * @var object SeedDMS_Core_DMS reference to the dms instance this attribute definition belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this attribute definition belongs to * * @access protected */ protected $_dms; + /** + * @var string + */ + protected $_separator; + /* * Possible skalar data types of an attribute */ @@ -398,20 +403,21 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ const objtype_document = '2'; const objtype_documentcontent = '3'; - /** - * Constructor - * - * @param integer $id internal id of attribute definition - * @param string $name name of attribute - * @param integer $objtype type of object for which this attribute definition - * may be used. - * @param integer $type skalar type of attribute - * @param boolean $multiple set to true if multiple values are allowed - * @param integer $minvalues minimum number of values - * @param integer $maxvalues maximum number of values - * @param string $valueset separated list of allowed values, the first char - * is taken as the separator - */ + /** + * Constructor + * + * @param integer $id internal id of attribute definition + * @param string $name name of attribute + * @param integer $objtype type of object for which this attribute definition + * may be used. + * @param integer $type skalar type of attribute + * @param boolean $multiple set to true if multiple values are allowed + * @param integer $minvalues minimum number of values + * @param integer $maxvalues maximum number of values + * @param string $valueset separated list of allowed values, the first char + * is taken as the separator + * @param $regex + */ function __construct($id, $name, $objtype, $type, $multiple, $minvalues, $maxvalues, $valueset, $regex) { /* {{{ */ $this->_id = $id; $this->_name = $name; @@ -472,14 +478,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ */ function getObjType() { return $this->_objtype; } - /** - * Set object type of attribute definition - * - * This can be one of objtype_all, - * objtype_folder, objtype_document, or objtype_documentcontent. - * - * @param integer $objtype type - */ + /** + * Set object type of attribute definition + * + * This can be one of objtype_all, + * objtype_folder, objtype_document, or objtype_documentcontent. + * + * @param integer $objtype type + * @return bool + */ function setObjType($objtype) { /* {{{ */ $db = $this->_dms->getDB(); @@ -502,14 +509,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ */ function getType() { return $this->_type; } - /** - * Set type of attribute definition - * - * This can be one of type_int, type_float, type_string, type_boolean, - * type_url, type_email. - * - * @param integer $type type - */ + /** + * Set type of attribute definition + * + * This can be one of type_int, type_float, type_string, type_boolean, + * type_url, type_email. + * + * @param integer $type type + * @return bool + */ function setType($type) { /* {{{ */ $db = $this->_dms->getDB(); @@ -529,12 +537,13 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ */ function getMultipleValues() { return $this->_multiple; } - /** - * Set if attribute definition allows multi values for attribute - * - * @param boolean $mv true if attribute may have multiple values, otherwise - * false - */ + /** + * Set if attribute definition allows multi values for attribute + * + * @param boolean $mv true if attribute may have multiple values, otherwise + * false + * @return bool + */ function setMultipleValues($mv) { /* {{{ */ $db = $this->_dms->getDB(); @@ -633,13 +642,14 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ return array(); } /* }}} */ - /** - * Get the n'th value of a value set - * - * @param interger $index - * @return string n'th value of value set or false if the index is - * out of range or the value set has less than 2 chars - */ + /** + * Get the n'th value of a value set + * + * @param $ind + * @return string n'th value of value set or false if the index is + * out of range or the value set has less than 2 chars + * @internal param int $index + */ function getValueSetValue($ind) { /* {{{ */ if(strlen($this->_valueset) > 1) { $tmp = explode($this->_valueset[0], substr($this->_valueset, 1)); @@ -745,17 +755,16 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ return true; } /* }}} */ - /** - * Parse a given value according to attribute definition - * - * The return value is always an array, even if the attribute is single - * value attribute. - * - * @return array list of single values - */ + /** + * Parse a given value according to attribute definition + * + * The return value is always an array, even if the attribute is single + * value attribute. + * + * @param $value + * @return array|bool + */ function parseValue($value) { /* {{{ */ - $db = $this->_dms->getDB(); - if($this->getMultipleValues()) { /* If the value doesn't start with the separator used in the value set, * then assume that the value was not saved with a leading separator. @@ -771,7 +780,6 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ } else { return array($value); } - return true; } /* }}} */ /** @@ -779,8 +787,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ * attribute definition is used * * @param integer $limit return not more the n objects of each type - * @return boolean true if attribute definition is used, otherwise false - */ + * @return array|bool + */ function getStatistics($limit=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -995,8 +1003,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ if(!$success) $this->_validation_error = 3; break; - case self::type_boolean: - foreach($values as $value) { + case self::type_boolean: /** @todo: Same case in LINE 966 */ + foreach($values as $value) { $success &= preg_match('/^[01]$/', $value); } break; @@ -1041,4 +1049,3 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ function getValidationError() { return $this->_validation_error; } } /* }}} */ -?> From e1fc45b69a4cd6bd61a34339d2c99f08bfb199b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Tue, 24 Oct 2017 13:36:07 +0200 Subject: [PATCH 05/81] inc.ClassDMS.php --- SeedDMS_Core/Core/inc.ClassDMS.php | 591 ++++++++++++++++------------- 1 file changed, 328 insertions(+), 263 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 71097e64d..127d542ee 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -181,8 +181,13 @@ class SeedDMS_Core_DMS { */ public $callbacks; + /** + * @var SeedDMS_Core_DMS + */ + public $_dms; - /** + + /** * Checks if two objects are equal by comparing their IDs * * The regular php check done by '==' compares all attributes of @@ -341,15 +346,15 @@ class SeedDMS_Core_DMS { return $tmp; } /* }}} */ - /** - * Create a new instance of the dms - * - * @param object $db object of class {@link SeedDMS_Core_DatabaseAccess} - * to access the underlying database - * @param string $contentDir path in filesystem containing the data store - * all document contents is stored - * @return object instance of {@link SeedDMS_Core_DMS} - */ + /** @noinspection PhpUndefinedClassInspection */ + /** + * Create a new instance of the dms + * + * @param SeedDMS_Core_DatabaseAccess $db object of class {@link SeedDMS_Core_DatabaseAccess} + * to access the underlying database + * @param string $contentDir path in filesystem containing the data store + * all document contents is stored + */ function __construct($db, $contentDir) { /* {{{ */ $this->db = $db; if(substr($contentDir, -1) == '/') @@ -377,11 +382,11 @@ class SeedDMS_Core_DMS { /** * Return class name of instantiated objects * - * This method returns the class name of those objects being instatiated + * This method returns the class name of those objects being instantiated * by the dms. Each class has an internal place holder, which must be * passed to function. * - * @param string placeholder (can be one of 'folder', 'document', + * @param string $objectname placeholder (can be one of 'folder', 'document', * 'documentcontent', 'user', 'group' * * @return string/boolean name of class or false if placeholder is invalid @@ -401,9 +406,9 @@ class SeedDMS_Core_DMS { * inherited from one of the available classes) implementing new * features. The method should be called in the postInitDMS hook. * - * @param string placeholder (can be one of 'folder', 'document', + * @param string $objectname placeholder (can be one of 'folder', 'document', * 'documentcontent', 'user', 'group' - * @param string name of class + * @param string $classname name of class * * @return string/boolean name of old class or false if not set */ @@ -431,8 +436,8 @@ class SeedDMS_Core_DMS { /** * Return the database version * - * @return array array with elements major, minor, subminor, date - */ + * @return array|bool + */ function getDBVersion() { /* {{{ */ $tbllist = $this->db->TableList(); $tbllist = explode(',',strtolower(join(',',$tbllist))); @@ -478,7 +483,7 @@ class SeedDMS_Core_DMS { * This function must be called right after creating an instance of * {@link SeedDMS_Core_DMS} * - * @param interger $id id of root folder + * @param integer $id id of root folder */ function setRootFolderID($id) { /* {{{ */ $this->rootFolderID = $id; @@ -504,7 +509,7 @@ class SeedDMS_Core_DMS { * This function must be called right after creating an instance of * {@link SeedDMS_Core_DMS} * - * @param interger $id id of root folder + * @param integer $id id of root folder */ function setMaxDirID($id) { /* {{{ */ $this->maxDirID = $id; @@ -513,7 +518,7 @@ class SeedDMS_Core_DMS { /** * Get root folder * - * @return object/boolean return the object of the root folder or false if + * @return SeedDMS_Core_Folder|boolean return the object of the root folder or false if * the root folder id was not set before with {@link setRootFolderID}. */ function getRootFolder() { /* {{{ */ @@ -569,7 +574,7 @@ class SeedDMS_Core_DMS { * This function retrieves a document from the database by its id. * * @param integer $id internal id of document - * @return object instance of {@link SeedDMS_Core_Document} or false + * @return SeedDMS_Core_Document instance of {@link SeedDMS_Core_Document} or false */ function getDocument($id) { /* {{{ */ $classname = $this->classnames['document']; @@ -596,13 +601,14 @@ class SeedDMS_Core_DMS { return $user->getDocumentsLocked(); } /* }}} */ - /** - * Returns all documents which already expired or will expire in the future - * - * @param string $date date in format YYYY-MM-DD or an integer with the number - * of days. A negative value will cover the days in the past. - * @return array list of documents - */ + /** + * Returns all documents which already expired or will expire in the future + * + * @param string $date date in format YYYY-MM-DD or an integer with the number + * of days. A negative value will cover the days in the past. + * @param SeedDMS_Core_User $user + * @return bool|SeedDMS_Core_Document[] + */ function getDocumentsExpired($date, $user=null) { /* {{{ */ $db = $this->getDB(); @@ -649,8 +655,8 @@ class SeedDMS_Core_DMS { if (is_bool($resArr) && !$resArr) return false; + /** @var SeedDMS_Core_Document[] $documents */ $documents = array(); - $ts = mktime(0, 0, 0) + 86400; foreach ($resArr as $row) { $document = $this->getDocument($row["id"]); if($updatestatus) @@ -668,7 +674,7 @@ class SeedDMS_Core_DMS { * * @param string $name * @param object $folder - * @return object/boolean found document or false + * @return SeedDMS_Core_Document|boolean found document or false */ function getDocumentByName($name, $folder=null) { /* {{{ */ if (!$name) return false; @@ -689,6 +695,7 @@ class SeedDMS_Core_DMS { return false; $row = $resArr[0]; + /** @var SeedDMS_Core_Document $document */ $document = new $this->classnames['document']($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]); $document->setDMS($this); return $document; @@ -703,7 +710,7 @@ class SeedDMS_Core_DMS { * * @param string $name * @param object $folder - * @return object/boolean found document or false + * @return SeedDMS_Core_Document|boolean found document or false */ function getDocumentByOriginalFilename($name, $folder=null) { /* {{{ */ if (!$name) return false; @@ -726,6 +733,7 @@ class SeedDMS_Core_DMS { return false; $row = $resArr[0]; + /** @var SeedDMS_Core_Document $document */ $document = new $this->classnames['document']($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]); $document->setDMS($this); return $document; @@ -737,7 +745,7 @@ class SeedDMS_Core_DMS { * This function retrieves a document content from the database by its id. * * @param integer $id internal id of document content - * @return object instance of {@link SeedDMS_Core_DocumentContent} or false + * @return bool|SeedDMS_Core_Document or false */ function getDocumentContent($id) { /* {{{ */ if (!is_numeric($id)) return false; @@ -755,52 +763,52 @@ class SeedDMS_Core_DMS { return $version; } /* }}} */ - /** - * Returns all documents with a predefined search criteria - * - * The records return have the following elements - * - * From Table tblDocuments - * [id] => id of document - * [name] => name of document - * [comment] => comment of document - * [date] => timestamp of creation date of document - * [expires] => timestamp of expiration date of document - * [owner] => user id of owner - * [folder] => id of parent folder - * [folderList] => column separated list of folder ids, e.g. :1:41: - * [inheritAccess] => 1 if access is inherited - * [defaultAccess] => default access mode - * [locked] => always -1 (TODO: is this field still used?) - * [keywords] => keywords of document - * [sequence] => sequence of document - * - * From Table tblDocumentLocks - * [lockUser] => id of user locking the document - * - * From Table tblDocumentStatusLog - * [version] => latest version of document - * [statusID] => id of latest status log - * [documentID] => id of document - * [status] => current status of document - * [statusComment] => comment of current status - * [statusDate] => datetime when the status was entered, e.g. 2014-04-17 21:35:51 - * [userID] => id of user who has initiated the status change - * - * From Table tblUsers - * [ownerName] => name of owner of document - * [statusName] => name of user who has initiated the status change - * - * @param string $listtype type of document list, can be 'AppRevByMe', - * 'AppRevOwner', 'ReceiptByMe', 'ReviseByMe', 'LockedByMe', 'MyDocs' - * @param object $param1 user - * @param string $param2 set to true - * if 'AppRevByMe', 'ReviseByMe', 'ReceiptByMe' shall return even documents - * І have already taken care of. - * @param string $param3 sort list by this field - * @param string $param4 order direction - * @return array list of documents records - */ + /** + * Returns all documents with a predefined search criteria + * + * The records return have the following elements + * + * From Table tblDocuments + * [id] => id of document + * [name] => name of document + * [comment] => comment of document + * [date] => timestamp of creation date of document + * [expires] => timestamp of expiration date of document + * [owner] => user id of owner + * [folder] => id of parent folder + * [folderList] => column separated list of folder ids, e.g. :1:41: + * [inheritAccess] => 1 if access is inherited + * [defaultAccess] => default access mode + * [locked] => always -1 (TODO: is this field still used?) + * [keywords] => keywords of document + * [sequence] => sequence of document + * + * From Table tblDocumentLocks + * [lockUser] => id of user locking the document + * + * From Table tblDocumentStatusLog + * [version] => latest version of document + * [statusID] => id of latest status log + * [documentID] => id of document + * [status] => current status of document + * [statusComment] => comment of current status + * [statusDate] => datetime when the status was entered, e.g. 2014-04-17 21:35:51 + * [userID] => id of user who has initiated the status change + * + * From Table tblUsers + * [ownerName] => name of owner of document + * [statusName] => name of user who has initiated the status change + * + * @param string $listtype type of document list, can be 'AppRevByMe', + * 'AppRevOwner', 'ReceiptByMe', 'ReviseByMe', 'LockedByMe', 'MyDocs' + * @param SeedDMS_Core_User $param1 user + * @param bool $param2 set to true + * if 'AppRevByMe', 'ReviseByMe', 'ReceiptByMe' shall return even documents + * І have already taken care of. + * @param string $param3 sort list by this field + * @param string $param4 order direction + * @return array|bool + */ function getDocumentList($listtype, $param1=null, $param2=false, $param3='', $param4='') { /* {{{ */ /* The following query will get all documents and lots of additional * information. It requires the two temporary tables ttcontentid and @@ -999,8 +1007,9 @@ class SeedDMS_Core_DMS { $orderdir = 'DESC'; else $orderdir = 'ASC'; - $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ". - "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.", ".S_IN_REVISION.") "; + /** @noinspection PhpUndefinedConstantInspection */ + $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ". + "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.", ".S_IN_REVISION.") "; /** @todo S_IN_REVISION is not defined */ if ($orderby=='e') $queryStr .= "ORDER BY `expires`"; else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`"; else if ($orderby=='s') $queryStr .= "ORDER BY `status`"; @@ -1127,7 +1136,7 @@ class SeedDMS_Core_DMS { return mktime($hour, $min, $sec, $month, $day, $year); } /* }}} */ - /* + /** * Search the database for documents * * Note: the creation date will be used to check againts the @@ -1137,31 +1146,31 @@ class SeedDMS_Core_DMS { * meanѕ that updateѕ of a document will only result in a searchable * modification if a new version is uploaded. * - * @param query string seach query with space separated words - * @param limit integer number of items in result set - * @param offset integer index of first item in result set - * @param logicalmode string either AND or OR - * @param searchin array() list of fields to search in + * @param string $query seach query with space separated words + * @param integer $limit number of items in result set + * @param integer $offset index of first item in result set + * @param string $logicalmode either AND or OR + * @param array $searchin list of fields to search in * 1 = keywords, 2=name, 3=comment, 4=attributes - * @param startFolder object search in the folder only (null for root folder) - * @param owner object search for documents owned by this user - * @param status array list of status - * @param creationstartdate array search for documents created after this date - * @param creationenddate array search for documents created before this date - * @param modificationstartdate array search for documents modified after this date - * @param modificationenddate array search for documents modified before this date - * @param categories array list of categories the documents must have assigned - * @param attributes array list of attributes. The key of this array is the + * @param SeedDMS_Core_Folder|null $startFolder search in the folder only (null for root folder) + * @param SeedDMS_Core_User $owner search for documents owned by this user + * @param array $status list of status + * @param array $creationstartdate search for documents created after this date + * @param array $creationenddate search for documents created before this date + * @param array $modificationstartdate search for documents modified after this date + * @param array $modificationenddate search for documents modified before this date + * @param array $categories list of categories the documents must have assigned + * @param array $attributes list of attributes. The key of this array is the * attribute definition id. The value of the array is the value of the * attribute. If the attribute may have multiple values it must be an array. - * @param mode int decide whether to search for documents/folders + * @param integer $mode decide whether to search for documents/folders * 0x1 = documents only * 0x2 = folders only * 0x3 = both - * @param expirationstartdate array search for documents expiring after this date - * @param expirationenddate array search for documents expiring before this date - * @return array containing the elements total and docs - */ + * @param array $expirationstartdate search for documents expiring after this date + * @param array $expirationenddate search for documents expiring before this date + * @return array|bool + */ function search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=null, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x3, $expirationstartdate=array(), $expirationenddate=array()) { /* {{{ */ // Split the search string into constituent keywords. $tkeys=array(); @@ -1243,7 +1252,8 @@ class SeedDMS_Core_DMS { if ($creationenddate) { $stopdate = SeedDMS_Core_DMS::makeTimeStamp($creationenddate['hour'], $creationstartdate['minute'], $creationstartdate['second'], $creationenddate["year"], $creationenddate["month"], $creationenddate["day"]); if ($stopdate) { - if($startdate) + /** @noinspection PhpUndefinedVariableInspection */ + if($startdate) $searchCreateDate .= " AND "; $searchCreateDate .= "`tblFolders`.`date` <= ".$stopdate; } @@ -1304,7 +1314,8 @@ class SeedDMS_Core_DMS { foreach ($resArr as $folderArr) { $folders[] = $this->getFolder($folderArr['id']); } - $folderresult = array('totalFolders'=>$totalFolders, 'folders'=>$folders); + /** @noinspection PhpUndefinedVariableInspection */ + $folderresult = array('totalFolders'=>$totalFolders, 'folders'=>$folders); } } else { $folderresult = array('totalFolders'=>0, 'folders'=>array()); @@ -1381,7 +1392,8 @@ class SeedDMS_Core_DMS { } elseif($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) { if($attrdef->getValueSet()) { if($attrdef->getMultipleValues()) { - $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentContentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentContentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentContentAttributes`.`document` = `tblDocumentContent`.`id`)"; + /** @noinspection PhpUndefinedVariableInspection */ + $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentContentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentContentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentContentAttributes`.`document` = `tblDocumentContent`.`id`)"; } else { $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentContentAttributes`.`value`='".$attribute."' AND `tblDocumentContentAttributes`.content = `tblDocumentContent`.id)"; } @@ -1539,7 +1551,8 @@ class SeedDMS_Core_DMS { foreach ($resArr as $docArr) { $docs[] = $this->getDocument($docArr['id']); } - $docresult = array('totalDocs'=>$totalDocs, 'docs'=>$docs); + /** @noinspection PhpUndefinedVariableInspection */ + $docresult = array('totalDocs'=>$totalDocs, 'docs'=>$docs); } } else { $docresult = array('totalDocs'=>0, 'docs'=>array()); @@ -1566,7 +1579,7 @@ class SeedDMS_Core_DMS { * This function retrieves a folder from the database by its id. * * @param integer $id internal id of folder - * @return object instance of SeedDMS_Core_Folder or false + * @return SeedDMS_Core_Folder instance of SeedDMS_Core_Folder or false */ function getFolder($id) { /* {{{ */ $classname = $this->classnames['folder']; @@ -1582,8 +1595,8 @@ class SeedDMS_Core_DMS { * only within this parent folder. It will not be done recursively. * * @param string $name name of the folder - * @param object $folder parent folder - * @return object/boolean found folder or false + * @param SeedDMS_Core_Folder $folder parent folder + * @return SeedDMS_Core_Folder|boolean found folder or false */ function getFolderByName($name, $folder=null) { /* {{{ */ if (!$name) return false; @@ -1601,6 +1614,7 @@ class SeedDMS_Core_DMS { return false; $resArr = $resArr[0]; + /** @var SeedDMS_Core_Folder $folder */ $folder = new $this->classnames['folder']($resArr["id"], $resArr["name"], $resArr["parent"], $resArr["comment"], $resArr["date"], $resArr["owner"], $resArr["inheritAccess"], $resArr["defaultAccess"], $resArr["sequence"]); $folder->setDMS($this); return $folder; @@ -1611,8 +1625,8 @@ class SeedDMS_Core_DMS { * * This function checks all folders in the database. * - * @return array list of errors - */ + * @return array|bool + */ function checkFolders() { /* {{{ */ $queryStr = "SELECT * FROM `tblFolders`"; $resArr = $this->db->getResultArray($queryStr); @@ -1645,8 +1659,8 @@ class SeedDMS_Core_DMS { * * This function checks all documents in the database. * - * @return array list of errors - */ + * @return array|bool + */ function checkDocuments() { /* {{{ */ $queryStr = "SELECT * FROM `tblFolders`"; $resArr = $this->db->getResultArray($queryStr); @@ -1728,30 +1742,37 @@ class SeedDMS_Core_DMS { return $classname::getInstance($email, $this, 'email'); } /* }}} */ - /** - * Return list of all users - * - * @return array of instances of {@link SeedDMS_Core_User} or false - */ + /** + * Return list of all users + * + * @param string $orderby + * @return array of instances of SeedDMS_Core_User or false + * or false + */ function getAllUsers($orderby = '') { /* {{{ */ $classname = $this->classnames['user']; return $classname::getAllInstances($orderby, $this); } /* }}} */ - /** - * Add a new user - * - * @param string $login login name - * @param string $pwd password of new user - * @param string $email Email of new user - * @param string $language language of new user - * @param string $comment comment of new user - * @param integer $role role of new user (can be 0=normal, 1=admin, 2=guest) - * @param integer $isHidden hide user in all lists, if this is set login - * is still allowed - * @param integer $isDisabled disable user and prevent login - * @return object of {@link SeedDMS_Core_User} - */ + /** + * Add a new user + * + * @param string $login login name + * @param string $pwd password of new user + * @param $fullName + * @param string $email Email of new user + * @param string $language language of new user + * @param $theme + * @param string $comment comment of new user + * @param int|string $role role of new user (can be 0=normal, 1=admin, 2=guest) + * @param integer $isHidden hide user in all lists, if this is set login + * is still allowed + * @param integer $isDisabled disable user and prevent login + * @param string $pwdexpiration + * @param int $quota + * @param null $homefolder + * @return bool|SeedDMS_Core_User + */ function addUser($login, $pwd, $fullName, $email, $language, $theme, $comment, $role='0', $isHidden=0, $isDisabled=0, $pwdexpiration='', $quota=0, $homefolder=null) { /* {{{ */ $db = $this->db; if (is_object($this->getUserByLogin($login))) { @@ -1776,7 +1797,8 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddUser' callback is set */ if(isset($this->_dms->callbacks['onPostAddUser'])) { foreach($this->_dms->callbacks['onPostUser'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $user)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $user)) { } } } @@ -1788,7 +1810,7 @@ class SeedDMS_Core_DMS { * Get a group by its id * * @param integer $id id of group - * @return object/boolean group or false if no group was found + * @return SeedDMS_Core_Group|boolean group or false if no group was found */ function getGroup($id) { /* {{{ */ $classname = $this->classnames['group']; @@ -1799,7 +1821,7 @@ class SeedDMS_Core_DMS { * Get a group by its name * * @param string $name name of group - * @return object/boolean group or false if no group was found + * @return SeedDMS_Core_Group|boolean group or false if no group was found */ function getGroupByName($name) { /* {{{ */ $classname = $this->classnames['group']; @@ -1809,7 +1831,7 @@ class SeedDMS_Core_DMS { /** * Get a list of all groups * - * @return array array of instances of {@link SeedDMS_Core_Group} + * @return SeedDMS_Core_Group[] array of instances of {@link SeedDMS_Core_Group} */ function getAllGroups() { /* {{{ */ $classname = $this->classnames['group']; @@ -1821,7 +1843,7 @@ class SeedDMS_Core_DMS { * * @param string $name name of group * @param string $comment comment of group - * @return object/boolean instance of {@link SeedDMS_Core_Group} or false in + * @return SeedDMS_Core_Group|boolean instance of {@link SeedDMS_Core_Group} or false in * case of an error. */ function addGroup($name, $comment) { /* {{{ */ @@ -1838,7 +1860,8 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddGroup' callback is set */ if(isset($this->_dms->callbacks['onPostAddGroup'])) { foreach($this->_dms->callbacks['onPostAddGroup'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $group)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $group)) { } } } @@ -1892,9 +1915,11 @@ class SeedDMS_Core_DMS { return $categories; } /* }}} */ - /** - * This function should be replaced by getAllKeywordCategories() - */ + /** + * This function should be replaced by getAllKeywordCategories() + * @param $userID + * @return SeedDMS_Core_KeywordCategory[]|bool + */ function getAllUserKeywordCategories($userID) { /* {{{ */ $queryStr = "SELECT * FROM `tblKeywordCategories`"; if ($userID != -1) @@ -1927,7 +1952,8 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddKeywordCategory' callback is set */ if(isset($this->_dms->callbacks['onPostAddKeywordCategory'])) { foreach($this->_dms->callbacks['onPostAddKeywordCategory'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $category)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $category)) { } } } @@ -1973,7 +1999,7 @@ class SeedDMS_Core_DMS { * The name of a category is by default unique. * * @param string $name human readable name of category - * @return object instance of {@link SeedDMS_Core_DocumentCategory} + * @return SeedDMS_Core_DocumentCategory|boolean instance of {@link SeedDMS_Core_DocumentCategory} */ function getDocumentCategoryByName($name) { /* {{{ */ if (!$name) return false; @@ -2003,7 +2029,8 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddDocumentCategory' callback is set */ if(isset($this->_dms->callbacks['onPostAddDocumentCategory'])) { foreach($this->_dms->callbacks['onPostAddDocumentCategory'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $category)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $category)) { } } } @@ -2037,13 +2064,14 @@ class SeedDMS_Core_DMS { return $user->getNotifications($type); } /* }}} */ - /** - * Create a token to request a new password. - * This function will not delete the password but just creates an entry - * in tblUserRequestPassword indicating a password request. - * - * @return string hash value of false in case of an error - */ + /** + * Create a token to request a new password. + * This function will not delete the password but just creates an entry + * in tblUserRequestPassword indicating a password request. + * + * @param SeedDMS_Core_User $user + * @return string|boolean hash value of false in case of an error + */ function createPasswordRequest($user) { /* {{{ */ $hash = md5(uniqid(time())); $queryStr = "INSERT INTO `tblUserPasswordRequest` (`userID`, `hash`, `date`) VALUES (" . $user->getId() . ", " . $this->db->qstr($hash) .", ".$this->db->getCurrentDatetime().")"; @@ -2053,13 +2081,14 @@ class SeedDMS_Core_DMS { } /* }}} */ - /** - * Check if hash for a password request is valid. - * This function searches a previously create password request and - * returns the user. - * - * @param string $hash - */ + /** + * Check if hash for a password request is valid. + * This function searches a previously create password request and + * returns the user. + * + * @param string $hash + * @return bool|SeedDMS_Core_User + */ function checkPasswordRequest($hash) { /* {{{ */ /* Get the password request from the database */ $queryStr = "SELECT * FROM `tblUserPasswordRequest` where `hash`=".$this->db->qstr($hash); @@ -2075,11 +2104,12 @@ class SeedDMS_Core_DMS { } /* }}} */ - /** - * Delete a password request - * - * @param string $hash - */ + /** + * Delete a password request + * + * @param string $hash + * @return bool + */ function deletePasswordRequest($hash) { /* {{{ */ /* Delete the request, so nobody can use it a second time */ $queryStr = "DELETE FROM `tblUserPasswordRequest` WHERE `hash`=".$this->db->qstr($hash); @@ -2120,7 +2150,7 @@ class SeedDMS_Core_DMS { * This function retrieves an attribute def. from the database by its name. * * @param string $name internal name of attribute def. - * @return object instance of {@link SeedDMS_Core_AttributeDefinition} or false + * @return SeedDMS_Core_AttributeDefinition|boolean instance of {@link SeedDMS_Core_AttributeDefinition} or false */ function getAttributeDefinitionByName($name) { /* {{{ */ if (!$name) return false; @@ -2138,12 +2168,13 @@ class SeedDMS_Core_DMS { return $attrdef; } /* }}} */ - /** - * Return list of all attributes definitions - * - * @param integer $objtype select those attributes defined for an object type - * @return array of instances of {@link SeedDMS_Core_AttributeDefinition} or false - */ + /** + * Return list of all attributes definitions + * + * @param integer $objtype select those attributes defined for an object type + * @return bool|SeedDMS_Core_AttributeDefinition[] of instances of SeedDMS_Core_AttributeDefinition or false + * or false + */ function getAllAttributeDefinitions($objtype=0) { /* {{{ */ $queryStr = "SELECT * FROM `tblAttributeDefinitions`"; if($objtype) { @@ -2158,6 +2189,7 @@ class SeedDMS_Core_DMS { if (is_bool($resArr) && $resArr == false) return false; + /** @var SeedDMS_Core_AttributeDefinition[] $attrdefs */ $attrdefs = array(); for ($i = 0; $i < count($resArr); $i++) { @@ -2169,17 +2201,19 @@ class SeedDMS_Core_DMS { return $attrdefs; } /* }}} */ - /** - * Add a new attribute definition - * - * @param string $name name of attribute - * @param string $type type of attribute - * @param boolean $multiple set to 1 if attribute has multiple attributes - * @param integer $minvalues minimum number of values - * @param integer $maxvalues maximum number of values if multiple is set - * @param string $valueset list of allowed values (csv format) - * @return object of {@link SeedDMS_Core_User} - */ + /** + * Add a new attribute definition + * + * @param string $name name of attribute + * @param $objtype + * @param string $type type of attribute + * @param bool|int $multiple set to 1 if attribute has multiple attributes + * @param integer $minvalues minimum number of values + * @param integer $maxvalues maximum number of values if multiple is set + * @param string $valueset list of allowed values (csv format) + * @param string $regex + * @return bool|SeedDMS_Core_User + */ function addAttributeDefinition($name, $objtype, $type, $multiple=0, $minvalues=0, $maxvalues=1, $valueset='', $regex='') { /* {{{ */ if (is_object($this->getAttributeDefinitionByName($name))) { return false; @@ -2203,7 +2237,7 @@ class SeedDMS_Core_DMS { /** * Return list of all workflows * - * @return array of instances of {@link SeedDMS_Core_Workflow} or false + * @return SeedDMS_Core_Workflow[]|bool of instances of {@link SeedDMS_Core_Workflow} or false */ function getAllWorkflows() { /* {{{ */ $queryStr = "SELECT * FROM `tblWorkflows` ORDER BY `name`"; @@ -2222,9 +2256,11 @@ class SeedDMS_Core_DMS { $wkfstates[$ressArr[$i]["id"]] = new SeedDMS_Core_Workflow_State($ressArr[$i]["id"], $ressArr[$i]["name"], $ressArr[$i]["maxtime"], $ressArr[$i]["precondfunc"], $ressArr[$i]["documentstatus"]); } + /** @var SeedDMS_Core_Workflow[] $workflows */ $workflows = array(); for ($i = 0; $i < count($resArr); $i++) { - $workflow = new SeedDMS_Core_Workflow($resArr[$i]["id"], $resArr[$i]["name"], $wkfstates[$resArr[$i]["initstate"]]); + /** @noinspection PhpUndefinedVariableInspection */ + $workflow = new SeedDMS_Core_Workflow($resArr[$i]["id"], $resArr[$i]["name"], $wkfstates[$resArr[$i]["initstate"]]); $workflow->setDMS($this); $workflows[$i] = $workflow; } @@ -2236,7 +2272,7 @@ class SeedDMS_Core_DMS { * Return workflow by its Id * * @param integer $id internal id of workflow - * @return object of instances of {@link SeedDMS_Core_Workflow} or false + * @return SeedDMS_Core_Workflow|bool of instances of {@link SeedDMS_Core_Workflow} or false */ function getWorkflow($id) { /* {{{ */ $queryStr = "SELECT * FROM `tblWorkflows` WHERE `id`=".intval($id); @@ -2260,7 +2296,7 @@ class SeedDMS_Core_DMS { * Return workflow by its name * * @param string $name name of workflow - * @return object of instances of {@link SeedDMS_Core_Workflow} or false + * @return SeedDMS_Core_Workflow|bool of instances of {@link SeedDMS_Core_Workflow} or false */ function getWorkflowByName($name) { /* {{{ */ if (!$name) return false; @@ -2282,12 +2318,13 @@ class SeedDMS_Core_DMS { return $workflow; } /* }}} */ - /** - * Add a new workflow - * - * @param string $name name of workflow - * @param string $initstate initial state of workflow - */ + /** + * Add a new workflow + * + * @param string $name name of workflow + * @param SeedDMS_Core_Workflow_State $initstate initial state of workflow + * @return bool|SeedDMS_Core_Workflow + */ function addWorkflow($name, $initstate) { /* {{{ */ $db = $this->db; if (is_object($this->getWorkflowByName($name))) { @@ -2307,7 +2344,7 @@ class SeedDMS_Core_DMS { * This function retrieves a workflow state from the database by its id. * * @param integer $id internal id of workflow state - * @return object instance of {@link SeedDMS_Core_Workflow_State} or false + * @return bool|SeedDMS_Core_Workflow_State or false */ function getWorkflowState($id) { /* {{{ */ if (!is_numeric($id)) @@ -2330,7 +2367,7 @@ class SeedDMS_Core_DMS { * Return workflow state by its name * * @param string $name name of workflow state - * @return object of instances of {@link SeedDMS_Core_Workflow_State} or false + * @return bool|SeedDMS_Core_Workflow_State or false */ function getWorkflowStateByName($name) { /* {{{ */ if (!$name) return false; @@ -2355,7 +2392,7 @@ class SeedDMS_Core_DMS { /** * Return list of all workflow states * - * @return array of instances of {@link SeedDMS_Core_Workflow_State} or false + * @return SeedDMS_Core_Workflow_State[]|bool of instances of {@link SeedDMS_Core_Workflow_State} or false */ function getAllWorkflowStates() { /* {{{ */ $queryStr = "SELECT * FROM `tblWorkflowStates` ORDER BY `name`"; @@ -2379,8 +2416,8 @@ class SeedDMS_Core_DMS { * * @param string $name name of workflow state * @param integer $docstatus document status when this state is reached - * @return object instance of new workflow state - */ + * @return bool|SeedDMS_Core_Workflow_State + */ function addWorkflowState($name, $docstatus) { /* {{{ */ $db = $this->db; if (is_object($this->getWorkflowStateByName($name))) { @@ -2400,7 +2437,7 @@ class SeedDMS_Core_DMS { * This function retrieves a workflow action from the database by its id. * * @param integer $id internal id of workflow action - * @return object instance of {@link SeedDMS_Core_Workflow_Action} or false + * @return SeedDMS_Core_Workflow_Action|bool instance of {@link SeedDMS_Core_Workflow_Action} or false */ function getWorkflowAction($id) { /* {{{ */ if (!is_numeric($id)) @@ -2425,7 +2462,7 @@ class SeedDMS_Core_DMS { * This function retrieves a workflow action from the database by its name. * * @param string $name name of workflow action - * @return object instance of {@link SeedDMS_Core_Workflow_Action} or false + * @return SeedDMS_Core_Workflow_Action|bool instance of {@link SeedDMS_Core_Workflow_Action} or false */ function getWorkflowActionByName($name) { /* {{{ */ if (!$name) return false; @@ -2446,7 +2483,7 @@ class SeedDMS_Core_DMS { /** * Return list of workflow action * - * @return array list of instances of {@link SeedDMS_Core_Workflow_Action} or false + * @return SeedDMS_Core_Workflow_Action[]|bool list of instances of {@link SeedDMS_Core_Workflow_Action} or false */ function getAllWorkflowActions() { /* {{{ */ $queryStr = "SELECT * FROM `tblWorkflowActions`"; @@ -2455,6 +2492,7 @@ class SeedDMS_Core_DMS { if (is_bool($resArr) && $resArr == false) return false; + /** @var SeedDMS_Core_Workflow_Action[] $wkfactions */ $wkfactions = array(); for ($i = 0; $i < count($resArr); $i++) { $action = new SeedDMS_Core_Workflow_Action($resArr[$i]["id"], $resArr[$i]["name"]); @@ -2469,8 +2507,8 @@ class SeedDMS_Core_DMS { * Add new workflow action * * @param string $name name of workflow action - * @return object instance new workflow action - */ + * @return SeedDMS_Core_Workflow_Action|bool + */ function addWorkflowAction($name) { /* {{{ */ $db = $this->db; if (is_object($this->getWorkflowActionByName($name))) { @@ -2490,7 +2528,7 @@ class SeedDMS_Core_DMS { * This function retrieves a workflow transition from the database by its id. * * @param integer $id internal id of workflow transition - * @return object instance of {@link SeedDMS_Core_Workflow_Transition} or false + * @return SeedDMS_Core_Workflow_Transition|bool instance of {@link SeedDMS_Core_Workflow_Transition} or false */ function getWorkflowTransition($id) { /* {{{ */ if (!is_numeric($id)) @@ -2509,15 +2547,17 @@ class SeedDMS_Core_DMS { return $transition; } /* }}} */ - /** + /** * Returns document content which is not linked to a document + * + * This method is for finding straying document content without + * a parent document. In normal operation this should not happen + * but little checks for database consistency and possible errors + * in the application may have left over document content though + * the document is gone already. * - * This method is for finding straying document content without - * a parent document. In normal operation this should not happen - * but little checks for database consistency and possible errors - * in the application may have left over document content though - * the document is gone already. - */ + * @return array|bool + */ function getUnlinkedDocumentContent() { /* {{{ */ $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` NOT IN (SELECT id FROM `tblDocuments`)"; $resArr = $this->db->getResultArray($queryStr); @@ -2526,6 +2566,7 @@ class SeedDMS_Core_DMS { $versions = array(); foreach($resArr as $row) { + /** @var SeedDMS_Core_Document $document */ $document = new $this->classnames['document']($row['document'], '', '', '', '', '', '', '', '', '', '', ''); $document->setDMS($this); $version = new $this->classnames['documentcontent']($row['id'], $document, $row['version'], $row['comment'], $row['date'], $row['createdBy'], $row['dir'], $row['orgFileName'], $row['fileType'], $row['mimeType'], $row['fileSize'], $row['checksum']); @@ -2535,21 +2576,25 @@ class SeedDMS_Core_DMS { } /* }}} */ - /** + /** * Returns document content which has no file size set + * + * This method is for finding document content without a file size + * set in the database. The file size of a document content was introduced + * in version 4.0.0 of SeedDMS for implementation of user quotas. * - * This method is for finding document content without a file size - * set in the database. The file size of a document content was introduced - * in version 4.0.0 of SeedDMS for implementation of user quotas. - */ + * @return SeedDMS_Core_Document[]|bool + */ function getNoFileSizeDocumentContent() { /* {{{ */ $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `fileSize` = 0 OR `fileSize` is null"; $resArr = $this->db->getResultArray($queryStr); if ($resArr === false) return false; + /** @var SeedDMS_Core_Document[] $versions */ $versions = array(); foreach($resArr as $row) { + /** @var SeedDMS_Core_Document $document */ $document = new $this->classnames['document']($row['document'], '', '', '', '', '', '', '', '', '', '', ''); $document->setDMS($this); $version = new $this->classnames['documentcontent']($row['id'], $document, $row['version'], $row['comment'], $row['date'], $row['createdBy'], $row['dir'], $row['orgFileName'], $row['fileType'], $row['mimeType'], $row['fileSize'], $row['checksum'], $row['fileSize'], $row['checksum']); @@ -2559,21 +2604,24 @@ class SeedDMS_Core_DMS { } /* }}} */ - /** - * Returns document content which has no checksum set - * - * This method is for finding document content without a checksum - * set in the database. The checksum of a document content was introduced - * in version 4.0.0 of SeedDMS for finding duplicates. - */ + /** + * Returns document content which has no checksum set + * + * This method is for finding document content without a checksum + * set in the database. The checksum of a document content was introduced + * in version 4.0.0 of SeedDMS for finding duplicates. + * @return bool|SeedDMS_Core_Document[] + */ function getNoChecksumDocumentContent() { /* {{{ */ $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `checksum` = '' OR `checksum` is null"; $resArr = $this->db->getResultArray($queryStr); if ($resArr === false) return false; + /** @var SeedDMS_Core_Document[] $versions */ $versions = array(); foreach($resArr as $row) { + /** @var SeedDMS_Core_Document $document */ $document = new $this->classnames['document']($row['document'], '', '', '', '', '', '', '', '', '', '', ''); $document->setDMS($this); $version = new $this->classnames['documentcontent']($row['id'], $document, $row['version'], $row['comment'], $row['date'], $row['createdBy'], $row['dir'], $row['orgFileName'], $row['fileType'], $row['mimeType'], $row['fileSize'], $row['checksum']); @@ -2583,19 +2631,21 @@ class SeedDMS_Core_DMS { } /* }}} */ - /** - * Returns document content which is duplicated - * - * This method is for finding document content which is available twice - * in the database. The checksum of a document content was introduced - * in version 4.0.0 of SeedDMS for finding duplicates. - */ + /** + * Returns document content which is duplicated + * + * This method is for finding document content which is available twice + * in the database. The checksum of a document content was introduced + * in version 4.0.0 of SeedDMS for finding duplicates. + * @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"; $resArr = $this->db->getResultArray($queryStr); if (!$resArr) return false; + /** @var SeedDMS_Core_Document[] $versions */ $versions = array(); foreach($resArr as $row) { $document = $this->getDocument($row['document']); @@ -2610,13 +2660,17 @@ class SeedDMS_Core_DMS { } /* }}} */ - /** - * Returns a list of reviews, approvals which are not linked - * to a user, group anymore - * - * This method is for finding reviews or approvals whose user - * or group was deleted and not just removed from the process. - */ + /** + * Returns a list of reviews, approvals which are not linked + * to a user, group anymore + * + * This method is for finding reviews or approvals whose user + * or group was deleted and not just removed from the process. + * + * @param string $process + * @param string $usergroup + * @return array + */ function getProcessWithoutUserGroup($process, $usergroup) { /* {{{ */ switch($process) { case 'review': @@ -2626,7 +2680,8 @@ class SeedDMS_Core_DMS { $queryStr = "SELECT a.*, b.`name` FROM `tblDocumentApprovers`"; break; } - $queryStr .= " a LEFT JOIN `tblDocuments` b ON a.`documentID`=b.`id` where"; + /** @noinspection PhpUndefinedVariableInspection */ + $queryStr .= " a LEFT JOIN `tblDocuments` b ON a.`documentID`=b.`id` where"; switch($usergroup) { case 'user': $queryStr .= " a.`type`=0 and a.`required` not in (select `id` from `tblUsers`) ORDER by b.`id`"; @@ -2638,14 +2693,18 @@ class SeedDMS_Core_DMS { return $this->db->getResultArray($queryStr); } /* }}} */ - /** - * Removes all reviews, approvals which are not linked - * to a user, group anymore - * - * This method is for removing all reviews or approvals whose user - * or group was deleted and not just removed from the process. - * If the optional parameter $id is set, only this user/group id is removed. - */ + /** + * Removes all reviews, approvals which are not linked + * to a user, group anymore + * + * This method is for removing all reviews or approvals whose user + * or group was deleted and not just removed from the process. + * If the optional parameter $id is set, only this user/group id is removed. + * @param string $process + * @param string $usergroup + * @param int $id + * @return array + */ function removeProcessWithoutUserGroup($process, $usergroup, $id=0) { /* {{{ */ /* Entries of tblDocumentReviewLog or tblDocumentApproveLog are deleted * because of CASCADE ON @@ -2658,7 +2717,8 @@ class SeedDMS_Core_DMS { $queryStr = "DELETE FROM tblDocumentApprovers"; break; } - $queryStr .= " WHERE"; + /** @noinspection PhpUndefinedVariableInspection */ + $queryStr .= " WHERE"; switch($usergroup) { case 'user': $queryStr .= " type=0 AND"; @@ -2683,8 +2743,8 @@ class SeedDMS_Core_DMS { * documents or used space per user, recent activity, etc. * * @param string $type type of statistic - * @return array statistical data - */ + * @return array|bool + */ function getStatisticalData($type='') { /* {{{ */ switch($type) { case 'docsperuser': @@ -2709,7 +2769,8 @@ class SeedDMS_Core_DMS { return $resArr; case 'docsperstatus': - $queryStr = "select b.`status` as `key`, count(b.`status`) as total from (select a.id, max(b.version), max(c.`statusLogID`) as maxlog from `tblDocuments` a left join `tblDocumentStatus` b on a.id=b.`documentID` left join `tblDocumentStatusLog` c on b.`statusID`=c.`statusID` group by a.`id`, b.`version` order by a.`id`, b.`statusID`) a left join `tblDocumentStatusLog` b on a.`maxlog`=b.`statusLogID` group by b.`status`"; + /** @noinspection PhpUnusedLocalVariableInspection */ + $queryStr = "select b.`status` as `key`, count(b.`status`) as total from (select a.id, max(b.version), max(c.`statusLogID`) as maxlog from `tblDocuments` a left join `tblDocumentStatus` b on a.id=b.`documentID` left join `tblDocumentStatusLog` c on b.`statusID`=c.`statusID` group by a.`id`, b.`version` order by a.`id`, b.`statusID`) a left join `tblDocumentStatusLog` b on a.`maxlog`=b.`statusLogID` group by b.`status`"; $queryStr = "select b.`status` as `key`, count(b.`status`) as total from (select a.`id`, max(c.`statusLogID`) as maxlog from `tblDocuments` a left join `tblDocumentStatus` b on a.id=b.`documentID` left join `tblDocumentStatusLog` c on b.`statusID`=c.`statusID` group by a.`id` order by a.id) a left join `tblDocumentStatusLog` b on a.maxlog=b.`statusLogID` group by b.`status`"; $resArr = $this->db->getResultArray($queryStr); if (!$resArr) @@ -2751,23 +2812,27 @@ class SeedDMS_Core_DMS { } } /* }}} */ - /** - * Returns changes with a period of time - * - * This method returns a list of all changes happened in the database - * within a given period of time. It currently just checks for - * entries in the database tables tblDocumentContent, tblDocumentFiles, - * and tblDocumentStatusLog - * - * @param string $start start date, defaults to start of current day - * @param string $end end date, defaults to end of start day - * @return array list of changes - */ + /** + * Returns changes with a period of time + * + * This method returns a list of all changes happened in the database + * within a given period of time. It currently just checks for + * entries in the database tables tblDocumentContent, tblDocumentFiles, + * and tblDocumentStatusLog + * + * @param string $startts + * @param string $endts + * @return array|bool + * @internal param string $start start date, defaults to start of current day + * @internal param string $end end date, defaults to end of start day + */ function getTimeline($startts='', $endts='') { /* {{{ */ if(!$startts) $startts = mktime(0, 0, 0); if(!$endts) $endts = $startts+86400; + + /** @var SeedDMS_Core_Document[] $timeline */ $timeline = array(); $queryStr = "SELECT DISTINCT document FROM `tblDocumentContent` WHERE `date` > ".$startts." AND `date` < ".$endts." UNION SELECT DISTINCT document FROM `tblDocumentFiles` WHERE `date` > ".$startts." AND `date` < ".$endts; @@ -2808,11 +2873,12 @@ class SeedDMS_Core_DMS { $this->callbacks[$name][] = array($func, $params); } /* }}} */ - /** - * Create an sql dump of the complete database - * - * @param string $filename name of dump file - */ + /** + * Create an sql dump of the complete database + * + * @param string $filename name of dump file + * @return bool + */ function createDump($filename) { /* {{{ */ $h = fopen($filename, "w"); if(!$h) @@ -2843,4 +2909,3 @@ class SeedDMS_Core_DMS { } /* }}} */ } -?> From ab73fe529894b19a393524af97a911db848c32d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Tue, 24 Oct 2017 14:00:56 +0200 Subject: [PATCH 06/81] inc.ClassDMS.php --- SeedDMS_Core/Core/inc.ClassDMS.php | 4 +- SeedDMS_Core/Core/inc.ClassDocument.php | 237 ++++++++++++++---------- SeedDMS_Core/Core/inc.ClassFolder.php | 4 +- SeedDMS_Core/Core/inc.ClassObject.php | 10 +- 4 files changed, 152 insertions(+), 103 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 127d542ee..704255ce6 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -74,7 +74,7 @@ require_once("inc.ClassAttribute.php"); */ class SeedDMS_Core_DMS { /** - * @var SeedDMS_Core_DMS $db reference to database object. This must be an instance + * @var SeedDMS_Core_DatabaseAccess $db reference to database object. This must be an instance * of {@link SeedDMS_Core_DatabaseAccess}. * @access protected */ @@ -427,7 +427,7 @@ class SeedDMS_Core_DMS { * This method returns the database object as it was set by the first * parameter of the constructor. * - * @return object database + * @return SeedDMS_Core_DatabaseAccess database */ function getDB() { /* {{{ */ return $this->db; diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 90758cf97..017ed1571 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -176,7 +176,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ protected $_keywords; /** - * @var array list of categories + * @var SeedDMS_Core_DocumentCategory[] list of categories */ protected $_categories; @@ -195,7 +195,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ */ protected $_content; - function __construct($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */ + /** + * @var SeedDMS_Core_Folder + */ + protected $_folder; + + /** @var SeedDMS_Core_UserAccess[] */ + protected $_accessList; + + function __construct($id, $name, $comment, $date, $expires, $ownerID, $folderID, $inheritAccess, $defaultAccess, $locked, $keywords, $sequence) { /* {{{ */ parent::__construct($id); $this->_name = $name; $this->_comment = $comment; @@ -214,14 +222,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $this->_content = null; } /* }}} */ - /** - * Return an array of database fields which used for searching - * a term entered in the database search form - * - * @param array $searchin integer list of search scopes (2=name, 3=comment, - * 4=attributes) - * @return array list of database fields - */ + /** + * Return an array of database fields which used for searching + * 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, + * 4=attributes) + * @return array list of database fields + */ public static function getSearchFields($dms, $searchin) { /* {{{ */ $db = $dms->getDB(); @@ -247,6 +256,11 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $searchFields; } /* }}} */ + /** + * @param integer $id + * @param SeedDMS_Core_DMS $dms + * @return bool|SeedDMS_Core_Document + */ public static function getInstance($id, $dms) { /* {{{ */ $db = $dms->getDB(); @@ -271,12 +285,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ } $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"], $lock, $resArr["keywords"], $resArr["sequence"]); $document->setDMS($dms); return $document; } /* }}} */ - /* + /** * Return the directory of the document in the file system relativ * to the contentDir * @@ -291,18 +306,19 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ } } /* }}} */ - /* + /** * Return the name of the document * * @return string name of document */ function getName() { return $this->_name; } - /* - * Set the name of the document - * - * @param $newName string new name of document - */ + /** + * Set the name of the document + * + * @param $newName string new name of document + * @return bool + */ function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -314,18 +330,19 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ - /* + /** * Return the comment of the document * * @return string comment of document */ function getComment() { return $this->_comment; } - /* - * Set the comment of the document - * - * @param $newComment string new comment of document - */ + /** + * Set the comment of the document + * + * @param $newComment string new comment of document + * @return bool + */ function setComment($newComment) { /* {{{ */ $db = $this->_dms->getDB(); @@ -337,8 +354,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getKeywords() { return $this->_keywords; } + /** + * @param string $newKeywords + * @return bool + */ function setKeywords($newKeywords) { /* {{{ */ $db = $this->_dms->getDB(); @@ -353,8 +377,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Retrieve a list of all categories this document belongs to * - * @return array list of category objects - */ + * @return bool|SeedDMS_Core_DocumentCategory[] + */ function getCategories() { /* {{{ */ $db = $this->_dms->getDB(); @@ -373,13 +397,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->_categories; } /* }}} */ - /** - * Set a list of categories for the document - * This function will delete currently assigned categories and sets new - * categories. - * - * @param array $newCategories list of category objects - */ + /** + * Set a list of categories for the document + * This function will delete currently assigned categories and sets new + * categories. + * + * @param SeedDMS_Core_DocumentCategory[] $newCategories list of category objects + * @return bool + */ function setCategories($newCategories) { /* {{{ */ $db = $this->_dms->getDB(); @@ -439,7 +464,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Return the parent folder of the document * - * @return object parent folder + * @return SeedDMS_Core_Folder parent folder */ function getFolder() { /* {{{ */ if (!isset($this->_folder)) @@ -453,7 +478,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * This function basically moves a document from a folder to another * folder. * - * @param object $newFolder + * @param SeedDMS_Core_Folder $newFolder * @return boolean false in case of an error, otherwise true */ function setFolder($newFolder) { /* {{{ */ @@ -463,12 +488,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if (!$db->getResult($queryStr)) return false; $this->_folderID = $newFolder->getID(); - $this->_folder = $newFolder; + /** @noinspection PhpUndefinedFieldInspection */ + $this->_folder = $newFolder; // Make sure that the folder search path is also updated. $path = $newFolder->getPath(); $flist = ""; - foreach ($path as $f) { + /** @var SeedDMS_Core_Folder[] $path */ + foreach ($path as $f) { $flist .= ":".$f->getID(); } if (strlen($flist)>1) { @@ -484,7 +511,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Return owner of document * - * @return object owner of document as an instance of {@link SeedDMS_Core_User} + * @return SeedDMS_Core_User owner of document as an instance of {@link SeedDMS_Core_User} */ function getOwner() { /* {{{ */ if (!isset($this->_owner)) @@ -495,7 +522,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Set owner of a document * - * @param object $newOwner new owner + * @param SeedDMS_Core_User $newOwner new owner * @return boolean true if successful otherwise false */ function setOwner($newOwner) { /* {{{ */ @@ -506,10 +533,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return false; $this->_ownerID = $newOwner->getID(); - $this->_owner = $newOwner; + /** @noinspection PhpUndefinedFieldInspection */ + $this->_owner = $newOwner; return true; } /* }}} */ + /** + * @return bool|int + */ function getDefaultAccess() { /* {{{ */ if ($this->inheritsAccess()) { $res = $this->getFolder(); @@ -519,15 +550,16 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->_defaultAccess; } /* }}} */ - /** - * Set default access mode - * - * This method sets the default access mode and also removes all notifiers which - * will not have read access anymore. - * - * @param integer $mode access mode - * @param boolean $noclean set to true if notifier list shall not be clean up - */ + /** + * Set default access mode + * + * This method sets the default access mode and also removes all notifiers which + * will not have read access anymore. + * + * @param integer $mode access mode + * @param boolean $noclean set to true if notifier list shall not be clean up + * @return bool + */ function setDefaultAccess($mode, $noclean="false") { /* {{{ */ $db = $this->_dms->getDB(); @@ -543,6 +575,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ + /** + * @return bool + */ function inheritsAccess() { return $this->_inheritAccess; } /** @@ -598,11 +633,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->_expires; } /* }}} */ - /** - * Set expiration date as unix timestamp - * - * @param integer unix timestamp of expiration date - */ + /** + * Set expiration date as unix timestamp + * + * @param integer $expires unix timestamp of expiration date + * @return bool + */ function setExpires($expires) { /* {{{ */ $db = $this->_dms->getDB(); @@ -670,7 +706,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Lock or unlock document * - * @param $falseOrUser user object for locking or false for unlocking + * @param SeedDMS_Core_User|bool $falseOrUser user object for locking or false for unlocking * @return boolean true if operation was successful otherwise false */ function setLocked($falseOrUser) { /* {{{ */ @@ -698,7 +734,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Get the user currently locking the document * - * @return object user have a lock + * @return SeedDMS_Core_User|bool user have a lock */ function getLockingUser() { /* {{{ */ if (!$this->isLocked()) @@ -709,8 +745,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->_lockingUser; } /* }}} */ + /** + * @return int + */ function getSequence() { return $this->_sequence; } + /** + * @param $seq + * @return bool + */ function setSequence($seq) { /* {{{ */ $db = $this->_dms->getDB(); @@ -743,24 +786,24 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ - /** - * Returns a list of access privileges - * - * If the document inherits the access privileges from the parent folder - * those will be returned. - * $mode and $op can be set to restrict the list of returned access - * privileges. If $mode is set to M_ANY no restriction will apply - * regardless of the value of $op. The returned array contains a list - * of {@link SeedDMS_Core_UserAccess} and - * {@link SeedDMS_Core_GroupAccess} objects. Even if the document - * has no access list the returned array contains the two elements - * 'users' and 'groups' which are than empty. The methode returns false - * if the function fails. - * - * @param integer $mode access mode (defaults to M_ANY) - * @param integer $op operation (defaults to O_EQ) - * @return array multi dimensional array or false in case of an error - */ + /** + * Returns a list of access privileges + * + * If the document inherits the access privileges from the parent folder + * those will be returned. + * $mode and $op can be set to restrict the list of returned access + * privileges. If $mode is set to M_ANY no restriction will apply + * regardless of the value of $op. The returned array contains a list + * of {@link SeedDMS_Core_UserAccess} and + * {@link SeedDMS_Core_GroupAccess} objects. Even if the document + * has no access list the returned array contains the two elements + * 'users' and 'groups' which are than empty. The methode returns false + * if the function fails. + * + * @param int $mode access mode (defaults to M_ANY) + * @param int|string $op operation (defaults to O_EQ) + * @return bool|SeedDMS_Core_UserAccess[] + */ function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */ $db = $this->_dms->getDB(); @@ -796,16 +839,17 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->_accessList[$mode]; } /* }}} */ - /** - * Add access right to folder - * This function may change in the future. Instead of passing the a flag - * and a user/group id a user or group object will be expected. - * - * @param integer $mode access mode - * @param integer $userOrGroupID id of user or group - * @param integer $isUser set to 1 if $userOrGroupID is the id of a - * user - */ + /** + * Add access right to folder + * This function may change in the future. Instead of passing the a flag + * and a user/group id a user or group object will be expected. + * + * @param integer $mode access mode + * @param integer $userOrGroupID id of user or group + * @param integer $isUser set to 1 if $userOrGroupID is the id of a + * user + * @return bool + */ function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */ $db = $this->_dms->getDB(); @@ -826,16 +870,17 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ - /** - * Change access right of document - * This function may change in the future. Instead of passing the a flag - * and a user/group id a user or group object will be expected. - * - * @param integer $newMode access mode - * @param integer $userOrGroupID id of user or group - * @param integer $isUser set to 1 if $userOrGroupID is the id of a - * user - */ + /** + * Change access right of document + * This function may change in the future. Instead of passing the a flag + * and a user/group id a user or group object will be expected. + * + * @param integer $newMode access mode + * @param integer $userOrGroupID id of user or group + * @param integer $isUser set to 1 if $userOrGroupID is the id of a + * user + * @return bool + */ function changeAccess($newMode, $userOrGroupID, $isUser) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1182,10 +1227,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * is allowed to remove a notification. This must be checked by the calling * application. * - * @param $userOrGroupID id of user or group - * @param $isUser boolean true if a user is passed in $userOrGroupID, false + * @param integer $userOrGroupID id of user or group + * @param boolean $isUser boolean true if a user is passed in $userOrGroupID, false * if a group is passed in $userOrGroupID - * @param $type type of notification (0 will delete all) Not used yet! + * @param integer $type type of notification (0 will delete all) Not used yet! * @return integer 0 if operation was succesful * -1 if the userid/groupid is invalid * -3 if the user/group is already subscribed diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index 9d2dee1cc..e2c7e2bf8 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -552,8 +552,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * Returns an array of all parents, grand parent, etc. up to root folder. * The folder itself is the last element of the array. * - * @return array Array of parents - */ + * @return array|bool + */ function getPath() { /* {{{ */ if (!isset($this->_parentID) || ($this->_parentID == "") || ($this->_parentID == 0) || ($this->_id == $this->_dms->rootFolderID)) { return array($this); diff --git a/SeedDMS_Core/Core/inc.ClassObject.php b/SeedDMS_Core/Core/inc.ClassObject.php index 3fbe48cf8..e53d2416c 100644 --- a/SeedDMS_Core/Core/inc.ClassObject.php +++ b/SeedDMS_Core/Core/inc.ClassObject.php @@ -38,12 +38,16 @@ class SeedDMS_Core_Object { /* {{{ */ */ public $_dms; + /** + * SeedDMS_Core_Object constructor. + * @param $id + */ function __construct($id) { /* {{{ */ $this->_id = $id; $this->_dms = null; } /* }}} */ - /* + /** * Set dms this object belongs to. * * Each object needs a reference to the dms it belongs to. It will be @@ -51,13 +55,13 @@ class SeedDMS_Core_Object { /* {{{ */ * The dms has a references to the currently logged in user * and the database connection. * - * @param object $dms reference to dms + * @param SeedDMS_Core_DMS $dms reference to dms */ function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ - /* + /** * Return the internal id of the document * * @return integer id of document From 3f2e24f80d6f3c1dea3e887797e4ecfdcb0d4c5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Sat, 28 Oct 2017 14:28:12 +0200 Subject: [PATCH 07/81] inc.ClassFolder.php --- SeedDMS_Core/Core/inc.ClassDMS.php | 2 +- SeedDMS_Core/Core/inc.ClassDocument.php | 89 +++-- SeedDMS_Core/Core/inc.ClassFolder.php | 465 ++++++++++++++---------- 3 files changed, 332 insertions(+), 224 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 704255ce6..f683eb086 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -561,7 +561,7 @@ class SeedDMS_Core_DMS { * If user authentication was done externally, this function can * be used to tell the dms who is currently logged in. * - * @return object $user + * @return SeedDMS_Core_User $user * */ function getLoggedInUser() { /* {{{ */ diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 017ed1571..37ec40bdb 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -186,7 +186,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ protected $_sequence; /** - * @var object temp. storage for latestcontent + * @var SeedDMS_Core_DocumentContent temp. storage for latestcontent */ protected $_latestContent; @@ -200,7 +200,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ */ protected $_folder; - /** @var SeedDMS_Core_UserAccess[] */ + /** @var array of SeedDMS_Core_UserAccess and SeedDMS_Core_GroupAccess */ protected $_accessList; 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. * * @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 */ 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|string $op operation (defaults to O_EQ) - * @return bool|SeedDMS_Core_UserAccess[] + * @return bool|array */ function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */ $db = $this->_dms->getDB(); @@ -970,7 +970,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $accessList = $this->getAccessList(); if (!$accessList) return false; - foreach ($accessList["users"] as $userAccess) { + /** @var SeedDMS_Core_UserAccess $userAccess */ + foreach ($accessList["users"] as $userAccess) { if ($userAccess->getUserID() == $user->getID()) { $mode = $userAccess->getMode(); if ($user->isGuest()) { @@ -983,7 +984,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /* Get the highest right defined by a group */ if($accessList['groups']) { $mode = 0; - foreach ($accessList["groups"] as $groupAccess) { + /** @var SeedDMS_Core_GroupAccess $groupAccess */ + foreach ($accessList["groups"] as $groupAccess) { if ($user->isMemberOfGroup($groupAccess->getGroup())) { if ($groupAccess->getMode() > $mode) $mode = $groupAccess->getMode(); @@ -1014,7 +1016,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * The function takes inherited access rights into account. * 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 */ function getGroupAccessMode($group) { /* {{{ */ @@ -1026,7 +1028,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if (!$accessList) return false; - foreach ($accessList["groups"] as $groupAccess) { + /** @var SeedDMS_Core_GroupAccess $groupAccess */ + foreach ($accessList["groups"] as $groupAccess) { if ($groupAccess->getGroupID() == $group->getID()) { $foundInACL = true; if ($groupAccess->getMode() > $highestPrivileged) @@ -1043,7 +1046,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return $this->getDefaultAccess(); } /* }}} */ - /** + /** * Returns a list of all notifications * * The returned list has two elements called 'users' and 'groups'. Each one @@ -1051,8 +1054,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * SeedDMS_Core_Group. * * @param integer $type type of notification (not yet used) - * @return array list of notifications - */ + * @return array|bool + */ function getNotifyList($type=0) { /* {{{ */ if (empty($this->_notifyList)) { $db = $this->_dms->getDB(); @@ -1092,7 +1095,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /* Make a copy of both notifier lists because removeNotify will empty * $this->_notifyList and the second foreach will not work anymore. */ + /** @var SeedDMS_Core_User[] $nusers */ $nusers = $this->_notifyList["users"]; + /** @var SeedDMS_Core_Group[] $ngroups */ $ngroups = $this->_notifyList["groups"]; foreach ($nusers as $u) { if ($this->getAccessMode($u) < M_READ) { @@ -1172,7 +1177,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ // that the current group has not been explicitly excluded. $acl = $this->getAccessList(M_NONE, O_EQ); $found = false; - foreach ($acl["groups"] as $group) { + /** @var SeedDMS_Core_GroupAccess $group */ + foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; break; @@ -1190,7 +1196,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return -4; } $found = false; - foreach ($acl["groups"] as $group) { + /** @var SeedDMS_Core_GroupAccess $group */ + foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; break; @@ -1240,6 +1247,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $db = $this->_dms->getDB(); /* Verify that user / group exists. */ + /** @var SeedDMS_Core_Group|SeedDMS_Core_User $obj */ $obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID)); if (!is_object($obj)) { return -1; @@ -1315,8 +1323,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * @param array $attributes list of version attributes. The element key * must be the id of the attribute definition. * @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) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1365,7 +1373,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $this->_content = 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->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 // a document be rejected. $pendingReview=false; - $reviewRes = array(); + /** @noinspection PhpUnusedLocalVariableInspection */ + $reviewRes = array(); /** @todo unused variable */ foreach (array("i", "g") as $i){ if (isset($reviewers[$i])) { 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 // and make a recommendation on its release as an approved version. $pendingApproval=false; - $approveRes = array(); + /** @noinspection PhpUnusedLocalVariableInspection */ + $approveRes = array(); /** @todo unused variable */ foreach (array("i", "g") as $i){ if (isset($approvers[$i])) { foreach ($approvers[$i] as $approverID) { @@ -1458,7 +1468,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return false; } - $docResultSet->setStatus($status,$comment,$user); + /** @noinspection PhpMethodParametersCountMismatchInspection */ + $docResultSet->setStatus($status,$comment,$user); /** @todo parameter count wrong */ $db->commitTransaction(); return $docResultSet; @@ -1496,7 +1507,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if ((int) $version<1) { $queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id; $resArr = $db->getResultArray($queryStr); - if (is_bool($resArr) && !$res) + if (is_bool($resArr) && !$res) /** @todo undefined variable */ return false; $version = $resArr[0]['m']; @@ -1551,21 +1562,22 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * out. Access rights based on the document status are calculated for the * currently logged in user. * - * @return array list of objects of class SeedDMS_Core_DocumentContent - */ + * @return bool|SeedDMS_Core_DocumentContent[] + */ function getContent() { /* {{{ */ $db = $this->_dms->getDB(); if (!isset($this->_content)) { $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version`"; $resArr = $db->getResultArray($queryStr); - if (is_bool($resArr) && !$res) + if (is_bool($resArr) && !$res) /** @todo undefined variable */ return false; $this->_content = array(); $classname = $this->_dms->getClassname('documentcontent'); $user = $this->_dms->getLoggedInUser(); 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']); if($user) { if($content->getAccessMode($user) >= M_READ) @@ -1587,7 +1599,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * currently logged in user. * * @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 */ function getContentByVersion($version) { /* {{{ */ @@ -1604,13 +1616,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." AND `version` = " . (int) $version; $resArr = $db->getResultArray($queryStr); - if (is_bool($resArr) && !$res) + if (is_bool($resArr) && !$res) /** @todo undefined variable */ return false; if (count($resArr) != 1) return false; $resArr = $resArr[0]; $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'])) { $user = $this->_dms->getLoggedInUser(); /* 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() { /* {{{ */ if (!$this->_latestContent) { $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 * 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() { /* {{{ */ if (!$this->_latestContent) { $db = $this->_dms->getDB(); $queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = ".$this->_id." ORDER BY `version` DESC"; $resArr = $db->getResultArray($queryStr); - if (is_bool($resArr) && !$res) + if (is_bool($resArr) && !$res) /** @todo: $res not defined */ return false; $classname = $this->_dms->getClassname('documentcontent'); $user = $this->_dms->getLoggedInUser(); foreach ($resArr as $row) { 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']); if($user) { /* 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 * - * @param interger $version version number of content + * @param SeedDMS_Core_DocumentContent $version version number of content * @return boolean true if successful, otherwise false */ private function _removeContent($version) { /* {{{ */ @@ -1813,11 +1830,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ - /** - * Call callback onPreRemoveDocument before deleting content - * - * @param integer $version version number of content - */ + /** + * Call callback onPreRemoveDocument before deleting content + * + * @param SeedDMS_Core_DocumentContent $version version number of content + * @return bool|mixed + */ function removeContent($version) { /* {{{ */ /* Check if 'onPreRemoveDocument' callback is set */ if(isset($this->_dms->callbacks['onPreRemoveContent'])) { @@ -1847,7 +1865,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * Return a certain document 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. */ 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"]); $user = $this->_dms->getLoggedInUser(); if($link->getAccessMode($user, $document, $target) >= M_READ) - return $file; + /** @noinspection PhpUndefinedVariableInspection */ + return $file; /** @todo variable not defined */ return null; } /* }}} */ diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index e2c7e2bf8..ffb348642 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -73,6 +73,48 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { */ 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) { /* {{{ */ parent::__construct($id); $this->_id = $id; @@ -87,14 +129,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $this->_notifyList = array(); } /* }}} */ - /** - * Return an array of database fields which used for searching - * a term entered in the database search form - * - * @param array $searchin integer list of search scopes (2=name, 3=comment, - * 4=attributes) - * @return array list of database fields - */ + /** + * Return an array of database fields which used for searching + * 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, + * 4=attributes) + * @return array list of database fields + */ public static function getSearchFields($dms, $searchin) { /* {{{ */ $db = $dms->getDB(); @@ -125,6 +168,11 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $sql; } /* }}} */ + /** + * @param $id + * @param SeedDMS_Core_DMS $dms + * @return bool|SeedDMS_Core_Folder + */ public static function getInstance($id, $dms) { /* {{{ */ $db = $dms->getDB(); @@ -137,23 +185,25 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $resArr = $resArr[0]; $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->setDMS($dms); return $folder; } /* }}} */ - /* + /** * Get the name of the folder. * * @return string name of folder */ public function getName() { return $this->_name; } - /* - * Set the name of the folder. - * - * @param string $newName set a new name of the folder - */ + /** + * Set the name of the folder. + * + * @param string $newName set a new name of the folder + * @return bool + */ public function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -166,8 +216,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ + /** + * @return string + */ public function getComment() { return $this->_comment; } + /** + * @param $newComment + * @return bool + */ public function setComment($newComment) { /* {{{ */ $db = $this->_dms->getDB(); @@ -215,8 +272,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /** * Returns the parent * - * @return object parent folder or false if there is no parent folder - */ + * @return bool|SeedDMS_Core_Folder + */ public function getParent() { /* {{{ */ if ($this->_id == $this->_dms->rootFolderID || empty($this->_parentID)) { return false; @@ -228,15 +285,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->_parent; } /* }}} */ - /** - * Check if the folder is subfolder - * - * This function checks if the passed folder is a subfolder of the current - * folder. - * - * @param object $subFolder potential sub folder - * @return boolean true if passes folder is a subfolder - */ + /** + * Check if the folder is subfolder + * + * This function checks if the passed folder is a subfolder of the current + * folder. + * + * @param SeedDMS_Core_Folder $subfolder + * @return bool true if passes folder is a subfolder + */ function isSubFolder($subfolder) { /* {{{ */ $target_path = $subfolder->getPath(); foreach($target_path as $next_folder) { @@ -252,7 +309,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * This function moves a folder from one parent folder into another parent * 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 */ public function setParent($newParent) { /* {{{ */ @@ -306,7 +363,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { foreach ($resArr as $row) { $newPath = preg_replace("/^.*:".$this->_id.":(.*$)/", $pathPrefix."\\1", $row["folderList"]); $queryStr="UPDATE `tblDocuments` SET `folderList` = '".$newPath."' WHERE `tblDocuments`.`id` = '".$row["id"]."'"; - $res = $db->getResult($queryStr); + /** @noinspection PhpUnusedLocalVariableInspection */ + $res = $db->getResult($queryStr); } /* Update path in folderList for all documents */ @@ -318,7 +376,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { foreach ($resArr as $row) { $newPath = preg_replace("/^.*:".$this->_id.":(.*$)/", $pathPrefix."\\1", $row["folderList"]); $queryStr="UPDATE `tblFolders` SET `folderList` = '".$newPath."' WHERE `tblFolders`.`id` = '".$row["id"]."'"; - $res = $db->getResult($queryStr); + /** @noinspection PhpUnusedLocalVariableInspection */ + $res = $db->getResult($queryStr); } return true; @@ -338,7 +397,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /** * 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 */ function setOwner($newOwner) { /* {{{ */ @@ -353,6 +412,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ + /** + * @return bool|int + */ function getDefaultAccess() { /* {{{ */ if ($this->inheritsAccess()) { $res = $this->getParent(); @@ -363,15 +425,16 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->_defaultAccess; } /* }}} */ - /** - * Set default access mode - * - * This method sets the default access mode and also removes all notifiers which - * will not have read access anymore. - * - * @param integer $mode access mode - * @param boolean $noclean set to true if notifier list shall not be clean up - */ + /** + * Set default access mode + * + * This method sets the default access mode and also removes all notifiers which + * will not have read access anymore. + * + * @param integer $mode access mode + * @param boolean $noclean set to true if notifier list shall not be clean up + * @return bool + */ function setDefaultAccess($mode, $noclean=false) { /* {{{ */ $db = $this->_dms->getDB(); @@ -443,7 +506,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { function hasSubFolders() { /* {{{ */ $db = $this->_dms->getDB(); 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; $resArr = $db->getResultArray($queryStr); @@ -462,8 +526,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @param string $orderby if set to 'n' the list is ordered by name, otherwise * it will be ordered by sequence * @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") { /* {{{ */ $db = $this->_dms->getDB(); @@ -497,8 +561,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @param integer $sequence position of folder in list of sub folders. * @param array $attributes list of document attributes. The element key * must be the id of the attribute definition. - * @return object object of type SeedDMS_Core_Folder or false in case of - * an error. + * @return bool|SeedDMS_Core_Folder + * an error. */ function addSubFolder($name, $comment, $owner, $sequence, $attributes=array()) { /* {{{ */ $db = $this->_dms->getDB(); @@ -540,7 +604,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /* Check if 'onPostAddSubFolder' callback is set */ if(isset($this->_dms->callbacks['onPostAddSubFolder'])) { foreach($this->_dms->callbacks['onPostAddSubFolder'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $newFolder)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $newFolder)) { } } } @@ -618,7 +683,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { function hasDocuments() { /* {{{ */ $db = $this->_dms->getDB(); 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; $resArr = $db->getResultArray($queryStr); @@ -628,16 +694,18 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $resArr[0]['c']; } /* }}} */ - /** - * Check if folder has document with given name - * - * @return boolean true if document exists, false if not or in case - * of an error - */ + /** + * Check if folder has document with given name + * + * @param string $name + * @return bool true if document exists, false if not or in case + * of an error + */ function hasDocumentByName($name) { /* {{{ */ $db = $this->_dms->getDB(); if (isset($this->_documents)) { - return count($this->documents); + /** @noinspection PhpUndefinedFieldInspection */ /** @todo not $this->_documents? */ + return count($this->documents); } $queryStr = "SELECT count(*) as c FROM `tblDocuments` WHERE `folder` = " . $this->_id . " AND `name` = ".$db->qstr($name); $resArr = $db->getResultArray($queryStr); @@ -656,8 +724,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @param string $orderby if set to 'n' the list is ordered by name, otherwise * it will be ordered by sequence * @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") { /* {{{ */ $db = $this->_dms->getDB(); @@ -682,29 +750,30 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->_documents; } /* }}} */ - /** - * Count all documents and subfolders of the folder - * - * This function also counts documents and folders of subfolders, so - * basically it works like recursively counting children. - * - * This function checks for access rights up the given limit. If more - * documents or folders are found, the returned value will be the number - * of objects available and the precise flag in the return array will be - * set to false. This number should not be revelead to the - * user, because it allows to gain information about the existens of - * objects without access right. - * Setting the parameter $limit to 0 will turn off access right checking - * which is reasonable if the $user is an administrator. - * - * @param string $orderby if set to 'n' the list is ordered by name, otherwise - * it will be ordered by sequence - * @param integer $limit maximum number of folders and documents that will - * be precisly counted by taken the access rights into account - * @return array array with four elements 'document_count', 'folder_count' - * 'document_precise', 'folder_precise' holding - * the counted number and a flag if the number is precise. - */ + /** + * Count all documents and subfolders of the folder + * + * This function also counts documents and folders of subfolders, so + * basically it works like recursively counting children. + * + * This function checks for access rights up the given limit. If more + * documents or folders are found, the returned value will be the number + * of objects available and the precise flag in the return array will be + * set to false. This number should not be revelead to the + * user, because it allows to gain information about the existens of + * objects without access right. + * Setting the parameter $limit to 0 will turn off access right checking + * which is reasonable if the $user is an administrator. + * + * @param SeedDMS_Core_User $user + * @param integer $limit maximum number of folders and documents that will + * be precisly counted by taken the access rights into account + * @return array|bool with four elements 'document_count', 'folder_count' + * 'document_precise', 'folder_precise' holding + * 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) { /* {{{ */ $db = $this->_dms->getDB(); @@ -771,38 +840,38 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { } /* }}} */ // $comment will be used for both document and version leaving empty the version_comment - /** - * Add a new document to the folder - * This function will add a new document and its content from a given file. - * It does not check for access rights on the folder. The new documents - * default access right is read only and the access right is inherited. - * - * @param string $name name of new document - * @param string $comment comment of new document - * @param integer $expires expiration date as a unix timestamp or 0 for no - * expiration date - * @param object $owner owner of the new document - * @param string $keywords keywords of new document - * @param array $categories list of category ids - * @param string $tmpFile the path of the file containing the content - * @param string $orgFileName the original file name - * @param string $fileType usually the extension of the filename - * @param string $mimeType mime type of the content - * @param float $sequence position of new document within the folder - * @param array $reviewers list of users who must review this document - * @param array $approvers list of users who must approve this document - * @param string $reqversion version number of the content - * @param string $version_comment comment of the content. If left empty - * the $comment will be used. - * @param array $attributes list of document attributes. The element key - * must be the id of the attribute definition. - * @param array $version_attributes list of document version attributes. - * The element key must be the id of the attribute definition. - * @param object $workflow - * @return array/boolean false in case of error, otherwise an array - * containing two elements. The first one is the new document, the - * second one is the result set returned when inserting the content. - */ + /** + * Add a new document to the folder + * This function will add a new document and its content from a given file. + * It does not check for access rights on the folder. The new documents + * default access right is read only and the access right is inherited. + * + * @param string $name name of new document + * @param string $comment comment of new document + * @param integer $expires expiration date as a unix timestamp or 0 for no + * expiration date + * @param object $owner owner of the new document + * @param SeedDMS_Core_User $keywords keywords of new document + * @param array $categories list of category ids + * @param string $tmpFile the path of the file containing the content + * @param string $orgFileName the original file name + * @param string $fileType usually the extension of the filename + * @param string $mimeType mime type of the content + * @param float $sequence position of new document within the folder + * @param array $reviewers list of users who must review this document + * @param array $approvers list of users who must approve this document + * @param int|string $reqversion version number of the content + * @param string $version_comment comment of the content. If left empty + * the $comment will be used. + * @param array $attributes list of document attributes. The element key + * must be the id of the attribute definition. + * @param array $version_attributes list of document version attributes. + * The element key must be the id of the attribute definition. + * @param SeedDMS_Core_Workflow $workflow + * @return array|bool false in case of error, otherwise an array + * containing two elements. The first one is the new document, the + * second one is the result set returned when inserting the content. + */ function addDocument($name, $comment, $expires, $owner, $keywords, $categories, $tmpFile, $orgFileName, $fileType, $mimeType, $sequence, $reviewers=array(), $approvers=array(),$reqversion=0,$version_comment="", $attributes=array(), $version_attributes=array(), $workflow=null) { /* {{{ */ $db = $this->_dms->getDB(); @@ -859,7 +928,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /* Check if 'onPostAddDocument' callback is set */ if(isset($this->_dms->callbacks['onPostAddDocument'])) { foreach($this->_dms->callbacks['onPostAddDocument'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $document)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $document)) { } } } @@ -923,7 +993,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /* Check if 'onPostRemoveFolder' callback is set */ if(isset($this->_dms->callbacks['onPostRemoveFolder'])) { foreach($this->_dms->callbacks['onPostRemoveFolder'] as $callback) { - if(!call_user_func($callback[0], $callback[1], $this->_id)) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ + if(!call_user_func($callback[0], $callback[1], $this->_id)) { } } } @@ -939,7 +1010,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @return boolean true on success, false in case of an error */ function remove() { /* {{{ */ - $db = $this->_dms->getDB(); + /** @noinspection PhpUnusedLocalVariableInspection */ + $db = $this->_dms->getDB(); // Do not delete the root folder. if ($this->_id == $this->_dms->rootFolderID || !isset($this->_parentID) || ($this->_parentID == null) || ($this->_parentID == "") || ($this->_parentID == 0)) { @@ -969,24 +1041,24 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->removeFromDatabase(); } /* }}} */ - /** - * Returns a list of access privileges - * - * If the folder inherits the access privileges from the parent folder - * those will be returned. - * $mode and $op can be set to restrict the list of returned access - * privileges. If $mode is set to M_ANY no restriction will apply - * regardless of the value of $op. The returned array contains a list - * of {@link SeedDMS_Core_UserAccess} and - * {@link SeedDMS_Core_GroupAccess} objects. Even if the document - * has no access list the returned array contains the two elements - * 'users' and 'groups' which are than empty. The methode returns false - * if the function fails. - * - * @param integer $mode access mode (defaults to M_ANY) - * @param integer $op operation (defaults to O_EQ) - * @return array multi dimensional array - */ + /** + * Returns a list of access privileges + * + * If the folder inherits the access privileges from the parent folder + * those will be returned. + * $mode and $op can be set to restrict the list of returned access + * privileges. If $mode is set to M_ANY no restriction will apply + * regardless of the value of $op. The returned array contains a list + * of {@link SeedDMS_Core_UserAccess} and + * {@link SeedDMS_Core_GroupAccess} objects. Even if the document + * has no access list the returned array contains the two elements + * 'users' and 'groups' which are than empty. The methode returns false + * if the function fails. + * + * @param int $mode access mode (defaults to M_ANY) + * @param int|string $op operation (defaults to O_EQ) + * @return bool|SeedDMS_Core_GroupAccess|SeedDMS_Core_UserAccess + */ function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1043,16 +1115,17 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ - /** - * Add access right to folder - * This function may change in the future. Instead of passing the a flag - * and a user/group id a user or group object will be expected. - * - * @param integer $mode access mode - * @param integer $userOrGroupID id of user or group - * @param integer $isUser set to 1 if $userOrGroupID is the id of a - * user - */ + /** + * Add access right to folder + * This function may change in the future. Instead of passing the a flag + * and a user/group id a user or group object will be expected. + * + * @param integer $mode access mode + * @param integer $userOrGroupID id of user or group + * @param integer $isUser set to 1 if $userOrGroupID is the id of a + * user + * @return bool + */ function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1073,16 +1146,17 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ - /** - * Change access right of folder - * This function may change in the future. Instead of passing the a flag - * and a user/group id a user or group object will be expected. - * - * @param integer $newMode access mode - * @param integer $userOrGroupID id of user or group - * @param integer $isUser set to 1 if $userOrGroupID is the id of a - * user - */ + /** + * Change access right of folder + * This function may change in the future. Instead of passing the a flag + * and a user/group id a user or group object will be expected. + * + * @param integer $newMode access mode + * @param integer $userOrGroupID id of user or group + * @param integer $isUser set to 1 if $userOrGroupID is the id of a + * user + * @return bool + */ function changeAccess($newMode, $userOrGroupID, $isUser) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1102,6 +1176,11 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ + /** + * @param $userOrGroupID + * @param $isUser + * @return bool + */ function removeAccess($userOrGroupID, $isUser) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1158,7 +1237,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $accessList = $this->getAccessList(); if (!$accessList) return false; - foreach ($accessList["users"] as $userAccess) { + /** @var SeedDMS_Core_UserAccess $userAccess */ + foreach ($accessList["users"] as $userAccess) { if ($userAccess->getUserID() == $user->getID()) { $mode = $userAccess->getMode(); if ($user->isGuest()) { @@ -1171,7 +1251,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /* Get the highest right defined by a group */ if($accessList['groups']) { $mode = 0; - foreach ($accessList["groups"] as $groupAccess) { + /** @var SeedDMS_Core_GroupAccess $groupAccess */ + foreach ($accessList["groups"] as $groupAccess) { if ($user->isMemberOfGroup($groupAccess->getGroup())) { if ($groupAccess->getMode() > $mode) $mode = $groupAccess->getMode(); @@ -1198,7 +1279,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * applied to get the access mode is the same as describe at * {@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 */ function getGroupAccessMode($group) { /* {{{ */ @@ -1208,7 +1289,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { if (!$accessList) return false; - foreach ($accessList["groups"] as $groupAccess) { + /** @var SeedDMS_Core_GroupAccess $groupAccess */ + foreach ($accessList["groups"] as $groupAccess) { if ($groupAccess->getGroupID() == $group->getID()) { $foundInACL = true; if ($groupAccess->getMode() > $highestPrivileged) @@ -1224,13 +1306,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->getDefaultAccess(); } /* }}} */ - /** + /** @noinspection PhpUnusedParameterInspection */ + /** * Get a list of all notification * This function returns all users and groups that have registerd a * notification for the folder * * @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. */ 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 * $this->_notifyList and the second foreach will not work anymore. */ + /** @var SeedDMS_Core_User[] $nusers */ $nusers = $this->_notifyList["users"]; $ngroups = $this->_notifyList["groups"]; foreach ($nusers as $u) { @@ -1279,6 +1363,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $this->removeNotify($u->getID(), true); } } + + /** @var SeedDMS_Core_Group[] $ngroups */ foreach ($ngroups as $g) { if ($this->getGroupAccessMode($g) < M_READ) { $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 * This function does not check if the currently logged in user * 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`"; /* Verify that user / group exists */ + /** @var SeedDMS_Core_User|SeedDMS_Core_Group $obj */ $obj = ($isUser ? $this->_dms->getUser($userOrGroupID) : $this->_dms->getGroup($userOrGroupID)); if (!is_object($obj)) { return -1; @@ -1356,7 +1443,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { // that the current group has not been explicitly excluded. $acl = $this->getAccessList(M_NONE, O_EQ); $found = false; - foreach ($acl["groups"] as $group) { + /** @var SeedDMS_Core_GroupAccess $group */ + foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; break; @@ -1374,7 +1462,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return -4; } $found = false; - foreach ($acl["groups"] as $group) { + /** @var SeedDMS_Core_GroupAccess $group */ + foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; break; @@ -1407,21 +1496,21 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return 0; } /* }}} */ - /* - * Removes notify for a user or group to folder - * This function does not check if the currently logged in user - * is allowed to remove a notification. This must be checked by the calling - * application. - * - * @param integer $userOrGroupID - * @param boolean $isUser true if $userOrGroupID is a user id otherwise false - * @param $type type of notification (0 will delete all) Not used yet! - * @return integer error code - * -1: Invalid User/Group ID. - * -3: User is not subscribed. - * -4: Database / internal error. - * 0: Update successful. - */ + /** + * Removes notify for a user or group to folder + * This function does not check if the currently logged in user + * is allowed to remove a notification. This must be checked by the calling + * application. + * + * @param integer $userOrGroupID + * @param boolean $isUser true if $userOrGroupID is a user id otherwise false + * @param int $type type of notification (0 will delete all) Not used yet! + * @return int error code + * -1: Invalid User/Group ID. + * -3: User is not subscribed. + * -4: Database / internal error. + * 0: Update successful. + */ function removeNotify($userOrGroupID, $isUser, $type=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1494,17 +1583,16 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return $this->getReadAccessList(0, 0); } /* }}} */ - /** - * Returns a list of groups and users with read access on the folder - * The list will not include any guest users, - * administrators and the owner of the folder unless $listadmin resp. - * $listowner is set to true. - * - * @param boolean $listadmin if set to true any admin will be listed too - * @param boolean $listowner if set to true the owner will be listed too - * - * @return array list of users and groups - */ + /** + * Returns a list of groups and users with read access on the folder + * The list will not include any guest users, + * administrators and the owner of the folder unless $listadmin resp. + * $listowner is set to true. + * + * @param bool|int $listadmin if set to true any admin 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 + */ function getReadAccessList($listadmin=0, $listowner=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1530,9 +1618,12 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { // to the folder. $tmpList = $this->getAccessList(M_NONE, O_LTEQ); } + /** @var SeedDMS_Core_GroupAccess $groupAccess */ foreach ($tmpList["groups"] as $groupAccess) { $groupIDs .= (strlen($groupIDs)==0 ? "" : ", ") . $groupAccess->getGroupID(); } + + /** @var SeedDMS_Core_UserAccess $userAccess */ foreach ($tmpList["users"] as $userAccess) { $user = $userAccess->getUser(); if (!$listadmin && $user->isAdmin()) continue; @@ -1671,6 +1762,4 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ -} - -?> +} \ No newline at end of file From fd5f341cb92eaece7cb60fa93e4d95e3265fb6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Neugebauer?= Date: Wed, 8 Nov 2017 13:54:49 +0100 Subject: [PATCH 08/81] SeedDMS_Core --- SeedDMS_Core/Core.php | 2 - SeedDMS_Core/Core/inc.ClassGroup.php | 68 +++- SeedDMS_Core/Core/inc.ClassKeywords.php | 49 ++- SeedDMS_Core/Core/inc.ClassUser.php | 277 +++++++++++---- SeedDMS_Core/Core/inc.ClassWorkflow.php | 410 ++++++++++++++++------ SeedDMS_Core/Core/inc.DBAccess.php | 67 ++-- SeedDMS_Core/Core/inc.DBAccessPDO.php | 98 +++--- SeedDMS_Core/Core/inc.FileUtils.php | 113 ++++-- SeedDMS_Lucene/Lucene/IndexedDocument.php | 19 +- 9 files changed, 818 insertions(+), 285 deletions(-) diff --git a/SeedDMS_Core/Core.php b/SeedDMS_Core/Core.php index 667a8554c..5006e3777 100644 --- a/SeedDMS_Core/Core.php +++ b/SeedDMS_Core/Core.php @@ -90,5 +90,3 @@ require_once('Core/inc.AccessUtils.php'); * @uses SeedDMS_File */ require_once('Core/inc.FileUtils.php'); - -?> diff --git a/SeedDMS_Core/Core/inc.ClassGroup.php b/SeedDMS_Core/Core/inc.ClassGroup.php index 7f7ab18f9..ab0b71e2e 100644 --- a/SeedDMS_Core/Core/inc.ClassGroup.php +++ b/SeedDMS_Core/Core/inc.ClassGroup.php @@ -36,6 +36,11 @@ class SeedDMS_Core_Group { /* {{{ */ */ protected $_name; + /** + * @var SeedDMS_Core_User[] + */ + protected $_users; + /** * The comment of the user group * @@ -46,7 +51,7 @@ class SeedDMS_Core_Group { /* {{{ */ /** * Back reference to DMS this user group belongs to * - * @var object + * @var SeedDMS_Core_DMS */ protected $_dms; @@ -62,10 +67,10 @@ class SeedDMS_Core_Group { /* {{{ */ * * @param string|integer $id Id, name of group, depending * on the 3rd parameter. - * @param object $dms instance of dms + * @param SeedDMS_Core_DMS $dms instance of dms * @param string $by search by group name if set to 'name'. * Search by Id of group if left empty. - * @return object instance of class SeedDMS_Core_Group + * @return SeedDMS_Core_Group|false instance of class SeedDMS_Core_Group */ public static function getInstance($id, $dms, $by='') { /* {{{ */ $db = $dms->getDB(); @@ -91,6 +96,11 @@ class SeedDMS_Core_Group { /* {{{ */ return $group; } /* }}} */ + /** + * @param $orderby + * @param SeedDMS_Core_DMS $dms + * @return array|bool + */ public static function getAllInstances($orderby, $dms) { /* {{{ */ $db = $dms->getDB(); @@ -113,14 +123,27 @@ class SeedDMS_Core_Group { /* {{{ */ return $groups; } /* }}} */ + /** + * @param SeedDMS_Core_DMS $dms + */ function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return string + */ function getName() { return $this->_name; } + /** + * @param $newName + * @return bool + */ function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -132,8 +155,15 @@ class SeedDMS_Core_Group { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getComment() { return $this->_comment; } + /** + * @param $newComment + * @return bool + */ function setComment($newComment) { /* {{{ */ $db = $this->_dms->getDB(); @@ -145,6 +175,9 @@ class SeedDMS_Core_Group { /* {{{ */ return true; } /* }}} */ + /** + * @return SeedDMS_Core_User[]|bool + */ function getUsers() { /* {{{ */ $db = $this->_dms->getDB(); @@ -159,7 +192,8 @@ class SeedDMS_Core_Group { /* {{{ */ $this->_users = array(); $classname = $this->_dms->getClassname('user'); - foreach ($resArr as $row) { + foreach ($resArr as $row) { + /** @var SeedDMS_Core_User $user */ $user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["role"], $row['hidden']); array_push($this->_users, $user); } @@ -167,6 +201,9 @@ class SeedDMS_Core_Group { /* {{{ */ return $this->_users; } /* }}} */ + /** + * @return SeedDMS_Core_User[]|bool + */ function getManagers() { /* {{{ */ $db = $this->_dms->getDB(); @@ -180,13 +217,19 @@ class SeedDMS_Core_Group { /* {{{ */ $managers = array(); $classname = $this->_dms->getClassname('user'); - foreach ($resArr as $row) { + foreach ($resArr as $row) { + /** @var SeedDMS_Core_User $user */ $user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $row["role"], $row['hidden']); array_push($managers, $user); } return $managers; } /* }}} */ + /** + * @param SeedDMS_Core_User $user + * @param bool $asManager + * @return bool + */ function addUser($user,$asManager=false) { /* {{{ */ $db = $this->_dms->getDB(); @@ -199,6 +242,10 @@ class SeedDMS_Core_Group { /* {{{ */ return true; } /* }}} */ + /** + * @param SeedDMS_Core_User $user + * @return bool + */ function removeUser($user) { /* {{{ */ $db = $this->_dms->getDB(); @@ -213,7 +260,7 @@ class SeedDMS_Core_Group { /* {{{ */ /** * Check if user is member of group * - * @param object $user user to be checked + * @param SeedDMS_Core_User $user user to be checked * @param boolean $asManager also check whether user is manager of group if * set to true, otherwise does not care about manager status * @return boolean true if user is member, otherwise false @@ -241,7 +288,7 @@ class SeedDMS_Core_Group { /* {{{ */ /** * Toggle manager status of user * - * @param object $user + * @param SeedDMS_Core_User $user * @return boolean true if operation was successful, otherwise false */ function toggleManager($user) { /* {{{ */ @@ -261,7 +308,7 @@ class SeedDMS_Core_Group { /* {{{ */ * This function deletes the user group and all it references, like access * control lists, notifications, as a child of other groups, etc. * - * @param object $user the user doing the removal (needed for entry in + * @param SeedDMS_Core_User $user the user doing the removal (needed for entry in * review log. * @return boolean true on success or false in case of an error */ @@ -405,7 +452,7 @@ class SeedDMS_Core_Group { /* {{{ */ * @param int $documentID optional document id for which to retrieve the * reviews * @param int $version optional version of the document - * @return array list of all workflows + * @return bool|array list of all workflows */ function getWorkflowStatus($documentID=null, $version=null) { /* {{{ */ $db = $this->_dms->getDB(); @@ -432,7 +479,7 @@ class SeedDMS_Core_Group { /* {{{ */ * Get all notifications of group * * @param integer $type type of item (T_DOCUMENT or T_FOLDER) - * @return array array of notifications + * @return SeedDMS_Core_Notification[]|bool array of notifications */ function getNotifications($type=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -457,4 +504,3 @@ class SeedDMS_Core_Group { /* {{{ */ } /* }}} */ } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassKeywords.php b/SeedDMS_Core/Core/inc.ClassKeywords.php index 0d58457be..0981023d3 100644 --- a/SeedDMS_Core/Core/inc.ClassKeywords.php +++ b/SeedDMS_Core/Core/inc.ClassKeywords.php @@ -42,11 +42,17 @@ class SeedDMS_Core_KeywordCategory { protected $_name; /** - * @var object $_dms reference to dms this category belongs to + * @var SeedDMS_Core_DMS $_dms reference to dms this category belongs to * @access protected */ protected $_dms; + /** + * SeedDMS_Core_KeywordCategory constructor. + * @param $id + * @param $ownerID + * @param $name + */ function __construct($id, $ownerID, $name) { $this->_id = $id; $this->_name = $name; @@ -54,20 +60,36 @@ class SeedDMS_Core_KeywordCategory { $this->_dms = null; } + /** + * @param SeedDMS_Core_DMS $dms + */ function setDMS($dms) { $this->_dms = $dms; } + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return string + */ function getName() { return $this->_name; } + /** + * @return bool|SeedDMS_Core_User + */ function getOwner() { if (!isset($this->_owner)) $this->_owner = $this->_dms->getUser($this->_ownerID); return $this->_owner; } + /** + * @param $newName + * @return bool + */ function setName($newName) { $db = $this->_dms->getDB(); @@ -79,6 +101,10 @@ class SeedDMS_Core_KeywordCategory { return true; } + /** + * @param SeedDMS_Core_User $user + * @return bool + */ function setOwner($user) { $db = $this->_dms->getDB(); @@ -91,6 +117,9 @@ class SeedDMS_Core_KeywordCategory { return true; } + /** + * @return array + */ function getKeywordLists() { $db = $this->_dms->getDB(); @@ -98,6 +127,11 @@ class SeedDMS_Core_KeywordCategory { return $db->getResultArray($queryStr); } + /** + * @param $listID + * @param $keywords + * @return bool + */ function editKeywordList($listID, $keywords) { $db = $this->_dms->getDB(); @@ -105,6 +139,10 @@ class SeedDMS_Core_KeywordCategory { return $db->getResult($queryStr); } + /** + * @param $keywords + * @return bool + */ function addKeywordList($keywords) { $db = $this->_dms->getDB(); @@ -112,6 +150,10 @@ class SeedDMS_Core_KeywordCategory { return $db->getResult($queryStr); } + /** + * @param $listID + * @return bool + */ function removeKeywordList($listID) { $db = $this->_dms->getDB(); @@ -119,6 +161,9 @@ class SeedDMS_Core_KeywordCategory { return $db->getResult($queryStr); } + /** + * @return bool + */ function remove() { $db = $this->_dms->getDB(); @@ -139,5 +184,3 @@ class SeedDMS_Core_KeywordCategory { return true; } } - -?> diff --git a/SeedDMS_Core/Core/inc.ClassUser.php b/SeedDMS_Core/Core/inc.ClassUser.php index 25260c333..b1aa6aba9 100644 --- a/SeedDMS_Core/Core/inc.ClassUser.php +++ b/SeedDMS_Core/Core/inc.ClassUser.php @@ -117,23 +117,51 @@ class SeedDMS_Core_User { /* {{{ */ var $_loginFailures; /** - * @var object home folder + * @var SeedDMS_Core_Folder home folder * * @access protected */ var $_homeFolder; /** - * @var object reference to the dms instance this user belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this user belongs to * * @access protected */ var $_dms; + /** + * @var int + */ + private $_quota; + + /** + * @var bool + */ + private $_hasImage; + const role_user = '0'; const role_admin = '1'; const role_guest = '2'; + /** + * SeedDMS_Core_User constructor. + * @param $id + * @param $login + * @param $pwd + * @param $fullName + * @param $email + * @param $language + * @param $theme + * @param $comment + * @param $role + * @param int $isHidden + * @param int $isDisabled + * @param string $pwdExpiration + * @param int $loginFailures + * @param int $quota + * @param null $homeFolder + */ function __construct($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $role, $isHidden=0, $isDisabled=0, $pwdExpiration='', $loginFailures=0, $quota=0, $homeFolder=null) { $this->_id = $id; $this->_login = $login; @@ -158,12 +186,12 @@ class SeedDMS_Core_User { /* {{{ */ * * @param string|integer $id Id, login name, or email of user, depending * on the 3rd parameter. - * @param object $dms instance of dms + * @param SeedDMS_Core_DMS $dms instance of dms * @param string $by search by [name|email]. If 'name' is passed, the method * will check for the 4th paramater and also filter by email. If this * parameter is left empty, the user will be search by its Id. * @param string $email optional email address if searching for name - * @return object instance of class SeedDMS_Core_User + * @return SeedDMS_Core_User|bool instance of class SeedDMS_Core_User */ public static function getInstance($id, $dms, $by='', $email='') { /* {{{ */ $db = $dms->getDB(); @@ -192,6 +220,11 @@ class SeedDMS_Core_User { /* {{{ */ return $user; } /* }}} */ + /** + * @param $orderby + * @param SeedDMS_Core_DMS $dms + * @return SeedDMS_Core_User[]|bool + */ public static function getAllInstances($orderby, $dms) { /* {{{ */ $db = $dms->getDB(); @@ -207,6 +240,7 @@ class SeedDMS_Core_User { /* {{{ */ $users = array(); for ($i = 0; $i < count($resArr); $i++) { + /** @var SeedDMS_Core_User $user */ $user = new self($resArr[$i]["id"], $resArr[$i]["login"], $resArr[$i]["pwd"], $resArr[$i]["fullName"], $resArr[$i]["email"], (isset($resArr[$i]["language"])?$resArr[$i]["language"]:NULL), (isset($resArr[$i]["theme"])?$resArr[$i]["theme"]:NULL), $resArr[$i]["comment"], $resArr[$i]["role"], $resArr[$i]["hidden"], $resArr[$i]["disabled"], $resArr[$i]["pwdExpiration"], $resArr[$i]["loginfailures"], $resArr[$i]["quota"], $resArr[$i]["homefolder"]); $user->setDMS($dms); $users[$i] = $user; @@ -215,14 +249,27 @@ class SeedDMS_Core_User { /* {{{ */ return $users; } /* }}} */ + /** + * @param SeedDMS_Core_DMS $dms + */ function setDMS($dms) { $this->_dms = $dms; } + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return string + */ function getLogin() { return $this->_login; } + /** + * @param $newLogin + * @return bool + */ function setLogin($newLogin) { /* {{{ */ $db = $this->_dms->getDB(); @@ -235,8 +282,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getFullName() { return $this->_fullName; } + /** + * @param $newFullName + * @return bool + */ function setFullName($newFullName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -249,8 +303,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getPwd() { return $this->_pwd; } + /** + * @param $newPwd + * @return bool + */ function setPwd($newPwd) { /* {{{ */ $db = $this->_dms->getDB(); @@ -263,8 +324,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getPwdExpiration() { return $this->_pwdExpiration; } + /** + * @param $newPwdExpiration + * @return bool + */ function setPwdExpiration($newPwdExpiration) { /* {{{ */ $db = $this->_dms->getDB(); @@ -283,8 +351,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getEmail() { return $this->_email; } + /** + * @param $newEmail + * @return bool + */ function setEmail($newEmail) { /* {{{ */ $db = $this->_dms->getDB(); @@ -297,9 +372,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function getLanguage() { return $this->_language; } + /** + * @return string + */ + function getLanguage() { return $this->_language; } - function setLanguage($newLanguage) { /* {{{ */ + /** + * @param $newLanguage + * @return bool + */ + function setLanguage($newLanguage) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `language` =".$db->qstr($newLanguage)." WHERE `id` = " . $this->_id; @@ -311,9 +393,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function getTheme() { return $this->_theme; } + /** + * @return string + */ + function getTheme() { return $this->_theme; } - function setTheme($newTheme) { /* {{{ */ + /** + * @param string $newTheme + * @return bool + */ + function setTheme($newTheme) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `theme` =".$db->qstr($newTheme)." WHERE `id` = " . $this->_id; @@ -325,9 +414,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function getComment() { return $this->_comment; } + /** + * @return string + */ + function getComment() { return $this->_comment; } - function setComment($newComment) { /* {{{ */ + /** + * @param $newComment + * @return bool + */ + function setComment($newComment) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `comment` =".$db->qstr($newComment)." WHERE `id` = " . $this->_id; @@ -339,9 +435,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function getRole() { return $this->_role; } + /** + * @return string + */ + function getRole() { return $this->_role; } - function setRole($newrole) { /* {{{ */ + /** + * @param $newrole + * @return bool + */ + function setRole($newrole) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `role` = " . $newrole . " WHERE `id` = " . $this->_id; @@ -352,9 +455,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function isAdmin() { return ($this->_role == SeedDMS_Core_User::role_admin); } + /** + * @return bool + */ + function isAdmin() { return ($this->_role == SeedDMS_Core_User::role_admin); } - function setAdmin($isAdmin) { /* {{{ */ + /** + * @return bool + */ + function setAdmin() { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `role` = " . SeedDMS_Core_User::role_admin . " WHERE `id` = " . $this->_id; @@ -365,9 +474,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function isGuest() { return ($this->_role == SeedDMS_Core_User::role_guest); } + /** + * @return bool + */ + function isGuest() { return ($this->_role == SeedDMS_Core_User::role_guest); } - function setGuest($isGuest) { /* {{{ */ + /** + * @return bool + */ + function setGuest() { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `role` = " . SeedDMS_Core_User::role_guest . " WHERE `id` = " . $this->_id; @@ -378,9 +493,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function isHidden() { return $this->_isHidden; } + /** + * @return bool|int + */ + function isHidden() { return $this->_isHidden; } - function setHidden($isHidden) { /* {{{ */ + /** + * @param $isHidden + * @return bool + */ + function setHidden($isHidden) { /* {{{ */ $db = $this->_dms->getDB(); $isHidden = ($isHidden) ? "1" : "0"; @@ -392,9 +514,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function isDisabled() { return $this->_isDisabled; } + /** + * @return bool|int + */ + function isDisabled() { return $this->_isDisabled; } - function setDisabled($isDisabled) { /* {{{ */ + /** + * @param $isDisabled + * @return bool + */ + function setDisabled($isDisabled) { /* {{{ */ $db = $this->_dms->getDB(); $isDisabled = ($isDisabled) ? "1" : "0"; @@ -406,7 +535,10 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function addLoginFailure() { /* {{{ */ + /** + * @return bool|int + */ + function addLoginFailure() { /* {{{ */ $db = $this->_dms->getDB(); $this->_loginFailures++; @@ -417,7 +549,10 @@ class SeedDMS_Core_User { /* {{{ */ return $this->_loginFailures; } /* }}} */ - function clearLoginFailures() { /* {{{ */ + /** + * @return bool + */ + function clearLoginFailures() { /* {{{ */ $db = $this->_dms->getDB(); $this->_loginFailures = 0; @@ -447,9 +582,16 @@ class SeedDMS_Core_User { /* {{{ */ return $resArr[0]['sum']; } /* }}} */ - function getQuota() { return $this->_quota; } + /** + * @return int + */ + function getQuota() { return $this->_quota; } - function setQuota($quota) { /* {{{ */ + /** + * @param $quota + * @return bool + */ + function setQuota($quota) { /* {{{ */ $db = $this->_dms->getDB(); $quota = intval($quota); @@ -461,9 +603,16 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - function getHomeFolder() { return $this->_homeFolder; } + /** + * @return null|SeedDMS_Core_Folder + */ + function getHomeFolder() { return $this->_homeFolder; } - function setHomeFolder($homefolder) { /* {{{ */ + /** + * @param $homefolder + * @return bool + */ + function setHomeFolder($homefolder) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblUsers` SET `homefolder` = " . ($homefolder ? (int) $homefolder : NULL) . " WHERE `id` = " . $this->_id; @@ -655,9 +804,9 @@ class SeedDMS_Core_User { /* {{{ */ * Do not remove folders and documents of the user, but assign them * to a different user. * - * @param object $user the user doing the removal (needed for entry in + * @param SeedDMS_Core_User $user the user doing the removal (needed for entry in * review and approve log). - * @param object $assignToUser the user who is new owner of folders and + * @param SeedDMS_Core_User $assignToUser the user who is new owner of folders and * documents which previously were owned by the delete user. * @return boolean true on success or false in case of an error */ @@ -670,8 +819,9 @@ class SeedDMS_Core_User { /* {{{ */ * anymore. */ if(!$assignToUser) - return; - $assignTo = $assignToUser->getID(); + return false; + /** @noinspection PhpUnusedLocalVariableInspection */ + $assignTo = $assignToUser->getID(); $db->startTransaction(); @@ -827,7 +977,7 @@ class SeedDMS_Core_User { /* {{{ */ * This function uses {@link SeedDMS_Group::addUser} but checks before if * the user is already a member of the group. * - * @param object $group group to be the member of + * @param SeedDMS_Core_Group $group group to be the member of * @return boolean true on success or false in case of an error or the user * is already a member of the group */ @@ -847,7 +997,7 @@ class SeedDMS_Core_User { /* {{{ */ * This function uses {@link SeedDMS_Group::removeUser} but checks before if * the user is a member of the group at all. * - * @param object $group group to leave + * @param SeedDMS_Core_Group $group group to leave * @return boolean true on success or false in case of an error or the user * is not a member of the group */ @@ -865,7 +1015,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Get all groups the user is a member of * - * @return array list of groups + * @return SeedDMS_Core_Group[]|bool list of groups */ function getGroups() { /* {{{ */ $db = $this->_dms->getDB(); @@ -882,6 +1032,7 @@ class SeedDMS_Core_User { /* {{{ */ $this->_groups = array(); $classname = $this->_dms->getClassname('group'); foreach ($resArr as $row) { + /** @var SeedDMS_Core_Group $group */ $group = new $classname($row["id"], $row["name"], $row["comment"]); $group->setDMS($this->_dms); array_push($this->_groups, $group); @@ -893,7 +1044,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Checks if user is member of a given group * - * @param object $group + * @param SeedDMS_Core_Group $group * @return boolean true if user is member of the given group otherwise false */ function isMemberOfGroup($group) { /* {{{ */ @@ -924,7 +1075,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Get the image from the users profile * - * @return array image data + * @return array|bool image data */ function getImage() { /* {{{ */ $db = $this->_dms->getDB(); @@ -939,7 +1090,12 @@ class SeedDMS_Core_User { /* {{{ */ return $resArr; } /* }}} */ - function setImage($tmpfile, $mimeType) { /* {{{ */ + /** + * @param $tmpfile + * @param $mimeType + * @return bool + */ + function setImage($tmpfile, $mimeType) { /* {{{ */ $db = $this->_dms->getDB(); $fp = fopen($tmpfile, "rb"); @@ -958,12 +1114,10 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ - /** - * Returns all documents of a given user - * - * @param object $user - * @return array list of documents - */ + /** + * Returns all documents of a given user + * @return SeedDMS_Core_Document[]|bool list of documents + */ function getDocuments() { /* {{{ */ $db = $this->_dms->getDB(); @@ -979,6 +1133,7 @@ class SeedDMS_Core_User { /* {{{ */ $documents = array(); $classname = $this->_dms->getClassname('document'); foreach ($resArr as $row) { + /** @var SeedDMS_Core_Document $document */ $document = new $classname($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]); $document->setDMS($this->_dms); $documents[] = $document; @@ -989,8 +1144,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Returns all documents locked by a given user * - * @param object $user - * @return array list of documents + * @return bool|SeedDMS_Core_Document[] list of documents */ function getDocumentsLocked() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1007,6 +1161,7 @@ class SeedDMS_Core_User { /* {{{ */ $documents = array(); $classname = $this->_dms->getClassname('document'); foreach ($resArr as $row) { + /** @var SeedDMS_Core_Document $document */ $document = new $classname($row["id"], $row["name"], $row["comment"], $row["date"], $row["expires"], $row["owner"], $row["folder"], $row["inheritAccess"], $row["defaultAccess"], $row["lockUser"], $row["keywords"], $row["sequence"]); $document->setDMS($this->_dms); $documents[] = $document; @@ -1032,7 +1187,7 @@ class SeedDMS_Core_User { /* {{{ */ * @param int $documentID optional document id for which to retrieve the * reviews * @param int $version optional version of the document - * @return array list of all reviews + * @return array|bool list of all reviews */ function getReviewStatus($documentID=null, $version=null) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1125,7 +1280,7 @@ class SeedDMS_Core_User { /* {{{ */ * @param int $documentID optional document id for which to retrieve the * approvals * @param int $version optional version of the document - * @return array list of all approvals + * @return array|bool list of all approvals */ function getApprovalStatus($documentID=null, $version=null) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1195,7 +1350,7 @@ class SeedDMS_Core_User { /* {{{ */ * @param int $documentID optional document id for which to retrieve the * reviews * @param int $version optional version of the document - * @return array list of all workflows + * @return array|bool list of all workflows */ function getWorkflowStatus($documentID=null, $version=null) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1237,7 +1392,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Get a list of workflows this user is involved as in individual * - * @return array list of all workflows + * @return array|bool list of all workflows */ function getWorkflowsInvolved() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1297,7 +1452,7 @@ class SeedDMS_Core_User { /* {{{ */ * This method is the reverse function of getMandatoryReviewers(). It returns * those user where the current user is a mandatory reviewer. * - * @return array list of users where this user is a mandatory reviewer. + * @return SeedDMS_Core_User[]|bool list of users where this user is a mandatory reviewer. */ function isMandatoryReviewerOf() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1320,7 +1475,7 @@ class SeedDMS_Core_User { /* {{{ */ * This method is the reverse function of getMandatoryApprovers(). It returns * those user where the current user is a mandatory approver. * - * @return array list of users where this user is a mandatory approver. + * @return SeedDMS_Core_User[]|bool list of users where this user is a mandatory approver. */ function isMandatoryApproverOf() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1344,7 +1499,7 @@ class SeedDMS_Core_User { /* {{{ */ * Whenever the user inserts a new document the mandatory workflow is * filled in as the workflow. * - * @return object workflow + * @return SeedDMS_Core_Workflow|bool workflow */ function getMandatoryWorkflow() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1367,7 +1522,7 @@ class SeedDMS_Core_User { /* {{{ */ * Whenever the user inserts a new document the mandatory workflow is * filled in as the workflow. * - * @return object workflow + * @return SeedDMS_Core_Workflow[]|bool workflow */ function getMandatoryWorkflows() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1418,6 +1573,7 @@ class SeedDMS_Core_User { /* {{{ */ if (is_bool($resArr) && !$resArr) return false; } + return false; } /* }}} */ /** @@ -1435,7 +1591,7 @@ class SeedDMS_Core_User { /* {{{ */ $queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverGroupID` = " . (int) $id; $resArr = $db->getResultArray($queryStr); - if (count($resArr)!=0) return; + if (count($resArr)!=0) return true; $queryStr = "INSERT INTO `tblMandatoryApprovers` (`userID`, `approverGroupID`) VALUES (" . $this->_id . ", " . $id .")"; $resArr = $db->getResult($queryStr); @@ -1445,12 +1601,14 @@ class SeedDMS_Core_User { /* {{{ */ $queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverUserID` = " . (int) $id; $resArr = $db->getResultArray($queryStr); - if (count($resArr)!=0) return; + if (count($resArr)!=0) return true; $queryStr = "INSERT INTO `tblMandatoryApprovers` (`userID`, `approverUserID`) VALUES (" . $this->_id . ", " . $id .")"; $resArr = $db->getResult($queryStr); if (is_bool($resArr) && !$resArr) return false; } + + return false; } /* }}} */ /** @@ -1465,18 +1623,20 @@ class SeedDMS_Core_User { /* {{{ */ $queryStr = "SELECT * FROM `tblWorkflowMandatoryWorkflow` WHERE `userid` = " . $this->_id . " AND `workflow` = " . (int) $workflow->getID(); $resArr = $db->getResultArray($queryStr); - if (count($resArr)!=0) return; + if (count($resArr)!=0) return true; $queryStr = "INSERT INTO `tblWorkflowMandatoryWorkflow` (`userid`, `workflow`) VALUES (" . $this->_id . ", " . $workflow->getID() .")"; $resArr = $db->getResult($queryStr); if (is_bool($resArr) && !$resArr) return false; + + return false; } /* }}} */ /** * Set a mandatory workflows * This function sets a list of mandatory workflows. * - * @param array $workflows list of workflow objects + * @param SeedDMS_Core_Workflow[] $workflows list of workflow objects * @return boolean true on success, otherwise false */ function setMandatoryWorkflows($workflows) { /* {{{ */ @@ -1543,7 +1703,7 @@ class SeedDMS_Core_User { /* {{{ */ * Get all notifications of user * * @param integer $type type of item (T_DOCUMENT or T_FOLDER) - * @return array array of notifications + * @return SeedDMS_Core_Notification[]|bool array of notifications */ function getNotifications($type=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1570,7 +1730,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Return list of personal keyword categories * - * @return array/boolean list of categories or false in case of an error + * @return SeedDMS_Core_KeywordCategory[]|bool list of categories or false in case of an error */ function getKeywordCategories() { /* {{{ */ $db = $this->_dms->getDB(); @@ -1592,4 +1752,3 @@ class SeedDMS_Core_User { /* {{{ */ } /* }}} */ } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassWorkflow.php b/SeedDMS_Core/Core/inc.ClassWorkflow.php index 474ae3c3c..3360f5d19 100644 --- a/SeedDMS_Core/Core/inc.ClassWorkflow.php +++ b/SeedDMS_Core/Core/inc.ClassWorkflow.php @@ -29,33 +29,39 @@ class SeedDMS_Core_Workflow { /* {{{ */ var $_id; /** - * @var name of the workflow + * @var string name of the workflow * * @access protected */ var $_name; /** - * @var initial state of the workflow + * @var SeedDMS_Core_Workflow_State initial state of the workflow * * @access protected */ var $_initstate; /** - * @var name of the workflow state + * @var SeedDMS_Core_Workflow_Transition[] name of the workflow state * * @access protected */ var $_transitions; /** - * @var object reference to the dms instance this attribute belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to * * @access protected */ var $_dms; + /** + * SeedDMS_Core_Workflow constructor. + * @param int $id + * @param string $name + * @param SeedDMS_Core_Workflow_State $initstate + */ function __construct($id, $name, $initstate) { /* {{{ */ $this->_id = $id; $this->_name = $name; @@ -64,15 +70,28 @@ class SeedDMS_Core_Workflow { /* {{{ */ $this->_dms = null; } /* }}} */ - function setDMS($dms) { /* {{{ */ + /** + * @param SeedDMS_Core_DMS $dms + */ + function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ - function getID() { return $this->_id; } + /** + * @return int + */ + function getID() { return $this->_id; } - function getName() { return $this->_name; } + /** + * @return string + */ + function getName() { return $this->_name; } - function setName($newName) { /* {{{ */ + /** + * @param $newName + * @return bool + */ + function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflows` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id; @@ -84,9 +103,16 @@ class SeedDMS_Core_Workflow { /* {{{ */ return true; } /* }}} */ - function getInitState() { return $this->_initstate; } + /** + * @return SeedDMS_Core_Workflow_State + */ + function getInitState() { return $this->_initstate; } - function setInitState($state) { /* {{{ */ + /** + * @param SeedDMS_Core_Workflow_State $state + * @return bool + */ + function setInitState($state) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflows` SET `initstate` = ".$state->getID()." WHERE `id` = " . $this->_id; @@ -98,7 +124,10 @@ class SeedDMS_Core_Workflow { /* {{{ */ return true; } /* }}} */ - function getTransitions() { /* {{{ */ + /** + * @return SeedDMS_Core_Workflow_Transition[]|bool + */ + function getTransitions() { /* {{{ */ $db = $this->_dms->getDB(); if($this->_transitions) @@ -121,8 +150,12 @@ class SeedDMS_Core_Workflow { /* {{{ */ return $this->_transitions; } /* }}} */ - function getStates() { /* {{{ */ - $db = $this->_dms->getDB(); + /** + * @return array + */ + function getStates() { /* {{{ */ + /** @noinspection PhpUnusedLocalVariableInspection */ + $db = $this->_dms->getDB(); if(!$this->_transitions) $this->getTransitions(); @@ -138,14 +171,15 @@ class SeedDMS_Core_Workflow { /* {{{ */ return $states; } /* }}} */ - /** - * Get the transition by its id - * - * @param integer $id id of transition - * @param object transition - */ + /** + * Get the transition by its id + * + * @param integer $id id of transition + * @return bool|SeedDMS_Core_Workflow_Transition + */ function getTransition($id) { /* {{{ */ - $db = $this->_dms->getDB(); + /** @noinspection PhpUnusedLocalVariableInspection */ + $db = $this->_dms->getDB(); if(!$this->_transitions) $this->getTransitions(); @@ -156,12 +190,12 @@ class SeedDMS_Core_Workflow { /* {{{ */ return false; } /* }}} */ - /** - * Get the transitions that can be triggered while being in the given state - * - * @param object $state current workflow state - * @param array list of transitions - */ + /** + * Get the transitions that can be triggered while being in the given state + * + * @param SeedDMS_Core_Workflow_State $state current workflow state + * @return SeedDMS_Core_Workflow_Transition[]|bool + */ function getNextTransitions($state) { /* {{{ */ $db = $this->_dms->getDB(); @@ -180,12 +214,12 @@ class SeedDMS_Core_Workflow { /* {{{ */ return $wkftransitions; } /* }}} */ - /** - * Get the transitions that lead to the given state - * - * @param object $state current workflow state - * @param array list of transitions - */ + /** + * Get the transitions that lead to the given state + * + * @param SeedDMS_Core_Workflow_State $state current workflow state + * @return SeedDMS_Core_Workflow_Transition[]|bool + */ function getPreviousTransitions($state) { /* {{{ */ $db = $this->_dms->getDB(); @@ -204,13 +238,13 @@ class SeedDMS_Core_Workflow { /* {{{ */ return $wkftransitions; } /* }}} */ - /** - * Get all transitions from one state into another state - * - * @param object $state state to start from - * @param object $nextstate state after transition - * @param array list of transitions - */ + /** + * Get all transitions from one state into another state + * + * @param SeedDMS_Core_Workflow_State $state state to start from + * @param SeedDMS_Core_Workflow_State $nextstate state after transition + * @return SeedDMS_Core_Workflow_Transition[]|bool + */ function getTransitionsByStates($state, $nextstate) { /* {{{ */ $db = $this->_dms->getDB(); @@ -233,7 +267,7 @@ class SeedDMS_Core_Workflow { /* {{{ */ * Remove a transition from a workflow * Deprecated! User SeedDMS_Core_Workflow_Transition::remove() instead. * - * @param object $transition + * @param SeedDMS_Core_Workflow_Transition $transition * @return boolean true if no error occured, otherwise false */ function removeTransition($transition) { /* {{{ */ @@ -243,12 +277,12 @@ class SeedDMS_Core_Workflow { /* {{{ */ /** * Add new transition to workflow * - * @param object $state - * @param object $action - * @param object $nextstate - * @param array $users - * @param array $groups - * @return object instance of new transition + * @param SeedDMS_Core_Workflow_State $state + * @param SeedDMS_Core_Workflow_Action $action + * @param SeedDMS_Core_Workflow_State $nextstate + * @param SeedDMS_Core_User[] $users + * @param SeedDMS_Core_Group[] $groups + * @return SeedDMS_Core_Workflow_Transition|bool instance of new transition */ function addTransition($state, $action, $nextstate, $users, $groups) { /* {{{ */ $db = $this->_dms->getDB(); @@ -301,7 +335,11 @@ class SeedDMS_Core_Workflow { /* {{{ */ return true; } /* }}} */ - private function penetrate($laststates) { + /** + * @param SeedDMS_Core_Workflow_State[] $laststates + * @return SeedDMS_Core_Workflow_State[]|bool + */ + private function penetrate($laststates) { $state = end($laststates); $transitions = $this->getNextTransitions($state); foreach($transitions as $transition) { @@ -323,7 +361,8 @@ class SeedDMS_Core_Workflow { /* {{{ */ * @return boolean list of states if workflow contains cycles, otherwise false */ function checkForCycles() { /* {{{ */ - $db = $this->_dms->getDB(); + /** @noinspection PhpUnusedLocalVariableInspection */ + $db = $this->_dms->getDB(); $initstate = $this->getInitState(); @@ -389,41 +428,49 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ var $_id; /** - * @var name of the workflow state + * @var string name of the workflow state * * @access protected */ var $_name; /** - * @var maximum of seconds allowed in this state + * @var int maximum of seconds allowed in this state * * @access protected */ var $_maxtime; /** - * @var maximum of seconds allowed in this state + * @var int maximum of seconds allowed in this state * * @access protected */ var $_precondfunc; /** - * @var matching documentstatus when this state is reached + * @var int matching documentstatus when this state is reached * * @access protected */ var $_documentstatus; /** - * @var object reference to the dms instance this attribute belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to * * @access protected */ var $_dms; - function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) { + /** + * SeedDMS_Core_Workflow_State constructor. + * @param $id + * @param $name + * @param $maxtime + * @param $precondfunc + * @param $documentstatus + */ + function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) { $this->_id = $id; $this->_name = $name; $this->_maxtime = $maxtime; @@ -432,15 +479,28 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ $this->_dms = null; } - function setDMS($dms) { + /** + * @param $dms + */ + function setDMS($dms) { $this->_dms = $dms; } - function getID() { return $this->_id; } + /** + * @return int + */ + function getID() { return $this->_id; } - function getName() { return $this->_name; } + /** + * @return string + */ + function getName() { return $this->_name; } - function setName($newName) { /* {{{ */ + /** + * @param string $newName + * @return bool + */ + function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowStates` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id; @@ -452,9 +512,16 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ return true; } /* }}} */ - function getMaxTime() { return $this->_maxtime; } + /** + * @return int maximum + */ + function getMaxTime() { return $this->_maxtime; } - function setMaxTime($maxtime) { /* {{{ */ + /** + * @param $maxtime + * @return bool + */ + function setMaxTime($maxtime) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowStates` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id; @@ -466,9 +533,16 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ return true; } /* }}} */ - function getPreCondFunc() { return $this->_precondfunc; } + /** + * @return int maximum + */ + function getPreCondFunc() { return $this->_precondfunc; } - function setPreCondFunc($precondfunc) { /* {{{ */ + /** + * @param $precondfunc + * @return bool + */ + function setPreCondFunc($precondfunc) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowStates` SET `precondfunc` = ".$db->qstr($precondfunc)." WHERE id = " . $this->_id; @@ -476,7 +550,8 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ if (!$res) return false; - $this->_maxtime = $maxtime; + /** @noinspection PhpUndefinedVariableInspection */ + $this->_maxtime = $maxtime; /* @todo fix me */ return true; } /* }}} */ @@ -490,7 +565,11 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ */ function getDocumentStatus() { return $this->_documentstatus; } - function setDocumentStatus($docstatus) { /* {{{ */ + /** + * @param $docstatus + * @return bool + */ + function setDocumentStatus($docstatus) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowStates` SET `documentstatus` = ".intval($docstatus)." WHERE id = " . $this->_id; @@ -520,7 +599,7 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ /** * Return workflow transitions the status is being used in * - * @return array/boolean array of workflow transitions or false in case of an error + * @return SeedDMS_Core_Workflow_Transition[]|boolean array of workflow transitions or false in case of an error */ function getTransitions() { /* {{{ */ $db = $this->_dms->getDB(); @@ -586,34 +665,52 @@ class SeedDMS_Core_Workflow_Action { /* {{{ */ var $_id; /** - * @var name of the workflow action + * @var string name of the workflow action * * @access protected */ var $_name; /** - * @var object reference to the dms instance this attribute belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to * * @access protected */ var $_dms; - function __construct($id, $name) { + /** + * SeedDMS_Core_Workflow_Action constructor. + * @param $id + * @param $name + */ + function __construct($id, $name) { $this->_id = $id; $this->_name = $name; $this->_dms = null; } - function setDMS($dms) { + /** + * @param $dms + */ + function setDMS($dms) { $this->_dms = $dms; } - function getID() { return $this->_id; } + /** + * @return int + */ + function getID() { return $this->_id; } - function getName() { return $this->_name; } + /** + * @return string name + */ + function getName() { return $this->_name; } - function setName($newName) { /* {{{ */ + /** + * @param $newName + * @return bool + */ + function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowActions` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id; @@ -643,7 +740,7 @@ class SeedDMS_Core_Workflow_Action { /* {{{ */ /** * Return workflow transitions the action is being used in * - * @return array/boolean array of workflow transitions or false in case of an error + * @return SeedDMS_Core_Workflow_Transition[]|boolean array of workflow transitions or false in case of an error */ function getTransitions() { /* {{{ */ $db = $this->_dms->getDB(); @@ -709,62 +806,71 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ var $_id; /** - * @var workflow this transition belongs to + * @var SeedDMS_Core_Workflow workflow this transition belongs to * * @access protected */ var $_workflow; /** - * @var state of the workflow transition + * @var SeedDMS_Core_Workflow_State of the workflow transition * * @access protected */ var $_state; /** - * @var next state of the workflow transition + * @var SeedDMS_Core_Workflow_State next state of the workflow transition * * @access protected */ var $_nextstate; /** - * @var action of the workflow transition + * @var SeedDMS_Core_Workflow_Action of the workflow transition * * @access protected */ var $_action; /** - * @var maximum of seconds allowed until this transition must be triggered + * @var integer maximum of seconds allowed until this transition must be triggered * * @access protected */ var $_maxtime; /** - * @var list of users allowed to trigger this transaction + * @var SeedDMS_Core_User[] of users allowed to trigger this transaction * * @access protected */ var $_users; /** - * @var list of groups allowed to trigger this transaction + * @var SeedDMS_Core_Group[] of groups allowed to trigger this transaction * * @access protected */ var $_groups; /** - * @var object reference to the dms instance this attribute belongs to + * @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to * * @access protected */ var $_dms; - function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) { + /** + * SeedDMS_Core_Workflow_Transition constructor. + * @param $id + * @param $workflow + * @param $state + * @param $action + * @param $nextstate + * @param $maxtime + */ + function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) { $this->_id = $id; $this->_workflow = $workflow; $this->_state = $state; @@ -774,15 +880,28 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ $this->_dms = null; } - function setDMS($dms) { + /** + * @param $dms + */ + function setDMS($dms) { $this->_dms = $dms; } - function getID() { return $this->_id; } + /** + * @return int + */ + function getID() { return $this->_id; } - function getWorkflow() { return $this->_workflow; } + /** + * @return SeedDMS_Core_Workflow + */ + function getWorkflow() { return $this->_workflow; } - function setWorkflow($newWorkflow) { /* {{{ */ + /** + * @param SeedDMS_Core_Workflow $newWorkflow + * @return bool + */ + function setWorkflow($newWorkflow) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowTransitions` SET `workflow` = ".$newWorkflow->getID()." WHERE `id` = " . $this->_id; @@ -794,9 +913,17 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ - function getState() { return $this->_state; } - function setState($newState) { /* {{{ */ + /** + * @return SeedDMS_Core_Workflow_State + */ + function getState() { return $this->_state; } + + /** + * @param SeedDMS_Core_Workflow_State $newState + * @return bool + */ + function setState($newState) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowTransitions` SET `state` = ".$newState->getID()." WHERE `id` = " . $this->_id; @@ -808,9 +935,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ - function getNextState() { return $this->_nextstate; } + /** + * @return SeedDMS_Core_Workflow_State + */ + function getNextState() { return $this->_nextstate; } - function setNextState($newNextState) { /* {{{ */ + /** + * @param SeedDMS_Core_Workflow_State $newNextState + * @return bool + */ + function setNextState($newNextState) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowTransitions` SET `nextstate` = ".$newNextState->getID()." WHERE `id` = " . $this->_id; @@ -822,9 +956,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ - function getAction() { return $this->_action; } + /** + * @return SeedDMS_Core_Workflow_Action + */ + function getAction() { return $this->_action; } - function setAction($newAction) { /* {{{ */ + /** + * @param SeedDMS_Core_Workflow_Action $newAction + * @return bool + */ + function setAction($newAction) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowTransitions` SET `action` = ".$newAction->getID()." WHERE `id` = " . $this->_id; @@ -836,9 +977,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ - function getMaxTime() { return $this->_maxtime; } + /** + * @return int + */ + function getMaxTime() { return $this->_maxtime; } - function setMaxTime($maxtime) { /* {{{ */ + /** + * @param $maxtime + * @return bool + */ + function setMaxTime($maxtime) { /* {{{ */ $db = $this->_dms->getDB(); $queryStr = "UPDATE `tblWorkflowTransitions` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id; @@ -853,7 +1001,7 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ /** * Get all users allowed to trigger this transition * - * @return array list of users + * @return SeedDMS_Core_User[]|bool list of users */ function getUsers() { /* {{{ */ $db = $this->_dms->getDB(); @@ -881,7 +1029,7 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ /** * Get all users allowed to trigger this transition * - * @return array list of users + * @return SeedDMS_Core_Group[]|bool list of users */ function getGroups() { /* {{{ */ $db = $this->_dms->getDB(); @@ -969,13 +1117,22 @@ class SeedDMS_Core_Workflow_Transition_User { /* {{{ */ */ var $_dms; - function __construct($id, $transition, $user) { + /** + * SeedDMS_Core_Workflow_Transition_User constructor. + * @param $id + * @param $transition + * @param $user + */ + function __construct($id, $transition, $user) { $this->_id = $id; $this->_transition = $transition; $this->_user = $user; } - function setDMS($dms) { /* {{{ */ + /** + * @param $dms + */ + function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ @@ -1043,14 +1200,24 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */ */ var $_dms; - function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */ + /** + * SeedDMS_Core_Workflow_Transition_Group constructor. + * @param $id + * @param $transition + * @param $group + * @param $numOfUsers + */ + function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */ $this->_id = $id; $this->_transition = $transition; $this->_group = $group; $this->_numOfUsers = $numOfUsers; } /* }}} */ - function setDMS($dms) { /* {{{ */ + /** + * @param $dms + */ + function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ @@ -1156,7 +1323,18 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */ */ var $_dms; - function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) { + /** + * SeedDMS_Core_Workflow_Log constructor. + * @param $id + * @param $document + * @param $version + * @param $workflow + * @param $user + * @param $transition + * @param $date + * @param $comment + */ + function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) { $this->_id = $id; $this->_document = $document; $this->_version = $version; @@ -1168,27 +1346,45 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */ $this->_dms = null; } - function setDMS($dms) { /* {{{ */ + /** + * @param $dms + */ + function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ - function getTransition() { /* {{{ */ + /** + * @return object + */ + function getTransition() { /* {{{ */ return $this->_transition; } /* }}} */ - function getWorkflow() { /* {{{ */ + /** + * @return object + */ + function getWorkflow() { /* {{{ */ return $this->_workflow; } /* }}} */ - function getUser() { /* {{{ */ + /** + * @return object + */ + function getUser() { /* {{{ */ return $this->_user; } /* }}} */ - function getComment() { /* {{{ */ + /** + * @return string + */ + function getComment() { /* {{{ */ return $this->_comment; } /* }}} */ - function getDate() { /* {{{ */ + /** + * @return string + */ + function getDate() { /* {{{ */ return $this->_date; } /* }}} */ diff --git a/SeedDMS_Core/Core/inc.DBAccess.php b/SeedDMS_Core/Core/inc.DBAccess.php index 8ebbf9cf1..d0a394df6 100644 --- a/SeedDMS_Core/Core/inc.DBAccess.php +++ b/SeedDMS_Core/Core/inc.DBAccess.php @@ -16,6 +16,7 @@ * Include the adodb database abstraction */ require_once "adodb/adodb.inc.php"; +/** @noinspection PhpUndefinedClassInspection */ /** * Class to represent the database access for the document management @@ -54,19 +55,19 @@ class SeedDMS_Core_DatabaseAccess { */ function TableList() { return $this->_conn->MetaTables("TABLES"); - } + } - /** - * Constructor of SeedDMS_Core_DatabaseAccess - * - * Sets all database parameters but does not connect. - * - * @param string $driver the database type e.g. mysql, sqlite - * @param string $hostname host of database server - * @param string $user name of user having access to database - * @param string $passw password of user - * @param string $database name of database - */ + /** + * Constructor of SeedDMS_Core_DatabaseAccess + * + * Sets all database parameters but does not connect. + * + * @param string $driver the database type e.g. mysql, sqlite + * @param string $hostname host of database server + * @param string $user name of user having access to database + * @param string $passw password of user + * @param bool|string $database name of database + */ function __construct($driver, $hostname, $user, $passw, $database = false) { $this->_driver = $driver; $this->_hostname = $hostname; @@ -127,7 +128,7 @@ class SeedDMS_Core_DatabaseAccess { /** * Sanitize String used in database operations * - * @param string text + * @param string $text * @return string sanitized string */ function qstr($text) { /* {{{ */ @@ -141,10 +142,11 @@ class SeedDMS_Core_DatabaseAccess { * Call this function only with sql query which return data records. * * @param string $queryStr sql query - * @return array/boolean data if query could be executed otherwise false + * @return array|boolean data if query could be executed otherwise false */ function getResultArray($queryStr) { /* {{{ */ - $resArr = array(); + /** @noinspection PhpUnusedLocalVariableInspection */ + $resArr = array(); $res = $this->_conn->Execute($queryStr); if (!$res) { @@ -157,17 +159,17 @@ class SeedDMS_Core_DatabaseAccess { return $resArr; } /* }}} */ - /** - * Execute SQL query - * - * Call this function only with sql query which do not return data records. - * - * @param string $queryStr sql query - * @param boolean $silent not used anymore. This was used when this method - * still issued an error message - * @return boolean true if query could be executed otherwise false - */ - function getResult($queryStr, $silent=false) { /* {{{ */ + /** + * Execute SQL query + * + * Call this function only with sql query which do not return data records. + * + * @param string $queryStr sql query + * @return bool true if query could be executed otherwise false + * @internal param bool $silent not used anymore. This was used when this method + * still issued an error message + */ + function getResult($queryStr) { /* {{{ */ $res = $this->_conn->Execute($queryStr); if(!$res) { if($this->_debug) @@ -215,9 +217,12 @@ class SeedDMS_Core_DatabaseAccess { return $this->_conn->ErrorNo(); } /* }}} */ - /** - * Create various temporary tables to speed up and simplify sql queries - */ + /** + * Create various temporary tables to speed up and simplify sql queries + * @param $tableName + * @param bool $override + * @return bool + */ function createTemporaryTable($tableName, $override=false) { /* {{{ */ if (!strcasecmp($tableName, "ttreviewid")) { $queryStr = "CREATE TEMPORARY TABLE IF NOT EXISTS `ttreviewid` (PRIMARY KEY (`reviewID`), INDEX (`maxLogID`)) ". @@ -309,6 +314,4 @@ class SeedDMS_Core_DatabaseAccess { } return false; } /* }}} */ -} - -?> +} \ No newline at end of file diff --git a/SeedDMS_Core/Core/inc.DBAccessPDO.php b/SeedDMS_Core/Core/inc.DBAccessPDO.php index 0e5260aae..0f7bca3a5 100644 --- a/SeedDMS_Core/Core/inc.DBAccessPDO.php +++ b/SeedDMS_Core/Core/inc.DBAccessPDO.php @@ -10,6 +10,7 @@ * @copyright Copyright (C) 2012 Uwe Steinmann * @version Release: @package_version@ */ +/** @noinspection PhpUndefinedClassInspection */ /** * Class to represent the database access for the document management @@ -107,7 +108,7 @@ class SeedDMS_Core_DatabaseAccess { * * This function is used to retrieve a list of database tables for backup * - * @return array list of table names + * @return string[]|bool list of table names */ function TableList() { /* {{{ */ switch($this->_driver) { @@ -130,17 +131,17 @@ class SeedDMS_Core_DatabaseAccess { return $res; } /* }}} */ - /** - * Constructor of SeedDMS_Core_DatabaseAccess - * - * Sets all database parameters but does not connect. - * - * @param string $driver the database type e.g. mysql, sqlite - * @param string $hostname host of database server - * @param string $user name of user having access to database - * @param string $passw password of user - * @param string $database name of database - */ + /** + * Constructor of SeedDMS_Core_DatabaseAccess + * + * Sets all database parameters but does not connect. + * + * @param string $driver the database type e.g. mysql, sqlite + * @param string $hostname host of database server + * @param string $user name of user having access to database + * @param string $passw password of user + * @param bool|string $database name of database + */ function __construct($driver, $hostname, $user, $passw, $database = false) { /* {{{ */ $this->_driver = $driver; $tmp = explode(":", $hostname); @@ -212,7 +213,8 @@ class SeedDMS_Core_DatabaseAccess { $dsn = $this->_driver.":".$this->_database; break; } - $this->_conn = new PDO($dsn, $this->_user, $this->_passw); + /** @noinspection PhpUndefinedVariableInspection */ + $this->_conn = new PDO($dsn, $this->_user, $this->_passw); if (!$this->_conn) return false; @@ -246,7 +248,7 @@ class SeedDMS_Core_DatabaseAccess { /** * Sanitize String used in database operations * - * @param string text + * @param string $text * @return string sanitized string */ function qstr($text) { /* {{{ */ @@ -256,21 +258,22 @@ class SeedDMS_Core_DatabaseAccess { /** * Replace back ticks by '"' * - * @param string text + * @param string $text * @return string sanitized string */ function rbt($text) { /* {{{ */ return str_replace('`', '"', $text); } /* }}} */ - /** - * Execute SQL query and return result - * - * Call this function only with sql query which return data records. - * - * @param string $queryStr sql query - * @return array/boolean data if query could be executed otherwise false - */ + /** + * Execute SQL query and return result + * + * Call this function only with sql query which return data records. + * + * @param string $queryStr sql query + * @param bool $retick + * @return array|bool data if query could be executed otherwise false + */ function getResultArray($queryStr, $retick=true) { /* {{{ */ $resArr = array(); @@ -341,11 +344,13 @@ class SeedDMS_Core_DatabaseAccess { $this->_intransaction--; } /* }}} */ - /** - * Return the id of the last instert record - * - * @return integer id used in last autoincrement - */ + /** + * Return the id of the last instert record + * + * @param string $tablename + * @param string $fieldname + * @return int id used in last autoincrement + */ function getInsertID($tablename='', $fieldname='id') { /* {{{ */ if($this->_driver == 'pgsql') return $this->_conn->lastInsertId('"'.$tablename.'_'.$fieldname.'_seq"'); @@ -362,9 +367,12 @@ class SeedDMS_Core_DatabaseAccess { return $this->_conn->errorCode(); } /* }}} */ - /** - * Create various temporary tables to speed up and simplify sql queries - */ + /** + * Create various temporary tables to speed up and simplify sql queries + * @param $tableName + * @param bool $override + * @return bool + */ function createTemporaryTable($tableName, $override=false) { /* {{{ */ if (!strcasecmp($tableName, "ttreviewid")) { switch($this->_driver) { @@ -533,13 +541,14 @@ class SeedDMS_Core_DatabaseAccess { return false; } /* }}} */ - /** - * Return sql statement for extracting the date part from a field - * containing a unix timestamp - * - * @param string $fieldname name of field containing the timestamp - * @return string sql code - */ + /** + * Return sql statement for extracting the date part from a field + * containing a unix timestamp + * + * @param string $fieldname name of field containing the timestamp + * @param string $format + * @return string sql code + */ function getDateExtract($fieldname, $format='%Y-%m-%d') { /* {{{ */ switch($this->_driver) { case 'mysql': @@ -603,11 +612,12 @@ class SeedDMS_Core_DatabaseAccess { return ''; } /* }}} */ - /** - * Return sql statement for returning the current timestamp - * - * @return string sql code - */ + /** + * Return sql statement for returning the current timestamp + * + * @param $field + * @return string sql code + */ function castToText($field) { /* {{{ */ switch($this->_driver) { case 'pgsql': @@ -617,5 +627,3 @@ class SeedDMS_Core_DatabaseAccess { return $field; } /* }}} */ } - -?> diff --git a/SeedDMS_Core/Core/inc.FileUtils.php b/SeedDMS_Core/Core/inc.FileUtils.php index b6228f531..2a322a0ae 100644 --- a/SeedDMS_Core/Core/inc.FileUtils.php +++ b/SeedDMS_Core/Core/inc.FileUtils.php @@ -25,25 +25,50 @@ * @version Release: @package_version@ */ class SeedDMS_Core_File { - static function renameFile($old, $new) { /* {{{ */ + /** + * @param $old + * @param $new + * @return bool + */ + static function renameFile($old, $new) { /* {{{ */ return @rename($old, $new); } /* }}} */ - static function removeFile($file) { /* {{{ */ + /** + * @param $file + * @return bool + */ + static function removeFile($file) { /* {{{ */ return @unlink($file); } /* }}} */ - static function copyFile($source, $target) { /* {{{ */ + /** + * @param $source + * @param $target + * @return bool + */ + static function copyFile($source, $target) { /* {{{ */ return @copy($source, $target); } /* }}} */ - static function moveFile($source, $target) { /* {{{ */ - if (!@copyFile($source, $target)) + /** + * @param $source + * @param $target + * @return bool + */ + static function moveFile($source, $target) { /* {{{ */ + /** @noinspection PhpUndefinedFunctionInspection */ + if (!@copyFile($source, $target)) return false; - return @removeFile($source); + /** @noinspection PhpUndefinedFunctionInspection */ + return @removeFile($source); } /* }}} */ - static function fileSize($file) { /* {{{ */ + /** + * @param $file + * @return bool|int + */ + static function fileSize($file) { /* {{{ */ if(!$a = fopen($file, 'r')) return false; fseek($a, 0, SEEK_END); @@ -52,12 +77,22 @@ class SeedDMS_Core_File { return $filesize; } /* }}} */ - static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */ + /** + * @param $size + * @param array $sizes + * @return string + */ + static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */ if ($size == 0) return('0 Bytes'); - return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]); + /** @noinspection PhpIllegalArrayKeyTypeInspection */ + return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]); } /* }}} */ - static function parse_filesize($str) { /* {{{ */ + /** + * @param $str + * @return bool|int + */ + static function parse_filesize($str) { /* {{{ */ preg_replace('/\s\s+/', ' ', $str); if(strtoupper(substr($str, -1)) == 'B') { $value = (int) substr($str, 0, -2); @@ -80,18 +115,32 @@ class SeedDMS_Core_File { return $value; break; } - return false; + /** @noinspection PhpUnreachableStatementInspection */ + return false; } /* }}} */ - static function checksum($file) { /* {{{ */ + /** + * @param $file + * @return string + */ + static function checksum($file) { /* {{{ */ return md5_file($file); } /* }}} */ - static function renameDir($old, $new) { /* {{{ */ + /** + * @param $old + * @param $new + * @return bool + */ + static function renameDir($old, $new) { /* {{{ */ return @rename($old, $new); } /* }}} */ - static function makeDir($path) { /* {{{ */ + /** + * @param $path + * @return bool + */ + static function makeDir($path) { /* {{{ */ if( !is_dir( $path ) ){ $res=@mkdir( $path , 0777, true); @@ -146,7 +195,11 @@ class SeedDMS_Core_File { */ } /* }}} */ - static function removeDir($path) { /* {{{ */ + /** + * @param $path + * @return bool + */ + static function removeDir($path) { /* {{{ */ $handle = @opendir($path); while ($entry = @readdir($handle) ) { @@ -167,7 +220,12 @@ class SeedDMS_Core_File { return @rmdir($path); } /* }}} */ - static function copyDir($sourcePath, $targetPath) { /* {{{ */ + /** + * @param $sourcePath + * @param $targetPath + * @return bool + */ + static function copyDir($sourcePath, $targetPath) { /* {{{ */ if (mkdir($targetPath, 0777)) { $handle = @opendir($sourcePath); while ($entry = @readdir($handle) ) { @@ -189,14 +247,26 @@ class SeedDMS_Core_File { return true; } /* }}} */ - static function moveDir($sourcePath, $targetPath) { /* {{{ */ - if (!copyDir($sourcePath, $targetPath)) + /** + * @param $sourcePath + * @param $targetPath + * @return bool + */ + static function moveDir($sourcePath, $targetPath) { /* {{{ */ + /** @noinspection PhpUndefinedFunctionInspection */ + if (!copyDir($sourcePath, $targetPath)) return false; - return removeDir($sourcePath); + /** @noinspection PhpUndefinedFunctionInspection */ + return removeDir($sourcePath); } /* }}} */ // code by Kioob (php.net manual) - static function gzcompressfile($source,$level=false) { /* {{{ */ + /** + * @param $source + * @param bool $level + * @return bool|string + */ + static function gzcompressfile($source, $level=false) { /* {{{ */ $dest=$source.'.gz'; $mode='wb'.$level; $error=false; @@ -214,5 +284,4 @@ class SeedDMS_Core_File { if($error) return false; else return $dest; } /* }}} */ -} -?> +} \ No newline at end of file diff --git a/SeedDMS_Lucene/Lucene/IndexedDocument.php b/SeedDMS_Lucene/Lucene/IndexedDocument.php index 54dbb2676..d49240b5a 100644 --- a/SeedDMS_Lucene/Lucene/IndexedDocument.php +++ b/SeedDMS_Lucene/Lucene/IndexedDocument.php @@ -24,6 +24,12 @@ */ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { + /** + * @param $cmd + * @param int $timeout + * @return string + * @throws Exception + */ static function execWithTimeout($cmd, $timeout=2) { /* {{{ */ $descriptorspec = array( 0 => array("pipe", "r"), @@ -60,10 +66,15 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { } } /* }}} */ - /** - * Constructor. Creates our indexable document and adds all - * necessary fields to it using the passed in document - */ + /** + * Constructor. Creates our indexable document and adds all + * necessary fields to it using the passed in document + * @param SeedDMS_Core_DMS $dms + * @param SeedDMS_Core_Document $document + * @param null $convcmd + * @param bool $nocontent + * @param int $timeout + */ public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { $_convcmd = array( 'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'', From c7dbe7d16fa69b221fe6d9b2cbd34ae2887b664b Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 1 Feb 2018 18:00:05 +0100 Subject: [PATCH 09/81] not needed anymore --- out/out.AddTransmittal.php | 39 --------- views/bootstrap/class.AddTransmittal.php | 107 ----------------------- 2 files changed, 146 deletions(-) delete mode 100644 out/out.AddTransmittal.php delete mode 100644 views/bootstrap/class.AddTransmittal.php diff --git a/out/out.AddTransmittal.php b/out/out.AddTransmittal.php deleted file mode 100644 index 85aea1b78..000000000 --- a/out/out.AddTransmittal.php +++ /dev/null @@ -1,39 +0,0 @@ -$dms, 'user'=>$user)); -if($view) { - $view->setParam('strictformcheck', $settings->_strictFormCheck); - $view($_GET); - exit; -} - -?> diff --git a/views/bootstrap/class.AddTransmittal.php b/views/bootstrap/class.AddTransmittal.php deleted file mode 100644 index aa9528c9e..000000000 --- a/views/bootstrap/class.AddTransmittal.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Copyright (C) 2002-2005 Markus Westphal, - * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, - * 2010-2012 Uwe Steinmann - * @version Release: @package_version@ - */ - -/** - * Include parent class - */ -require_once("class.Bootstrap.php"); - -/** - * Class which outputs the html page for AddTransmittal view - * - * @category DMS - * @package SeedDMS - * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann - * @copyright Copyright (C) 2002-2005 Markus Westphal, - * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, - * 2010-2012 Uwe Steinmann - * @version Release: @package_version@ - */ -class SeedDMS_View_AddTransmittal extends SeedDMS_Bootstrap_Style { - - function js() { /* {{{ */ - $strictformcheck = $this->params['strictformcheck']; - header('Content-Type: application/javascript; charset=UTF-8'); -?> -function checkForm() -{ - msg = new Array(); - if (document.form1.name.value == "") msg.push(""); - - if (document.form1.comment.value == "") msg.push(""); - - if (msg != "") { - noty({ - text: msg.join('
'), - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - _timeout: 1500, - }); - return false; - } - else - return true; -} -$(document).ready(function() { - $('body').on('submit', '#form1', function(ev){ - if(checkForm()) return; - event.preventDefault(); - }); -}); -params['dms']; - $user = $this->params['user']; - $strictformcheck = $this->params['strictformcheck']; - - $this->htmlStartPage(getMLText("my_documents")); - $this->globalNavigation($folder); - $this->contentStart(); - $this->pageNavigation(getMLText("my_documents"), "my_documents"); - $this->contentHeading(getMLText("add_transmittal")); - $this->contentContainerStart(); -?> - -
- - - - - - - - - - - - - -
:
:
">
-
-contentContainerEnd(); - $this->contentEnd(); - $this->htmlEndPage(); - } /* }}} */ -} -?> From d824ca30fbaa02c3d22bb730dab5a0a30beb12a1 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 08:48:53 +0100 Subject: [PATCH 10/81] may[Receipt|Review|Approve|Revise] also checks for document access --- inc/inc.ClassAccessOperation.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/inc/inc.ClassAccessOperation.php b/inc/inc.ClassAccessOperation.php index d702d71d7..c9295c6c5 100644 --- a/inc/inc.ClassAccessOperation.php +++ b/inc/inc.ClassAccessOperation.php @@ -225,7 +225,7 @@ class SeedDMS_AccessOperation { if(get_class($document) == $this->dms->getClassname('document')) { if($latestContent = $document->getLatestContent()) { $status = $latestContent->getStatus(); - if ((($document->getAccessMode($this->user) == M_ALL) || $this->user->isAdmin()) && ($status["status"]!=S_OBSOLETE)) { + if ((($document->getAccessMode($this->user) >= M_READWRITE) || $this->user->isAdmin()) && ($status["status"]!=S_OBSOLETE)) { return true; } } @@ -293,7 +293,7 @@ class SeedDMS_AccessOperation { if(get_class($document) == $this->dms->getClassname('document')) { if($latestContent = $document->getLatestContent()) { $status = $latestContent->getStatus(); - if ($status["status"]==S_DRAFT_REV) { + if ($document->getAccessMode($this->user) >= M_READ && $status["status"]==S_DRAFT_REV) { return true; } } @@ -309,7 +309,7 @@ class SeedDMS_AccessOperation { */ function mayUpdateReview($document, $updateUser) { /* {{{ */ if(get_class($document) == 'SeedDMS_Core_Document') { - if($this->settings->_enableUpdateRevApp && ($updateUser == $this->user) && !$document->hasExpired()) { + if($this->settings->_enableUpdateRevApp && ($updateUser == $this->user) && $document->getAccessMode($this->user) >= M_READ && !$document->hasExpired()) { return true; } } @@ -324,7 +324,7 @@ class SeedDMS_AccessOperation { */ function mayUpdateApproval($document, $updateUser) { /* {{{ */ if(get_class($document) == 'SeedDMS_Core_Document') { - if($this->settings->_enableUpdateRevApp && ($updateUser == $this->user) && !$document->hasExpired()) { + if($this->settings->_enableUpdateRevApp && ($updateUser == $this->user) && $document->getAccessMode($this->user) >= M_READ && !$document->hasExpired()) { return true; } } @@ -344,7 +344,7 @@ class SeedDMS_AccessOperation { if(get_class($document) == $this->dms->getClassname('document')) { if($latestContent = $document->getLatestContent()) { $status = $latestContent->getStatus(); - if ($status["status"]==S_DRAFT_APP) { + if ($document->getAccessMode($this->user) >= M_READ && $status["status"]==S_DRAFT_APP) { return true; } } @@ -363,7 +363,7 @@ class SeedDMS_AccessOperation { if(get_class($document) == $this->dms->getClassname('document')) { if($latestContent = $document->getLatestContent()) { $status = $latestContent->getStatus(); - if ($status["status"]==S_RELEASED) { + if ($document->getAccessMode($this->user) >= M_READ && $status["status"]==S_RELEASED) { return true; } } @@ -379,7 +379,7 @@ class SeedDMS_AccessOperation { */ function mayUpdateReceipt($document, $updateUser) { /* {{{ */ if(get_class($document) == 'SeedDMS_Core_Document') { - if($this->settings->_enableUpdateReceipt && ($updateUser == $this->user) && !$document->hasExpired()) { + if($this->settings->_enableUpdateReceipt && ($updateUser == $this->user) && $document->getAccessMode($this->user) >= M_READ && !$document->hasExpired()) { return true; } } @@ -397,7 +397,7 @@ class SeedDMS_AccessOperation { if(get_class($document) == $this->dms->getClassname('document')) { if($latestContent = $document->getLatestContent()) { $status = $latestContent->getStatus(); - if ($status["status"]!=S_OBSOLETE) { + if ($document->getAccessMode($this->user) >= M_READ && $status["status"]!=S_OBSOLETE) { return true; } } From 16e70a0cdd45517c7e7838c9551cc7a54c7bc081 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 08:50:15 +0100 Subject: [PATCH 11/81] recipients may be set with read/write access --- op/op.SetRecipients.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op/op.SetRecipients.php b/op/op.SetRecipients.php index 926e010a8..554af3267 100644 --- a/op/op.SetRecipients.php +++ b/op/op.SetRecipients.php @@ -40,7 +40,7 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } -if ($document->getAccessMode($user) < M_ALL) { +if ($document->getAccessMode($user) < M_READWRITE) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } From 2ad6a04965373c1c21d483fb6a7dffdc5ed449e1 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 08:50:39 +0100 Subject: [PATCH 12/81] move some code at beginning of file --- op/op.ApproveDocument.php | 15 +++++---------- op/op.ReceiptDocument.php | 16 +++++----------- op/op.ReviewDocument.php | 15 +++++---------- op/op.ReviseDocument.php | 15 +++++---------- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/op/op.ApproveDocument.php b/op/op.ApproveDocument.php index b49f779e6..e9da967e2 100644 --- a/op/op.ApproveDocument.php +++ b/op/op.ApproveDocument.php @@ -33,6 +33,7 @@ include("../inc/inc.ClassController.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $controller = Controller::factory($tmp[1]); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); /* Check if the form data comes from a trusted request */ if(!checkFormKey('approvedocument')) { @@ -50,12 +51,13 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } -$folder = $document->getFolder(); - -if ($document->getAccessMode($user) < M_READ) { +// verify if document may be approved +if (!$accessop->mayApprove($document)){ UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } +$folder = $document->getFolder(); + if (!isset($_POST["version"]) || !is_numeric($_POST["version"]) || intval($_POST["version"])<1) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } @@ -73,14 +75,7 @@ if ($latestContent->getVersion()!=$version) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - $olddocstatus = $content->getStatus(); -// verify if document may be approved -if (!$accessop->mayApprove($document)){ - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); -} if (!isset($_POST["approvalStatus"]) || !is_numeric($_POST["approvalStatus"]) || (intval($_POST["approvalStatus"])!=1 && intval($_POST["approvalStatus"])!=-1)) { diff --git a/op/op.ReceiptDocument.php b/op/op.ReceiptDocument.php index e973019f6..a978a7a2f 100644 --- a/op/op.ReceiptDocument.php +++ b/op/op.ReceiptDocument.php @@ -32,6 +32,7 @@ include("../inc/inc.ClassController.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $controller = Controller::factory($tmp[1]); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); /* Check if the form data comes for a trusted request */ if(!checkFormKey('receiptdocument')) { @@ -49,12 +50,13 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } -$folder = $document->getFolder(); - -if ($document->getAccessMode($user) < M_READ) { +// verify if document may be receіpted +if (!$accessop->mayReceipt($document)){ UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } +$folder = $document->getFolder(); + if (!isset($_POST["version"]) || !is_numeric($_POST["version"]) || intval($_POST["version"])<1) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } @@ -72,14 +74,6 @@ if ($latestContent->getVersion()!=$version) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -// verify if document may be receіpted -if (!$accessop->mayReceipt($document)){ - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); -} - if (!isset($_POST["receiptStatus"]) || !is_numeric($_POST["receiptStatus"]) || (intval($_POST["receiptStatus"])!=1 && intval($_POST["receiptStatus"])!=-1)) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_receipt_status")); diff --git a/op/op.ReviewDocument.php b/op/op.ReviewDocument.php index 2e43716bf..da2a1e160 100644 --- a/op/op.ReviewDocument.php +++ b/op/op.ReviewDocument.php @@ -33,6 +33,7 @@ include("../inc/inc.ClassController.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $controller = Controller::factory($tmp[1]); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); /* Check if the form data comes from a trusted request */ if(!checkFormKey('reviewdocument')) { @@ -50,12 +51,13 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } -$folder = $document->getFolder(); - -if ($document->getAccessMode($user) < M_READ) { +// verify if document may be reviewed +if (!$accessop->mayReview($document)){ UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } +$folder = $document->getFolder(); + if (!isset($_POST["version"]) || !is_numeric($_POST["version"]) || intval($_POST["version"])<1) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } @@ -73,14 +75,7 @@ if ($latestContent->getVersion()!=$version) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - $olddocstatus = $content->getStatus(); -// verify if document may be reviewed -if (!$accessop->mayReview($document)){ - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); -} if (!isset($_POST["reviewStatus"]) || !is_numeric($_POST["reviewStatus"]) || (intval($_POST["reviewStatus"])!=1 && intval($_POST["reviewStatus"])!=-1)) { diff --git a/op/op.ReviseDocument.php b/op/op.ReviseDocument.php index f3b99fe6c..307550976 100644 --- a/op/op.ReviseDocument.php +++ b/op/op.ReviseDocument.php @@ -32,6 +32,7 @@ include("../inc/inc.ClassController.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $controller = Controller::factory($tmp[1]); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); /* Check if the form data comes for a trusted request */ if(!checkFormKey('revisedocument')) { @@ -49,12 +50,13 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } -$folder = $document->getFolder(); - -if ($document->getAccessMode($user) < M_READ) { +// verify if document maybe revised +if (!$accessop->mayRevise($document)){ UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); } +$folder = $document->getFolder(); + if (!isset($_POST["version"]) || !is_numeric($_POST["version"]) || intval($_POST["version"])<1) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } @@ -72,14 +74,7 @@ if ($latestContent->getVersion()!=$version) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); } -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - $olddocstatus = $content->getStatus(); -// verify if document maybe revised -if (!$accessop->mayRevise($document)){ - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); -} if (!isset($_POST["revisionStatus"]) || !is_numeric($_POST["revisionStatus"]) || (!in_array(intval($_POST["revisionStatus"]), array(1, -1, 6)))) { From 51f3416c70824e66dc097b77da011c2f94443af5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 08:57:05 +0100 Subject: [PATCH 13/81] =?UTF-8?q?include=20LogInit,=20move=20inclu=D1=95io?= =?UTF-8?q?n=20of=20Preview.php=20into=20view?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- out/out.ReceiptSummary.php | 7 ++----- views/bootstrap/class.ReceiptSummary.php | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/out/out.ReceiptSummary.php b/out/out.ReceiptSummary.php index 977ff6efd..4b522fc64 100644 --- a/out/out.ReceiptSummary.php +++ b/out/out.ReceiptSummary.php @@ -20,6 +20,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. include("../inc/inc.Settings.php"); +include("../inc/inc.LogInit.php"); include("../inc/inc.Language.php"); include("../inc/inc.Init.php"); include("../inc/inc.Extension.php"); @@ -27,11 +28,6 @@ include("../inc/inc.DBInit.php"); include("../inc/inc.ClassUI.php"); include("../inc/inc.Authentication.php"); -/** - * Include class to preview documents - */ -require_once("SeedDMS/Preview.php"); - $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); @@ -41,6 +37,7 @@ if ($user->isGuest()) { } if($view) { + $view->setParam('showtree', showtree()); $view->setParam('cachedir', $settings->_cacheDir); $view->setParam('previewWidthList', $settings->_previewWidthList); $view->setParam('previewconverters', $settings->_converters['preview']); diff --git a/views/bootstrap/class.ReceiptSummary.php b/views/bootstrap/class.ReceiptSummary.php index baaafa224..c7a1aa46d 100644 --- a/views/bootstrap/class.ReceiptSummary.php +++ b/views/bootstrap/class.ReceiptSummary.php @@ -18,6 +18,11 @@ */ require_once("class.Bootstrap.php"); +/** + * Include class to preview documents + */ +require_once("SeedDMS/Preview.php"); + /** * Class which outputs the html page for ReceiptSummary view * From 28a0860824b0762a4eb0d4374f9fbb40c73034ae Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 10:28:06 +0100 Subject: [PATCH 14/81] check view access --- out/out.ApprovalSummary.php | 3 +++ out/out.GroupView.php | 3 +++ out/out.ReceiptSummary.php | 3 +++ out/out.ReviewSummary.php | 3 +++ out/out.UsrView.php | 3 +++ out/out.WorkflowSummary.php | 3 +++ 6 files changed, 18 insertions(+) diff --git a/out/out.ApprovalSummary.php b/out/out.ApprovalSummary.php index 965aedd8f..323c294fa 100644 --- a/out/out.ApprovalSummary.php +++ b/out/out.ApprovalSummary.php @@ -31,6 +31,9 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("my_documents"),getMLText("access_denied")); +} if ($user->isGuest()) { UI::exitError(getMLText("my_documents"),getMLText("access_denied")); diff --git a/out/out.GroupView.php b/out/out.GroupView.php index a5ed5a876..76532fff2 100644 --- a/out/out.GroupView.php +++ b/out/out.GroupView.php @@ -29,6 +29,9 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("my_account"),getMLText("access_denied"), false, $isajax); +} if ($user->isGuest()) { UI::exitError(getMLText("my_account"),getMLText("access_denied")); diff --git a/out/out.ReceiptSummary.php b/out/out.ReceiptSummary.php index 4b522fc64..00d8ed5ae 100644 --- a/out/out.ReceiptSummary.php +++ b/out/out.ReceiptSummary.php @@ -31,6 +31,9 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("my_documents"),getMLText("access_denied")); +} if ($user->isGuest()) { UI::exitError(getMLText("my_documents"),getMLText("access_denied")); diff --git a/out/out.ReviewSummary.php b/out/out.ReviewSummary.php index 965aedd8f..323c294fa 100644 --- a/out/out.ReviewSummary.php +++ b/out/out.ReviewSummary.php @@ -31,6 +31,9 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("my_documents"),getMLText("access_denied")); +} if ($user->isGuest()) { UI::exitError(getMLText("my_documents"),getMLText("access_denied")); diff --git a/out/out.UsrView.php b/out/out.UsrView.php index 698850bd3..21b048c6a 100644 --- a/out/out.UsrView.php +++ b/out/out.UsrView.php @@ -29,6 +29,9 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("my_account"),getMLText("access_denied"), false, $isajax); +} if ($user->isGuest()) { UI::exitError(getMLText("my_account"),getMLText("access_denied")); diff --git a/out/out.WorkflowSummary.php b/out/out.WorkflowSummary.php index 28851c3c1..c6e92ca83 100644 --- a/out/out.WorkflowSummary.php +++ b/out/out.WorkflowSummary.php @@ -31,6 +31,9 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); $accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("my_documents"),getMLText("access_denied")); +} if ($user->isGuest()) { UI::exitError(getMLText("my_documents"),getMLText("access_denied")); From 2c3dff2a24090c5e9bd778641a3cd01a2a59832f Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 10:28:32 +0100 Subject: [PATCH 15/81] add check view access --- out/out.DocumentAccess.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/out/out.DocumentAccess.php b/out/out.DocumentAccess.php index 6abe0ed75..241f5a6cc 100644 --- a/out/out.DocumentAccess.php +++ b/out/out.DocumentAccess.php @@ -30,6 +30,13 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); +if (!$accessop->check_view_access($view, $_GET)) { + UI::exitError(getMLText("document_title"),getMLText("access_denied")); +} + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -48,11 +55,6 @@ $folder = $document->getFolder(); $allUsers = $dms->getAllUsers($settings->_sortUsersInList); $allGroups = $dms->getAllGroups(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); From 264147821648ef9946efdc4702c798d9c997d932 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 10:29:53 +0100 Subject: [PATCH 16/81] move around code to create view and access object --- out/out.DocumentNotify.php | 12 +++++++----- out/out.DocumentVersionDetail.php | 9 ++++----- out/out.EditAttributes.php | 16 ++++++++-------- out/out.EditDocument.php | 14 +++++++++----- out/out.EditDocumentFile.php | 9 ++++----- out/out.MoveDocument.php | 14 ++++++++------ out/out.OverrideContentStatus.php | 16 ++++++++-------- out/out.ReceiptDocument.php | 18 +++++++++--------- out/out.RemoveDocument.php | 9 ++++----- out/out.RemoveDocumentFile.php | 9 ++++----- out/out.RemoveEvent.php | 5 +++-- out/out.RemoveTransmittal.php | 5 +++-- out/out.RemoveUserFromProcesses.php | 5 +++-- out/out.SetExpires.php | 11 +++++------ 14 files changed, 79 insertions(+), 73 deletions(-) diff --git a/out/out.DocumentNotify.php b/out/out.DocumentNotify.php index 752c7dd6d..5f3fddb16 100644 --- a/out/out.DocumentNotify.php +++ b/out/out.DocumentNotify.php @@ -30,6 +30,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"]<1)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -46,12 +50,10 @@ if ($document->getAccessMode($user) < M_READ) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); } -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'folder'=>$folder, 'document'=>$document, 'sortusersinlist'=>$settings->_sortUsersInList)); if($view) { + $view->setParam('folder', $folder); + $view->setParam('document', $document); + $view->setParam('sortusersinlist', $settings->_sortUsersInList); $view->setParam('accessobject', $accessop); $view($_GET); exit; diff --git a/out/out.DocumentVersionDetail.php b/out/out.DocumentVersionDetail.php index 5df8f09ec..58885cb04 100644 --- a/out/out.DocumentVersionDetail.php +++ b/out/out.DocumentVersionDetail.php @@ -30,6 +30,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -64,11 +68,6 @@ if ($latestContent->getVersion()==$version->getVersion()) { $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.EditAttributes.php b/out/out.EditAttributes.php index 1f5c34ec2..f795d6f7d 100644 --- a/out/out.EditAttributes.php +++ b/out/out.EditAttributes.php @@ -30,6 +30,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -39,6 +43,10 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } +if(!$accessop->mayEditAttributes($document)) { + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); +} + $version = $document->getContentByVersion($_GET["version"]); if (!is_object($version)) { @@ -47,16 +55,8 @@ if (!is_object($version)) { $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); -if(!$accessop->mayEditAttributes($document)) { - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); -} - $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all)); -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.EditDocument.php b/out/out.EditDocument.php index f4de9cc4b..225fd9c88 100644 --- a/out/out.EditDocument.php +++ b/out/out.EditDocument.php @@ -29,6 +29,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -52,12 +56,12 @@ if($document->isLocked()) { $folder = $document->getFolder(); $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_all)); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'folder'=>$folder, 'document'=>$document, 'attrdefs'=>$attrdefs, 'strictformcheck'=>$settings->_strictFormCheck, 'orderby'=>$settings->_sortFoldersDefault)); if($view) { + $view->setParam('folder', $folder); + $view->setParam('document', $document); + $view->setParam('attrdefs', $attrdefs); + $view->setParam('strictformcheck', $settings->_strictFormCheck); + $view->setParam('orderby', $settings->_sortFoldersDefault); $view->setParam('accessobject', $accessop); $view($_GET); exit; diff --git a/out/out.EditDocumentFile.php b/out/out.EditDocumentFile.php index 20499f566..baab461d9 100644 --- a/out/out.EditDocumentFile.php +++ b/out/out.EditDocumentFile.php @@ -28,6 +28,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -54,11 +58,6 @@ if (($document->getAccessMode($user) < M_ALL)&&($user->getID()!=$file->getUserID $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.MoveDocument.php b/out/out.MoveDocument.php index 1e04d9ad0..e0edd0cee 100644 --- a/out/out.MoveDocument.php +++ b/out/out.MoveDocument.php @@ -29,6 +29,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -52,7 +56,7 @@ if($document->isLocked()) { if(isset($_GET['targetid']) && $_GET['targetid']) { $target = $dms->getFolder($_GET["targetid"]); if (!is_object($target)) { - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_target_folder")); + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_target_folder")); } if ($target->getAccessMode($user) < M_READWRITE) { @@ -65,12 +69,10 @@ if(isset($_GET['targetid']) && $_GET['targetid']) { $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user, 'folder'=>$folder, 'document'=>$document, 'target'=>$target)); if($view) { + $view->setParam('folder', $folder); + $view->setParam('document', $document); + $view->setParam('target', $target); $view->setParam('accessobject', $accessop); $view($_GET); exit; diff --git a/out/out.OverrideContentStatus.php b/out/out.OverrideContentStatus.php index c1a5bd426..c21abb68c 100644 --- a/out/out.OverrideContentStatus.php +++ b/out/out.OverrideContentStatus.php @@ -29,6 +29,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -39,6 +43,10 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } +if(!$accessop->mayOverrideStatus($document)) { + UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("cannot_change_final_states")); +} + if ($document->getAccessMode($user) < M_ALL) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); } @@ -55,14 +63,6 @@ if (!is_object($content)) { $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); -if(!$accessop->mayOverrideStatus($document)) { - UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("cannot_change_final_states")); -} - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.ReceiptDocument.php b/out/out.ReceiptDocument.php index 8584c2967..cf6f3f955 100644 --- a/out/out.ReceiptDocument.php +++ b/out/out.ReceiptDocument.php @@ -28,6 +28,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -38,6 +42,11 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } +// verify if document may be receipted +if (!$accessop->mayReceipt($document)){ + UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); +} + $folder = $document->getFolder(); if ($document->getAccessMode($user) < M_READ) { @@ -58,21 +67,12 @@ $latestContent = $document->getLatestContent(); if ($latestContent->getVersion()!=$version) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_version")); } -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -// verify if document may be receipted -if (!$accessop->mayReceipt($document)){ - UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); -} $receipts = $content->getReceiptStatus(); if(!$receipts) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("no_action")); } -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.RemoveDocument.php b/out/out.RemoveDocument.php index be20a720c..a76bb323b 100644 --- a/out/out.RemoveDocument.php +++ b/out/out.RemoveDocument.php @@ -29,6 +29,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -51,11 +55,6 @@ if($document->isLocked()) { $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.RemoveDocumentFile.php b/out/out.RemoveDocumentFile.php index bc061aaab..0ffc8c82e 100644 --- a/out/out.RemoveDocumentFile.php +++ b/out/out.RemoveDocumentFile.php @@ -28,6 +28,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -54,11 +58,6 @@ if (($document->getAccessMode($user) < M_ALL)&&($user->getID()!=$file->getUserID $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); diff --git a/out/out.RemoveEvent.php b/out/out.RemoveEvent.php index 5b5c28ec6..abe5a87d6 100644 --- a/out/out.RemoveEvent.php +++ b/out/out.RemoveEvent.php @@ -27,6 +27,9 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.Calendar.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); + if (!isset($_GET["id"]) || !is_numeric($_GET["id"]) || intval($_GET["id"])<1) { UI::exitError(getMLText("edit_event"),getMLText("error_occured")); } @@ -40,8 +43,6 @@ if (($user->getID()!=$event["userID"])&&(!$user->isAdmin())){ UI::exitError(getMLText("edit_event"),getMLText("access_denied")); } -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('event', $event); $view($_GET); diff --git a/out/out.RemoveTransmittal.php b/out/out.RemoveTransmittal.php index 3716cc53e..b060ff4d6 100644 --- a/out/out.RemoveTransmittal.php +++ b/out/out.RemoveTransmittal.php @@ -26,6 +26,9 @@ include("../inc/inc.DBInit.php"); include("../inc/inc.ClassUI.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); + if ($user->isGuest()) { UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); } @@ -39,8 +42,6 @@ if (!is_object($rmtransmittal)) { UI::exitError(getMLText("rm_transmittal"),getMLText("invalid_transmittal_id")); } -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('rmtransmittal', $rmtransmittal); $view($_GET); diff --git a/out/out.RemoveUserFromProcesses.php b/out/out.RemoveUserFromProcesses.php index 3948a5d78..0878cdbc0 100644 --- a/out/out.RemoveUserFromProcesses.php +++ b/out/out.RemoveUserFromProcesses.php @@ -26,6 +26,9 @@ include("../inc/inc.DBInit.php"); include("../inc/inc.ClassUI.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); + if (!$user->isAdmin()) { UI::exitError(getMLText("admin_tools"),getMLText("access_denied")); } @@ -43,8 +46,6 @@ if ($rmuser->getID()==$user->getID()) { UI::exitError(getMLText("rm_user"),getMLText("cannot_delete_yourself")); } -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('rmuser', $rmuser); $view($_GET); diff --git a/out/out.SetExpires.php b/out/out.SetExpires.php index c46d7118e..08b2dcefc 100644 --- a/out/out.SetExpires.php +++ b/out/out.SetExpires.php @@ -30,6 +30,10 @@ include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassAccessOperation.php"); include("../inc/inc.Authentication.php"); +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } @@ -39,17 +43,12 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } -if ($document->getAccessMode($user) < M_READWRITE) { +if(!$accessop->maySetExpires($document)) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); } $folder = $document->getFolder(); -/* Create object for checking access to certain operations */ -$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); - -$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); -$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); if($view) { $view->setParam('folder', $folder); $view->setParam('document', $document); From ceb7d6591348d7573227717fd4a36942d2625a69 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 10:31:07 +0100 Subject: [PATCH 17/81] add additional view access checks DocumentAccess, UsrView, GroupView, ReviewSummary, ApprovalSummary, WorkflowSummary, ReceiptSummary --- views/bootstrap/class.Bootstrap.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 8dc0db5f7..8f9abfa8b 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -630,7 +630,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);; } if ($accessMode == M_ALL) { $menuitems['rm_document'] = array('link'=>"../out/out.RemoveDocument".$docid, 'label'=>'rm_document'); - $menuitems['edit_document_access'] = array('link'=>"../out/out.DocumentAccess". $docid, 'label'=>'edit_document_access'); + if ($this->check_access('DocumentAccess')) + $menuitems['edit_document_access'] = array('link'=>"../out/out.DocumentAccess". $docid, 'label'=>'edit_document_access'); } if ($accessMode >= M_READ && !$this->params['user']->isGuest()) { $menuitems['edit_existing_notify'] = array('link'=>"../out/out.DocumentNotify". $docid, 'label'=>'edit_existing_notify'); @@ -679,8 +680,10 @@ background-image: linear-gradient(to bottom, #882222, #111111);; echo "
  • ".getMLText("2_factor_auth")."
  • \n"; if ($this->params['enableusersview']){ - echo "
  • ".getMLText("users")."
  • \n"; - echo "
  • ".getMLText("groups")."
  • \n"; + if ($this->check_access('UsrView')) + echo "
  • ".getMLText("users")."
  • \n"; + if ($this->check_access('GroupView')) + echo "
  • ".getMLText("groups")."
  • \n"; } echo "\n"; echo "\n"; @@ -697,12 +700,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);; // echo "
  • ".getMLText("all_documents")."
  • \n"; if($this->params['workflowmode'] == 'traditional' || $this->params['workflowmode'] == 'traditional_only_approval') { if($this->params['workflowmode'] == 'traditional') - echo "
  • ".getMLText("review_summary")."
  • \n"; - echo "
  • ".getMLText("approval_summary")."
  • \n"; + if ($this->check_access('ReviewSummary')) + echo "
  • ".getMLText("review_summary")."
  • \n"; + if ($this->check_access('ApprovalSummary')) + echo "
  • ".getMLText("approval_summary")."
  • \n"; } else { - echo "
  • ".getMLText("workflow_summary")."
  • \n"; + if ($this->check_access('WorkflowSummary')) + echo "
  • ".getMLText("workflow_summary")."
  • \n"; } - echo "
  • ".getMLText("receipt_summary")."
  • \n"; + if ($this->check_access('ReceiptSummary')) + echo "
  • ".getMLText("receipt_summary")."
  • \n"; echo "\n"; echo "\n"; return; From 233cf9b1f1eafba9a22404822e02a854fb589f91 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 14:10:18 +0100 Subject: [PATCH 18/81] fix error in listing approvers --- views/bootstrap/class.ViewDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index c4a666447..371dce0f5 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -912,7 +912,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { } break; } - if($user->isAdmin() || $r["status"] > -2) { + if($user->isAdmin() || $a["status"] > -2) { print "\n"; print "".$reqName."\n"; print "
    • ".$a["date"]."
    • "; From 8a473031a6b4041ca235fdda4401bad2a1e60a72 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 14:18:47 +0100 Subject: [PATCH 19/81] create access object later --- out/out.UpdateDocument.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/out/out.UpdateDocument.php b/out/out.UpdateDocument.php index 2f4081222..92433bff9 100644 --- a/out/out.UpdateDocument.php +++ b/out/out.UpdateDocument.php @@ -32,7 +32,6 @@ include("../inc/inc.Authentication.php"); $tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); $view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); -$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings); if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); @@ -43,6 +42,8 @@ if (!is_object($document)) { UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); } +$accessop = new SeedDMS_AccessOperation($dms, $document, $user, $settings); + if ($document->getAccessMode($user) < M_READWRITE) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("access_denied")); } From 25657c2f6497c3fa03fc03c36b537dbd919026ab Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 14:27:54 +0100 Subject: [PATCH 20/81] save missing translations into cachedir --- op/op.Ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/op/op.Ajax.php b/op/op.Ajax.php index f4ba8d96c..9a24abe1b 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -493,7 +493,7 @@ switch($command) { case 'submittranslation': /* {{{ */ if($settings->_showMissingTranslations) { if($user && !empty($_POST['phrase'])) { - if($fp = fopen('/tmp/newtranslations.txt', 'a+')) { + if($fp = fopen($settings->_cacheDir.'/newtranslations.txt', 'a+')) { fputcsv($fp, array(date('Y-m-d H:i:s'), $user->getLogin(), $_POST['key'], $_POST['lang'], $_POST['phrase'])); fclose($fp); } From 4e9d2411080b4b53e8f90230fd9cd39bd4957fea Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 15:12:18 +0100 Subject: [PATCH 21/81] include autoload.php instead of robthree classes --- op/op.Login.php | 11 +++ out/out.Setup2Factor.php | 37 ++++++++ views/bootstrap/class.Setup2Factor.php | 114 +++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 out/out.Setup2Factor.php create mode 100644 views/bootstrap/class.Setup2Factor.php diff --git a/op/op.Login.php b/op/op.Login.php index f758ddb89..3b1967afe 100644 --- a/op/op.Login.php +++ b/op/op.Login.php @@ -130,6 +130,17 @@ if ($user->isAdmin() && ($_SERVER['REMOTE_ADDR'] != $settings->_adminIP ) && ( $ exit; } +if($settings->_enable2FactorAuthentication) { + if($secret = $user->getSecret()) { + require "vendor/autoload.php"; + $tfa = new \RobThree\Auth\TwoFactorAuth('SeedDMS'); + if($tfa->verifyCode($secret, $_POST['twofactauth']) !== true) { + _printMessage(getMLText("login_error_title"), getMLText("login_error_text")); + exit; + } + } +} + /* Clear login failures if login was successful */ $user->clearLoginFailures(); diff --git a/out/out.Setup2Factor.php b/out/out.Setup2Factor.php new file mode 100644 index 000000000..2bbcc3007 --- /dev/null +++ b/out/out.Setup2Factor.php @@ -0,0 +1,37 @@ + + * @copyright Copyright (C) 2016 Uwe Steinmann + * @version Release: @package_version@ + */ + +include("../inc/inc.Settings.php"); +include("../inc/inc.Language.php"); +include("../inc/inc.Init.php"); +include("../inc/inc.Extension.php"); +include("../inc/inc.DBInit.php"); +include("../inc/inc.ClassUI.php"); +include("../inc/inc.Authentication.php"); + +$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME'])); +$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user)); +$accessop = new SeedDMS_AccessOperation($dms, $user, $settings); + +if ($user->isGuest()) { + UI::exitError(getMLText("2_factor_auth"),getMLText("access_denied")); +} + +if($view) { + $view->setParam('sitename', $settings->_siteName); + $view->setParam('enable2factauth', $settings->_enable2FactorAuthentication); + $view->setParam('accessobject', $accessop); + $view($_GET); + exit; +} + diff --git a/views/bootstrap/class.Setup2Factor.php b/views/bootstrap/class.Setup2Factor.php new file mode 100644 index 000000000..775001340 --- /dev/null +++ b/views/bootstrap/class.Setup2Factor.php @@ -0,0 +1,114 @@ + + * @copyright Copyright (C) 2016 Uwe Steinmann + * @version Release: @package_version@ + */ + +/** + * Include parent class + */ +require_once("class.Bootstrap.php"); + +/** + * Include classes for 2-factor authentication + */ +require "vendor/autoload.php"; + +/** + * Class which outputs the html page for ForcePasswordChange view + * + * @category DMS + * @package SeedDMS + * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann + * @copyright Copyright (C) 2016 Uwe Steinmann + * @version Release: @package_version@ + */ +class SeedDMS_View_Setup2Factor extends SeedDMS_Bootstrap_Style { + + function js() { /* {{{ */ + header('Content-Type: application/javascript'); +?> +function checkForm() +{ + msg = new Array(); + + if($("#currentpwd").val() == "") msg.push(""); + if($("#pwd").val() == "") msg.push(""); + if($("#pwd").val() != $("#pwdconf").val()) msg.push(""); + if (msg != "") { + noty({ + text: msg.join('
      '), + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + _timeout: 1500, + }); + return false; + } + else + return true; +} + +$(document).ready( function() { + $('body').on('submit', '#form', function(ev){ + if(checkForm()) return; + ev.preventDefault(); + }); +}); +params['dms']; + $user = $this->params['user']; + $sitename = $this->params['sitename']; + + $this->htmlStartPage(getMLText("2_factor_auth"), "forcepasswordchange"); + $this->globalNavigation(); + $this->contentStart(); + $this->pageNavigation(getMLText("my_account"), "my_account"); + $this->contentHeading(getMLText('2_factor_auth')); + echo "
      ".getMLText('2_factor_auth_info')."
      "; + echo '
      '; + $this->contentContainerStart('span6'); + + $tfa = new \RobThree\Auth\TwoFactorAuth('SeedDMS'); + $oldsecret = $user->getSecret(); + $secret = $tfa->createSecret(); +?> +
      +
      +
      +
      +
      + +
      +
      + ">
      +
      +
      +contentContainerEnd(); + $this->contentContainerStart('span6'); + echo '
      '.$oldsecret.'
      '; + echo '
      '; +?> +contentContainerEnd(); + echo '
      '; + $this->contentEnd(); + $this->htmlEndPage(); + } /* }}} */ +} +?> From a1a8abceea66179bd48256a7152b3a8709e01fe0 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 15:17:39 +0100 Subject: [PATCH 22/81] add entry for 6.0.3 --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index cfb00c017..67c47c786 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,7 +17,8 @@ will no longer be in status 'rejected' but 'needs correction' - better error handling when indexing documents fails - apache xsendfile module is used for downloading documents when installed - +- add view access check for ApprovalSummary, ReviewSummary, ReceiptSummary, + WorkflowSummary, DocumentAccess, GroupView, UsrView, WorkflowSummary -------------------------------------------------------------------------------- Changes in version 6.0.2 From 86df87031b0958ca667011b1ffcb87c4ee7fc00d Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 15:18:12 +0100 Subject: [PATCH 23/81] add item for 5.1.6 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 2816a7e7e..eadd30bc9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ - use converters for creating preview images as configured in settings (Closes #389) - propperly check if user is already in database when doing ldap auth (Closes #388) - list linked documents on the ViewDocument page in the way as in other document lists +- fix 2-factor authentification -------------------------------------------------------------------------------- Changes in version 5.1.5 From 7e0b1b690734e9a05234f4995d0489395cad0bb1 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 5 Feb 2018 15:19:59 +0100 Subject: [PATCH 24/81] start new version 6.0.4 --- CHANGELOG | 4 ++++ Makefile | 2 +- SeedDMS_Core/Core/inc.ClassDMS.php | 2 +- inc/inc.Version.php | 2 +- install/install.php | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 00ea65a5b..5a52e0aed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +-------------------------------------------------------------------------------- + Changes in version 6.0.4 +-------------------------------------------------------------------------------- + -------------------------------------------------------------------------------- Changes in version 6.0.3 -------------------------------------------------------------------------------- diff --git a/Makefile b/Makefile index c401b96b2..f4e499fcb 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=6.0.3 +VERSION=6.0.4 SRC=CHANGELOG inc conf utils index.php languages views op out controllers doc styles TODO LICENSE webdav install restapi pdfviewer # webapp diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 7b8903164..eff0c6284 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -446,7 +446,7 @@ class SeedDMS_Core_DMS { $this->callbacks = array(); $this->version = '@package_version@'; if($this->version[0] == '@') - $this->version = '6.0.3'; + $this->version = '6.0.4'; } /* }}} */ /** diff --git a/inc/inc.Version.php b/inc/inc.Version.php index 6be1396ef..312b32c21 100644 --- a/inc/inc.Version.php +++ b/inc/inc.Version.php @@ -20,7 +20,7 @@ class SeedDMS_Version { - public $_number = "6.0.3"; + public $_number = "6.0.4"; private $_string = "SeedDMS"; function __construct() { diff --git a/install/install.php b/install/install.php index 7ba4923a8..cb2e6bea7 100644 --- a/install/install.php +++ b/install/install.php @@ -123,7 +123,7 @@ function fileExistsInIncludePath($file) { /* {{{ */ * Load default settings + set */ define("SEEDDMS_INSTALL", "on"); -define("SEEDDMS_VERSION", "6.0.3"); +define("SEEDDMS_VERSION", "6.0.4"); require_once('../inc/inc.ClassSettings.php'); From 16ce0f6de6ed1220a0c04191b51a2125ddaa0460 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 6 Feb 2018 17:03:35 +0100 Subject: [PATCH 25/81] all config variables with options may also be declared empty --- views/bootstrap/class.Settings.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index 8bd40e5af..8002475a0 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -804,11 +804,14 @@ if(!is_writeable($settings->_configFilePath)) { echo ""; } elseif(!empty($conf['internal'])) { $selections = empty($settings->_extensions[$extname][$confkey]) ? array() : explode(",", $settings->_extensions[$extname][$confkey]); + $allowempty = empty($conf['allow_empty']) ? false : $conf['allow_empty']; switch($conf['internal']) { case "categories": $categories = $dms->getDocumentCategories(); if($categories) { - echo ""; + if($allowempty) + echo ""; foreach($categories as $category) { echo ""; foreach($users as $curuser) { echo ""; foreach($recs as $rec) { echo ""; foreach($recs as $rec) { echo "