diff --git a/CHANGELOG b/CHANGELOG index ded6bb2f8..39b0ff938 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,68 @@ +-------------------------------------------------------------------------------- + Changes in version 5.1.9 +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- + Changes in version 5.1.8 +-------------------------------------------------------------------------------- +- fix javascript errors when an error page was shown +- add new extraTabs in ViewDocument for adding more tabs +- fix validation of maxuplodsize in fine uploader +- do not leak information in calendar about documents the logged in user has + no read access on +- fix vulnerability when uploading a new file with the fine uploader, make + sure the chunk identifier contains only allowed chars '[0-9a-f-]' (CVE-2018-12939 + and CVE-2018-12940) +- fix vulnerability when clearing the cache, make sure the cache directory + to clean actually exists. (CVE-2018-12941) +- prevent cross side scripting when loading the dashboard, removed dashboard + as it was never finished anyway (CVE-2018-12944) +- prevent cross side scripting when url parameter 'action' is manipulated, + url parameter is run through htmlspecialchars() before output (CVE-2018-12943) +- fix possible sql-injection, do not use integers in sql statement before + casting them to int (CVE-2018-12942) + +-------------------------------------------------------------------------------- + Changes in version 5.1.7 +-------------------------------------------------------------------------------- +- PLEASE READ doc/README.Dist-Layout WHEN UPGRADING!!!! +- support for upload/import/download of extensions +- extension can have a changelog file +- remove ancient code to upgrade from old config file +- place all log files in contentDir/log +- add readme for new dist layout +- do not list empty groups as reviewer/approver +- fix sending notification when document attributes change +- sending notification when folder attributes change +- check if converters are set in out/out.ViewDocument.php at all (Closes #394) +- do not remove user when transfering objects +- do not periodically count tasks if task list in menu is turned off +- use utf8_basename() in op.ImportFS.php +- update font-awesome from 3.1.0 to 3.2.1 +- merged changes up to 5.0.14 + +-------------------------------------------------------------------------------- + Changes in version 5.1.6 +-------------------------------------------------------------------------------- +- fix wrong check in restapi (part of #373) +- mayApprove() and mayReview() require the status of the document to be + S_DRAFT_APP resp. S_DRAFT_REV +- add preview for webm videos (Closes #374) +- add support for apache mod_xsendfile, minor optimization of file download (see #382) +- animate button to download more objects in folder list when loading is active +- 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 same way as in other document lists +- fix 2-factor authentification +- configuration variables in extension of type 'select' may have an empty option +- default position of documents/folders can be set in configuration (Closes #381) +- attribute values can be deleted from all folders, documents +- new settings to disallow upload of documents with just a reviewer in traditional + workflow mode +- webdav and various script use the controller framework instead of calling + SeedDMS_Core methods +- do not verify peer name and certificate when connecting to smtp server + -------------------------------------------------------------------------------- Changes in version 5.1.5 -------------------------------------------------------------------------------- @@ -73,6 +138,7 @@ -------------------------------------------------------------------------------- - use cmd timeout when indexing documents (Closes #344) - add change password function to rest api (merge from sebbuku) +- merged changes from 4.3.37 -------------------------------------------------------------------------------- Changes in version 5.0.13 @@ -178,6 +244,10 @@ -------------------------------------------------------------------------------- - fix label in password forgotten form (Closes #346) - translation updates +- search result contains documents without a status log +- fix setting categories in utils/adddoc.php +- fetch all records from tblVersion in install/update.php. If not, the database + will be locked and e.g. a drop table in the update script will not work -------------------------------------------------------------------------------- Changes in version 4.3.36 diff --git a/Makefile b/Makefile index 0805e195a..2f37dcb9b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=5.1.5 +VERSION=5.1.8 SRC=CHANGELOG inc conf utils index.php languages views op out controllers doc styles TODO LICENSE webdav install restapi pdfviewer # webapp @@ -14,7 +14,7 @@ PHPDOC=~/Downloads/phpDocumentor-2.8.1/bin/phpdoc dist: mkdir -p tmp/seeddms-$(VERSION) cp -a $(SRC) tmp/seeddms-$(VERSION) - (cd tmp/seeddms-$(VERSION); rm -rf $(NODISTFILES)) + (cd tmp/seeddms-$(VERSION); rm -rf $(NODISTFILES); mv conf conf.template) (cd tmp; tar --exclude=.svn --exclude=.gitignore --exclude=views/blue --exclude=views/hc --exclude=views/clean --exclude=styles/blue --exclude=styles/hc --exclude=styles/clean -czvf ../seeddms-$(VERSION).tar.gz seeddms-$(VERSION)) rm -rf tmp @@ -36,6 +36,16 @@ webapp: (cd tmp; tar --exclude=.svn -czvf ../seeddms-webapp-$(VERSION).tar.gz seeddms-webapp-$(VERSION)) rm -rf tmp +repository: + mkdir -p tmp/seeddms-repository-$(VERSION) + cp -a repository/www repository/utils repository/doc tmp/seeddms-repository-$(VERSION) + mkdir -p tmp/seeddms-repository-$(VERSION)/files + mkdir -p tmp/seeddms-repository-$(VERSION)/accounts + cp -a repository/files/.htaccess tmp/seeddms-repository-$(VERSION)/files + cp -a repository/accounts/.htaccess tmp/seeddms-repository-$(VERSION)/accounts + (cd tmp; tar --exclude=.svn -czvf ../seeddms-repository-$(VERSION).tar.gz seeddms-repository-$(VERSION)) + rm -rf tmp + dynamic_content.tar.gz: ext/dynamic_content tar czvf dynamic_content.tar.gz ext/dynamic_content @@ -53,4 +63,4 @@ doc: apidoc: apigen generate -s SeedDMS_Core --exclude tests -d html -.PHONY: webdav webapp +.PHONY: webdav webapp repository 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.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.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 diff --git a/SeedDMS_Core/Core/inc.ClassAttribute.php b/SeedDMS_Core/Core/inc.ClassAttribute.php index b1d74c5e9..f6b874c2b 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,19 +65,18 @@ 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; @@ -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 */ @@ -411,6 +416,7 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ * @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; @@ -474,11 +480,12 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ /** * 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(); @@ -504,11 +511,12 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ /** * 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(); @@ -531,9 +539,10 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ /** * 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(); @@ -636,9 +645,10 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ /** * Get the n'th value of a value set * - * @param interger $index + * @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) { @@ -751,11 +761,10 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ * The return value is always an array, even if the attribute is single * value attribute. * - * @return array list of single values + * @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,7 +787,7 @@ 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(); @@ -801,7 +809,17 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ $queryStr = "SELECT count(*) c, `value` FROM `tblDocumentAttributes` WHERE `attrdef`=".$this->_id." GROUP BY `value` ORDER BY c DESC"; $resArr = $db->getResultArray($queryStr); if($resArr) { - $result['frequencies']['document'] = $resArr; + foreach($resArr as $row) { + $tmpattr = new SeedDMS_Core_Attribute(0, null, $this, $row['value']); + foreach($tmpattr->getValueAsArray() as $value) { + if(isset($possiblevalues[md5($value)])) { + $possiblevalues[md5($value)]['c'] += $row['c']; + } else { + $possiblevalues[md5($value)] = array('value'=>$value, 'c'=>$row['c']); + } + } + } + $result['frequencies']['document'] = $possiblevalues; } } @@ -818,10 +836,25 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ } } } + $valueset = $this->getValueSetAsArray(); + $possiblevalues = array(); + foreach($valueset as $value) { + $possiblevalues[md5($value)] = array('value'=>$value, 'c'=>0); + } $queryStr = "SELECT count(*) c, `value` FROM `tblFolderAttributes` WHERE `attrdef`=".$this->_id." GROUP BY `value` ORDER BY c DESC"; $resArr = $db->getResultArray($queryStr); if($resArr) { - $result['frequencies']['folder'] = $resArr; + foreach($resArr as $row) { + $tmpattr = new SeedDMS_Core_Attribute(0, null, $this, $row['value']); + foreach($tmpattr->getValueAsArray() as $value) { + if(isset($possiblevalues[md5($value)])) { + $possiblevalues[md5($value)]['c'] += $row['c']; + } else { + $possiblevalues[md5($value)] = array('value'=>$value, 'c'=>$row['c']); + } + } + } + $result['frequencies']['folder'] = $possiblevalues; } } @@ -838,10 +871,25 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ } } } + $valueset = $this->getValueSetAsArray(); + $possiblevalues = array(); + foreach($valueset as $value) { + $possiblevalues[md5($value)] = array('value'=>$value, 'c'=>0); + } $queryStr = "SELECT count(*) c, `value` FROM `tblDocumentContentAttributes` WHERE `attrdef`=".$this->_id." GROUP BY `value` ORDER BY c DESC"; $resArr = $db->getResultArray($queryStr); if($resArr) { - $result['frequencies']['content'] = $resArr; + foreach($resArr as $row) { + $tmpattr = new SeedDMS_Core_Attribute(0, null, $this, $row['value']); + foreach($tmpattr->getValueAsArray() as $value) { + if(isset($possiblevalues[md5($value)])) { + $possiblevalues[md5($value)]['c'] += $row['c']; + } else { + $possiblevalues[md5($value)] = array('value'=>$value, 'c'=>$row['c']); + } + } + } + $result['frequencies']['content'] = $possiblevalues; } } @@ -868,19 +916,25 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ } /* }}} */ /** - * Get all documents and folder by a given attribute value + * Get all documents and folders by a given attribute value * * @param string $attrvalue value of attribute * @param integer $limit limit number of documents/folders * @return array array containing list of documents and folders */ - public function getObjects($attrvalue, $limit) { /* {{{ */ + public function getObjects($attrvalue, $limit='') { /* {{{ */ $db = $this->_dms->getDB(); $result = array('docs'=>array(), 'folders'=>array(), 'contents'=>array()); if($this->_objtype == SeedDMS_Core_AttributeDefinition::objtype_all || $this->_objtype == SeedDMS_Core_AttributeDefinition::objtype_document) { - $queryStr = "SELECT * FROM `tblDocumentAttributes` WHERE `attrdef`=".$this->_id." AND `value`=".$db->qstr($attrvalue); + $queryStr = "SELECT * FROM `tblDocumentAttributes` WHERE `attrdef`=".$this->_id." AND "; + if($this->getMultipleValues()) { + $sep = $this->getValueSetSeparator(); + $queryStr .= "(`value` like ".$db->qstr($sep.$attrvalue.'%')." OR `value` like ".$db->qstr('%'.$sep.$attrvalue.$sep.'%')." OR `value` like ".$db->qstr('%'.$sep.$attrvalue).")"; + } else { + $queryStr .= "`value`=".$db->qstr($attrvalue); + } if($limit) $queryStr .= " limit ".(int) $limit; $resArr = $db->getResultArray($queryStr); @@ -895,7 +949,13 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ if($this->_objtype == SeedDMS_Core_AttributeDefinition::objtype_all || $this->_objtype == SeedDMS_Core_AttributeDefinition::objtype_folder) { - $queryStr = "SELECT * FROM `tblFolderAttributes` WHERE `attrdef`=".$this->_id." AND `value`=".$db->qstr($attrvalue); + $queryStr = "SELECT * FROM `tblFolderAttributes` WHERE `attrdef`=".$this->_id." AND "; + if($this->getMultipleValues()) { + $sep = $this->getValueSetSeparator(); + $queryStr .= "(`value` like ".$db->qstr($sep.$attrvalue.'%')." OR `value` like ".$db->qstr('%'.$sep.$attrvalue.$sep.'%')." OR `value` like ".$db->qstr('%'.$sep.$attrvalue).")"; + } else { + $queryStr .= "`value`=".$db->qstr($attrvalue); + } if($limit) $queryStr .= " limit ".(int) $limit; $resArr = $db->getResultArray($queryStr); @@ -911,6 +971,72 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ return $result; } /* }}} */ + /** + * Remove a given attribute value from all documents, versions and folders + * + * @param string $attrvalue value of attribute + * @return array array containing list of documents and folders + */ + public function removeValue($attrvalue) { /* {{{ */ + $db = $this->_dms->getDB(); + + foreach(array('document', 'documentcontent', 'folder') as $type) { + if($type == 'document') { + $tablename = "tblDocumentAttributes"; + $objtype = SeedDMS_Core_AttributeDefinition::objtype_document; + } elseif($type == 'documentcontent') { + $tablename = "tblDocumentContentAttributes"; + $objtype = SeedDMS_Core_AttributeDefinition::objtype_documentcontent; + } elseif($type == 'folder') { + $tablename = "tblFolderAttributes"; + $objtype = SeedDMS_Core_AttributeDefinition::objtype_folder; + } + if($this->_objtype == SeedDMS_Core_AttributeDefinition::objtype_all || $objtype) { + $queryStr = "SELECT * FROM `".$tablename."` WHERE `attrdef`=".$this->_id." AND "; + if($this->getMultipleValues()) { + $sep = $this->getValueSetSeparator(); + $queryStr .= "(`value` like ".$db->qstr($sep.$attrvalue.'%')." OR `value` like ".$db->qstr('%'.$sep.$attrvalue.$sep.'%')." OR `value` like ".$db->qstr('%'.$sep.$attrvalue).")"; + } else { + $queryStr .= "`value`=".$db->qstr($attrvalue); + } + + $resArr = $db->getResultArray($queryStr); + if($resArr) { + $db->startTransaction(); + foreach($resArr as $rec) { + if($rec['value'] == $attrvalue) { + $queryStr = "DELETE FROM `".$tablename."` WHERE `id`=".$rec['id']; + } else { + if($this->getMultipleValues()) { + $sep = substr($rec['value'], 0, 1); + $vsep = $this->getValueSetSeparator(); + if($sep == $vsep) + $values = explode($sep, substr($rec['value'], 1)); + else + $values = array($rec['value']); + if (($key = array_search($attrvalue, $values)) !== false) { + unset($values[$key]); + } + if($values) { + $queryStr = "UPDATE `".$tablename."` SET `value`=".$db->qstr($sep.implode($sep, $values))." WHERE `id`=".$rec['id']; + } else { + $queryStr = "DELETE FROM `".$tablename."` WHERE `id`=".$rec['id']; + } + } else { + } + } + if (!$db->getResult($queryStr)) { + $db->rollbackTransaction(); + return false; + } + } + $db->commitTransaction(); + } + } + } + return true; + } /* }}} */ + /** * Validate value against attribute definition * @@ -997,7 +1123,7 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ if(!$success) $this->_validation_error = 3; break; - case self::type_boolean: + case self::type_boolean: /** @todo: Same case in LINE 966 */ foreach($values as $value) { $success &= preg_match('/^[01]$/', $value); } @@ -1043,4 +1169,3 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */ function getValidationError() { return $this->_validation_error; } } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 7c4e91b28..cd25d5d4f 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_DatabaseAccess $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 @@ -181,6 +181,11 @@ class SeedDMS_Core_DMS { */ public $callbacks; + /** + * @var SeedDMS_Core_DMS + */ + public $_dms; + /** * Checks if two objects are equal by comparing their IDs @@ -214,7 +219,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 */ @@ -294,7 +299,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 @@ -341,14 +346,14 @@ class SeedDMS_Core_DMS { return $tmp; } /* }}} */ + /** @noinspection PhpUndefinedClassInspection */ /** * Create a new instance of the dms * - * @param object $db object of class {@link SeedDMS_Core_DatabaseAccess} + * @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 - * @return object instance of {@link SeedDMS_Core_DMS} */ function __construct($db, $contentDir) { /* {{{ */ $this->db = $db; @@ -371,17 +376,17 @@ class SeedDMS_Core_DMS { $this->callbacks = array(); $this->version = '@package_version@'; if($this->version[0] == '@') - $this->version = '5.1.5'; + $this->version = '5.1.9'; } /* }}} */ /** * 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 */ @@ -422,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; @@ -431,7 +436,7 @@ 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(); @@ -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() { /* {{{ */ @@ -556,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() { /* {{{ */ @@ -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']; @@ -601,7 +606,8 @@ class SeedDMS_Core_DMS { * * @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 + * @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; @@ -793,14 +801,13 @@ class SeedDMS_Core_DMS { * * @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 + * @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. - * if 'ExpiredOwner' contains the date in days or as 'yyyy-mm-dd' * @param string $param3 sort list by this field * @param string $param4 order direction - * @return array list of documents records + * @return array|bool */ function getDocumentList($listtype, $param1=null, $param2=false, $param3='', $param4='') { /* {{{ */ /* The following query will get all documents and lots of additional @@ -1091,8 +1098,9 @@ class SeedDMS_Core_DMS { $orderdir = 'DESC'; else $orderdir = 'ASC'; + /** @noinspection PhpUndefinedConstantInspection */ $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' ". - "AND `tblDocumentStatusLog`.`status` IN (".S_DRAFT_REV.", ".S_DRAFT_APP.", ".S_IN_REVISION.") "; + "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`"; @@ -1263,7 +1271,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 @@ -1273,30 +1281,30 @@ 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. @@ -1358,6 +1366,8 @@ class SeedDMS_Core_DMS { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { if($valueset = $attrdef->getValueSet()) { if($attrdef->getMultipleValues()) { + if(is_string($attribute)) + $attribute = array($attribute); $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblFolderAttributes` WHERE `tblFolderAttributes`.`attrdef`=".$attrdefid." AND (`tblFolderAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblFolderAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblFolderAttributes`.`folder`=`tblFolders`.`id`)"; } else $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblFolderAttributes` WHERE `tblFolderAttributes`.`attrdef`=".$attrdefid." AND `tblFolderAttributes`.`value`='".$attribute."' AND `tblFolderAttributes`.`folder`=`tblFolders`.`id`)"; @@ -1379,6 +1389,7 @@ 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) { + /** @noinspection PhpUndefinedVariableInspection */ if($startdate) $searchCreateDate .= " AND "; $searchCreateDate .= "`tblFolders`.`date` <= ".$stopdate; @@ -1440,6 +1451,7 @@ class SeedDMS_Core_DMS { foreach ($resArr as $folderArr) { $folders[] = $this->getFolder($folderArr['id']); } + /** @noinspection PhpUndefinedVariableInspection */ $folderresult = array('totalFolders'=>$totalFolders, 'folders'=>$folders); } } else { @@ -1509,6 +1521,8 @@ class SeedDMS_Core_DMS { if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document || $attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_all) { if($valueset = $attrdef->getValueSet()) { if($attrdef->getMultipleValues()) { + if(is_string($attribute)) + $attribute = array($attribute); $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)"; } else $searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentAttributes` WHERE `tblDocumentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentAttributes`.`value`='".$attribute."' AND `tblDocumentAttributes`.`document` = `tblDocuments`.`id`)"; @@ -1517,6 +1531,9 @@ class SeedDMS_Core_DMS { } elseif($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) { if($attrdef->getValueSet()) { if($attrdef->getMultipleValues()) { + /** @noinspection PhpUndefinedVariableInspection */ + if(is_string($attribute)) + $attribute = array($attribute); $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)"; @@ -1588,18 +1605,19 @@ class SeedDMS_Core_DMS { return false; } - $searchQuery = "FROM `tblDocumentContent` ". - "LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` ". + $searchQuery = "FROM `tblDocuments` ". + "LEFT JOIN `tblDocumentContent` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` ". "LEFT JOIN `tblDocumentAttributes` ON `tblDocuments`.`id` = `tblDocumentAttributes`.`document` ". "LEFT JOIN `tblDocumentContentAttributes` ON `tblDocumentContent`.`id` = `tblDocumentContentAttributes`.`content` ". "LEFT JOIN `tblDocumentStatus` ON `tblDocumentStatus`.`documentID` = `tblDocumentContent`.`document` ". - "LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusID` = `tblDocumentStatus`.`statusID` ". - "LEFT JOIN `ttstatid` ON `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` ". + "LEFT JOIN `ttstatid` ON `ttstatid`.`statusID` = `tblDocumentStatus`.`statusID` ". + "LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusLogID` = `ttstatid`.`maxLogID` ". "LEFT JOIN `ttcontentid` ON `ttcontentid`.`maxVersion` = `tblDocumentStatus`.`version` AND `ttcontentid`.`document` = `tblDocumentStatus`.`documentID` ". "LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` ". "LEFT JOIN `tblDocumentCategory` ON `tblDocuments`.`id`=`tblDocumentCategory`.`documentID` ". - "WHERE `ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` ". - "AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version`"; + "WHERE ". + // "`ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` AND ". + "`ttcontentid`.`maxVersion` = `tblDocumentContent`.`version`"; if (strlen($searchKey)>0) { $searchQuery .= " AND (".$searchKey.")"; @@ -1659,13 +1677,17 @@ class SeedDMS_Core_DMS { // Send the complete search query to the database. $resArr = $this->db->getResultArray($searchQuery); + if($resArr === false) + return false; } else { $resArr = array(); } } else { // Send the complete search query to the database. $resArr = $this->db->getResultArray($searchQuery); - } + if($resArr === false) + return false; + } // ------------------- Ausgabe der Ergebnisse ---------------------------- $numResults = count($resArr); @@ -1675,6 +1697,7 @@ class SeedDMS_Core_DMS { foreach ($resArr as $docArr) { $docs[] = $this->getDocument($docArr['id']); } + /** @noinspection PhpUndefinedVariableInspection */ $docresult = array('totalDocs'=>$totalDocs, 'docs'=>$docs); } } else { @@ -1702,7 +1725,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']; @@ -1718,8 +1741,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; @@ -1737,6 +1760,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; @@ -1747,7 +1771,7 @@ 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`"; @@ -1781,7 +1805,7 @@ 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`"; @@ -1827,7 +1851,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']; @@ -1867,7 +1891,9 @@ class SeedDMS_Core_DMS { /** * Return list of all users * - * @return array of instances of {@link SeedDMS_Core_User} or false + * @param string $orderby + * @return array of instances of SeedDMS_Core_User or false + * or false */ function getAllUsers($orderby = '') { /* {{{ */ $classname = $this->classnames['user']; @@ -1879,14 +1905,19 @@ class SeedDMS_Core_DMS { * * @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 integer $role role of new user (can be 0=normal, 1=admin, 2=guest) + * @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 - * @return object of {@link SeedDMS_Core_User} + * @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; @@ -1912,6 +1943,7 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddUser' callback is set */ if(isset($this->_dms->callbacks['onPostAddUser'])) { foreach($this->_dms->callbacks['onPostUser'] as $callback) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $user)) { } } @@ -1924,7 +1956,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']; @@ -1935,7 +1967,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']; @@ -1945,7 +1977,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']; @@ -1957,7 +1989,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) { /* {{{ */ @@ -1974,6 +2006,7 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddGroup' callback is set */ if(isset($this->_dms->callbacks['onPostAddGroup'])) { foreach($this->_dms->callbacks['onPostAddGroup'] as $callback) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $group)) { } } @@ -2030,6 +2063,8 @@ class SeedDMS_Core_DMS { /** * This function should be replaced by getAllKeywordCategories() + * @param $userID + * @return SeedDMS_Core_KeywordCategory[]|bool */ function getAllUserKeywordCategories($userID) { /* {{{ */ $queryStr = "SELECT * FROM `tblKeywordCategories`"; @@ -2063,6 +2098,7 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddKeywordCategory' callback is set */ if(isset($this->_dms->callbacks['onPostAddKeywordCategory'])) { foreach($this->_dms->callbacks['onPostAddKeywordCategory'] as $callback) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $category)) { } } @@ -2109,7 +2145,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; @@ -2139,6 +2175,7 @@ class SeedDMS_Core_DMS { /* Check if 'onPostAddDocumentCategory' callback is set */ if(isset($this->_dms->callbacks['onPostAddDocumentCategory'])) { foreach($this->_dms->callbacks['onPostAddDocumentCategory'] as $callback) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $category)) { } } @@ -2178,7 +2215,8 @@ class SeedDMS_Core_DMS { * 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 + * @param SeedDMS_Core_User $user + * @return string|boolean hash value of false in case of an error */ function createPasswordRequest($user) { /* {{{ */ $hash = md5(uniqid(time())); @@ -2195,6 +2233,7 @@ class SeedDMS_Core_DMS { * returns the user. * * @param string $hash + * @return bool|SeedDMS_Core_User */ function checkPasswordRequest($hash) { /* {{{ */ /* Get the password request from the database */ @@ -2215,6 +2254,7 @@ class SeedDMS_Core_DMS { * Delete a password request * * @param string $hash + * @return bool */ function deletePasswordRequest($hash) { /* {{{ */ /* Delete the request, so nobody can use it a second time */ @@ -2231,7 +2271,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)) @@ -2256,7 +2296,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; @@ -2278,7 +2318,8 @@ class SeedDMS_Core_DMS { * 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 bool|SeedDMS_Core_AttributeDefinition[] of instances of SeedDMS_Core_AttributeDefinition or false + * or false */ function getAllAttributeDefinitions($objtype=0) { /* {{{ */ $queryStr = "SELECT * FROM `tblAttributeDefinitions`"; @@ -2294,6 +2335,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++) { @@ -2309,12 +2351,14 @@ class SeedDMS_Core_DMS { * Add a new attribute definition * * @param string $name name of attribute + * @param $objtype * @param string $type type of attribute - * @param boolean $multiple set to 1 if attribute has multiple attributes + * @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) - * @return object of {@link SeedDMS_Core_User} + * @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))) { @@ -2339,7 +2383,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`"; @@ -2358,8 +2402,10 @@ 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++) { + /** @noinspection PhpUndefinedVariableInspection */ $workflow = new SeedDMS_Core_Workflow($resArr[$i]["id"], $resArr[$i]["name"], $wkfstates[$resArr[$i]["initstate"]]); $workflow->setDMS($this); $workflows[$i] = $workflow; @@ -2372,7 +2418,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); @@ -2396,7 +2442,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; @@ -2422,7 +2468,8 @@ class SeedDMS_Core_DMS { * Add a new workflow * * @param string $name name of workflow - * @param string $initstate initial state of workflow + * @param SeedDMS_Core_Workflow_State $initstate initial state of workflow + * @return bool|SeedDMS_Core_Workflow */ function addWorkflow($name, $initstate) { /* {{{ */ $db = $this->db; @@ -2443,7 +2490,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)) @@ -2466,7 +2513,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; @@ -2491,7 +2538,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`"; @@ -2515,7 +2562,7 @@ 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; @@ -2536,7 +2583,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)) @@ -2561,7 +2608,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; @@ -2582,7 +2629,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`"; @@ -2591,6 +2638,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"]); @@ -2605,7 +2653,7 @@ 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; @@ -2626,7 +2674,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)) @@ -2653,6 +2701,8 @@ class SeedDMS_Core_DMS { * 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`)"; @@ -2662,6 +2712,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']); @@ -2677,6 +2728,8 @@ class SeedDMS_Core_DMS { * 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"; @@ -2684,8 +2737,10 @@ class SeedDMS_Core_DMS { 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']); @@ -2701,6 +2756,7 @@ class SeedDMS_Core_DMS { * 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"; @@ -2708,8 +2764,10 @@ class SeedDMS_Core_DMS { 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']); @@ -2725,6 +2783,7 @@ class SeedDMS_Core_DMS { * 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"; @@ -2732,6 +2791,7 @@ class SeedDMS_Core_DMS { if (!$resArr) return false; + /** @var SeedDMS_Core_Document[] $versions */ $versions = array(); foreach($resArr as $row) { $document = $this->getDocument($row['document']); @@ -2752,6 +2812,10 @@ class SeedDMS_Core_DMS { * * 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) { @@ -2762,6 +2826,7 @@ class SeedDMS_Core_DMS { $queryStr = "SELECT a.*, b.`name` FROM `tblDocumentApprovers`"; break; } + /** @noinspection PhpUndefinedVariableInspection */ $queryStr .= " a LEFT JOIN `tblDocuments` b ON a.`documentID`=b.`id` where"; switch($usergroup) { case 'user': @@ -2781,6 +2846,10 @@ class SeedDMS_Core_DMS { * 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 @@ -2794,6 +2863,7 @@ class SeedDMS_Core_DMS { $queryStr = "DELETE FROM tblDocumentApprovers"; break; } + /** @noinspection PhpUndefinedVariableInspection */ $queryStr .= " WHERE"; switch($usergroup) { case 'user': @@ -2819,7 +2889,7 @@ 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) { @@ -2845,6 +2915,7 @@ class SeedDMS_Core_DMS { return $resArr; case 'docsperstatus': + /** @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); @@ -2895,15 +2966,19 @@ class SeedDMS_Core_DMS { * 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 + * @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; @@ -2948,6 +3023,7 @@ class SeedDMS_Core_DMS { * Create an sql dump of the complete database * * @param string $filename name of dump file + * @return bool */ function createDump($filename) { /* {{{ */ $h = fopen($filename, "w"); @@ -2979,4 +3055,3 @@ class SeedDMS_Core_DMS { } /* }}} */ } -?> diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 622d7f271..4d96054a4 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; @@ -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; @@ -195,6 +195,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ */ protected $_content; + /** + * @var SeedDMS_Core_Folder + */ + protected $_folder; + + /** @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) { /* {{{ */ parent::__construct($id); $this->_name = $name; @@ -218,6 +226,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * 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 @@ -251,7 +260,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * Return an document by its id * * @param integer $id id of document - * @return object/boolean instance of SeedDMS_Core_Document if document exists, null + * @param SeedDMS_Core_DMS $dms + * @return bool|SeedDMS_Core_Document instance of SeedDMS_Core_Document if document exists, null * if document does not exist, false in case of error */ public static function getInstance($id, $dms) { /* {{{ */ @@ -278,12 +288,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 * @@ -298,17 +309,18 @@ 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 + * @return bool */ function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -321,17 +333,18 @@ 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 + * @return bool */ function setComment($newComment) { /* {{{ */ $db = $this->_dms->getDB(); @@ -344,8 +357,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(); @@ -360,7 +380,7 @@ 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(); @@ -385,7 +405,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * This function will delete currently assigned categories and sets new * categories. * - * @param array $newCategories list of category objects + * @param SeedDMS_Core_DocumentCategory[] $newCategories list of category objects + * @return bool */ function setCategories($newCategories) { /* {{{ */ $db = $this->_dms->getDB(); @@ -501,7 +522,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 getParent() { /* {{{ */ return self::getFolder(); @@ -519,7 +540,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) { /* {{{ */ @@ -529,11 +550,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if (!$db->getResult($queryStr)) return false; $this->_folderID = $newFolder->getID(); + /** @noinspection PhpUndefinedFieldInspection */ $this->_folder = $newFolder; // Make sure that the folder search path is also updated. $path = $newFolder->getPath(); $flist = ""; + /** @var SeedDMS_Core_Folder[] $path */ foreach ($path as $f) { $flist .= ":".$f->getID(); } @@ -550,7 +573,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)) @@ -561,7 +584,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) { /* {{{ */ @@ -572,10 +595,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return false; $this->_ownerID = $newOwner->getID(); + /** @noinspection PhpUndefinedFieldInspection */ $this->_owner = $newOwner; return true; } /* }}} */ + /** + * @return bool|int + */ function getDefaultAccess() { /* {{{ */ if ($this->inheritsAccess()) { $res = $this->getFolder(); @@ -592,7 +619,8 @@ 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") { /* {{{ */ $db = $this->_dms->getDB(); @@ -609,6 +637,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ + /** + * @return bool + */ function inheritsAccess() { return $this->_inheritAccess; } /** @@ -667,7 +698,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Set expiration date as unix timestamp * - * @param integer unix timestamp of expiration date + * @param integer $expires unix timestamp of expiration date + * @return bool */ function setExpires($expires) { /* {{{ */ $db = $this->_dms->getDB(); @@ -736,7 +768,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) { /* {{{ */ @@ -764,7 +796,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()) @@ -775,8 +807,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(); @@ -823,9 +862,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * '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 + * @param int $mode access mode (defaults to M_ANY) + * @param int|string $op operation (defaults to O_EQ) + * @return bool|array */ function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */ $db = $this->_dms->getDB(); @@ -871,6 +910,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * @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(); @@ -901,6 +941,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ * @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(); @@ -991,6 +1032,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ $accessList = $this->getAccessList(); if (!$accessList) return false; + /** @var SeedDMS_Core_UserAccess $userAccess */ foreach ($accessList["users"] as $userAccess) { if ($userAccess->getUserID() == $user->getID()) { $mode = $userAccess->getMode(); @@ -1004,6 +1046,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /* Get the highest right defined by a group */ if($accessList['groups']) { $mode = 0; + /** @var SeedDMS_Core_GroupAccess $groupAccess */ foreach ($accessList["groups"] as $groupAccess) { if ($user->isMemberOfGroup($groupAccess->getGroup())) { if ($groupAccess->getMode() > $mode) @@ -1035,7 +1078,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) { /* {{{ */ @@ -1047,6 +1090,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if (!$accessList) return false; + /** @var SeedDMS_Core_GroupAccess $groupAccess */ foreach ($accessList["groups"] as $groupAccess) { if ($groupAccess->getGroupID() == $group->getID()) { $foundInACL = true; @@ -1072,9 +1116,10 @@ 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 + * @param bool $incdisabled set to true if disabled user shall be included + * @return array|bool */ - function getNotifyList($type=0) { /* {{{ */ + function getNotifyList($type=0, $incdisabled=false) { /* {{{ */ if (empty($this->_notifyList)) { $db = $this->_dms->getDB(); @@ -1088,7 +1133,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ { if ($row["userID"] != -1) { $u = $this->_dms->getUser($row["userID"]); - if($u && !$u->isDisabled()) + if($u && (!$u->isDisabled() || $incdisabled)) array_push($this->_notifyList["users"], $u); } else { //if ($row["groupID"] != -1) $g = $this->_dms->getGroup($row["groupID"]); @@ -1113,7 +1158,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) { @@ -1193,6 +1240,7 @@ 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; + /** @var SeedDMS_Core_GroupAccess $group */ foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; @@ -1211,6 +1259,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ return -4; } $found = false; + /** @var SeedDMS_Core_GroupAccess $group */ foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; @@ -1248,10 +1297,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 @@ -1261,6 +1310,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; @@ -1336,7 +1386,7 @@ 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(); @@ -1386,7 +1436,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); @@ -1423,7 +1473,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) { @@ -1441,7 +1492,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) { @@ -1479,7 +1531,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; @@ -1517,7 +1570,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']; @@ -1572,7 +1625,7 @@ 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(); @@ -1580,13 +1633,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ 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) @@ -1608,7 +1662,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) { /* {{{ */ @@ -1625,13 +1679,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 */ @@ -1644,6 +1699,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ } } /* }}} */ + /** + * @return bool|null|SeedDMS_Core_DocumentContent + */ function __getLatestContent() { /* {{{ */ if (!$this->_latestContent) { $db = $this->_dms->getDB(); @@ -1672,20 +1730,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. @@ -1707,7 +1766,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) { /* {{{ */ @@ -1837,7 +1896,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ /** * Call callback onPreRemoveDocument before deleting content * - * @param integer $version version number of content + * @param SeedDMS_Core_DocumentContent $version version number of content + * @return bool|mixed */ function removeContent($version) { /* {{{ */ /* Check if 'onPreRemoveDocument' callback is set */ @@ -1868,7 +1928,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) { /* {{{ */ @@ -2130,7 +2190,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ if(isset($this->_dms->callbacks['onPreRemoveDocument'])) { foreach($this->_dms->callbacks['onPreRemoveDocument'] as $callback) { $ret = call_user_func($callback[0], $callback[1], $this); - if($ret === false) + if(is_bool($ret)) return $ret; } } @@ -3505,7 +3565,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return 0; $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, - `comment`, `date`, `userID`) ". + `comment`, `date`, `userID`) ". "VALUES ('". $indstatus["reviewID"] ."', '". (int) $status ."', ".$db->qstr($comment).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; @@ -3557,7 +3617,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return 0; $queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, - `comment`, `date`, `userID`) ". + `comment`, `date`, `userID`) ". "VALUES ('". $reviewStatus[0]["reviewID"] ."', '". (int) $status ."', ".$db->qstr($comment).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; @@ -3727,7 +3787,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return 0; $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, - `comment`, `date`, `userID`) ". + `comment`, `date`, `userID`) ". "VALUES ('". $indstatus["approveID"] ."', '". (int) $status ."', ".$db->qstr($comment).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; @@ -3771,7 +3831,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return 0; $queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, - `comment`, `date`, `userID`) ". + `comment`, `date`, `userID`) ". "VALUES ('". $approvalStatus[0]["approveID"] ."', '". (int) $status ."', ".$db->qstr($comment).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')"; @@ -4664,7 +4724,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; @@ -4683,6 +4743,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; @@ -4691,22 +4759,37 @@ 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; } /** @@ -4717,8 +4800,10 @@ class SeedDMS_Core_DocumentLink { /* {{{ */ * 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 + * @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; @@ -4761,7 +4846,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; @@ -4818,6 +4903,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; @@ -4833,15 +4933,30 @@ 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; } /* * Set the comment of the document file * - * @param $newComment string new comment of document + * @param string $newComment string new comment of document */ function setComment($newComment) { /* {{{ */ $db = $this->_document->_dms->getDB(); @@ -4854,6 +4969,9 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getDate() { return $this->_date; } /** @@ -4880,10 +4998,29 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ return true; } /* }}} */ + /** + * @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; } /* @@ -4902,16 +5039,25 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ return true; } /* }}} */ + /** + * @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; } /* @@ -4933,6 +5079,9 @@ class SeedDMS_Core_DocumentFile { /* {{{ */ return true; } /* }}} */ + /** + * @return int + */ function isPublic() { return $this->_public; } /* @@ -4999,18 +5148,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; @@ -5021,7 +5197,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 @@ -5029,12 +5205,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; @@ -5062,6 +5244,12 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ return true; } /* }}} */ + /** + * @param $approver + * @param $type + * @param $status + * @return bool + */ function addApprover($approver, $type, $status) { /* {{{ */ $dms = $this->_dms; @@ -5089,6 +5277,10 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ return true; } /* }}} */ + /** + * @param $status + * @return bool + */ function setStatus($status) { /* {{{ */ if (!is_integer($status)) { return false; @@ -5100,14 +5292,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; @@ -5120,6 +5322,10 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ } } /* }}} */ + /** + * @param $type + * @return array|bool|null + */ function getApprovers($type) { /* {{{ */ if (strcasecmp($type, "i") && strcasecmp($type, "g")) { return false; @@ -5132,4 +5338,3 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */ } } /* }}} */ } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index 985208be9..b6ff9e035 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; @@ -91,6 +133,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * 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 @@ -129,7 +172,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * Return a folder by its id * * @param integer $id id of folder - * @return object/boolean instance of SeedDMS_Core_Folder if document exists, null + * @param SeedDMS_Core_DMS $dms + * @return SeedDMS_Core_Folder|bool instance of SeedDMS_Core_Folder if document exists, null * if document does not exist, false in case of error */ public static function getInstance($id, $dms) { /* {{{ */ @@ -144,22 +188,24 @@ 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 + * @return bool */ public function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -173,8 +219,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(); @@ -222,7 +275,7 @@ 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)) { @@ -239,10 +292,10 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * Check if the folder is subfolder * * This function checks if the passed folder is a subfolder of the current - * folder. + * folder. * - * @param object $subFolder potential sub folder - * @return boolean true if passes folder is a subfolder + * @param SeedDMS_Core_Folder $subfolder + * @return bool true if passes folder is a subfolder */ function isSubFolder($subfolder) { /* {{{ */ $target_path = $subfolder->getPath(); @@ -259,7 +312,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) { /* {{{ */ @@ -313,6 +366,7 @@ 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"]."'"; + /** @noinspection PhpUnusedLocalVariableInspection */ $res = $db->getResult($queryStr); } @@ -325,6 +379,7 @@ 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"]."'"; + /** @noinspection PhpUnusedLocalVariableInspection */ $res = $db->getResult($queryStr); } @@ -345,7 +400,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) { /* {{{ */ @@ -360,6 +415,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ + /** + * @return bool|int + */ function getDefaultAccess() { /* {{{ */ if ($this->inheritsAccess()) { $res = $this->getParent(); @@ -378,6 +436,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * * @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(); @@ -450,7 +509,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); @@ -471,7 +531,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @param string $dir direction of sorting (asc or desc) * @param integer $limit limit number of subfolders * @param integer $offset offset in retrieved list of subfolders - * @return array list of folder objects or false in case of an error + * @return SeedDMS_Core_Folder[]|bool list of folder objects or false in case of an error */ function getSubFolders($orderby="", $dir="asc", $limit=0, $offset=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -511,7 +571,7 @@ 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 + * @return bool|SeedDMS_Core_Folder * an error. */ function addSubFolder($name, $comment, $owner, $sequence, $attributes=array()) { /* {{{ */ @@ -554,7 +614,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)) { } } } @@ -566,7 +627,7 @@ 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)) { @@ -632,7 +693,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); @@ -645,12 +707,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /** * Check if folder has document with given name * - * @return boolean true if document exists, false if not or in case + * @param string $name + * @return bool true if document exists, false if not or in case * of an error */ function hasDocumentByName($name) { /* {{{ */ $db = $this->_dms->getDB(); if (isset($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); @@ -672,7 +736,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @param string $dir direction of sorting (asc or desc) * @param integer $limit limit number of documents * @param integer $offset offset in retrieved list of documents - * @return array list of documents or false in case of an error + * @return SeedDMS_Core_Document[]|bool list of documents or false in case of an error */ function getDocuments($orderby="", $dir="asc", $limit=0, $offset=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -718,13 +782,14 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * 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 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 array with four elements 'document_count', 'folder_count' + * @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. + * 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(); @@ -794,7 +859,7 @@ 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. + * 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. * @@ -803,8 +868,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @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 SeedDMS_Core_User $keywords keywords of new document + * @param SeedDMS_Core_DocumentCategory[] $categories list of category objects * @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 @@ -812,17 +877,17 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @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 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 object $workflow - * @return array/boolean false in case of error, otherwise an array + * @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. + * 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(); @@ -880,7 +945,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)) { } } } @@ -901,8 +967,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $db = $this->_dms->getDB(); /* Check if 'onPreRemoveFolder' callback is set */ - if(isset($this->_dms->callbacks['onPreRemoveFolder'])) { - foreach($this->_dms->callbacks['onPreRemoveFolder'] as $callback) { + if(isset($this->_dms->callbacks['onPreRemoveFromDatabaseFolder'])) { + foreach($this->_dms->callbacks['onPreRemoveFromDatabaseFolder'] as $callback) { $ret = call_user_func($callback[0], $callback[1], $this); if(is_bool($ret)) return $ret; @@ -942,8 +1008,9 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $db->commitTransaction(); /* Check if 'onPostRemoveFolder' callback is set */ - if(isset($this->_dms->callbacks['onPostRemoveFolder'])) { - foreach($this->_dms->callbacks['onPostRemoveFolder'] as $callback) { + if(isset($this->_dms->callbacks['onPostRemoveFromDatabaseFolder'])) { + foreach($this->_dms->callbacks['onPostRemoveFromDatabaseFolder'] as $callback) { + /** @noinspection PhpStatementHasEmptyBodyInspection */ if(!call_user_func($callback[0], $callback[1], $this->_id)) { } } @@ -960,6 +1027,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @return boolean true on success, false in case of an error */ function remove() { /* {{{ */ + /** @noinspection PhpUnusedLocalVariableInspection */ $db = $this->_dms->getDB(); // Do not delete the root folder. @@ -967,6 +1035,15 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return false; } + /* Check if 'onPreRemoveFolder' callback is set */ + if(isset($this->_dms->callbacks['onPreRemoveFolder'])) { + foreach($this->_dms->callbacks['onPreRemoveFolder'] as $callback) { + $ret = call_user_func($callback[0], $callback[1], $this); + if(is_bool($ret)) + return $ret; + } + } + //Entfernen der Unterordner und Dateien $res = $this->getSubFolders(); if (is_bool($res) && !$res) return false; @@ -987,7 +1064,18 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { } } - return $this->removeFromDatabase(); + $ret = $this->removeFromDatabase(); + if(!$ret) + return $ret; + + /* Check if 'onPostRemoveFolder' callback is set */ + if(isset($this->_dms->callbacks['onPostRemoveFolder'])) { + foreach($this->_dms->callbacks['onPostRemoveFolder'] as $callback) { + call_user_func($callback[0], $callback[1], $this); + } + } + + return $ret; } /* }}} */ /** @@ -1003,10 +1091,10 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * 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 + * + * @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(); @@ -1073,6 +1161,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @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(); @@ -1103,6 +1192,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * @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(); @@ -1123,6 +1213,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(); @@ -1179,6 +1274,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { $accessList = $this->getAccessList(); if (!$accessList) return false; + /** @var SeedDMS_Core_UserAccess $userAccess */ foreach ($accessList["users"] as $userAccess) { if ($userAccess->getUserID() == $user->getID()) { $mode = $userAccess->getMode(); @@ -1192,6 +1288,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { /* Get the highest right defined by a group */ if($accessList['groups']) { $mode = 0; + /** @var SeedDMS_Core_GroupAccess $groupAccess */ foreach ($accessList["groups"] as $groupAccess) { if ($user->isMemberOfGroup($groupAccess->getGroup())) { if ($groupAccess->getMode() > $mode) @@ -1219,7 +1316,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) { /* {{{ */ @@ -1229,6 +1326,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { if (!$accessList) return false; + /** @var SeedDMS_Core_GroupAccess $groupAccess */ foreach ($accessList["groups"] as $groupAccess) { if ($groupAccess->getGroupID() == $group->getID()) { $foundInACL = true; @@ -1245,13 +1343,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) { /* {{{ */ @@ -1293,6 +1392,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) { @@ -1300,6 +1400,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); @@ -1307,7 +1409,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 @@ -1328,6 +1430,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; @@ -1377,6 +1480,7 @@ 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; + /** @var SeedDMS_Core_GroupAccess $group */ foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; @@ -1395,6 +1499,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return -4; } $found = false; + /** @var SeedDMS_Core_GroupAccess $group */ foreach ($acl["groups"] as $group) { if ($group->getGroupID() == $userOrGroupID) { $found = true; @@ -1428,7 +1533,7 @@ 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 @@ -1436,12 +1541,12 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * * @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 + * @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. + * -3: User is not subscribed. + * -4: Database / internal error. + * 0: Update successful. */ function removeNotify($userOrGroupID, $isUser, $type=0) { /* {{{ */ $db = $this->_dms->getDB(); @@ -1521,9 +1626,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { * 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 - * + * @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) { /* {{{ */ @@ -1551,9 +1655,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; @@ -1692,6 +1799,22 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object { return true; } /* }}} */ + /** + * Get the min and max sequence value for documents + * + * @return bool|array array with keys 'min' and 'max', false in case of an error + */ + function getDocumentsMinMax() { /* {{{ */ + $db = $this->_dms->getDB(); + + $queryStr = "SELECT min(`sequence`) AS `min`, max(`sequence`) AS `max` FROM `tblDocuments` WHERE `folder` = " . (int) $this->_id; + $resArr = $db->getResultArray($queryStr); + if (is_bool($resArr) && $resArr == false) + return false; + + return $resArr[0]; + } /* }}} */ + } ?> diff --git a/SeedDMS_Core/Core/inc.ClassGroup.php b/SeedDMS_Core/Core/inc.ClassGroup.php index 83dbd0d49..8bcbf253e 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,11 +67,11 @@ 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 if group was found, null - * if group was not found, false in case of error + * @return SeedDMS_Core_Group|bool instance of class SeedDMS_Core_Group if group was + * found, null if group was not found, false in case of error */ public static function getInstance($id, $dms, $by='') { /* {{{ */ $db = $dms->getDB(); @@ -92,6 +97,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(); @@ -114,14 +124,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(); @@ -133,8 +156,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(); @@ -146,6 +176,9 @@ class SeedDMS_Core_Group { /* {{{ */ return true; } /* }}} */ + /** + * @return SeedDMS_Core_User[]|bool + */ function getUsers() { /* {{{ */ $db = $this->_dms->getDB(); @@ -161,6 +194,7 @@ class SeedDMS_Core_Group { /* {{{ */ $classname = $this->_dms->getClassname('user'); 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); } @@ -168,6 +202,9 @@ class SeedDMS_Core_Group { /* {{{ */ return $this->_users; } /* }}} */ + /** + * @return SeedDMS_Core_User[]|bool + */ function getManagers() { /* {{{ */ $db = $this->_dms->getDB(); @@ -182,12 +219,18 @@ class SeedDMS_Core_Group { /* {{{ */ $classname = $this->_dms->getClassname('user'); 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(); @@ -200,6 +243,10 @@ class SeedDMS_Core_Group { /* {{{ */ return true; } /* }}} */ + /** + * @param SeedDMS_Core_User $user + * @return bool + */ function removeUser($user) { /* {{{ */ $db = $this->_dms->getDB(); @@ -214,7 +261,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 @@ -242,7 +289,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) { /* {{{ */ @@ -262,7 +309,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 */ @@ -406,7 +453,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(); @@ -433,7 +480,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(); @@ -458,4 +505,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.ClassObject.php b/SeedDMS_Core/Core/inc.ClassObject.php index 4a9df2a30..e53d2416c 100644 --- a/SeedDMS_Core/Core/inc.ClassObject.php +++ b/SeedDMS_Core/Core/inc.ClassObject.php @@ -34,16 +34,20 @@ 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; + /** + * 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 @@ -67,8 +71,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 +106,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 +129,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 +160,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 +190,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 +209,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 +262,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 +293,3 @@ class SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassUser.php b/SeedDMS_Core/Core/inc.ClassUser.php index 6e809e73b..86286c6c8 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,13 +186,13 @@ 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 if user was found, null - * if user was not found, false in case of error + * @return SeedDMS_Core_User|bool instance of class SeedDMS_Core_User if user was + * found, null if user was not found, false in case of error */ public static function getInstance($id, $dms, $by='', $email='') { /* {{{ */ $db = $dms->getDB(); @@ -193,6 +221,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(); @@ -208,6 +241,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; @@ -216,14 +250,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(); @@ -236,8 +283,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(); @@ -250,8 +304,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(); @@ -264,8 +325,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(); @@ -284,8 +352,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(); @@ -298,8 +373,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getLanguage() { return $this->_language; } + /** + * @param $newLanguage + * @return bool + */ function setLanguage($newLanguage) { /* {{{ */ $db = $this->_dms->getDB(); @@ -312,8 +394,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getTheme() { return $this->_theme; } + /** + * @param string $newTheme + * @return bool + */ function setTheme($newTheme) { /* {{{ */ $db = $this->_dms->getDB(); @@ -326,8 +415,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getComment() { return $this->_comment; } + /** + * @param $newComment + * @return bool + */ function setComment($newComment) { /* {{{ */ $db = $this->_dms->getDB(); @@ -340,10 +436,18 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return string + */ function getRole() { return $this->_role; } + /** + * @param integer $newrole + * @return bool + */ function setRole($newrole) { /* {{{ */ $db = $this->_dms->getDB(); + $newrole = intval($newrole); $queryStr = "UPDATE `tblUsers` SET `role` = " . $newrole . " WHERE `id` = " . $this->_id; if (!$db->getResult($queryStr)) @@ -353,9 +457,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @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; @@ -366,9 +476,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @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; @@ -379,8 +495,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return bool|int + */ function isHidden() { return $this->_isHidden; } + /** + * @param $isHidden + * @return bool + */ function setHidden($isHidden) { /* {{{ */ $db = $this->_dms->getDB(); @@ -393,8 +516,15 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return bool|int + */ function isDisabled() { return $this->_isDisabled; } + /** + * @param $isDisabled + * @return bool + */ function setDisabled($isDisabled) { /* {{{ */ $db = $this->_dms->getDB(); @@ -407,6 +537,9 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return bool|int + */ function addLoginFailure() { /* {{{ */ $db = $this->_dms->getDB(); @@ -418,6 +551,9 @@ class SeedDMS_Core_User { /* {{{ */ return $this->_loginFailures; } /* }}} */ + /** + * @return bool + */ function clearLoginFailures() { /* {{{ */ $db = $this->_dms->getDB(); @@ -448,8 +584,15 @@ class SeedDMS_Core_User { /* {{{ */ return $resArr[0]['sum']; } /* }}} */ + /** + * @return int + */ function getQuota() { return $this->_quota; } + /** + * @param integer $quota + * @return bool + */ function setQuota($quota) { /* {{{ */ $db = $this->_dms->getDB(); @@ -462,12 +605,20 @@ class SeedDMS_Core_User { /* {{{ */ return true; } /* }}} */ + /** + * @return null|SeedDMS_Core_Folder + */ function getHomeFolder() { return $this->_homeFolder; } + /** + * @param integer $homefolder + * @return bool + */ function setHomeFolder($homefolder) { /* {{{ */ $db = $this->_dms->getDB(); + $homefolder = intval($homefolder); - $queryStr = "UPDATE `tblUsers` SET `homefolder` = " . ($homefolder ? (int) $homefolder : NULL) . " WHERE `id` = " . $this->_id; + $queryStr = "UPDATE `tblUsers` SET `homefolder` = " . ($homefolder ? $homefolder : NULL) . " WHERE `id` = " . $this->_id; if (!$db->getResult($queryStr)) return false; @@ -656,9 +807,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 */ @@ -671,8 +822,9 @@ class SeedDMS_Core_User { /* {{{ */ * anymore. */ if(!$assignToUser) - return; - $assignTo = $assignToUser->getID(); + return false; + /** @noinspection PhpUnusedLocalVariableInspection */ + $assignTo = $assignToUser->getID(); $db->startTransaction(); @@ -828,7 +980,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 */ @@ -848,7 +1000,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 */ @@ -866,7 +1018,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(); @@ -883,6 +1035,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); @@ -894,7 +1047,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) { /* {{{ */ @@ -925,7 +1078,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(); @@ -940,6 +1093,11 @@ class SeedDMS_Core_User { /* {{{ */ return $resArr; } /* }}} */ + /** + * @param $tmpfile + * @param $mimeType + * @return bool + */ function setImage($tmpfile, $mimeType) { /* {{{ */ $db = $this->_dms->getDB(); @@ -961,9 +1119,7 @@ class SeedDMS_Core_User { /* {{{ */ /** * Returns all documents of a given user - * - * @param object $user - * @return array list of documents + * @return SeedDMS_Core_Document[]|bool list of documents */ function getDocuments() { /* {{{ */ $db = $this->_dms->getDB(); @@ -980,6 +1136,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; @@ -990,8 +1147,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(); @@ -1008,6 +1164,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; @@ -1033,7 +1190,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(); @@ -1126,14 +1283,14 @@ 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(); $status = array("indstatus"=>array(), "grpstatus"=>array()); $queryStr = - "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ". + "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ". "`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ". "`tblDocumentApproveLog`.`userID` ". "FROM `tblDocumentApprovers` ". @@ -1196,7 +1353,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(); @@ -1238,7 +1395,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(); @@ -1298,7 +1455,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(); @@ -1321,7 +1478,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(); @@ -1345,7 +1502,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(); @@ -1368,7 +1525,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(); @@ -1397,6 +1554,7 @@ class SeedDMS_Core_User { /* {{{ */ */ function setMandatoryReviewer($id, $isgroup=false) { /* {{{ */ $db = $this->_dms->getDB(); + $id = (int) $id; if ($isgroup){ @@ -1419,6 +1577,7 @@ class SeedDMS_Core_User { /* {{{ */ if (is_bool($resArr) && !$resArr) return false; } + return false; } /* }}} */ /** @@ -1431,12 +1590,13 @@ class SeedDMS_Core_User { /* {{{ */ */ function setMandatoryApprover($id, $isgroup=false) { /* {{{ */ $db = $this->_dms->getDB(); + $id = (int) $id; if ($isgroup){ - $queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverGroupID` = " . (int) $id; + $queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverGroupID` = " . $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); @@ -1444,14 +1604,16 @@ class SeedDMS_Core_User { /* {{{ */ }else{ - $queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverUserID` = " . (int) $id; + $queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverUserID` = " . $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; } /* }}} */ /** @@ -1466,18 +1628,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) { /* {{{ */ @@ -1544,7 +1708,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(); @@ -1571,7 +1735,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(); @@ -1593,4 +1757,3 @@ class SeedDMS_Core_User { /* {{{ */ } /* }}} */ } /* }}} */ -?> diff --git a/SeedDMS_Core/Core/inc.ClassWorkflow.php b/SeedDMS_Core/Core/inc.ClassWorkflow.php index 474ae3c3c..0374bfafb 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,14 +70,27 @@ class SeedDMS_Core_Workflow { /* {{{ */ $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; } + /** + * @param $newName + * @return bool + */ function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -84,8 +103,15 @@ class SeedDMS_Core_Workflow { /* {{{ */ return true; } /* }}} */ + /** + * @return SeedDMS_Core_Workflow_State + */ function getInitState() { return $this->_initstate; } + /** + * @param SeedDMS_Core_Workflow_State $state + * @return bool + */ function setInitState($state) { /* {{{ */ $db = $this->_dms->getDB(); @@ -98,6 +124,9 @@ class SeedDMS_Core_Workflow { /* {{{ */ return true; } /* }}} */ + /** + * @return SeedDMS_Core_Workflow_Transition[]|bool + */ function getTransitions() { /* {{{ */ $db = $this->_dms->getDB(); @@ -121,7 +150,11 @@ class SeedDMS_Core_Workflow { /* {{{ */ return $this->_transitions; } /* }}} */ + /** + * @return array + */ function getStates() { /* {{{ */ + /** @noinspection PhpUnusedLocalVariableInspection */ $db = $this->_dms->getDB(); if(!$this->_transitions) @@ -142,9 +175,10 @@ class SeedDMS_Core_Workflow { /* {{{ */ * Get the transition by its id * * @param integer $id id of transition - * @param object transition + * @return bool|SeedDMS_Core_Workflow_Transition */ function getTransition($id) { /* {{{ */ + /** @noinspection PhpUnusedLocalVariableInspection */ $db = $this->_dms->getDB(); if(!$this->_transitions) @@ -159,8 +193,8 @@ class SeedDMS_Core_Workflow { /* {{{ */ /** * Get the transitions that can be triggered while being in the given state * - * @param object $state current workflow state - * @param array list of transitions + * @param SeedDMS_Core_Workflow_State $state current workflow state + * @return SeedDMS_Core_Workflow_Transition[]|bool */ function getNextTransitions($state) { /* {{{ */ $db = $this->_dms->getDB(); @@ -183,8 +217,8 @@ class SeedDMS_Core_Workflow { /* {{{ */ /** * Get the transitions that lead to the given state * - * @param object $state current workflow state - * @param array list of transitions + * @param SeedDMS_Core_Workflow_State $state current workflow state + * @return SeedDMS_Core_Workflow_Transition[]|bool */ function getPreviousTransitions($state) { /* {{{ */ $db = $this->_dms->getDB(); @@ -207,9 +241,9 @@ class SeedDMS_Core_Workflow { /* {{{ */ /** * 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 + * @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,6 +335,10 @@ class SeedDMS_Core_Workflow { /* {{{ */ return true; } /* }}} */ + /** + * @param SeedDMS_Core_Workflow_State[] $laststates + * @return SeedDMS_Core_Workflow_State[]|bool + */ private function penetrate($laststates) { $state = end($laststates); $transitions = $this->getNextTransitions($state); @@ -323,6 +361,7 @@ class SeedDMS_Core_Workflow { /* {{{ */ * @return boolean list of states if workflow contains cycles, otherwise false */ function checkForCycles() { /* {{{ */ + /** @noinspection PhpUnusedLocalVariableInspection */ $db = $this->_dms->getDB(); $initstate = $this->getInitState(); @@ -389,40 +428,48 @@ 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; + /** + * 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; @@ -432,14 +479,27 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ $this->_dms = null; } + /** + * @param $dms + */ function setDMS($dms) { $this->_dms = $dms; } + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return string + */ function getName() { return $this->_name; } + /** + * @param string $newName + * @return bool + */ function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -452,8 +512,15 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ return true; } /* }}} */ + /** + * @return int maximum + */ function getMaxTime() { return $this->_maxtime; } + /** + * @param $maxtime + * @return bool + */ function setMaxTime($maxtime) { /* {{{ */ $db = $this->_dms->getDB(); @@ -466,8 +533,15 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ return true; } /* }}} */ + /** + * @return int maximum + */ function getPreCondFunc() { return $this->_precondfunc; } + /** + * @param $precondfunc + * @return bool + */ function setPreCondFunc($precondfunc) { /* {{{ */ $db = $this->_dms->getDB(); @@ -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,6 +565,10 @@ class SeedDMS_Core_Workflow_State { /* {{{ */ */ function getDocumentStatus() { return $this->_documentstatus; } + /** + * @param $docstatus + * @return bool + */ function setDocumentStatus($docstatus) { /* {{{ */ $db = $this->_dms->getDB(); @@ -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,33 +665,51 @@ 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; + /** + * SeedDMS_Core_Workflow_Action constructor. + * @param $id + * @param $name + */ function __construct($id, $name) { $this->_id = $id; $this->_name = $name; $this->_dms = null; } + /** + * @param $dms + */ function setDMS($dms) { $this->_dms = $dms; } + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return string name + */ function getName() { return $this->_name; } + /** + * @param $newName + * @return bool + */ function setName($newName) { /* {{{ */ $db = $this->_dms->getDB(); @@ -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,61 +806,70 @@ 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; + /** + * 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; @@ -774,14 +880,27 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ $this->_dms = null; } + /** + * @param $dms + */ function setDMS($dms) { $this->_dms = $dms; } + /** + * @return int + */ function getID() { return $this->_id; } + /** + * @return SeedDMS_Core_Workflow + */ function getWorkflow() { return $this->_workflow; } + /** + * @param SeedDMS_Core_Workflow $newWorkflow + * @return bool + */ function setWorkflow($newWorkflow) { /* {{{ */ $db = $this->_dms->getDB(); @@ -794,8 +913,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ + + /** + * @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(); @@ -808,8 +935,15 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ + /** + * @return SeedDMS_Core_Workflow_State + */ function getNextState() { return $this->_nextstate; } + /** + * @param SeedDMS_Core_Workflow_State $newNextState + * @return bool + */ function setNextState($newNextState) { /* {{{ */ $db = $this->_dms->getDB(); @@ -822,8 +956,15 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ + /** + * @return SeedDMS_Core_Workflow_Action + */ function getAction() { return $this->_action; } + /** + * @param SeedDMS_Core_Workflow_Action $newAction + * @return bool + */ function setAction($newAction) { /* {{{ */ $db = $this->_dms->getDB(); @@ -836,8 +977,15 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */ return true; } /* }}} */ + /** + * @return int + */ function getMaxTime() { return $this->_maxtime; } + /** + * @param $maxtime + * @return bool + */ function setMaxTime($maxtime) { /* {{{ */ $db = $this->_dms->getDB(); @@ -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,12 +1117,21 @@ class SeedDMS_Core_Workflow_Transition_User { /* {{{ */ */ var $_dms; + /** + * 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; } + /** + * @param $dms + */ function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ @@ -1043,6 +1200,13 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */ */ var $_dms; + /** + * 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; @@ -1050,6 +1214,9 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */ $this->_numOfUsers = $numOfUsers; } /* }}} */ + /** + * @param $dms + */ function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ @@ -1156,6 +1323,17 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */ */ var $_dms; + /** + * 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; @@ -1168,26 +1346,44 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */ $this->_dms = null; } + /** + * @param $dms + */ function setDMS($dms) { /* {{{ */ $this->_dms = $dms; } /* }}} */ + /** + * @return object + */ function getTransition() { /* {{{ */ return $this->_transition; } /* }}} */ + /** + * @return object + */ function getWorkflow() { /* {{{ */ return $this->_workflow; } /* }}} */ + /** + * @return object + */ function getUser() { /* {{{ */ return $this->_user; } /* }}} */ + /** + * @return string + */ function getComment() { /* {{{ */ return $this->_comment; } /* }}} */ + /** + * @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 ae7fb09ca..ce1efd7bc 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 @@ -112,7 +113,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) { @@ -172,7 +173,7 @@ class SeedDMS_Core_DatabaseAccess { * @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 + * @param bool|string $database name of database */ function __construct($driver, $hostname, $user, $passw, $database = false) { /* {{{ */ $this->_driver = $driver; @@ -204,7 +205,7 @@ class SeedDMS_Core_DatabaseAccess { $this->_ttapproveid = false; $this->_ttstatid = false; $this->_ttcontentid = false; - $this->_useviews = true; + $this->_useviews = false; $this->_debug = false; } /* }}} */ @@ -246,6 +247,7 @@ class SeedDMS_Core_DatabaseAccess { $dsn = $this->_driver.":".$this->_database; break; } + /** @noinspection PhpUndefinedVariableInspection */ $this->_conn = new PDO($dsn, $this->_user, $this->_passw); if (!$this->_conn) return false; @@ -291,7 +293,7 @@ class SeedDMS_Core_DatabaseAccess { /** * Sanitize String used in database operations * - * @param string text + * @param string $text * @return string sanitized string */ function qstr($text) { /* {{{ */ @@ -301,7 +303,7 @@ class SeedDMS_Core_DatabaseAccess { /** * Replace back ticks by '"' * - * @param string text + * @param string $text * @return string sanitized string */ function rbt($text) { /* {{{ */ @@ -314,7 +316,8 @@ 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 + * @param bool $retick + * @return array|bool data if query could be executed otherwise false */ function getResultArray($queryStr, $retick=true) { /* {{{ */ $resArr = array(); @@ -389,7 +392,9 @@ class SeedDMS_Core_DatabaseAccess { /** * Return the id of the last instert record * - * @return integer id used in last autoincrement + * @param string $tablename + * @param string $fieldname + * @return int id used in last autoincrement */ function getInsertID($tablename='', $fieldname='id') { /* {{{ */ if($this->_driver == 'pgsql') @@ -409,6 +414,10 @@ class SeedDMS_Core_DatabaseAccess { /** * Create various temporary tables to speed up and simplify sql queries + * + * @param string $tableName + * @param bool $override + * @return bool */ private function __createTemporaryTable($tableName, $override=false) { /* {{{ */ if (!strcasecmp($tableName, "ttreviewid")) { @@ -579,7 +588,11 @@ class SeedDMS_Core_DatabaseAccess { } /* }}} */ /** - * Create various temporary tables to speed up and simplify sql queries + * Create various views to speed up and simplify sql queries + * + * @param string $tableName + * @param bool $override + * @return bool */ private function __createView($tableName, $override=false) { /* {{{ */ if (!strcasecmp($tableName, "ttreviewid")) { @@ -741,7 +754,11 @@ class SeedDMS_Core_DatabaseAccess { } /* }}} */ /** - * Create various temporary tables to speed up and simplify sql queries + * Create various temporary tables or view to speed up and simplify sql queries + * + * @param string $tableName + * @param bool $override + * @return bool */ public function createTemporaryTable($tableName, $override=false) { /* {{{ */ if($this->_useviews) @@ -755,6 +772,7 @@ class SeedDMS_Core_DatabaseAccess { * 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') { /* {{{ */ @@ -823,6 +841,7 @@ class SeedDMS_Core_DatabaseAccess { /** * Return sql statement for returning the current timestamp * + * @param $field * @return string sql code */ function castToText($field) { /* {{{ */ @@ -834,5 +853,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..abc56fb86 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; @@ -215,4 +285,3 @@ class SeedDMS_Core_File { else return $dest; } /* }}} */ } -?> diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index 7c7eb22d7..054d70519 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -12,11 +12,11 @@ uwe@steinmann.cx yes - 2017-11-07 + 2018-07-03 - 5.1.5 - 5.1.5 + 5.1.9 + 5.1.9 stable @@ -24,18 +24,6 @@ GPL License -- use views instead of temp. tables -- add list of expired documents in SeedDMS_Core_DMS::getDocumentList() -- add methods to set comment, name, public, version of document files -- add method SeedDMS_Core_Document::transferToUser() -- SeedDMS_Core_Document::addDocumentFile() returns object of file -- add SeedDMS_Core_DocumentFile::setDate() -- remove SeedDMS_Core_DocumentCategory::addCategory() and getCategories() -- add optional parameters $limit and $offset to SeedDMS_Core_Folder::getDocuments() - and SeedDMS_Core_Folder::getSubFolders() -- getInstance() returns now null instead of false if the object was not found in the db -- add new methods SeedDMS_Core_Document::addCategories() and - SeedDMS_Core_Document::removeCategories() @@ -1226,7 +1214,7 @@ do not sort some temporary tables anymore, because it causes an error in mysql i - 2017-09-05 + 2018-02-14 4.3.37 @@ -1238,6 +1226,7 @@ do not sort some temporary tables anymore, because it causes an error in mysql i GPL License +- SeedDMS_Core_DMS::search() finds documents without a status log @@ -1545,5 +1534,85 @@ returns just users which are not disabled - all changes from 5.0.14 merged + + 2017-11-07 + + + 5.1.5 + 5.1.5 + + + stable + stable + + GPL License + +- use views instead of temp. tables +- add list of expired documents in SeedDMS_Core_DMS::getDocumentList() +- add methods to set comment, name, public, version of document files +- add method SeedDMS_Core_Document::transferToUser() +- SeedDMS_Core_Document::addDocumentFile() returns object of file +- add SeedDMS_Core_DocumentFile::setDate() +- remove SeedDMS_Core_DocumentCategory::addCategory() and getCategories() +- add optional parameters $limit and $offset to SeedDMS_Core_Folder::getDocuments() + and SeedDMS_Core_Folder::getSubFolders() +- getInstance() returns now null instead of false if the object was not found in the db +- add new methods SeedDMS_Core_Document::addCategories() and + SeedDMS_Core_Document::removeCategories() + + + + 2018-02-14 + + + 5.1.6 + 5.1.6 + + + stable + stable + + GPL License + +add SeedDMS_Core_Folder::getDocumentsMinMax() +add lots of DocBlocks from merge request #8 +add SeedDMS_Core_AttributeDefinition::removeValue() + + + + 2018-04-05 + + + 5.1.7 + 5.1.7 + + + stable + stable + + GPL License + +just bump version + + + + 2018-07-02 + + + 5.1.8 + 5.1.8 + + + stable + stable + + GPL License + +SeedDMS_Core_DMS::search() returns false in case of an error +do not use views in DBAccessPDO by default anymore, use temp. tables +SeedDMS_Core_Document::getNotifyList() has new parameter to include disabled user in list +fix possible sql injection in SeedDMS_Core_User + + diff --git a/SeedDMS_Lucene/Lucene/IndexedDocument.php b/SeedDMS_Lucene/Lucene/IndexedDocument.php index 32720007a..237150097 100644 --- a/SeedDMS_Lucene/Lucene/IndexedDocument.php +++ b/SeedDMS_Lucene/Lucene/IndexedDocument.php @@ -24,6 +24,27 @@ */ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { + /** + * @var string + */ + protected $errormsg; + + /** + * @var string + */ + protected $mimetype; + + /** + * @var string + */ + protected $cmd; + + /** + * @param $cmd + * @param int $timeout + * @return string + * @throws Exception + */ static function execWithTimeout($cmd, $timeout=2) { /* {{{ */ $descriptorspec = array( 0 => array("pipe", "r"), @@ -37,17 +58,23 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { if (!is_resource($process)) { throw new Exception("proc_open failed on: " . $cmd); } + stream_set_blocking($pipes[1], 0); + stream_set_blocking($pipes[2], 0); - $output = ''; + $output = $error = ''; $timeleft = $timeout - time(); - $read = array($pipes[1]); + $read = array($pipes[1], $pipes[2]); $write = NULL; $exeptions = NULL; do { - stream_select($read, $write, $exeptions, $timeleft, 200000); - - if (!empty($read)) { + $num_changed_streams = stream_select($read, $write, $exeptions, $timeleft, 200000); + + if ($num_changed_streams === false) { + proc_terminate($process); + throw new Exception("stream select failed on: " . $cmd); + } elseif ($num_changed_streams > 0) { $output .= fread($pipes[1], 8192); + $error .= fread($pipes[2], 8192); } $timeleft = $timeout - time(); } while (!feof($pipes[1]) && $timeleft > 0); @@ -56,15 +83,23 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { proc_terminate($process); throw new Exception("command timeout on: " . $cmd); } else { - return $output; + return array('stdout'=>$output, 'stderr'=>$error); } } /* }}} */ /** * 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) { + public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { /* {{{ */ + $this->errormsg = ''; + $this->cmd = ''; + $this->mimetype = ''; $_convcmd = array( 'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'', 'application/postscript' => 'ps2pdf14 %s - | pdftotext -enc UTF-8 -nopgbrk - - | sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'', @@ -125,6 +160,7 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { $path = $dms->contentDir . $version->getPath(); $content = ''; $mimetype = $version->getMimeType(); + $this->mimetype = $mimetype; $cmd = ''; $mimeparts = explode('/', $mimetype, 2); if(isset($_convcmd[$mimetype])) { @@ -135,15 +171,31 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document { $cmd = sprintf($_convcmd[$mimetype], $path); } if($cmd) { + $this->cmd = $cmd; try { $content = self::execWithTimeout($cmd, $timeout); - if($content) { - $this->addField(Zend_Search_Lucene_Field::UnStored('content', $content, 'utf-8')); + if($content['stdout']) { + $this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8')); + } + if($content['stderr']) { + $this->errormsg = $content['stderr']; } } catch (Exception $e) { } } - } - } + } + } /* }}} */ + + public function getErrorMsg() { /* {{{ */ + return $this->errormsg; + } /* }}} */ + + public function getMimeType() { /* {{{ */ + return $this->mimetype; + } /* }}} */ + + public function getCmd() { /* {{{ */ + return $this->cmd; + } /* }}} */ } ?> diff --git a/SeedDMS_Lucene/package.xml b/SeedDMS_Lucene/package.xml index 4d1d826ca..4f55862ad 100644 --- a/SeedDMS_Lucene/package.xml +++ b/SeedDMS_Lucene/package.xml @@ -11,11 +11,11 @@ uwe@steinmann.cx yes - 2017-12-04 + 2018-04-11 - 1.1.11 - 1.1.11 + 1.1.13 + 1.1.13 stable @@ -23,7 +23,7 @@ GPL License -allow conversion commands for mimetypes with wildcards +IndexedDocument() remembers cmd and mimetype @@ -267,5 +267,37 @@ make all functions in Indexer.php static catch exception in execWithTimeout() + + 2017-12-04 + + + 1.1.11 + 1.1.11 + + + stable + stable + + GPL License + +allow conversion commands for mimetypes with wildcards + + + + 2018-01-30 + + + 1.1.12 + 1.1.12 + + + stable + stable + + GPL License + +execWithTimeout() reads data from stderr and saves it into error msg + + diff --git a/SeedDMS_Preview/Preview/Base.php b/SeedDMS_Preview/Preview/Base.php index 897c54d4a..4d6b9cf1f 100644 --- a/SeedDMS_Preview/Preview/Base.php +++ b/SeedDMS_Preview/Preview/Base.php @@ -70,18 +70,24 @@ class SeedDMS_Preview_Base { if (!is_resource($process)) { throw new Exception("proc_open failed on: " . $cmd); } + stream_set_blocking($pipes[1], 0); + stream_set_blocking($pipes[2], 0); - $output = ''; + $output = $error = ''; $timeleft = $timeout - time(); - $read = array($pipes[1]); + $read = array($pipes[1], $pipes[2]); $write = NULL; $exeptions = NULL; do { - stream_select($read, $write, $exeptions, $timeleft, 200000); + $num_changed_streams = stream_select($read, $write, $exeptions, $timeleft, 200000); - if (!empty($read)) { + if ($num_changed_streams === false) { + proc_terminate($process); + throw new Exception("stream select failed on: " . $cmd); + } elseif ($num_changed_streams > 0) { $output .= fread($pipes[1], 8192); - } + $error .= fread($pipes[2], 8192); + } $timeleft = $timeout - time(); } while (!feof($pipes[1]) && $timeleft > 0); @@ -89,7 +95,7 @@ class SeedDMS_Preview_Base { proc_terminate($process); throw new Exception("command timeout on: " . $cmd); } else { - return $output; + return array('stdout'=>$output, 'stderr'=>$error); } } /* }}} */ @@ -129,5 +135,24 @@ class SeedDMS_Preview_Base { return array_key_exists($mimetype, $this->converters) && $this->converters[$mimetype]; } /* }}} */ +/** + * Send a file from disk to the browser + * + * This function uses either readfile() or the xѕendfile apache module if + * it is installed. + * + * @param string $filename + */ + protected function sendFile($filename) { /* {{{ */ + if(function_exists('apache_get_modules') && in_array('mod_xsendfile',apache_get_modules())) { + header("X-Sendfile: ".$filename); + } else { + /* Make sure output buffering is off */ + if (ob_get_level()) { + ob_end_clean(); + } + readfile($filename); + } + } /* }}} */ } diff --git a/SeedDMS_Preview/Preview/PdfPreviewer.php b/SeedDMS_Preview/Preview/PdfPreviewer.php index 3b563b334..6833a7ae8 100644 --- a/SeedDMS_Preview/Preview/PdfPreviewer.php +++ b/SeedDMS_Preview/Preview/PdfPreviewer.php @@ -196,7 +196,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base { $target = $this->previewDir.$dir.md5($infile); if($target && file_exists($target.'.pdf')) { - readfile($target.'.pdf'); + $this->sendFile($target.'.pdf'); } } /* }}} */ @@ -215,7 +215,7 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base { $target = $this->getFileName($object); if($target && file_exists($target.'.pdf')) { - readfile($target.'.pdf'); + $this->sendFile($target.'.pdf'); } } /* }}} */ diff --git a/SeedDMS_Preview/Preview/Previewer.php b/SeedDMS_Preview/Preview/Previewer.php index 519307dc5..23c5a97de 100644 --- a/SeedDMS_Preview/Preview/Previewer.php +++ b/SeedDMS_Preview/Preview/Previewer.php @@ -57,9 +57,10 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base { return false; $document = $object->getDocument(); + $dms = $document->_dms; $dir = $this->previewDir.'/'.$document->getDir(); switch(get_class($object)) { - case "SeedDMS_Core_DocumentContent": + case $dms->getClassname('documentcontent'): $target = $dir.'p'.$object->getVersion().'-'.$width; break; case "SeedDMS_Core_DocumentFile": @@ -115,27 +116,6 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base { $cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters['*']); } - /* - switch($mimetype) { - case "image/png": - case "image/gif": - case "image/jpeg": - case "image/jpg": - case "image/svg+xml": - $cmd = 'convert -resize '.$width.'x '.$infile.' '.$target.'.png'; - break; - case "application/pdf": - case "application/postscript": - $cmd = 'convert -density 100 -resize '.$width.'x '.$infile.'[0] '.$target.'.png'; - break; - case "text/plain": - $cmd = 'convert -resize '.$width.'x '.$infile.'[0] '.$target.'.png'; - break; - case "application/x-compressed-tar": - $cmd = 'tar tzvf '.$infile.' | convert -density 100 -resize '.$width.'x text:-[0] '.$target.'.png'; - break; - } - */ if($cmd) { try { self::execWithTimeout($cmd, $this->timeout); @@ -247,7 +227,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base { $target = $this->previewDir.$dir.md5($infile).'-'.$width; if($target && file_exists($target.'.png')) { - readfile($target.'.png'); + $this->sendFile($target.'.png'); } } /* }}} */ @@ -271,7 +251,7 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base { $target = $this->getFileName($object, $width); if($target && file_exists($target.'.png')) { - readfile($target.'.png'); + $this->sendFile($target.'.png'); } } /* }}} */ diff --git a/SeedDMS_Preview/package.xml b/SeedDMS_Preview/package.xml index 3d99daa0b..2afd6da7b 100644 --- a/SeedDMS_Preview/package.xml +++ b/SeedDMS_Preview/package.xml @@ -11,10 +11,10 @@ uwe@steinmann.cx yes - 2017-12-04 + 2018-03-08 - 1.2.6 + 1.2.8 1.2.0 @@ -23,8 +23,7 @@ GPL License -SeedDMS_Preview_Base::setConverters() overrides existing converters. -New method SeedDMS_Preview_Base::addConverters() merges new converters with old ones. +preview is also created if SeedDMS_Core_DocumentContent has a child class @@ -336,5 +335,40 @@ fix typo in converter for tar.gz files SeedDMS_Preview_Base::hasConverter() returns only try if command is set + + 2017-12-04 + + + 1.2.6 + 1.2.0 + + + stable + stable + + GPL License + +SeedDMS_Preview_Base::setConverters() overrides existing converters. +New method SeedDMS_Preview_Base::addConverters() merges new converters with old ones. + + + + 2018-01-18 + + + 1.2.7 + 1.2.0 + + + stable + stable + + GPL License + +add SeedDMS_Preview_Base::sendFile() as a replacement for readfile() which uses +mod_xsendfile if available +execWithTimeout() reads data from stderr and returns it together with stdout in array + + diff --git a/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php b/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php index 5a8e1cbfc..fb87503b8 100644 --- a/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php +++ b/SeedDMS_SQLiteFTS/SQLiteFTS/IndexedDocument.php @@ -29,6 +29,21 @@ require_once('Document.php'); */ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { + /** + * @var string + */ + protected $errormsg; + + /** + * @var string + */ + protected $mimetype; + + /** + * @var string + */ + protected $cmd; + static function execWithTimeout($cmd, $timeout=2) { /* {{{ */ $descriptorspec = array( 0 => array("pipe", "r"), @@ -36,23 +51,29 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { 2 => array("pipe", "w") ); $pipes = array(); - + $timeout += time(); $process = proc_open($cmd, $descriptorspec, $pipes); if (!is_resource($process)) { throw new Exception("proc_open failed on: " . $cmd); } + stream_set_blocking($pipes[1], 0); + stream_set_blocking($pipes[2], 0); - $output = ''; + $output = $error = ''; $timeleft = $timeout - time(); - $read = array($pipes[1]); + $read = array($pipes[1], $pipes[2]); $write = NULL; $exeptions = NULL; do { - stream_select($read, $write, $exeptions, $timeleft, 200000); - - if (!empty($read)) { + $num_changed_streams = stream_select($read, $write, $exeptions, $timeleft, 200000); + + if ($num_changed_streams === false) { + proc_terminate($process); + throw new Exception("stream select failed on: " . $cmd); + } elseif ($num_changed_streams > 0) { $output .= fread($pipes[1], 8192); + $error .= fread($pipes[2], 8192); } $timeleft = $timeout - time(); } while (!feof($pipes[1]) && $timeleft > 0); @@ -61,7 +82,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { proc_terminate($process); throw new Exception("command timeout on: " . $cmd); } else { - return $output; + return array('stdout'=>$output, 'stderr'=>$error); } } /* }}} */ @@ -69,7 +90,10 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { * Constructor. Creates our indexable document and adds all * necessary fields to it using the passed in document */ - public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { + public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { /* {{{ */ + $this->errormsg = ''; + $this->cmd = ''; + $this->mimetype = ''; $_convcmd = array( 'application/pdf' => 'pdftotext -enc UTF-8 -nopgbrk %s - |sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'', 'application/postscript' => 'ps2pdf14 %s - | pdftotext -enc UTF-8 -nopgbrk - - | sed -e \'s/ [a-zA-Z0-9.]\{1\} / /g\' -e \'s/[0-9.]//g\'', @@ -130,6 +154,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { $path = $dms->contentDir . $version->getPath(); $content = ''; $mimetype = $version->getMimeType(); + $this->mimetype = $mimetype; $cmd = ''; $mimeparts = explode('/', $mimetype, 2); if(isset($_convcmd[$mimetype])) { @@ -140,15 +165,31 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document { $cmd = sprintf($_convcmd[$mimetype], $path); } if($cmd) { + $this->cmd = $cmd; try { $content = self::execWithTimeout($cmd, $timeout); - if($content) { - $this->addField('content', $content, 'unstored'); + if($content['stdout']) { + $this->addField('content', $content['stdout'], 'unstored'); + } + if($content['stderr']) { + $this->errormsg = $content['stderr']; } } catch (Exception $e) { } } } - } + } /* }}} */ + + public function getErrorMsg() { /* {{{ */ + return $this->errormsg; + } /* }}} */ + + public function getMimeType() { /* {{{ */ + return $this->mimetype; + } /* }}} */ + + public function getCmd() { /* {{{ */ + return $this->cmd; + } /* }}} */ } ?> diff --git a/SeedDMS_SQLiteFTS/package.xml b/SeedDMS_SQLiteFTS/package.xml index 89c93b4f4..ed2256393 100644 --- a/SeedDMS_SQLiteFTS/package.xml +++ b/SeedDMS_SQLiteFTS/package.xml @@ -11,11 +11,11 @@ uwe@steinmann.cx yes - 2017-12-04 + 2018-04-11 - 1.0.8 - 1.0.8 + 1.0.10 + 1.0.10 stable @@ -23,7 +23,7 @@ GPL License -allow conversion commands for mimetypes with wildcards +IndexedDocument() remembers cmd and mimetype @@ -194,5 +194,37 @@ fix calculation of timeout (see bug #269) catch exception in execWithTimeout() + + 2017-12-04 + + + 1.0.8 + 1.0.8 + + + stable + stable + + GPL License + +allow conversion commands for mimetypes with wildcards + + + + 2018-01-30 + + + 1.0.9 + 1.0.9 + + + stable + stable + + GPL License + +execWithTimeout() reads data from stderr and saves it into error msg + + diff --git a/conf/settings.xml.template b/conf/settings.xml.template index ad8f8481d..452c847fe 100644 --- a/conf/settings.xml.template +++ b/conf/settings.xml.template @@ -71,6 +71,9 @@ calendarDefaultView = "y" firstDayOfWeek = "0" /> + - - "> - : - showTextField('siteName', $settings->_siteName); ?> - - "> - : - showTextField("footNote", $settings->_footNote); ?> - - "> - : - _printDisclaimer) echo "checked" ?> /> - - "> - : - - - - - "> - : - - - - - "> - : - - - - - "> - : - showTextField("previewWidthList", $settings->_previewWidthList); ?> - - "> - : - showTextField("previewWidthMenuList", $settings->_previewWidthMenuList); ?> - - "> - : - showTextField("previewWidthDropFolderList", $settings->_previewWidthDropFolderList); ?> - - "> - : - showTextField("previewWidthDetail", $settings->_previewWidthDetail); ?> - - "> - : - _showFullPreview) echo "checked" ?> /> - - "> - : - _convertToPdf) echo "checked" ?> /> - - "> - : - showTextField("maxItemsPerPage", $settings->_maxItemsPerPage); ?> - - "> - : - showTextField("incItemsPerPage", $settings->_incItemsPerPage); ?> - + --> +showConfigHeadline('settings_Display'); ?> +showConfigText('settings_siteName', 'siteName'); ?> +showConfigText('settings_footNote', 'footNote'); ?> +showConfigCheckbox('settings_printDisclaimer', 'printDisclaimer'); ?> +showConfigOption('settings_available_languages', 'availablelanguages', getAvailableLanguages(), true, true); ?> +showConfigOption('settings_language', 'language', getAvailableLanguages(), false, true); ?> +showConfigOption('settings_theme', 'theme', UI::getStyles(), false, false); ?> +showConfigText('settings_previewWidthList', 'previewWidthList'); ?> +showConfigText('settings_previewWidthMenuList', 'previewWidthMenuList'); ?> +showConfigText('settings_previewWidthDropFolderList', 'previewWidthDropFolderList'); ?> +showConfigText('settings_previewWidthDetail', 'previewWidthDetail'); ?> +showConfigCheckbox('settings_showFullPreview', 'showFullPreview'); ?> +showConfigCheckbox('settings_convertToPdf', 'convertToPdf'); ?> +showConfigText('settings_maxItemsPerPage', 'maxItemsPerPage'); ?> +showConfigText('settings_incItemsPerPage', 'incItemsPerPage'); ?> - - "> - : - _strictFormCheck) echo "checked" ?> /> - - "> - : - showTextField("viewOnlineFileTypes", $settings->getViewOnlineFileTypesToString()); ?> - - "> - : - showTextField("editOnlineFileTypes", $settings->getEditOnlineFileTypesToString()); ?> - - "> - : - _enableConverting) echo "checked" ?> /> - - "> - : - _enableEmail) echo "checked" ?> /> - - "> - : - _enableUsersView) echo "checked" ?> /> - - "> - : - _enableFullSearch) echo "checked" ?> /> - - "> - : - showTextField("maxSizeForFullText", $settings->_maxSizeForFullText); ?> - - "> - : - - - - - "> - : - - - - - "> - : - _showSingleSearchHit) echo "checked" ?> /> - - "> - : - showTextField("stopWordsFile", $settings->_stopWordsFile); ?> - - "> - : - _enableClipboard) echo "checked" ?> /> - - "> - : - _enableMenuTasks) echo "checked" ?> /> - - "> - : - _enableDropFolderList) echo "checked" ?> /> - - "> - : - _enableSessionList) echo "checked" ?> /> - - "> - : - _enableDropUpload) echo "checked" ?> /> - - "> - : - _enableMultiUpload) echo "checked" ?> /> - - "> - : - _enableFolderTree) echo "checked" ?> /> - - "> - : - - - - "> - : - _enableRecursiveCount) echo "checked" ?> /> - - "> - : - showTextField("maxRecursiveCount", $settings->_maxRecursiveCount); ?> - - "> - : - _enableLanguageSelector) echo "checked" ?> /> - - "> - : - _enableHelp) echo "checked" ?> /> - - "> - : - _enableThemeSelector) echo "checked" ?> /> - - "> - : - - - - "> - : - - - +showConfigHeadline('settings_Edition'); ?> +showConfigCheckbox('settings_strictFormCheck', 'strictFormCheck'); ?> +showConfigText('settings_viewOnlineFileTypes', 'viewOnlineFileTypes', 'array'); ?> +showConfigText('settings_editOnlineFileTypes', 'editOnlineFileTypes', 'array'); ?> +showConfigCheckbox('settings_enableConverting', 'enableConverting'); ?> +showConfigCheckbox('settings_enableEmail', 'enableEmail'); ?> +showConfigCheckbox('settings_enableUsersView', 'enableUsersView'); ?> +showConfigCheckbox('settings_enableFullSearch', 'enableFullSearch'); ?> +showConfigText('settings_maxSizeForFullText', 'maxSizeForFullText'); ?> +showConfigOption('settings_fullSearchEngine', 'fullSearchEngine', array('lucene'=>'settings_fullSearchEngine_vallucene', 'sqlitefts'=>'settings_fullSearchEngine_valsqlitefts'), false, true); ?> +showConfigOption('settings_defaultSearchMethod', 'defaultSearchMethod', array('database'=>'settings_defaultSearchMethod_valdatabase', 'fulltext'=>'settings_defaultSearchMethod_valfulltext'), false, true); ?> +showConfigCheckbox('settings_showSingleSearchHit', 'showSingleSearchHit'); ?> +showConfigText('settings_stopWordsFile', 'stopWordsFile'); ?> +showConfigCheckbox('settings_enableClipboard', 'enableClipboard'); ?> +showConfigCheckbox('settings_enableMenuTasks', 'enableMenuTasks'); ?> +showConfigCheckbox('settings_enableDropFolderList', 'enableDropFolderList'); ?> +showConfigCheckbox('settings_enableSessionList', 'enableSessionList'); ?> +showConfigCheckbox('settings_enableDropUpload', 'enableDropUpload'); ?> +showConfigCheckbox('settings_enableMultiUpload', 'enableMultiUpload'); ?> +showConfigCheckbox('settings_enableFolderTree', 'enableFolderTree'); ?> +showConfigOption('settings_expandFolderTree', 'expandFolderTree', array(' 0'=>'settings_expandFolderTree_val0', ' 1'=>'settings_expandFolderTree_val1', ' 2'=>'settings_expandFolderTree_val2'), false, true); ?> +showConfigCheckbox('settings_enableRecursiveCount', 'enableRecursiveCount'); ?> +showConfigText('settings_maxRecursiveCount', 'maxRecursiveCount'); ?> +showConfigCheckbox('settings_enableLanguageSelector', 'enableLanguageSelector'); ?> +showConfigCheckbox('settings_enableHelp', 'enableHelp'); ?> +showConfigCheckbox('settings_enableThemeSelector', 'enableThemeSelector'); ?> +showConfigOption('settings_sortUsersInList', 'sortUsersInList', array(' '=>'settings_sortUsersInList_val_login', 'fullname'=>'settings_sortUsersInList_val_fullname'), false, true); ?> +showConfigOption('settings_sortFoldersDefault', 'sortFoldersDefault', array('u'=>'settings_sortFoldersDefault_val_unsorted', 's'=>'settings_sortFoldersDefault_val_sequence', 'n'=>'settings_sortFoldersDefault_val_name'), false, true); ?> +showConfigOption('settings_defaultDocPosition', 'defaultDocPosition', array('end'=>'settings_defaultDocPosition_val_end', 'start'=>'settings_defaultDocPosition_val_start'), false, true); ?> + + +showConfigHeadline('settings_webdav'); ?> +showConfigCheckbox('settings_enableWebdavReplaceDoc', 'enableWebdavReplaceDoc'); ?> - - "> - : - _enableCalendar) echo "checked" ?> /> - - "> - : - - - - "> - : - - - - -contentContainerEnd(); ?> - +showConfigHeadline('settings_Calendar'); ?> +showConfigCheckbox('settings_enableCalendar', 'enableCalendar'); ?> +showConfigOption('settings_calendarDefaultView', 'calendarDefaultView', array('w'=>'week_view', 'm'=>'month_view', 'y'=>'year_view'), false, true); ?> +showConfigOption('settings_firstDayOfWeek', 'firstDayOfWeek', array(' 0'=>'sunday', ' 1'=>'monday', ' 2'=>'tuesday', ' 3'=>'wednesday', ' 4'=>'thursday', ' 5'=>'friday', ' 6'=>'saturday'), false, true); ?> +showEndPaneContent('site', $currenttab); -
-contentContainerStart(); ?> - + $this->showStartPaneContent('system', $currenttab == 'system'); +?> - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Server'); ?> +showConfigText('settings_rootDir', 'rootDir'); ?> +showConfigText('settings_httpRoot', 'httpRoot'); ?> +showConfigText('settings_contentDir', 'contentDir'); ?> +showConfigText('settings_backupDir', 'backupDir'); ?> +showConfigText('settings_cacheDir', 'cacheDir'); ?> +showConfigText('settings_stagingDir', 'stagingDir'); ?> +showConfigText('settings_luceneDir', 'luceneDir'); ?> +showConfigText('settings_dropFolderDir', 'dropFolderDir'); ?> +showConfigText('settings_repositoryUrl', 'repositoryUrl'); ?> +showConfigCheckbox('settings_logFileEnable', 'logFileEnable'); ?> +showConfigOption('settings_logFileRotation', 'logFileRotation', array('h'=>'hourly', 'd'=>'daily', 'm'=>'monthly'), false, true); ?> +showConfigCheckbox('settings_enableLargeFileUpload', 'enableLargeFileUpload'); ?> +showConfigText('settings_partitionSize', 'partitionSize'); ?> +showConfigText('settings_maxUploadSize', 'maxUploadSize'); ?> - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Authentication'); ?> +showConfigCheckbox('settings_enableGuestLogin', 'enableGuestLogin'); ?> +showConfigCheckbox('settings_enableGuestAutoLogin', 'enableGuestAutoLogin'); ?> +showConfigCheckbox('settings_restricted', 'restricted'); ?> +showConfigCheckbox('settings_enableUserImage', 'enableUserImage'); ?> +showConfigCheckbox('settings_disableSelfEdit', 'disableSelfEdit'); ?> +showConfigCheckbox('settings_enablePasswordForgotten', 'enablePasswordForgotten'); ?> +showConfigText('settings_passwordStrength', 'passwordStrength'); ?> +showConfigOption('settings_passwordStrengthAlgorithm', 'passwordStrengthAlgorithm', array('simple'=>'settings_passwordStrengthAlgorithm_valsimple', 'advanced'=>'settings_passwordStrengthAlgorithm_valadvanced'), false, true); ?> +showConfigText('settings_passwordExpiration', 'passwordExpiration'); ?> +showConfigText('settings_passwordHistory', 'passwordHistory'); ?> +showConfigText('settings_loginFailure', 'loginFailure'); ?> +showConfigText('settings_autoLoginUser', 'autoLoginUser'); ?> +showConfigText('settings_quota', 'quota'); ?> +showConfigText('settings_undelUserIds', 'undelUserIds'); ?> +showConfigText('settings_encryptionKey', 'encryptionKey'); ?> +showConfigText('settings_cookieLifetime', 'cookieLifetime'); ?> +showConfigOption('settings_defaultAccessDocs', 'defaultAccessDocs', array(' 0'=>'inherited', ' '.M_NONE=>'access_mode_none', ' '.M_READ=>'access_mode_read', ' '.M_READWRITE=>'access_mode_readwrite'), false, true); ?> - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Database'); ?> +showConfigText('settings_dbDriver', 'dbDriver'); ?> +showConfigText('settings_dbHostname', 'dbHostname'); ?> +showConfigText('settings_dbDatabase', 'dbDatabase'); ?> +showConfigText('settings_dbUser', 'dbUser'); ?> +showConfigText('settings_dbPass', 'dbPass', 'password'); ?> - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - + --> +showConfigHeadline('settings_SMTP'); ?> +showConfigText('settings_smtpServer', 'smtpServer'); ?> +showConfigText('settings_smtpPort', 'smtpPort'); ?> +showConfigText('settings_smtpSendFrom', 'smtpSendFrom'); ?> +showConfigText('settings_smtpUser', 'smtpUser'); ?> +showConfigText('settings_smtpPassword', 'smtpPassword', 'password'); ?> +showConfigPlain(htmlspecialchars(getMLText('settings_smtpSendTestMail')), htmlspecialchars(getMLText('settings_smtpSendTestMail_desc')), ''.getMLText('send_test_mail').''); ?> +showEndPaneContent('system', $currenttab); -
:showTextField("rootDir", $settings->_rootDir); ?>
:showTextField("httpRoot", $settings->_httpRoot); ?>
:showTextField("contentDir", $settings->_contentDir); ?>
:showTextField("backupDir", $settings->_backupDir); ?>
:showTextField("cacheDir", $settings->_cacheDir); ?>
:showTextField("stagingDir", $settings->_stagingDir); ?>
:showTextField("luceneDir", $settings->_luceneDir); ?>
:showTextField("dropFolderDir", $settings->_dropFolderDir); ?>
:_logFileEnable) echo "checked" ?> />
: - -
:_enableLargeFileUpload) echo "checked" ?> />
:showTextField("partitionSize", $settings->_partitionSize); ?>
:showTextField("maxUploadSize", $settings->_maxUploadSize); ?>
:_enableGuestLogin) echo "checked" ?> />
:_enableGuestAutoLogin) echo "checked" ?> />
:_restricted) echo "checked" ?> />
:_enableUserImage) echo "checked" ?> />
:_disableSelfEdit) echo "checked" ?> />
:_enablePasswordForgotten) echo "checked" ?> />
:showTextField("passwordStrength", $settings->_passwordStrength); ?>
: - -
:showTextField("passwordExpiration", $settings->_passwordExpiration); ?>
:showTextField("passwordHistory", $settings->_passwordHistory); ?>
:showTextField("loginFailure", $settings->_loginFailure); ?>
:showTextField("autoLoginUser", $settings->_autoLoginUser); ?>
:showTextField("quota", $settings->_quota); ?>
:showTextField("undelUserIds", $settings->_undelUserIds); ?>
:showTextField("encryptionKey", $settings->_encryptionKey); ?>
:showTextField("cookieLifetime", $settings->_cookieLifetime); ?>
: - -
:showTextField("dbDriver", $settings->_dbDriver); ?>
:showTextField("dbHostname", $settings->_dbHostname); ?>
:showTextField("dbDatabase", $settings->_dbDatabase); ?>
:showTextField("dbUser", $settings->_dbUser); ?>
:showTextField("dbPass", $settings->_dbPass, 'password'); ?>
:showTextField("smtpServer", $settings->_smtpServer); ?>
:showTextField("smtpPort", $settings->_smtpPort); ?>
:showTextField("smtpSendFrom", $settings->_smtpSendFrom); ?>
:showTextField("smtpUser", $settings->_smtpUser); ?>
:
-contentContainerEnd(); ?> -
- -
-contentContainerStart(); ?> - + $this->showStartPaneContent('advanced', $currenttab == 'advanced'); +?> - - "> - - - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Display'); ?> +showConfigText('settings_siteDefaultPage', 'siteDefaultPage'); ?> +showConfigText('settings_rootFolderID', 'rootFolderID'); ?> +showConfigCheckbox('settings_titleDisplayHack', 'titleDisplayHack'); ?> +showConfigCheckbox('settings_showMissingTranslations', 'showMissingTranslations'); ?> - - "> - - - - "> - - - +showConfigHeadline('settings_Authentication'); ?> +showConfigText('settings_guestID', 'guestID'); ?> +showConfigText('settings_adminIP', 'adminIP'); ?> - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Edition'); ?> +showConfigOption('settings_workflowMode', 'workflowMode', array('traditional'=>'settings_workflowMode_valtraditional', 'traditional_only_approval'=>'settings_workflowMode_valtraditional_only_approval', 'advanced'=>'settings_workflowMode_valadvanced'), false, true); ?> +showConfigText('settings_versioningFileName', 'versioningFileName'); ?> +showConfigText('settings_presetExpirationDate', 'presetExpirationDate'); ?> +showConfigCheckbox('settings_allowReviewerOnly', 'allowReviewerOnly'); ?> +showConfigCheckbox('settings_enableAdminRevApp', 'enableAdminRevApp'); ?> +showConfigCheckbox('settings_enableOwnerRevApp', 'enableOwnerRevApp'); ?> +showConfigCheckbox('settings_enableSelfRevApp', 'enableSelfRevApp'); ?> +showConfigCheckbox('settings_enableUpdateRevApp', 'enableUpdateRevApp'); ?> +showConfigCheckbox('settings_enableVersionDeletion', 'enableVersionDeletion'); ?> +showConfigCheckbox('settings_enableVersionModification', 'enableVersionModification'); ?> +showConfigCheckbox('settings_enableDuplicateDocNames', 'enableDuplicateDocNames'); ?> +showConfigCheckbox('settings_overrideMimeType', 'overrideMimeType'); ?> +showConfigCheckbox('settings_removeFromDropFolder', 'removeFromDropFolder'); ?> - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Notification'); ?> +showConfigCheckbox('settings_enableOwnerNotification', 'enableOwnerNotification'); ?> +showConfigCheckbox('settings_enableNotificationAppRev', 'enableNotificationAppRev'); ?> +showConfigCheckbox('settings_enableNotificationWorkflow', 'enableNotificationWorkflow'); ?> - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - - "> - - - +showConfigHeadline('settings_Server'); ?> +showConfigText('settings_coreDir', 'coreDir'); ?> +showConfigText('settings_luceneClassDir', 'luceneClassDir'); ?> +showConfigText('settings_extraPath', 'extraPath'); ?> +showConfigText('settings_contentOffsetDir', 'contentOffsetDir'); ?> +showConfigText('settings_maxDirID', 'maxDirID'); ?> +showConfigText('settings_updateNotifyTime', 'updateNotifyTime'); ?> +showConfigText('settings_maxExecutionTime', 'maxExecutionTime'); ?> +showConfigText('settings_cmdTimeout', 'cmdTimeout'); ?> - -_converters[$target] as $mimetype=>$cmd) { -?> - - - - -showConfigHeadline($target."_converters"); + if(!empty($settings->_converters[$target])) { + foreach($settings->_converters[$target] as $mimetype=>$cmd) { + $this->showConfigPlain(htmlspecialchars($mimetype), htmlspecialchars($mimetype), $this->getTextField("converters[".$target."][".$mimetype."]", htmlspecialchars($cmd))); + } + } + $this->showConfigPlain($this->getTextField("converters[".$target."][newmimetype]", "", '', getMLText('converter_new_mimetype')), '', $this->getTextField("converters[".$target."][newcmd]", "", "", getMLText('converter_new_cmd'))); } -?> - - - - - -
:showTextField("siteDefaultPage", $settings->_siteDefaultPage); ?>
:showTextField("rootFolderID", $settings->_rootFolderID); ?>
:_titleDisplayHack) echo "checked" ?> />
:_showMissingTranslations) echo "checked" ?> />
:showTextField("guestID", $settings->_guestID); ?>
:showTextField("adminIP", $settings->_adminIP); ?>
: - -
:showTextField("versioningFileName", $settings->_versioningFileName); ?>
:showTextField("presetExpirationDate", $settings->_presetExpirationDate); ?>
:_enableAdminRevApp) echo "checked" ?> />
:_enableOwnerRevApp) echo "checked" ?> />
:_enableSelfRevApp) echo "checked" ?> />
:_enableUpdateRevApp) echo "checked" ?> />
:_enableVersionDeletion) echo "checked" ?> />
:_enableVersionModification) echo "checked" ?> />
:_enableDuplicateDocNames) echo "checked" ?> />
:_overrideMimeType) echo "checked" ?> />
:_removeFromDropFolder) echo "checked" ?> />
:_enableOwnerNotification) echo "checked" ?> />
:_enableNotificationAppRev) echo "checked" ?> />
:_enableNotificationWorkflow) echo "checked" ?> />
:showTextField("coreDir", $settings->_coreDir); ?>
:showTextField("luceneClassDir", $settings->_luceneClassDir); ?>
:showTextField("extraPath", $settings->_extraPath); ?>
:showTextField("contentOffsetDir", $settings->_contentOffsetDir); ?>
:showTextField("maxDirID", $settings->_maxDirID); ?>
:showTextField("updateNotifyTime", $settings->_updateNotifyTime); ?>
:showTextField("maxExecutionTime", $settings->_maxExecutionTime); ?>
:showTextField("cmdTimeout", $settings->_cmdTimeout); ?>
:showTextField("converters[".$target."][".$mimetype."]", htmlspecialchars($cmd)); ?>
showTextField("converters[".$target."][newmimetype]", "", '', getMLText('converter_new_mimetype')); ?>:showTextField("converters[".$target."][newcmd]", "", "", getMLText('converter_new_cmd')); ?>
-contentContainerEnd(); ?> -
+ $this->showEndPaneContent('advanced', $currenttab); -
-contentContainerStart(); ?> - + $this->showStartPaneContent('extensions', $currenttab == 'extensions'); +?> $extconf) { -?> - -$conf) { -?> - - -showConfigPlain($conf['title'], isset($conf['help']) ? $conf['help'] : '', $html); } - } + } + } + $this->showEndPaneContent('extensions', $currenttab); ?> -
: -$extconf) { + if($extconf['config']) { + $this->showRawConfigHeadline("".$extconf['title']); + foreach($extconf['config'] as $confkey=>$conf) { + ob_start(); switch($conf['type']) { case 'checkbox': ?> @@ -802,11 +476,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 "
-contentContainerEnd(); ?> -
_configFilePath)) { diff --git a/views/bootstrap/class.Setup2Factor.php b/views/bootstrap/class.Setup2Factor.php new file mode 100644 index 000000000..12311557f --- /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(); +?> +
+
+
+
+
+ +
+formSubmit(getMLText('submit_2_fact_auth')); +?> +
+contentContainerEnd(); + $this->contentContainerStart('span6'); + echo '
'.$oldsecret.'
'; + echo '
'; +?> +contentContainerEnd(); + echo '
'; + $this->contentEnd(); + $this->htmlEndPage(); + } /* }}} */ +} +?> diff --git a/views/bootstrap/class.Statistic.php b/views/bootstrap/class.Statistic.php index a234b91c5..dd1ba1c68 100644 --- a/views/bootstrap/class.Statistic.php +++ b/views/bootstrap/class.Statistic.php @@ -179,17 +179,17 @@ class SeedDMS_View_Statistic extends SeedDMS_Bootstrap_Style { $this->contentHeading(getMLText("folders_and_documents_statistic")); echo "
\n"; echo "
\n"; - echo "
\n"; + $this->contentContainerStart(); print "
    \n"; $this->printFolder($rootfolder); print "
\n"; - echo "
\n"; + $this->contentContainerEnd(); echo "
\n"; echo "
\n"; - echo "
\n"; + $this->contentContainerStart(); print "".getMLText("legend")."\n"; print "
    \n"; print "
  • ".getMLText("access_inheritance")."
  • "; @@ -208,7 +208,7 @@ class SeedDMS_View_Statistic extends SeedDMS_Bootstrap_Style { print "
\n"; - echo "
\n"; + $this->contentContainerEnd(); echo "
\n"; echo "
\n"; diff --git a/views/bootstrap/class.Tasks.php b/views/bootstrap/class.Tasks.php index 11c121d03..4ab43fe2f 100644 --- a/views/bootstrap/class.Tasks.php +++ b/views/bootstrap/class.Tasks.php @@ -39,25 +39,42 @@ class SeedDMS_View_Tasks extends SeedDMS_Bootstrap_Style { private function __myTasks() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; - $tasks['review'] = array(); - $tasks['approval'] = array(); - $tasks['receipt'] = array(); - $tasks['revision'] = array(); - $resArr = $dms->getDocumentList('ApproveByMe', $user); - if($resArr) { - foreach ($resArr as $res) { - $document = $dms->getDocument($res["id"]); - if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { - $tasks['approval'][] = array('id'=>$res['id'], 'name'=>$res['name']); + $workflowmode = $this->params['workflowmode']; + if($workflowmode == 'traditional') + $tasks['review'] = array(); + elseif($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') + $tasks['approval'] = array(); + elseif($workflowmode == 'advanced') + $tasks['workflow'] = array(); + + if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { + $resArr = $dms->getDocumentList('ApproveByMe', $user); + if($resArr) { + foreach ($resArr as $res) { + $document = $dms->getDocument($res["id"]); + if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { + $tasks['approval'][] = array('id'=>$res['id'], 'name'=>$res['name']); + } } } - } - $resArr = $dms->getDocumentList('ReviewByMe', $user); - if($resArr) { - foreach ($resArr as $res) { - $document = $dms->getDocument($res["id"]); - if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { - $tasks['review'][] = array('id'=>$res['id'], 'name'=>$res['name']); + } elseif($workflowmode == 'traditional') { + $resArr = $dms->getDocumentList('ReviewByMe', $user); + if($resArr) { + foreach ($resArr as $res) { + $document = $dms->getDocument($res["id"]); + if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { + $tasks['review'][] = array('id'=>$res['id'], 'name'=>$res['name']); + } + } + } + } elseif($workflowmode == 'advanced') { + $resArr = $dms->getDocumentList('WorkflowByMe', $user); + if($resArr) { + foreach ($resArr as $res) { + $document = $dms->getDocument($res["id"]); + if($document->getAccessMode($user) >= M_READ && $document->getLatestContent()) { + $tasks['workflow'][] = array('id'=>$res['id'], 'name'=>$res['name']); + } } } } @@ -104,9 +121,20 @@ class SeedDMS_View_Tasks extends SeedDMS_Bootstrap_Style { $content = ''; // $content .= " \n"; echo $content; diff --git a/views/bootstrap/class.Timeline.php b/views/bootstrap/class.Timeline.php index 0acc3e9cc..578309311 100644 --- a/views/bootstrap/class.Timeline.php +++ b/views/bootstrap/class.Timeline.php @@ -232,43 +232,50 @@ div.timeline-event-selected { echo "
\n"; $this->contentHeading(getMLText("timeline")); - echo "
\n"; + $this->contentContainerStart(); ?>
-
- -
- - +params['session']->getLanguage()).'"> + - - - + + - -
-
-
- -
- >
- >
- >
- >
- >
- >
- >
-
-
-
- -
- -
-
+ '; + $this->formField( + getMLText("date"), + $html + ); +*/ + $this->formField( + getMLText("from"), + $this->getDateChooser(date('Y-m-d', $from), 'fromdate', $this->params['session']->getLanguage()) + ); + $this->formField( + getMLText("to"), + $this->getDateChooser(date('Y-m-d', $to), 'todate', $this->params['session']->getLanguage()) + ); + $html = ' + '.getMLText('timeline_skip_add_file').'
+ '.getMLText('timeline_skip_status_change_0').'
+ '.getMLText('timeline_skip_status_change_1').'
+ '.getMLText('timeline_skip_status_change_2').'
+ '.getMLText('timeline_skip_status_change_3').'
+ '.getMLText('timeline_skip_status_change_-1').'
+ '.getMLText('timeline_skip_status_change_-3').'
'; + $this->formField( + getMLText("exclude_items"), + $html + ); + $this->formSubmit(' '.getMLText('update'), 'update'); +?>
\n"; + $this->contentContainerEnd(); echo "
"; echo "
\n"; diff --git a/views/bootstrap/class.TransferDocument.php b/views/bootstrap/class.TransferDocument.php index ab1bd58a8..941526dcc 100644 --- a/views/bootstrap/class.TransferDocument.php +++ b/views/bootstrap/class.TransferDocument.php @@ -44,37 +44,27 @@ class SeedDMS_View_TransferDocument extends SeedDMS_Bootstrap_Style {
- -
- -
-'; + $this->formField( + getMLText("transfer_to_user"), + $html + ); + $this->formSubmit(" ".getMLText('transfer_document')); ?> - -
-
- -
-
- -
-
-
contentContainerEnd(); diff --git a/views/bootstrap/class.TransferObjects.php b/views/bootstrap/class.TransferObjects.php index 1855f9a45..2baba8902 100644 --- a/views/bootstrap/class.TransferObjects.php +++ b/views/bootstrap/class.TransferObjects.php @@ -50,32 +50,26 @@ class SeedDMS_View_TransferObjects extends SeedDMS_Bootstrap_Style { - -
- -
- -
-
- -
-
- -
-
- contentContainerEnd(); diff --git a/views/bootstrap/class.TriggerWorkflow.php b/views/bootstrap/class.TriggerWorkflow.php index b7880b997..05db1cc1b 100644 --- a/views/bootstrap/class.TriggerWorkflow.php +++ b/views/bootstrap/class.TriggerWorkflow.php @@ -107,19 +107,21 @@ $(document).ready(function() {
- -
- -
- -
-
-
- -
+ +formField( + getMLText("comment"), + array( + 'element'=>'textarea', + 'name'=>'comment', + 'rows'=>4 + ) + ); + $this->formSubmit(getMLText("action_".strtolower($action->getName()), array(), $action->getName())); +?>
diff --git a/views/bootstrap/class.UpdateDocument.php b/views/bootstrap/class.UpdateDocument.php index 4133de761..ee94d8c6b 100644 --- a/views/bootstrap/class.UpdateDocument.php +++ b/views/bootstrap/class.UpdateDocument.php @@ -215,147 +215,153 @@ console.log(element); $this->contentContainerStart(); ?> -
+ - - - - - - - - - - - - - - - - -formField( + getMLText("local_file"), + $enablelargefileupload ? $this->getFineUploaderHtml() : $this->getFileChooser('userfile', false) + ); + if($dropfolderdir) { + $this->formField( + getMLText("dropfolder_file"), + $this->getDropFolderChooserHtml("form1") + ); + } + $this->formField( + getMLText("comment"), + array( + 'element'=>'textarea', + 'name'=>'comment', + 'rows'=>4, + 'cols'=>80 + ) + ); + if($presetexpiration) { + if(!($expts = strtotime($presetexpiration))) $expts = false; + } else { + $expts = false; + } + $options = array(); + $options[] = array('never', getMLText('does_not_expire')); + $options[] = array('date', getMLText('expire_by_date'), $expts); + $options[] = array('1w', getMLText('expire_in_1w')); + $options[] = array('1m', getMLText('expire_in_1m')); + $options[] = array('1y', getMLText('expire_in_1y')); + $options[] = array('2y', getMLText('expire_in_2y')); + $this->formField( + getMLText("preset_expires"), + array( + 'element'=>'select', + 'id'=>'presetexpdate', + 'name'=>'presetexpdate', + 'options'=>$options + ) + ); + $this->formField( + getMLText("expires"), + $this->getDateChooser(($expts ? date('Y-m-d', $expts) : ''), "expdate", $this->params['session']->getLanguage()) + ); + $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all)); + if($attrdefs) { + foreach($attrdefs as $attrdef) { + $arr = $this->callHook('editDocumentContentAttribute', $document, $attrdef); + if(is_array($arr)) { + if($arr) + $this->formField($arr[0], $arr[1]); + } else { + $presetbtnhtml = ''; + if($latestContent->getAttributeValue($attrdef)) { + switch($attrdef->getType()) { + case SeedDMS_Core_AttributeDefinition::type_string: + case SeedDMS_Core_AttributeDefinition::type_date: + case SeedDMS_Core_AttributeDefinition::type_int: + case SeedDMS_Core_AttributeDefinition::type_float: + $presetbtnhtml = $this->getInputPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef), $attrdef->getValueSetSeparator()); + break; + case SeedDMS_Core_AttributeDefinition::type_boolean: + $presetbtnhtml = $this->gettCheckboxPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef)); + break; + } + } + $this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, '', 'attributes_version')." ".$presetbtnhtml); + } } -?> - - - - - > - - - -getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all)); - if($attrdefs) { - foreach($attrdefs as $attrdef) { - $arr = $this->callHook('editDocumentContentAttribute', $document, $attrdef); - if(is_array($arr)) { - if($arr) { - echo ""; - echo ""; - echo ""; - echo ""; + } + $arrs = $this->callHook('addDocumentContentAttributes', $folder); + if(is_array($arrs)) { + foreach($arrs as $arr) { + $this->formField($arr[0], $arr[1]); + } + } + + if($workflowmode == 'advanced') { + $mandatoryworkflows = $user->getMandatoryWorkflows(); + if($mandatoryworkflows) { + if(count($mandatoryworkflows) == 1) { + $this->formField( + getMLText("workflow"), + htmlspecialchars($mandatoryworkflows[0]->getName()).'' + ); + } else { + $options = array(); + $curworkflow = $latestContent->getWorkflow(); + foreach ($mandatoryworkflows as $workflow) { + $options[] = array($workflow->getID(), htmlspecialchars($workflow->getName()), $curworkflow && $curworkflow->getID() == $workflow->getID()); + } + $this->formField( + getMLText("workflow"), + array( + 'element'=>'select', + 'id'=>'workflow', + 'name'=>'workflow', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_workflow'))), + 'options'=>$options + ) + ); } } else { -?> - - - - -callHook('addDocumentContentAttributes', $folder); - if(is_array($arrs)) { - foreach($arrs as $arr) { - echo ""; - echo ""; - echo ""; - echo ""; - } - } - - if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { - // Retrieve a list of all users and groups that have review / approve - // privileges. - $docAccess = $folder->getReadAccessList($enableadminrevapp, $enableownerrevapp); - if($workflowmode != 'traditional_only_approval') { -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
: printFineUploaderHtml(); - else - $this->printFileChooser('userfile', false); -?> -
:printDropFolderChooserHtml("form1");?>
: - -
: - -
: - - - - -
".$arr[0].":".$arr[1]."
getName()); ?>:printAttributeEditField($attrdef, '', 'attributes_version') ?> -getAttributeValue($attrdef)) { - switch($attrdef->getType()) { - case SeedDMS_Core_AttributeDefinition::type_string: - case SeedDMS_Core_AttributeDefinition::type_date: - case SeedDMS_Core_AttributeDefinition::type_int: - case SeedDMS_Core_AttributeDefinition::type_float: - $this->printInputPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef), $attrdef->getValueSetSeparator()); - break; - case SeedDMS_Core_AttributeDefinition::type_boolean: - $this->printCheckboxPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef)); - break; + $options = array(); + $options[] = array('', ''); + $workflows=$dms->getAllWorkflows(); + foreach ($workflows as $workflow) { + $options[] = array($workflow->getID(), htmlspecialchars($workflow->getName())); } -// print_r($latestContent->getAttributeValue($attrdef)); + $this->formField( + getMLText("workflow"), + array( + 'element'=>'select', + 'id'=>'workflow', + 'name'=>'workflow', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-allow-clear', 'true'), array('data-placeholder', getMLText('select_workflow'))), + 'options'=>$options + ) + ); } -?>
".$arr[0].":".$arr[1]."
- contentSubHeading(getMLText("assign_reviewers")); ?> -
-
:
-
- -printSelectPresetButtonHtml("IndReviewer", $tmp); + $fieldwrap = array('', $this->getSelectPresetButtonHtml("IndReviewers", $tmp)); } /* List all mandatory reviewers */ if($res) { @@ -381,11 +388,24 @@ console.log(element); } } if($tmp) { - echo '
'.getMLText('mandatory_reviewers').': '; - echo implode(', ', $tmp); - echo "
\n"; + $fieldwrap[1] .= '
'.getMLText('mandatory_reviewers').': '.implode(', ', $tmp)."
\n"; } } + + $this->formField( + getMLText("individuals"), + array( + 'element'=>'select', + 'name'=>'indReviewers[]', + 'id'=>'IndReviewers', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_ind_reviewers'))), + 'multiple'=>true, + 'options'=>$options + ), + array('field_wrap'=>$fieldwrap) + ); + /* Check for mandatory reviewer without access */ foreach($res as $r) { if($r['reviewerUserID']) { @@ -396,31 +416,20 @@ console.log(element); } if(!$hasAccess) { $noAccessUser = $dms->getUser($r['reviewerUserID']); - echo "
".getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")")))."
"; + $this->warningMsg(getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")")))); } } } -?> -
-
:
-
- -printSelectPresetButtonHtml("GrpReviewer", $tmp); + $fieldwrap = array('', $this->getSelectPresetButtonHtml("GrpReviewers", $tmp)); } /* List all mandatory groups of reviewers */ if($res) { @@ -450,11 +460,22 @@ console.log(element); } } if($tmp) { - echo '
'.getMLText('mandatory_reviewergroups').': '; - echo implode(', ', $tmp); - echo "
\n"; + $fieldwrap[1] .= '
'.getMLText('mandatory_reviewergroups').': '.implode(', ', $tmp)."
\n"; } } + $this->formField( + getMLText("groups"), + array( + 'element'=>'select', + 'name'=>'grpReviewers[]', + 'id'=>'GrpReviewers', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_grp_reviewers'))), + 'multiple'=>true, + 'options'=>$options + ), + array('field_wrap'=>$fieldwrap) + ); /* Check for mandatory reviewer group without access */ foreach($res as $r) { @@ -466,73 +487,72 @@ console.log(element); } if(!$hasAccess) { $noAccessGroup = $dms->getGroup($r['reviewerGroupID']); - echo "
".getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))."
"; + $this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))); } } } -?> -
- contentSubHeading(getMLText("assign_approvers")); ?> -
-
:
-
- -contentSubHeading(getMLText("assign_approvers")); + $options = array(); + $res=$user->getMandatoryApprovers(); + foreach ($docAccess["users"] as $usr) { + if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue; + + $mandatory=false; + foreach ($res as $r) if ($r['approverUserID']==$usr->getID()) $mandatory=true; + + $option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null); + if ($mandatory) $option[] = array(array('disabled', 'disabled')); + $options[] = $option; + } + $tmp = array(); + foreach($approvalStatus as $r) { + if($r['type'] == 0) { + if($res) { + $mandatory=false; + foreach ($res as $rr) + if ($rr['approverUserID']==$r['required']) { + $mandatory=true; + } + if(!$mandatory) $tmp[] = $r['required']; - } + } else { + $tmp[] = $r['required']; + } + } + } + $fieldwrap = array(); + if($tmp) { + $fieldwrap = array('', $this->getSelectPresetButtonHtml("IndApprovers", $tmp)); + } + /* List all mandatory approvers */ + if($res) { + $tmp = array(); + foreach ($res as $r) { + if($r['approverUserID'] > 0) { + $u = $dms->getUser($r['approverUserID']); + $tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')'); } } if($tmp) { - $this->printSelectPresetButtonHtml("IndApprover", $tmp); - } - /* List all mandatory approvers */ - if($res) { - $tmp = array(); - foreach ($res as $r) { - if($r['approverUserID'] > 0) { - $u = $dms->getUser($r['approverUserID']); - $tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')'); - } - } - if($tmp) { - echo '
'.getMLText('mandatory_approvers').': '; - echo implode(', ', $tmp); - echo "
\n"; - } + $fieldwrap[1] .= '
'.getMLText('mandatory_approvers').': '.implode(', ', $tmp)."
\n"; } + } + + $this->formField( + getMLText("individuals"), + array( + 'element'=>'select', + 'name'=>'indApprovers[]', + 'id'=>'IndApprovers', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_ind_approvers'))), + 'multiple'=>true, + 'options'=>$options + ), + array('field_wrap'=>$fieldwrap) + ); /* Check for mandatory approvers without access */ foreach($res as $r) { @@ -544,31 +564,22 @@ console.log(element); } if(!$hasAccess) { $noAccessUser = $dms->getUser($r['approverUserID']); - echo "
".getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")")))."
"; + $this->warningMsg(getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")")))); } } } -?> -
-
:
-
- -printSelectPresetButtonHtml("GrpApprover", $tmp); + $fieldwrap = array('', $this->getSelectPresetButtonHtml("GrpApprovers", $tmp)); } /* List all mandatory groups of approvers */ if($res) { @@ -598,12 +610,24 @@ console.log(element); } } if($tmp) { - echo '
'.getMLText('mandatory_approvergroups').': '; - echo implode(', ', $tmp); - echo "
\n"; + $fieldwrap[1] .= '
'.getMLText('mandatory_approvergroups').': '.implode(', ', $tmp)."
\n"; } } + $this->formField( + getMLText("groups"), + array( + 'element'=>'select', + 'name'=>'grpApprovers[]', + 'id'=>'GrpApprovers', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_grp_approvers'))), + 'multiple'=>true, + 'options'=>$options + ), + array('field_wrap'=>$fieldwrap) + ); + /* Check for mandatory approver groups without access */ foreach($res as $r) { if ($r['approverGroupID']) { @@ -614,77 +638,14 @@ console.log(element); } if(!$hasAccess) { $noAccessGroup = $dms->getGroup($r['approverGroupID']); - echo "
".getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))."
"; + $this->warningMsg(getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName())))); } } } + $this->warningMsg(getMLText("add_doc_reviewer_approver_warning")); + } + $this->formSubmit(getMLText('update_document')); ?> -
-
:
-
-getMandatoryWorkflows(); - if($mandatoryworkflows) { - if(count($mandatoryworkflows) == 1) { -?> - getName()); ?> - - - - - - -
- warningMsg(getMLText("add_doc_workflow_warning")); ?> -
">
-
+ contentContainerStart(); ?>
-
- -
- -
-
-
+ contentContainerEnd(); ?>
-
+ contentContainerStart(); ?> -
+ contentContainerEnd(); ?>
diff --git a/views/bootstrap/class.UsrMgr.php b/views/bootstrap/class.UsrMgr.php index 328d6d1dc..49761f06b 100644 --- a/views/bootstrap/class.UsrMgr.php +++ b/views/bootstrap/class.UsrMgr.php @@ -214,7 +214,7 @@ $(document).ready( function() { $workflowmode = $this->params['workflowmode']; $quota = $this->params['quota']; ?> -
+ - - - - - - - - - -formField( + getMLText("user_login"), + array( + 'element'=>'input', + 'type'=>'text', + 'id'=>'login', + 'name'=>'login', + 'value'=>($currUser ? htmlspecialchars($currUser->getLogin()) : '') + ) + ); + $this->formField( + getMLText("password"), + ''.(($currUser && $currUser->isGuest()) ? ' '.getMLText('clear_password') : '') + ); if($passwordstrength > 0) { -?> - - - - -formField( + getMLText("password_strength"), + '
' + ); } -?> - - - - - 0) { -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + $this->formField( + getMLText("groups"), + array( + 'element'=>'select', + 'name'=>'groups[]', + 'class'=>'chzn-select', + 'multiple'=>true, + 'attributes'=>array(array('data-placeholder', getMLText('select_groups'))), + 'options'=>$options + ) + ); + $this->formField(getMLText("home_folder"), $this->getFolderChooserHtml("form".($currUser ? $currUser->getId() : '0'), M_READ, -1, $currUser ? $dms->getFolder($currUser->getHomeFolder()) : 0, 'homefolder')); + echo ''; - - - - - - - - - - - - - - - - - - -formField( + getMLText("quota"), + array( + 'element'=>'input', + 'type'=>'text', + 'id'=>'quota', + 'name'=>'quota', + 'value'=>($currUser ? $currUser->getQuota() : '') + ) + ); + if($quota > 0) + $this->warningMsg(getMLText('current_quota', array('quota'=>SeedDMS_Core_File::format_filesize($quota)))); + else + $this->warningMsg(getMLText('quota_is_disabled')); + $this->formField( + getMLText("is_hidden"), + array( + 'element'=>'input', + 'type'=>'checkbox', + 'name'=>'ishidden', + 'value'=>1, + 'checked'=>$currUser && $currUser->isHidden() + ) + ); + $this->formField( + getMLText("is_disabled"), + array( + 'element'=>'input', + 'type'=>'checkbox', + 'name'=>'isdisabled', + 'value'=>1, + 'checked'=>$currUser && $currUser->isDisabled() + ) + ); + if ($enableuserimage) { + if ($currUser) { + $this->formField( + getMLText("user_image"), + ($currUser->hasImage() ? "getId()."\">" : getMLText('no_user_image')) + ); + $this->formField( + getMLText("new_user_image"), + $this->getFileChooser('userfile', false, "image/jpeg") + ); + } else { + $this->formField( + getMLText("user_image"), + $this->getFileChooser('userfile', false, "image/jpeg") + ); + } } if($workflowmode == "traditional" || $workflowmode == 'traditional_only_approval') { - if($workflowmode == "traditional") { -?> - - - - - - - - - - - - - - - - - - - - - - - - -getID()) $checked=true; + + $options[] = array($grp->getID(), htmlspecialchars($grp->getName()), $checked); + } + $this->formField( + getMLText("groups"), + array( + 'element'=>'select', + 'name'=>'grpApprovers[]', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_groups'))), + 'multiple'=>true, + 'options'=>$options + ) + ); } else { $workflows = $dms->getAllWorkflows(); if($workflows) { -?> - - - - -formField( + getMLText("workflow"), + array( + 'element'=>'select', + 'name'=>'workflows[]', + 'class'=>'chzn-select', + 'attributes'=>array(array('data-placeholder', getMLText('select_workflow'))), + 'multiple'=>true, + 'options'=>$options + ) + ); } } + $this->formSubmit(" ".getMLText($currUser ? "save" : "add_user")); ?> - - - - -
:">
:" name="pwd" id="pwd">isGuest()) echo ' '.getMLText('clear_password'); ?>
: -
" class="progress" style="width: 220px; height: 30px; margin-bottom: 8px;">
-
:
: getPwdExpiration() : ""; ?>
:">
:">
:
:
:
:printFolderChooser("form".($currUser ? $currUser->getId() : '0'), M_READ, -1, $currUser ? $dms->getFolder($currUser->getHomeFolder()) : 0, 'homefolder');?>
:"> - 0) - echo $this->warningMsg(getMLText('current_quota', array('quota'=>SeedDMS_Core_File::format_filesize($quota)))); - else - echo $this->warningMsg(getMLText('quota_is_disabled')); -?> -
:isHidden() ? " checked='checked'" : "");?>>
:isDisabled() ? " checked='checked'" : "");?>>
: -hasImage()) - print ""; - else - printMLText("no_user_image"); -?> -
: -printFileChooser('userfile', false, "image/jpeg"); -?> -
: -printFileChooser('userfile', false, 'image/jpeg'); -?> -
:
-
:
-
- -
-
:
-
- -
:
-
:
-
- -
-
:
-
- -
-
:
-
- -
-
getID()."\"" : "") ?>>
getID()."\"" : "") ?>>
-
+ contentContainerStart(); ?>
getID()."\"" : "") ?>>
-
+ contentContainerEnd(); ?>
printTimelineJs('out.ViewDocument.php?action=timelinedata&documentid='.$document->getID(), 300, '', date('Y-m-d')); } $this->printDocumentChooserJs("form1"); + $this->printDeleteDocumentButtonJs(); } /* }}} */ function documentInfos() { /* {{{ */ @@ -356,7 +357,11 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { contentHeading(getMLText("preview")); ?>
isAdmin()) { diff --git a/views/bootstrap/class.ViewFolder.php b/views/bootstrap/class.ViewFolder.php index 0e0bce9fd..70e899051 100644 --- a/views/bootstrap/class.ViewFolder.php +++ b/views/bootstrap/class.ViewFolder.php @@ -99,6 +99,8 @@ function folderSelected(id, name) { function loadMoreObjects(element, limit) { if(!$(element).is(":visible")) return; + element.text(''); + element.prop("disabled",true); var folder = element.data('folder') var offset = element.data('offset') // var limit = element.data('limit') @@ -115,6 +117,7 @@ function loadMoreObjects(element, limit) { var str = ''; element.text(str.replace('[number]', data.count)); element.data('offset', offset+limit); + element.prop("disabled",false); } } }); diff --git a/views/bootstrap/class.WorkflowActionsMgr.php b/views/bootstrap/class.WorkflowActionsMgr.php index 28d9f2a07..3b833ff46 100644 --- a/views/bootstrap/class.WorkflowActionsMgr.php +++ b/views/bootstrap/class.WorkflowActionsMgr.php @@ -103,9 +103,7 @@ $(document).ready( function() { function showWorkflowActionForm($action) { /* {{{ */ if($action) { if($action->isUsed()) { -?> -

-infoMsg(getMLText('workflow_action_in_use')); } else { ?>
@@ -117,6 +115,7 @@ $(document).ready( function() { } } ?> + contentContainerStart(); ?> formField( + getMLText("workflow_action_name"), + array( + 'element'=>'input', + 'type'=>'text', + 'id'=>'name', + 'name'=>'name', + 'value'=>($action ? htmlspecialchars($action->getName()) : '') + ) + ); + $this->formSubmit(' '.getMLText("save")); ?> -
- -
- -
-
-
- -
- -
-
+ contentContainerEnd(); ?>
-
-
-
-
- -
- -
+ + contentContainerEnd(); ?> +
getID()."\"" : "") ?>>
- -
-
getID()."\"" : "") ?>>
-
-
-
+
getID()."\"" : "") ?>>
-
contentEnd(); $this->htmlEndPage(); diff --git a/views/bootstrap/class.WorkflowMgr.php b/views/bootstrap/class.WorkflowMgr.php index 6844cd1ce..685495b1b 100644 --- a/views/bootstrap/class.WorkflowMgr.php +++ b/views/bootstrap/class.WorkflowMgr.php @@ -134,7 +134,7 @@ $(document).ready(function() { } } ?> -
+ contentContainerStart(); ?>
formField( + getMLText("workflow_name"), + array( + 'element'=>'input', + 'type'=>'text', + 'id'=>'name', + 'name'=>'name', + 'value'=>($workflow ? htmlspecialchars($workflow->getName()) : '') + ) + ); + $options = array(); + foreach($workflowstates as $workflowstate) { + $options[] = array($workflowstate->getID(), htmlspecialchars($workflowstate->getName()), $workflow && $workflow->getInitState()->getID() == $workflowstate->getID()); + } + $this->formField( + getMLText("workflow_initstate"), + array( + 'element'=>'select', + 'name'=>'initstate', + 'options'=>$options + ) + ); + $this->formSubmit(' '.getMLText("save")); ?> -
- -
- "> -
-
-
- -
- -
-
- -
- -
-
-
+ contentContainerEnd(); ?> getAllWorkflowActions(); @@ -320,31 +317,33 @@ $(document).ready(function() { ?>
-
-
-
-
- -
- -
+ + contentContainerEnd(); ?> +
getID()."\"" : "") ?>>
- -
-
getID()."\"" : "") ?>>
-
-
+
getID()."\"" : "") ?>>
-
+
isUsed()) { -?> -

-infoMsg(getMLText('workflow_state_in_use')); } else { ?>
@@ -118,6 +116,7 @@ $(document).ready(function() { } } ?> + contentContainerStart(); ?> formField( + getMLText("workflow_state_name"), + array( + 'element'=>'input', + 'type'=>'text', + 'id'=>'name', + 'name'=>'name', + 'value'=>($state ? htmlspecialchars($state->getName()) : '') + ) + ); + $options = array(); + $options[] = array("", getMLText("keep_doc_status")); + $options[] = array(S_RELEASED, getMLText("released"), ($state && $state->getDocumentStatus() == S_RELEASED)); + $options[] = array(S_REJECTED, getMLText("rejected"), ($state && $state->getDocumentStatus() == S_REJECTED)); + $this->formField( + getMLText("workflow_state_docstatus"), + array( + 'element'=>'select', + 'name'=>'docstatus', + 'options'=>$options + ) + ); + $this->formSubmit(' '.getMLText("save")); ?> -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+ contentContainerEnd(); ?>
-
-
-
-
- -
- -
+ + contentContainerEnd(); ?> +
getID()."\"" : "") ?>>
- -
-
getID()."\"" : "") ?>>
-
-
-
-
getID()."\"" : "") ?>>
+
+
getID()."\"" : "") ?>>
-
contentEnd(); diff --git a/views/clean b/views/clean deleted file mode 120000 index f5ac3db8c..000000000 --- a/views/clean +++ /dev/null @@ -1 +0,0 @@ -blue \ No newline at end of file diff --git a/views/hc b/views/hc deleted file mode 120000 index f5ac3db8c..000000000 --- a/views/hc +++ /dev/null @@ -1 +0,0 @@ -blue \ No newline at end of file diff --git a/webdav/index.php b/webdav/index.php index 377e80789..8d1cf3e92 100644 --- a/webdav/index.php +++ b/webdav/index.php @@ -1,24 +1,30 @@ _dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase); -$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\""); -$db->getResult("set names 'utf8'"); - -$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir); if($settings->_logFileEnable) { if ($settings->_logFileRotation=="h") $logname=date("YmdH", time()); else if ($settings->_logFileRotation=="d") $logname=date("Ymd", time()); else $logname=date("Ym", time()); - $logname = $settings->_contentDir."webdav-".$logname.".log"; - $log = Log::factory('file', $logname); + $logname = $settings->_contentDir."log/webdav-".$logname.".log"; + if(!file_exists($settings->_contentDir.'log')) + @mkdir($settings->_contentDir.'log'); + if(file_exists($settings->_contentDir.'log') && is_dir($settings->_contentDir.'log')) { + $log = Log::factory('file', $logname); + $log->setMask(Log::MAX(PEAR_LOG_INFO)); + } else + $log = null; } else { $log = null; } +include("webdav.php"); $server = new HTTP_WebDAV_Server_SeedDMS(); $server->ServeRequest($dms, $log); //$files = array(); diff --git a/webdav/webdav.php b/webdav/webdav.php index 716c6cfb7..e077e4858 100644 --- a/webdav/webdav.php +++ b/webdav/webdav.php @@ -1,10 +1,6 @@ _coreDir)) - require_once($settings->_coreDir.'/Core.php'); -else - require_once('SeedDMS/Core.php'); /** * SeedDMS access using WebDAV @@ -59,18 +55,6 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server */ function ServeRequest($dms = null, $logger = null) /* {{{ */ { - // special treatment for litmus compliance test - // reply on its identifier header - // not needed for the test itself but eases debugging - if( function_exists('apache_request_headers') ) { - foreach (apache_request_headers() as $key => $value) { - if (stristr($key, "litmus")) { - error_log("Litmus test $value"); - header("X-Litmus-reply: ".$value); - } - } - } - // set root directory, defaults to webserver document root if not set if ($dms) { $this->dms = $dms; @@ -81,12 +65,18 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server // set logger $this->logger = $logger; - // establish connection to property/locking db - /* - mysql_connect($this->db_host, $this->db_user, $this->db_passwd) or die(mysql_error()); - mysql_select_db($this->db_name) or die(mysql_error()); - */ - // TODO throw on connection problems + // special treatment for litmus compliance test + // reply on its identifier header + // not needed for the test itself but eases debugging + if( function_exists('apache_request_headers') ) { + foreach (apache_request_headers() as $key => $value) { + if (stristr($key, "litmus")) { + if($this->logger) + $this->logger->log('Litmus test '.$value, PEAR_LOG_DEBUG); + header("X-Litmus-reply: ".$value); + } + } + } // let the base class do all the work parent::ServeRequest(); @@ -101,7 +91,14 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server */ function log_options($methode, $options) { /* {{{ */ if($this->logger) { - $this->logger->log($methode.': '.$options['path'], PEAR_LOG_INFO); + switch($methode) { + case 'MOVE': + $msg = $methode.': '.$options['path'].' -> '.$options['dest']; + break; + default: + $msg = $methode.': '.$options['path']; + } + $this->logger->log($msg, PEAR_LOG_INFO); foreach($options as $key=>$option) { if(is_array($option)) { $this->logger->log($methode.': '.$key.'='.var_export($option, true), PEAR_LOG_DEBUG); @@ -144,11 +141,17 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $userobj = $authobj->authenticate($user, $pass); } /* }}} */ - if(!$userobj) + if(!$userobj) { + if($this->logger) + $this->logger->log('check_auth: No such user', PEAR_LOG_NOTICE); return false; + } - if(($userobj->getID() == $settings->_guestID) && (!$settings->_enableGuestLogin)) + if(($userobj->getID() == $settings->_guestID) && (!$settings->_enableGuestLogin)) { + if($this->logger) + $this->logger->log('check_auth: Login as guest is not allowed', PEAR_LOG_NOTICE); return false; + } if($userobj->isDisabled()) return false; @@ -270,7 +273,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $files["files"][] = $this->fileinfo($obj); // information for contained resources requested? - if (get_class($obj) == 'SeedDMS_Core_Folder' && !empty($options["depth"])) { + if (get_class($obj) == $this->dms->getClassname('folder') && !empty($options["depth"])) { $subfolders = $obj->getSubFolders(); $subfolders = SeedDMS_Core_DMS::filterAccess($subfolders, $this->user, M_READ); @@ -320,7 +323,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $info["props"] = array(); // type and size (caller already made sure that path exists) - if (get_class($obj) == 'SeedDMS_Core_Folder') { + if (get_class($obj) == $this->dms->getClassname('folder')) { // modification time /* folders do not have a modification time */ $info["props"][] = $this->mkprop("getlastmodified", time()); @@ -421,7 +424,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server if (!$obj) return false; // is this a collection? - if (get_class($obj) == 'SeedDMS_Core_Folder') { + if (get_class($obj) == $this->dms->getClassname('folder')) { return $this->GetDir($obj, $options); } @@ -502,7 +505,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server foreach ($objs as $obj) { $filename = $obj->getName(); $fullpath = $_fullpath.$filename; - if(get_class($obj) == 'SeedDMS_Core_Folder') { + if(get_class($obj) == $this->dms->getClassname('folder')) { $fullpath .= '/'; $filename .= '/'; $filesize = 0; @@ -542,6 +545,8 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server */ function PUT(&$options) /* {{{ */ { + global $settings, $indexconf; + $this->log_options('PUT', $options); $path = $options["path"]; @@ -553,12 +558,14 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $parent = ''; $folder = $this->reverseLookup($parent.'/'); - if (!$folder || get_class($folder) != "SeedDMS_Core_Folder") { + if (!$folder || get_class($folder) != $this->dms->getClassname('folder')) { return "409 Conflict"; } /* Check if user is logged in */ if(!$this->user) { + if($this->logger) + $this->logger->log('PUT: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } @@ -584,47 +591,113 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server if($lastDotIndex === false) $fileType = "."; else $fileType = substr($name, $lastDotIndex); } + if($this->logger) + $this->logger->log('PUT: file is of type '.$mimetype, PEAR_LOG_INFO); + /* First check whether there is already a file with the same name */ if($this->useorgfilename) $document = $this->dms->getDocumentByOriginalFilename($name, $folder); else $document = $this->dms->getDocumentByName($name, $folder); if($document) { + if($this->logger) + $this->logger->log('PUT: replacing document id='.$document->getID(), PEAR_LOG_INFO); if ($document->getAccessMode($this->user) < M_READWRITE) { + if($this->logger) + $this->logger->log('PUT: no access on document', PEAR_LOG_ERR); unlink($tmpFile); return "403 Forbidden"; - } else{ + } else { /* Check if the new version iѕ identical to the current version. * In that case just update the modification date */ $lc = $document->getLatestContent(); if($lc->getChecksum() == SeedDMS_Core_File::checksum($tmpFile)) { + if($this->logger) + $this->logger->log('PUT: identical to latest version', PEAR_LOG_INFO); $lc->setDate(); } else { if($this->user->getID() == $lc->getUser()->getID() && $name == $lc->getOriginalFileName() && $fileType == $lc->getFileType() && - $mimetype == $lc->getMimeType()) { + $mimetype == $lc->getMimeType() && + $settings->_enableWebdavReplaceDoc) { + if($this->logger) + $this->logger->log('PUT: replacing latest version', PEAR_LOG_INFO); if(!$document->replaceContent($lc->getVersion(), $this->user, $tmpFile, $name, $fileType, $mimetype)) { + if($this->logger) + $this->logger->log('PUT: error replacing latest version', PEAR_LOG_ERR); unlink($tmpFile); return "403 Forbidden"; } } else { + if($this->logger) + $this->logger->log('PUT: adding new version', PEAR_LOG_INFO); if(!$document->addContent('', $this->user, $tmpFile, $name, $fileType, $mimetype, array(), array(), 0)) { + if($this->logger) + $this->logger->log('PUT: error adding new version', PEAR_LOG_ERR); unlink($tmpFile); return "409 Conflict"; } } } } - } else { + if($this->logger) + $this->logger->log('PUT: adding new document', PEAR_LOG_INFO); if ($folder->getAccessMode($this->user) < M_READWRITE) { + if($this->logger) + $this->logger->log('PUT: no access on folder', PEAR_LOG_ERR); unlink($tmpFile); return "403 Forbidden"; - } elseif(!$res = $folder->addDocument($name, '', 0, $this->user, '', array(), $tmpFile, $name, $fileType, $mimetype, 0, array(), array(), 0, "")) { + } + if($settings->_enableFullSearch) { + $index = $indexconf['Indexer']::open($settings->_luceneDir); + $indexconf['Indexer']::init($settings->_stopWordsFile); + } else { + $index = null; + $indexconf = null; + } + + $controller = Controller::factory('AddDocument'); + $controller->setParam('dms', $this->dms); + $controller->setParam('user', $this->user); + $controller->setParam('documentsource', 'webdav'); + $controller->setParam('folder', $folder); + $controller->setParam('index', $index); + $controller->setParam('indexconf', $indexconf); + $controller->setParam('name', $name); + $controller->setParam('comment', ''); + $controller->setParam('expires', 0); + $controller->setParam('keywords', ''); + $controller->setParam('categories', array()); + $controller->setParam('owner', $this->user); + $controller->setParam('userfiletmp', $tmpFile); + $controller->setParam('userfilename', $name); + $controller->setParam('filetype', $fileType); + $controller->setParam('userfiletype', $mimetype); + $minmax = $folder->getDocumentsMinMax(); + if($settings->_defaultDocPosition == 'start') + $controller->setParam('sequence', $minmax['min'] - 1); + else + $controller->setParam('sequence', $minmax['max'] + 1); + $controller->setParam('reviewers', array()); + $controller->setParam('approvers', array()); + $controller->setParam('reqversion', 0); + $controller->setParam('versioncomment', ''); + $controller->setParam('attributes', array()); + $controller->setParam('attributesversion', array()); + $controller->setParam('workflow', null); + $controller->setParam('notificationgroups', array()); + $controller->setParam('notificationusers', array()); + $controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText); + $controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs); + if(!$document = $controller->run()) { +// if(!$res = $folder->addDocument($name, '', 0, $this->user, '', array(), $tmpFile, $name, $fileType, $mimetype, 0, array(), array(), 0, "")) { unlink($tmpFile); - return "409 Conflict"; + if($this->logger) + $this->logger->log('PUT: error adding object: '.$controller->getErrorMsg(), PEAR_LOG_ERR); + return "409 Conflict ".$controller->getErrorMsg(); } } @@ -658,7 +731,9 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server } /* Check if parent of new folder is a folder */ - if (get_class($folder) != 'SeedDMS_Core_Folder') { + if (get_class($folder) != $this->dms->getClassname('folder')) { + if($this->logger) + $this->logger->log('MKCOL: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } @@ -673,15 +748,30 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server /* Check if user is logged in */ if(!$this->user) { + if($this->logger) + $this->logger->log('MKCOL: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } if ($folder->getAccessMode($this->user) < M_READWRITE) { + if($this->logger) + $this->logger->log('MKCOL: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } - if (!$folder->addSubFolder($name, '', $this->user, 0)) { - return "403 Forbidden"; + $controller = Controller::factory('AddSubFolder'); + $controller->setParam('dms', $this->dms); + $controller->setParam('user', $this->user); + $controller->setParam('folder', $folder); + $controller->setParam('name', $name); + $controller->setParam('comment', ''); + $controller->setParam('sequence', 0); + $controller->setParam('attributes', array()); + $controller->setParam('notificationgroups', array()); + $controller->setParam('notificationusers', array()); + if(!$subFolder = $controller->run()) { +// if (!$folder->addSubFolder($name, '', $this->user, 0)) { + return "409 Conflict ".$controller->getErrorMsg(); } return ("201 Created"); @@ -696,6 +786,8 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server */ function DELETE($options) /* {{{ */ { + global $settings, $indexconf; + $this->log_options('DELETE', $options); // get folder or document from path @@ -709,27 +801,45 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server // check for access rights if($obj->getAccessMode($this->user) < M_ALL) { + if($this->logger) + $this->logger->log('DELETE: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } - if (get_class($obj) == 'SeedDMS_Core_Folder') { + if($settings->_enableFullSearch) { + $index = $indexconf['Indexer']::open($settings->_luceneDir); + $indexconf['Indexer']::init($settings->_stopWordsFile); + } else { + $index = null; + $indexconf = null; + } + + if (get_class($obj) == $this->dms->getClassname('folder')) { if($obj->hasDocuments() || $obj->hasSubFolders()) { + if($this->logger) + $this->logger->log('DELETE: cannot delete, folder has children', PEAR_LOG_ERR); return "409 Conflict"; } - if(!$obj->remove()) { - return "409 Conflict"; + $controller = Controller::factory('RemoveFolder'); + $controller->setParam('dms', $this->dms); + $controller->setParam('user', $this->user); + $controller->setParam('folder', $obj); + $controller->setParam('index', $index); + $controller->setParam('indexconf', $indexconf); + if(!$controller->run()) { +// if(!$obj->remove()) { + return "409 Conflict ".$controller->getErrorMsg(); } } else { - // check if user is admin - // only admins may delete documents - /* There is not reason to allow only admins to remove a document - if(!$this->user->isAdmin()) { - return "403 Forbidden"; - } - */ - - if(!$obj->remove()) { - return "409 Conflict"; + $controller = Controller::factory('RemoveDocument'); + $controller->setParam('dms', $this->dms); + $controller->setParam('user', $this->user); + $controller->setParam('document', $obj); + $controller->setParam('index', $index); + $controller->setParam('indexconf', $indexconf); + if(!$controller->run()) { +// if(!$obj->remove()) { + return "409 Conflict ".$controller->getErrorMsg(); } } @@ -779,15 +889,17 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server * destination object */ if (($objsource->getAccessMode($this->user) < M_READWRITE) || ($objdest->getAccessMode($this->user) < M_READWRITE)) { + if($this->logger) + $this->logger->log('MOVE: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } - if(get_class($objdest) == 'SeedDMS_Core_Document') { + if(get_class($objdest) == $this->dms->getClassname('document')) { /* If destination object is a document it must be overwritten */ if (!$options["overwrite"]) { return "412 precondition failed"; } - if(get_class($objsource) == 'SeedDMS_Core_Folder') { + if(get_class($objsource) == $this->dms->getClassname('folder')) { return "400 Bad request"; } @@ -808,11 +920,11 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $objsource->remove(); return "204 No Content"; - } elseif(get_class($objdest) == 'SeedDMS_Core_Folder') { + } elseif(get_class($objdest) == $this->dms->getClassname('folder')) { /* Set the new Folder of the source object */ - if(get_class($objsource) == 'SeedDMS_Core_Document') + if(get_class($objsource) == $this->dms->getClassname('document')) $objsource->setFolder($objdest); - elseif(get_class($objsource) == 'SeedDMS_Core_Folder') + elseif(get_class($objsource) == $this->dms->getClassname('folder')) $objsource->setParent($objdest); else return "500 Internal server error"; @@ -830,6 +942,8 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server */ function COPY($options, $del=false) /* {{{ */ { + global $settings, $indexconf; + if(!$del) $this->log_options('COPY', $options); @@ -852,7 +966,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server if (!$objsource) return "404 Not found"; - if (get_class($objsource) == 'SeedDMS_Core_Folder' && ($options["depth"] != "infinity")) { + if (get_class($objsource) == $this->dms->getClassname('folder') && ($options["depth"] != "infinity")) { // RFC 2518 Section 9.2, last paragraph return "400 Bad request"; } @@ -876,16 +990,18 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server * access on the destination object */ if (($objsource->getAccessMode($this->user) < M_READ) || ($objdest->getAccessMode($this->user) < M_READWRITE)) { + if($this->logger) + $this->logger->log('COPY: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } /* If destination object is a document it must be overwritten */ - if(get_class($objdest) == 'SeedDMS_Core_Document') { + if(get_class($objdest) == $this->dms->getClassname('document')) { if (!$options["overwrite"]) { return "412 precondition failed"; } /* Copying a folder into a document makes no sense */ - if(get_class($objsource) == 'SeedDMS_Core_Folder') { + if(get_class($objsource) == $this->dms->getClassname('folder')) { return "400 Bad request"; } @@ -902,12 +1018,12 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $objdest->setName($objsource->getName()); return "204 No Content"; - } elseif(get_class($objdest) == 'SeedDMS_Core_Folder') { + } elseif(get_class($objdest) == $this->dms->getClassname('folder')) { if($this->logger) $this->logger->log('COPY: copy \''.$objdest->getName().'\' to folder '.$objdest->getName().'', PEAR_LOG_INFO); /* Currently no support for copying folders */ - if(get_class($objsource) == 'SeedDMS_Core_Folder') { + if(get_class($objsource) == $this->dms->getClassname('folder')) { if($this->logger) $this->logger->log('COPY: source is a folder '.$objsource->getName().'', PEAR_LOG_INFO); @@ -921,9 +1037,51 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server $content = $objsource->getLatestContent(); $fspath = $this->dms->contentDir.'/'.$content->getPath(); - if(!$newdoc = $objdest->addDocument($newdocname, '', 0, $this->user, '', array(), $fspath, $content->getOriginalFileName(), $content->getFileType(), $content->getMimeType(), 0, array(), array(), 0, "")) { + if($settings->_enableFullSearch) { + $index = $indexconf['Indexer']::open($settings->_luceneDir); + $indexconf['Indexer']::init($settings->_stopWordsFile); + } else { + $index = null; + $indexconf = null; + } + + $controller = Controller::factory('AddDocument'); + $controller->setParam('dms', $this->dms); + $controller->setParam('user', $this->user); + $controller->setParam('documentsource', 'webdav'); + $controller->setParam('folder', $objdest); + $controller->setParam('index', $index); + $controller->setParam('indexconf', $indexconf); + $controller->setParam('name', $newdocname); + $controller->setParam('comment', ''); + $controller->setParam('expires', 0); + $controller->setParam('keywords', ''); + $controller->setParam('categories', array()); + $controller->setParam('owner', $this->user); + $controller->setParam('userfiletmp', $fspath); + $controller->setParam('userfilename', $content->getOriginalFileName()); + $controller->setParam('filetype', $content->getFileType()); + $controller->setParam('userfiletype', $content->getMimeType()); + $minmax = $objdest->getDocumentsMinMax(); + if($settings->_defaultDocPosition == 'start') + $controller->setParam('sequence', $minmax['min'] - 1); + else + $controller->setParam('sequence', $minmax['max'] + 1); + $controller->setParam('reviewers', array()); + $controller->setParam('approvers', array()); + $controller->setParam('reqversion', 0); + $controller->setParam('versioncomment', ''); + $controller->setParam('attributes', array()); + $controller->setParam('attributesversion', array()); + $controller->setParam('workflow', null); + $controller->setParam('notificationgroups', array()); + $controller->setParam('notificationusers', array()); + $controller->setParam('maxsizeforfulltext', $settings->_maxSizeForFullText); + $controller->setParam('defaultaccessdocs', $settings->_defaultAccessDocs); + if(!$document = $controller->run()) { +// if(!$newdoc = $objdest->addDocument($newdocname, '', 0, $this->user, '', array(), $fspath, $content->getOriginalFileName(), $content->getFileType(), $content->getMimeType(), 0, array(), array(), 0, "")) { if($this->logger) - $this->logger->log('COPY: error copying object', PEAR_LOG_INFO); + $this->logger->log('COPY: error copying object', PEAR_LOG_ERR); return "409 Conflict"; } return "201 Created"; @@ -1016,11 +1174,13 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server return "200 OK"; // TODO recursive locks on directories not supported yet - if (get_class($obj) == 'SeedDMS_Core_Folder' && !empty($options["depth"])) { + if (get_class($obj) == $this->dms->getClassname('folder') && !empty($options["depth"])) { return "409 Conflict"; } if ($obj->getAccessMode($this->user) < M_READWRITE) { + if($this->logger) + $this->logger->log('LOCK: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } @@ -1054,11 +1214,13 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server return "204 No Content"; // TODO recursive locks on directories not supported yet - if (get_class($obj) == 'SeedDMS_Core_Folder' && !empty($options["depth"])) { + if (get_class($obj) == $this->dms->getClassname('folder') && !empty($options["depth"])) { return "409 Conflict"; } if ($obj->getAccessMode($this->user) < M_READWRITE) { + if($this->logger) + $this->logger->log('UNLOCK: access forbidden', PEAR_LOG_ERR); return "403 Forbidden"; } @@ -1091,7 +1253,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server } // Folders cannot be locked - if(get_class($obj) == 'SeedDMS_Core_Folder') { + if(get_class($obj) == $this->dms->getClassname('folder')) { if($this->logger) $this->logger->log('checkLock: object is a folder', PEAR_LOG_INFO); return false;