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

This commit is contained in:
Uwe Steinmann 2018-02-08 14:26:36 +01:00
commit 5d51f18c5b
18 changed files with 1591 additions and 620 deletions

View File

@ -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);

View File

@ -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;
}
} /* }}} */
?>
} /* }}} */

View File

@ -36,7 +36,7 @@ class SeedDMS_Core_Attribute { /* {{{ */
protected $_id;
/**
* @var object SeedDMS_Core_Object folder, document or document content
* @var SeedDMS_Core_Folder|SeedDMS_Core_Document|SeedDMS_Core_DocumentContent SeedDMS_Core_Object folder, document or document content
* this attribute belongs to
*
* @access protected
@ -44,7 +44,7 @@ class SeedDMS_Core_Attribute { /* {{{ */
protected $_obj;
/**
* @var object SeedDMS_Core_AttributeDefinition definition of this attribute
* @var SeedDMS_Core_AttributeDefinition definition of this attribute
*
* @access protected
*/
@ -65,20 +65,19 @@ class SeedDMS_Core_Attribute { /* {{{ */
protected $_validation_error;
/**
* @var object SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
protected $_dms;
/**
* Constructor
*
* @param integer $id internal id of attribute
* @param SeedDMS_Core_Object $obj object this attribute is attached to
* @param SeedDMS_Core_AttributeDefinition $attrdef reference to the attribute definition
* @param string $value value of the attribute
*/
/**
* SeedDMS_Core_Attribute constructor.
* @param $id
* @param $obj
* @param $attrdef
* @param $value
*/
function __construct($id, $obj, $attrdef, $value) { /* {{{ */
$this->_id = $id;
$this->_obj = $obj;
@ -242,10 +241,11 @@ class SeedDMS_Core_Attribute { /* {{{ */
* If the validation fails the validation error will be set which
* can be requested by SeedDMS_Core_Attribute::getValidationError()
*
* @return boolean true if validation succeds, otherwise false
* @return boolean true if validation succeeds, otherwise false
*/
function validate() { /* {{{ */
$attrdef = $this->_attrdef();
/** @var SeedDMS_Core_AttributeDefinition $attrdef */
$attrdef = $this->_attrdef(); /** @todo check this out, this method is not existing */
$result = $attrdef->validate($this->_value);
$this->_validation_error = $attrdef->getValidationError();
return $result;
@ -373,12 +373,17 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
protected $_validation_error;
/**
* @var object SeedDMS_Core_DMS reference to the dms instance this attribute definition belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute definition belongs to
*
* @access protected
*/
protected $_dms;
/**
* @var string
*/
protected $_separator;
/*
* Possible skalar data types of an attribute
*/
@ -398,20 +403,21 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
const objtype_document = '2';
const objtype_documentcontent = '3';
/**
* Constructor
*
* @param integer $id internal id of attribute definition
* @param string $name name of attribute
* @param integer $objtype type of object for which this attribute definition
* may be used.
* @param integer $type skalar type of attribute
* @param boolean $multiple set to true if multiple values are allowed
* @param integer $minvalues minimum number of values
* @param integer $maxvalues maximum number of values
* @param string $valueset separated list of allowed values, the first char
* is taken as the separator
*/
/**
* Constructor
*
* @param integer $id internal id of attribute definition
* @param string $name name of attribute
* @param integer $objtype type of object for which this attribute definition
* may be used.
* @param integer $type skalar type of attribute
* @param boolean $multiple set to true if multiple values are allowed
* @param integer $minvalues minimum number of values
* @param integer $maxvalues maximum number of values
* @param string $valueset separated list of allowed values, the first char
* is taken as the separator
* @param $regex
*/
function __construct($id, $name, $objtype, $type, $multiple, $minvalues, $maxvalues, $valueset, $regex) { /* {{{ */
$this->_id = $id;
$this->_name = $name;
@ -472,14 +478,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
*/
function getObjType() { return $this->_objtype; }
/**
* Set object type of attribute definition
*
* This can be one of objtype_all,
* objtype_folder, objtype_document, or objtype_documentcontent.
*
* @param integer $objtype type
*/
/**
* Set object type of attribute definition
*
* This can be one of objtype_all,
* objtype_folder, objtype_document, or objtype_documentcontent.
*
* @param integer $objtype type
* @return bool
*/
function setObjType($objtype) { /* {{{ */
$db = $this->_dms->getDB();
@ -502,14 +509,15 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
*/
function getType() { return $this->_type; }
/**
* Set type of attribute definition
*
* This can be one of type_int, type_float, type_string, type_boolean,
* type_url, type_email.
*
* @param integer $type type
*/
/**
* Set type of attribute definition
*
* This can be one of type_int, type_float, type_string, type_boolean,
* type_url, type_email.
*
* @param integer $type type
* @return bool
*/
function setType($type) { /* {{{ */
$db = $this->_dms->getDB();
@ -529,12 +537,13 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
*/
function getMultipleValues() { return $this->_multiple; }
/**
* Set if attribute definition allows multi values for attribute
*
* @param boolean $mv true if attribute may have multiple values, otherwise
* false
*/
/**
* Set if attribute definition allows multi values for attribute
*
* @param boolean $mv true if attribute may have multiple values, otherwise
* false
* @return bool
*/
function setMultipleValues($mv) { /* {{{ */
$db = $this->_dms->getDB();
@ -633,13 +642,14 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
return array();
} /* }}} */
/**
* Get the n'th value of a value set
*
* @param interger $index
* @return string n'th value of value set or false if the index is
* out of range or the value set has less than 2 chars
*/
/**
* Get the n'th value of a value set
*
* @param $ind
* @return string n'th value of value set or false if the index is
* out of range or the value set has less than 2 chars
* @internal param int $index
*/
function getValueSetValue($ind) { /* {{{ */
if(strlen($this->_valueset) > 1) {
$tmp = explode($this->_valueset[0], substr($this->_valueset, 1));
@ -745,17 +755,16 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
return true;
} /* }}} */
/**
* Parse a given value according to attribute definition
*
* The return value is always an array, even if the attribute is single
* value attribute.
*
* @return array list of single values
*/
/**
* Parse a given value according to attribute definition
*
* The return value is always an array, even if the attribute is single
* value attribute.
*
* @param $value
* @return array|bool
*/
function parseValue($value) { /* {{{ */
$db = $this->_dms->getDB();
if($this->getMultipleValues()) {
/* If the value doesn't start with the separator used in the value set,
* then assume that the value was not saved with a leading separator.
@ -771,7 +780,6 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
} else {
return array($value);
}
return true;
} /* }}} */
/**
@ -779,8 +787,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
* attribute definition is used
*
* @param integer $limit return not more the n objects of each type
* @return boolean true if attribute definition is used, otherwise false
*/
* @return array|bool
*/
function getStatistics($limit=0) { /* {{{ */
$db = $this->_dms->getDB();
@ -1048,8 +1056,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
if(!$success)
$this->_validation_error = 3;
break;
case self::type_boolean:
foreach($values as $value) {
case self::type_boolean: /** @todo: Same case in LINE 966 */
foreach($values as $value) {
$success &= preg_match('/^[01]$/', $value);
}
break;
@ -1094,4 +1102,3 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
function getValidationError() { return $this->_validation_error; }
} /* }}} */
?>

View File

@ -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
@ -183,6 +183,11 @@ class SeedDMS_Core_DMS {
*/
public $callbacks;
/**
* @var SeedDMS_Core_DMS
*/
public $_dms;
/**
* Checks if two objects are equal by comparing their IDs
@ -216,7 +221,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
*/
@ -309,7 +314,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
@ -413,14 +418,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;
@ -452,11 +457,11 @@ class SeedDMS_Core_DMS {
/**
* Return class name of instantiated objects
*
* This method returns the class name of those objects being instatiated
* This method returns the class name of those objects being instantiated
* by the dms. Each class has an internal place holder, which must be
* passed to function.
*
* @param string placeholder (can be one of 'folder', 'document',
* @param string $objectname placeholder (can be one of 'folder', 'document',
* 'documentcontent', 'user', 'group'
*
* @return string/boolean name of class or false if placeholder is invalid
@ -476,9 +481,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
*/
@ -497,7 +502,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;
@ -506,7 +511,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();
@ -553,7 +558,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;
@ -579,7 +584,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;
@ -588,7 +593,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() { /* {{{ */
@ -631,7 +636,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() { /* {{{ */
@ -644,7 +649,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'];
@ -676,7 +681,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();
@ -724,8 +730,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)
@ -743,7 +749,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;
@ -764,6 +770,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;
@ -778,7 +785,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;
@ -801,6 +808,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;
@ -812,7 +820,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;
@ -966,14 +974,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
@ -1411,8 +1418,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`";
@ -1720,7 +1728,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
@ -1730,30 +1738,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(), $reception=array()) { /* {{{ */
// Split the search string into constituent keywords.
@ -1836,6 +1844,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;
@ -1897,6 +1906,7 @@ class SeedDMS_Core_DMS {
foreach ($resArr as $folderArr) {
$folders[] = $this->getFolder($folderArr['id']);
}
/** @noinspection PhpUndefinedVariableInspection */
$folderresult = array('totalFolders'=>$totalFolders, 'folders'=>$folders);
}
} else {
@ -1974,6 +1984,7 @@ class SeedDMS_Core_DMS {
} elseif($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) {
if($attrdef->getValueSet()) {
if($attrdef->getMultipleValues()) {
/** @noinspection PhpUndefinedVariableInspection */
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND (`tblDocumentContentAttributes`.`value` like '%".$valueset[0].implode("%' OR `tblDocumentContentAttributes`.`value` like '%".$valueset[0], $attribute)."%') AND `tblDocumentContentAttributes`.`document` = `tblDocumentContent`.`id`)";
} else {
$searchAttributes[] = "EXISTS (SELECT NULL FROM `tblDocumentContentAttributes` WHERE `tblDocumentContentAttributes`.`attrdef`=".$attrdefid." AND `tblDocumentContentAttributes`.`value`='".$attribute."' AND `tblDocumentContentAttributes`.content = `tblDocumentContent`.id)";
@ -2162,6 +2173,7 @@ class SeedDMS_Core_DMS {
foreach ($resArr as $docArr) {
$docs[] = $this->getDocument($docArr['id']);
}
/** @noinspection PhpUndefinedVariableInspection */
$docresult = array('totalDocs'=>$totalDocs, 'docs'=>$docs);
}
} else {
@ -2189,7 +2201,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'];
@ -2205,8 +2217,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;
@ -2224,6 +2236,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;
@ -2234,7 +2247,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`";
@ -2268,7 +2281,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`";
@ -2314,7 +2327,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'];
@ -2354,7 +2367,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 <a href='psi_element://SeedDMS_Core_User'>SeedDMS_Core_User</a> or false
* or false
*/
function getAllUsers($orderby = '') { /* {{{ */
$classname = $this->classnames['user'];
@ -2366,14 +2381,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;
@ -2401,6 +2421,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)) {
}
}
@ -2413,7 +2434,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'];
@ -2424,7 +2445,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'];
@ -2434,7 +2455,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'];
@ -2446,7 +2467,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) { /* {{{ */
@ -2463,6 +2484,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)) {
}
}
@ -2623,6 +2645,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`";
@ -2656,6 +2680,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)) {
}
}
@ -2702,7 +2727,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;
@ -2732,6 +2757,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)) {
}
}
@ -2771,7 +2797,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()));
@ -2788,6 +2815,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 */
@ -2808,6 +2836,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 */
@ -2824,7 +2853,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))
@ -2849,7 +2878,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;
@ -2871,7 +2900,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 <a href='psi_element://SeedDMS_Core_AttributeDefinition'>SeedDMS_Core_AttributeDefinition</a> or false
* or false
*/
function getAllAttributeDefinitions($objtype=0) { /* {{{ */
$queryStr = "SELECT * FROM `tblAttributeDefinitions`";
@ -2887,6 +2917,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++) {
@ -2902,12 +2933,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))) {
@ -2932,7 +2965,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`";
@ -2951,8 +2984,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"]], $resArr[$i]["layoutdata"]);
$workflow->setDMS($this);
$workflows[$i] = $workflow;
@ -2965,7 +3000,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);
@ -2989,7 +3024,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;
@ -3015,7 +3050,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;
@ -3036,7 +3072,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))
@ -3059,7 +3095,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;
@ -3084,7 +3120,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`";
@ -3108,7 +3144,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;
@ -3129,7 +3165,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))
@ -3154,7 +3190,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;
@ -3175,7 +3211,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`";
@ -3184,6 +3220,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"]);
@ -3198,7 +3235,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;
@ -3219,7 +3256,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))
@ -3284,6 +3321,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`)";
@ -3293,6 +3332,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']);
@ -3308,6 +3348,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";
@ -3315,8 +3357,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']);
@ -3332,6 +3376,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";
@ -3339,8 +3384,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']);
@ -3356,6 +3403,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";
@ -3363,6 +3411,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']);
@ -3383,6 +3432,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) {
@ -3399,6 +3452,7 @@ class SeedDMS_Core_DMS {
$queryStr = "SELECT a.*, b.`name` FROM `tblDocumentRevisors`";
break;
}
/** @noinspection PhpUndefinedVariableInspection */
$queryStr .= " a LEFT JOIN `tblDocuments` b ON a.`documentID`=b.`id` where";
switch($usergroup) {
case 'user':
@ -3418,6 +3472,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
@ -3437,6 +3495,7 @@ class SeedDMS_Core_DMS {
$queryStr = "DELETE FROM tblDocumentRevisors";
break;
}
/** @noinspection PhpUndefinedVariableInspection */
$queryStr .= " WHERE";
switch($usergroup) {
case 'user':
@ -3462,7 +3521,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) {
@ -3488,6 +3547,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);
@ -3538,15 +3598,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." OR `revisiondate` > '".date('Y-m-d H:i:s', $startts)."' AND `revisiondate` < '".date('Y-m-d H:i:s', $endts)."' UNION SELECT DISTINCT document FROM `tblDocumentFiles` WHERE `date` > ".$startts." AND `date` < ".$endts;
@ -3591,6 +3655,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");
@ -3622,4 +3687,3 @@ class SeedDMS_Core_DMS {
} /* }}} */
}
?>

View File

@ -203,7 +203,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;
@ -213,7 +213,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;
@ -222,6 +222,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;
@ -245,6 +253,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
@ -278,7 +287,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) { /* {{{ */
@ -305,12 +315,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
*
@ -325,17 +336,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();
@ -348,17 +360,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();
@ -371,8 +384,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();
@ -387,7 +407,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();
@ -412,7 +432,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();
@ -528,7 +549,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();
@ -546,7 +567,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) { /* {{{ */
@ -556,11 +577,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();
}
@ -577,7 +600,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))
@ -588,7 +611,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) { /* {{{ */
@ -621,10 +644,14 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
$db->commitTransaction();
$this->_ownerID = $newOwner->getID();
/** @noinspection PhpUndefinedFieldInspection */
$this->_owner = $newOwner;
return true;
} /* }}} */
/**
* @return bool|int
*/
function getDefaultAccess() { /* {{{ */
if ($this->inheritsAccess()) {
$res = $this->getFolder();
@ -641,7 +668,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();
@ -658,6 +686,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return true;
} /* }}} */
/**
* @return bool
*/
function inheritsAccess() { return $this->_inheritAccess; }
/**
@ -716,7 +747,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();
@ -837,7 +869,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) { /* {{{ */
@ -865,7 +897,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())
@ -1095,8 +1127,15 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return 0;
} /* }}} */
/**
* @return int
*/
function getSequence() { return $this->_sequence; }
/**
* @param $seq
* @return bool
*/
function setSequence($seq) { /* {{{ */
$db = $this->_dms->getDB();
@ -1143,9 +1182,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();
@ -1195,6 +1234,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();
@ -1225,6 +1265,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();
@ -1324,6 +1365,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();
@ -1337,6 +1379,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)
@ -1368,7 +1411,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) { /* {{{ */
@ -1380,6 +1423,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;
@ -1405,7 +1449,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* SeedDMS_Core_Group.
*
* @param integer $type type of notification (not yet used)
* @return array list of notifications
* @return array|bool
*/
function getNotifyList($type=0) { /* {{{ */
if (empty($this->_notifyList)) {
@ -1446,7 +1490,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) {
@ -1526,6 +1572,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;
@ -1544,6 +1591,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;
@ -1581,10 +1629,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
@ -1594,6 +1642,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;
@ -1670,7 +1719,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
* must be the id of the attribute definition.
* @param object $workflow
* @param integer $initstate intial document status
* @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, $initstate=S_RELEASED) { /* {{{ */
$db = $this->_dms->getDB();
@ -1720,7 +1769,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);
@ -1757,7 +1806,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) {
@ -1775,7 +1825,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) {
@ -1816,7 +1867,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;
@ -1854,7 +1906,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'];
@ -1909,7 +1961,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();
@ -1917,13 +1969,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'], $row['revisiondate']);
if($user) {
if($content->getAccessMode($user) >= M_READ)
@ -1945,7 +1998,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) { /* {{{ */
@ -1962,13 +2015,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'], $resArr['revisiondate'])) {
$user = $this->_dms->getLoggedInUser();
/* A user with write access on the document may always see the version */
@ -1981,6 +2035,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
}
} /* }}} */
/**
* @return bool|null|SeedDMS_Core_DocumentContent
*/
function __getLatestContent() { /* {{{ */
if (!$this->_latestContent) {
$db = $this->_dms->getDB();
@ -2009,19 +2066,20 @@ 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) {
/** @var SeedDMS_Core_DocumentContent $content */
if (!$this->_latestContent) {
$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'], $row['revisiondate']);
if($user) {
@ -2044,7 +2102,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) { /* {{{ */
@ -2238,7 +2296,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 */
@ -2269,7 +2328,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) { /* {{{ */
@ -4226,7 +4285,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() ."')";
@ -4278,7 +4337,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() ."')";
@ -4448,7 +4507,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() ."')";
@ -4492,7 +4551,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() ."')";
@ -6055,7 +6114,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;
@ -6074,6 +6133,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;
@ -6082,22 +6149,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; }
/**
@ -6108,8 +6190,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;
@ -6152,7 +6236,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;
@ -6209,6 +6293,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;
@ -6224,15 +6323,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();
@ -6245,6 +6359,9 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getDate() { return $this->_date; }
/**
@ -6271,10 +6388,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; }
/*
@ -6293,16 +6429,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; }
/*
@ -6324,6 +6469,9 @@ class SeedDMS_Core_DocumentFile { /* {{{ */
return true;
} /* }}} */
/**
* @return int
*/
function isPublic() { return $this->_public; }
/*
@ -6390,18 +6538,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;
@ -6412,7 +6587,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
@ -6420,12 +6595,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;
@ -6453,6 +6634,12 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */
return true;
} /* }}} */
/**
* @param $approver
* @param $type
* @param $status
* @return bool
*/
function addApprover($approver, $type, $status) { /* {{{ */
$dms = $this->_dms;
@ -6480,6 +6667,10 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */
return true;
} /* }}} */
/**
* @param $status
* @return bool
*/
function setStatus($status) { /* {{{ */
if (!is_integer($status)) {
return false;
@ -6491,14 +6682,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;
@ -6511,6 +6712,10 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */
}
} /* }}} */
/**
* @param $type
* @return array|bool|null
*/
function getApprovers($type) { /* {{{ */
if (strcasecmp($type, "i") && strcasecmp($type, "g")) {
return false;
@ -6523,4 +6728,3 @@ class SeedDMS_Core_AddContentResultSet { /* {{{ */
}
} /* }}} */
} /* }}} */
?>

View File

@ -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,7 +868,7 @@ 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 SeedDMS_Core_User $keywords keywords of new document
* @param array $categories list of category ids
* @param string $tmpFile the path of the file containing the content
* @param string $orgFileName the original file name
@ -812,19 +877,19 @@ 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
* @param SeedDMS_Core_Workflow $workflow
* @param integer $initstate initial document state (only S_RELEASED and
* S_DRAFT are allowed)
* @return array/boolean false in case of error, otherwise an array
* @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, $initstate=S_RELEASED) { /* {{{ */
$db = $this->_dms->getDB();
@ -882,7 +947,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)) {
}
}
}
@ -946,7 +1012,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
/* Check if 'onPostRemoveFolder' callback is set */
if(isset($this->_dms->callbacks['onPostRemoveFolder'])) {
foreach($this->_dms->callbacks['onPostRemoveFolder'] as $callback) {
if(!call_user_func($callback[0], $callback[1], $this->_id)) {
/** @noinspection PhpStatementHasEmptyBodyInspection */
if(!call_user_func($callback[0], $callback[1], $this->_id)) {
}
}
}
@ -962,6 +1029,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.
@ -1008,7 +1076,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
*
* @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
* @return bool|SeedDMS_Core_GroupAccess|SeedDMS_Core_UserAccess
*/
function getAccessList($mode = M_ANY, $op = O_EQ) { /* {{{ */
$db = $this->_dms->getDB();
@ -1079,6 +1147,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();
@ -1109,6 +1178,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();
@ -1129,6 +1199,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();
@ -1185,6 +1260,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();
@ -1198,6 +1274,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)
@ -1225,7 +1302,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) { /* {{{ */
@ -1235,6 +1312,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;
@ -1251,13 +1329,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) { /* {{{ */
@ -1299,6 +1378,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) {
@ -1306,6 +1386,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);
@ -1313,7 +1395,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
@ -1334,6 +1416,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;
@ -1383,6 +1466,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;
@ -1401,6 +1485,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;
@ -1434,7 +1519,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
@ -1442,12 +1527,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();
@ -1527,9 +1612,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) { /* {{{ */
@ -1557,9 +1641,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;
@ -1701,7 +1788,7 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
/**
* Get the min and max sequence value for documents
*
* @return boolean/array array with keys 'min' and 'max', false in case of an error
* @return bool|array array with keys 'min' and 'max', false in case of an error
*/
function getDocumentsMinMax() { /* {{{ */
$db = $this->_dms->getDB();

View File

@ -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();
@ -162,6 +195,7 @@ class SeedDMS_Core_Group { /* {{{ */
$classnamerole = $this->_dms->getClassname('role');
$classname = $this->_dms->getClassname('user');
foreach ($resArr as $row) {
/** @var SeedDMS_Core_User $user */
$role = $classnamerole::getInstance($row['role'], $this->_dms);
$user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $role, $row['hidden']);
$user->setDMS($this->_dms);
@ -171,6 +205,9 @@ class SeedDMS_Core_Group { /* {{{ */
return $this->_users;
} /* }}} */
/**
* @return SeedDMS_Core_User[]|bool
*/
function getManagers() { /* {{{ */
$db = $this->_dms->getDB();
@ -185,12 +222,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();
@ -203,6 +246,10 @@ class SeedDMS_Core_Group { /* {{{ */
return true;
} /* }}} */
/**
* @param SeedDMS_Core_User $user
* @return bool
*/
function removeUser($user) { /* {{{ */
$db = $this->_dms->getDB();
@ -217,7 +264,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
@ -245,7 +292,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) { /* {{{ */
@ -265,7 +312,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
*/
@ -504,7 +551,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();
@ -531,7 +578,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();
@ -556,4 +603,3 @@ class SeedDMS_Core_Group { /* {{{ */
} /* }}} */
} /* }}} */
?>

View File

@ -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;
}
}
?>

View File

@ -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;
} /* }}} */
} /* }}} */
?>

View File

@ -341,7 +341,7 @@ class SeedDMS_Core_User { /* {{{ */
var $_loginFailures;
/**
* @var object home folder
* @var SeedDMS_Core_Folder home folder
*
* @access protected
*/
@ -362,16 +362,45 @@ class SeedDMS_Core_User { /* {{{ */
var $_rev_substitutes;
/**
* @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
* @param string $secret
*/
function __construct($id, $login, $pwd, $fullName, $email, $language, $theme, $comment, $role, $isHidden=0, $isDisabled=0, $pwdExpiration='', $loginFailures=0, $quota=0, $homeFolder=null, $secret='') {
$this->_id = $id;
$this->_login = $login;
@ -399,13 +428,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();
@ -437,6 +466,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();
@ -453,6 +487,7 @@ class SeedDMS_Core_User { /* {{{ */
$classname = $dms->getClassname('role');
for ($i = 0; $i < count($resArr); $i++) {
/** @var SeedDMS_Core_User $user */
$role = $classname::getInstance($resArr[$i]['role'], $dms);
$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"], $role, $resArr[$i]["hidden"], $resArr[$i]["disabled"], $resArr[$i]["pwdExpiration"], $resArr[$i]["loginfailures"], $resArr[$i]["quota"], $resArr[$i]["homefolder"]);
$user->setDMS($dms);
@ -462,14 +497,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();
@ -482,8 +530,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();
@ -496,8 +551,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();
@ -510,8 +572,14 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getSecret() { return $this->_secret; }
/**
* @param string $newSecret
*/
function setSecret($newSecret) { /* {{{ */
$db = $this->_dms->getDB();
@ -524,8 +592,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();
@ -543,8 +618,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();
@ -557,8 +639,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();
@ -571,8 +660,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();
@ -585,8 +681,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();
@ -599,8 +702,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getRole() { return $this->_role; }
/**
* @param $newrole
* @return bool
*/
function setRole($newrole) { /* {{{ */
$db = $this->_dms->getDB();
@ -615,6 +725,9 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return bool
*/
function isAdmin() { return (is_object($this->_role) ? $this->_role->isAdmin() : $this->_role == SeedDMS_Core_User::role_admin); }
/**
@ -631,6 +744,9 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return bool
*/
function isGuest() { return (is_object($this->_role) ? $this->_role->isGuest() : $this->_role == SeedDMS_Core_User::role_guest); }
/**
@ -647,8 +763,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();
@ -661,8 +784,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();
@ -675,6 +805,9 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return bool|int
*/
function addLoginFailure() { /* {{{ */
$db = $this->_dms->getDB();
@ -686,6 +819,9 @@ class SeedDMS_Core_User { /* {{{ */
return $this->_loginFailures;
} /* }}} */
/**
* @return bool
*/
function clearLoginFailures() { /* {{{ */
$db = $this->_dms->getDB();
@ -716,8 +852,15 @@ class SeedDMS_Core_User { /* {{{ */
return $resArr[0]['sum'];
} /* }}} */
/**
* @return int
*/
function getQuota() { return $this->_quota; }
/**
* @param $quota
* @return bool
*/
function setQuota($quota) { /* {{{ */
$db = $this->_dms->getDB();
@ -730,8 +873,15 @@ class SeedDMS_Core_User { /* {{{ */
return true;
} /* }}} */
/**
* @return null|SeedDMS_Core_Folder
*/
function getHomeFolder() { return $this->_homeFolder; }
/**
* @param $homefolder
* @return bool
*/
function setHomeFolder($homefolder) { /* {{{ */
$db = $this->_dms->getDB();
@ -949,9 +1099,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
*/
@ -964,8 +1114,9 @@ class SeedDMS_Core_User { /* {{{ */
* anymore.
*/
if(!$assignToUser)
return;
$assignTo = $assignToUser->getID();
return false;
/** @noinspection PhpUnusedLocalVariableInspection */
$assignTo = $assignToUser->getID();
$db->startTransaction();
@ -1121,7 +1272,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
*/
@ -1141,7 +1292,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
*/
@ -1159,7 +1310,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();
@ -1176,6 +1327,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);
@ -1187,7 +1339,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) { /* {{{ */
@ -1218,7 +1370,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();
@ -1233,6 +1385,11 @@ class SeedDMS_Core_User { /* {{{ */
return $resArr;
} /* }}} */
/**
* @param $tmpfile
* @param $mimeType
* @return bool
*/
function setImage($tmpfile, $mimeType) { /* {{{ */
$db = $this->_dms->getDB();
@ -1254,9 +1411,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();
@ -1273,6 +1428,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;
@ -1283,8 +1439,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();
@ -1301,6 +1456,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;
@ -1354,7 +1510,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();
@ -1450,7 +1606,7 @@ class SeedDMS_Core_User { /* {{{ */
* @param int $documentID optional document id for which to retrieve the
* approvals
* @param int $version optional version of the document
* @return array list of all approvals
* @return array|bool list of all approvals
*/
function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
@ -1460,7 +1616,7 @@ class SeedDMS_Core_User { /* {{{ */
* latest version. This may be needed here too.
*/
$queryStr =
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
@ -1702,7 +1858,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();
@ -1744,7 +1900,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();
@ -1804,7 +1960,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();
@ -1827,7 +1983,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();
@ -1851,7 +2007,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();
@ -1874,7 +2030,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();
@ -1925,6 +2081,7 @@ class SeedDMS_Core_User { /* {{{ */
if (is_bool($resArr) && !$resArr) return false;
}
return false;
} /* }}} */
/**
@ -1942,7 +2099,7 @@ class SeedDMS_Core_User { /* {{{ */
$queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverGroupID` = " . (int) $id;
$resArr = $db->getResultArray($queryStr);
if (count($resArr)!=0) return;
if (count($resArr)!=0) return true;
$queryStr = "INSERT INTO `tblMandatoryApprovers` (`userID`, `approverGroupID`) VALUES (" . $this->_id . ", " . $id .")";
$resArr = $db->getResult($queryStr);
@ -1952,12 +2109,14 @@ class SeedDMS_Core_User { /* {{{ */
$queryStr = "SELECT * FROM `tblMandatoryApprovers` WHERE `userID` = " . $this->_id . " AND `approverUserID` = " . (int) $id;
$resArr = $db->getResultArray($queryStr);
if (count($resArr)!=0) return;
if (count($resArr)!=0) return true;
$queryStr = "INSERT INTO `tblMandatoryApprovers` (`userID`, `approverUserID`) VALUES (" . $this->_id . ", " . $id .")";
$resArr = $db->getResult($queryStr);
if (is_bool($resArr) && !$resArr) return false;
}
return false;
} /* }}} */
/**
@ -1972,18 +2131,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) { /* {{{ */
@ -2209,7 +2370,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();
@ -2236,7 +2397,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();
@ -2258,4 +2419,3 @@ class SeedDMS_Core_User { /* {{{ */
} /* }}} */
} /* }}} */
?>

View File

@ -29,14 +29,14 @@ 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
*/
@ -50,19 +50,26 @@ class SeedDMS_Core_Workflow { /* {{{ */
var $_layoutdata;
/**
* @var name of the workflow state
* @var SeedDMS_Core_Workflow_Transition[] list of transitions
*
* @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
* @param string $layoutdata
*/
function __construct($id, $name, $initstate, $layoutdata) { /* {{{ */
$this->_id = $id;
$this->_name = $name;
@ -72,14 +79,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();
@ -92,9 +112,16 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
function getInitState() { return $this->_initstate; }
/**
* @return SeedDMS_Core_Workflow_State
*/
function getInitState() { return $this->_initstate; }
function setInitState($state) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow_State $state
* @return bool
*/
function setInitState($state) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflows` SET `initstate` = ".$state->getID()." WHERE `id` = " . $this->_id;
@ -106,8 +133,14 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
/**
* @return string
*/
function getLayoutData() { return $this->_layoutdata; }
/**
* @param string $layoutdata
*/
function setLayoutData($newdata) { /* {{{ */
$db = $this->_dms->getDB();
@ -120,6 +153,9 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
/**
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getTransitions() { /* {{{ */
$db = $this->_dms->getDB();
@ -143,8 +179,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $this->_transitions;
} /* }}} */
function getStates() { /* {{{ */
$db = $this->_dms->getDB();
/**
* @return array
*/
function getStates() { /* {{{ */
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
if(!$this->_transitions)
$this->getTransitions();
@ -160,14 +200,15 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $states;
} /* }}} */
/**
* Get the transition by its id
*
* @param integer $id id of transition
* @param object transition
*/
/**
* Get the transition by its id
*
* @param integer $id id of transition
* @return bool|SeedDMS_Core_Workflow_Transition
*/
function getTransition($id) { /* {{{ */
$db = $this->_dms->getDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
if(!$this->_transitions)
$this->getTransitions();
@ -178,12 +219,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
return false;
} /* }}} */
/**
* Get the transitions that can be triggered while being in the given state
*
* @param object $state current workflow state
* @param array list of transitions
*/
/**
* Get the transitions that can be triggered while being in the given state
*
* @param SeedDMS_Core_Workflow_State $state current workflow state
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getNextTransitions($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -202,12 +243,12 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $wkftransitions;
} /* }}} */
/**
* Get the transitions that lead to the given state
*
* @param object $state current workflow state
* @param array list of transitions
*/
/**
* Get the transitions that lead to the given state
*
* @param SeedDMS_Core_Workflow_State $state current workflow state
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getPreviousTransitions($state) { /* {{{ */
$db = $this->_dms->getDB();
@ -226,13 +267,13 @@ class SeedDMS_Core_Workflow { /* {{{ */
return $wkftransitions;
} /* }}} */
/**
* Get all transitions from one state into another state
*
* @param object $state state to start from
* @param object $nextstate state after transition
* @param array list of transitions
*/
/**
* Get all transitions from one state into another state
*
* @param SeedDMS_Core_Workflow_State $state state to start from
* @param SeedDMS_Core_Workflow_State $nextstate state after transition
* @return SeedDMS_Core_Workflow_Transition[]|bool
*/
function getTransitionsByStates($state, $nextstate) { /* {{{ */
$db = $this->_dms->getDB();
@ -255,7 +296,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) { /* {{{ */
@ -265,12 +306,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();
@ -323,7 +364,11 @@ class SeedDMS_Core_Workflow { /* {{{ */
return true;
} /* }}} */
private function penetrate($laststates) {
/**
* @param SeedDMS_Core_Workflow_State[] $laststates
* @return SeedDMS_Core_Workflow_State[]|bool
*/
private function penetrate($laststates) {
$state = end($laststates);
$transitions = $this->getNextTransitions($state);
foreach($transitions as $transition) {
@ -345,7 +390,8 @@ class SeedDMS_Core_Workflow { /* {{{ */
* @return boolean list of states if workflow contains cycles, otherwise false
*/
function checkForCycles() { /* {{{ */
$db = $this->_dms->getDB();
/** @noinspection PhpUnusedLocalVariableInspection */
$db = $this->_dms->getDB();
$initstate = $this->getInitState();
@ -411,41 +457,49 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
var $_id;
/**
* @var name of the workflow state
* @var string name of the workflow state
*
* @access protected
*/
var $_name;
/**
* @var maximum of seconds allowed in this state
* @var int maximum of seconds allowed in this state
*
* @access protected
*/
var $_maxtime;
/**
* @var maximum of seconds allowed in this state
* @var int maximum of seconds allowed in this state
*
* @access protected
*/
var $_precondfunc;
/**
* @var matching documentstatus when this state is reached
* @var int matching documentstatus when this state is reached
*
* @access protected
*/
var $_documentstatus;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) {
/**
* SeedDMS_Core_Workflow_State constructor.
* @param $id
* @param $name
* @param $maxtime
* @param $precondfunc
* @param $documentstatus
*/
function __construct($id, $name, $maxtime, $precondfunc, $documentstatus) {
$this->_id = $id;
$this->_name = $name;
$this->_maxtime = $maxtime;
@ -454,15 +508,28 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
$this->_dms = null;
}
function setDMS($dms) {
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getName() { return $this->_name; }
/**
* @return string
*/
function getName() { return $this->_name; }
function setName($newName) { /* {{{ */
/**
* @param string $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
@ -474,9 +541,16 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
function getMaxTime() { return $this->_maxtime; }
/**
* @return int maximum
*/
function getMaxTime() { return $this->_maxtime; }
function setMaxTime($maxtime) { /* {{{ */
/**
* @param $maxtime
* @return bool
*/
function setMaxTime($maxtime) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id;
@ -488,9 +562,16 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
return true;
} /* }}} */
function getPreCondFunc() { return $this->_precondfunc; }
/**
* @return int maximum
*/
function getPreCondFunc() { return $this->_precondfunc; }
function setPreCondFunc($precondfunc) { /* {{{ */
/**
* @param $precondfunc
* @return bool
*/
function setPreCondFunc($precondfunc) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `precondfunc` = ".$db->qstr($precondfunc)." WHERE id = " . $this->_id;
@ -498,7 +579,8 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
if (!$res)
return false;
$this->_maxtime = $maxtime;
/** @noinspection PhpUndefinedVariableInspection */
$this->_maxtime = $maxtime; /* @todo fix me */
return true;
} /* }}} */
@ -512,7 +594,11 @@ class SeedDMS_Core_Workflow_State { /* {{{ */
*/
function getDocumentStatus() { return $this->_documentstatus; }
function setDocumentStatus($docstatus) { /* {{{ */
/**
* @param $docstatus
* @return bool
*/
function setDocumentStatus($docstatus) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowStates` SET `documentstatus` = ".intval($docstatus)." WHERE id = " . $this->_id;
@ -542,7 +628,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();
@ -608,34 +694,52 @@ class SeedDMS_Core_Workflow_Action { /* {{{ */
var $_id;
/**
* @var name of the workflow action
* @var string name of the workflow action
*
* @access protected
*/
var $_name;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
function __construct($id, $name) {
/**
* SeedDMS_Core_Workflow_Action constructor.
* @param $id
* @param $name
*/
function __construct($id, $name) {
$this->_id = $id;
$this->_name = $name;
$this->_dms = null;
}
function setDMS($dms) {
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getName() { return $this->_name; }
/**
* @return string name
*/
function getName() { return $this->_name; }
function setName($newName) { /* {{{ */
/**
* @param $newName
* @return bool
*/
function setName($newName) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowActions` SET `name` = ".$db->qstr($newName)." WHERE `id` = " . $this->_id;
@ -665,7 +769,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();
@ -731,62 +835,71 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
var $_id;
/**
* @var workflow this transition belongs to
* @var SeedDMS_Core_Workflow workflow this transition belongs to
*
* @access protected
*/
var $_workflow;
/**
* @var state of the workflow transition
* @var SeedDMS_Core_Workflow_State of the workflow transition
*
* @access protected
*/
var $_state;
/**
* @var next state of the workflow transition
* @var SeedDMS_Core_Workflow_State next state of the workflow transition
*
* @access protected
*/
var $_nextstate;
/**
* @var action of the workflow transition
* @var SeedDMS_Core_Workflow_Action of the workflow transition
*
* @access protected
*/
var $_action;
/**
* @var maximum of seconds allowed until this transition must be triggered
* @var integer maximum of seconds allowed until this transition must be triggered
*
* @access protected
*/
var $_maxtime;
/**
* @var list of users allowed to trigger this transaction
* @var SeedDMS_Core_User[] of users allowed to trigger this transaction
*
* @access protected
*/
var $_users;
/**
* @var list of groups allowed to trigger this transaction
* @var SeedDMS_Core_Group[] of groups allowed to trigger this transaction
*
* @access protected
*/
var $_groups;
/**
* @var object reference to the dms instance this attribute belongs to
* @var SeedDMS_Core_DMS reference to the dms instance this attribute belongs to
*
* @access protected
*/
var $_dms;
function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) {
/**
* SeedDMS_Core_Workflow_Transition constructor.
* @param $id
* @param $workflow
* @param $state
* @param $action
* @param $nextstate
* @param $maxtime
*/
function __construct($id, $workflow, $state, $action, $nextstate, $maxtime) {
$this->_id = $id;
$this->_workflow = $workflow;
$this->_state = $state;
@ -796,15 +909,28 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
$this->_dms = null;
}
function setDMS($dms) {
/**
* @param $dms
*/
function setDMS($dms) {
$this->_dms = $dms;
}
function getID() { return $this->_id; }
/**
* @return int
*/
function getID() { return $this->_id; }
function getWorkflow() { return $this->_workflow; }
/**
* @return SeedDMS_Core_Workflow
*/
function getWorkflow() { return $this->_workflow; }
function setWorkflow($newWorkflow) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow $newWorkflow
* @return bool
*/
function setWorkflow($newWorkflow) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `workflow` = ".$newWorkflow->getID()." WHERE `id` = " . $this->_id;
@ -816,9 +942,17 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getState() { return $this->_state; }
function setState($newState) { /* {{{ */
/**
* @return SeedDMS_Core_Workflow_State
*/
function getState() { return $this->_state; }
/**
* @param SeedDMS_Core_Workflow_State $newState
* @return bool
*/
function setState($newState) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `state` = ".$newState->getID()." WHERE `id` = " . $this->_id;
@ -830,9 +964,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getNextState() { return $this->_nextstate; }
/**
* @return SeedDMS_Core_Workflow_State
*/
function getNextState() { return $this->_nextstate; }
function setNextState($newNextState) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow_State $newNextState
* @return bool
*/
function setNextState($newNextState) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `nextstate` = ".$newNextState->getID()." WHERE `id` = " . $this->_id;
@ -844,9 +985,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getAction() { return $this->_action; }
/**
* @return SeedDMS_Core_Workflow_Action
*/
function getAction() { return $this->_action; }
function setAction($newAction) { /* {{{ */
/**
* @param SeedDMS_Core_Workflow_Action $newAction
* @return bool
*/
function setAction($newAction) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `action` = ".$newAction->getID()." WHERE `id` = " . $this->_id;
@ -858,9 +1006,16 @@ class SeedDMS_Core_Workflow_Transition { /* {{{ */
return true;
} /* }}} */
function getMaxTime() { return $this->_maxtime; }
/**
* @return int
*/
function getMaxTime() { return $this->_maxtime; }
function setMaxTime($maxtime) { /* {{{ */
/**
* @param $maxtime
* @return bool
*/
function setMaxTime($maxtime) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE `tblWorkflowTransitions` SET `maxtime` = ".intval($maxtime)." WHERE `id` = " . $this->_id;
@ -875,7 +1030,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();
@ -903,7 +1058,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();
@ -991,13 +1146,22 @@ class SeedDMS_Core_Workflow_Transition_User { /* {{{ */
*/
var $_dms;
function __construct($id, $transition, $user) {
/**
* SeedDMS_Core_Workflow_Transition_User constructor.
* @param $id
* @param $transition
* @param $user
*/
function __construct($id, $transition, $user) {
$this->_id = $id;
$this->_transition = $transition;
$this->_user = $user;
}
function setDMS($dms) { /* {{{ */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
@ -1065,14 +1229,24 @@ class SeedDMS_Core_Workflow_Transition_Group { /* {{{ */
*/
var $_dms;
function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */
/**
* SeedDMS_Core_Workflow_Transition_Group constructor.
* @param $id
* @param $transition
* @param $group
* @param $numOfUsers
*/
function __construct($id, $transition, $group, $numOfUsers) { /* {{{ */
$this->_id = $id;
$this->_transition = $transition;
$this->_group = $group;
$this->_numOfUsers = $numOfUsers;
} /* }}} */
function setDMS($dms) { /* {{{ */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
@ -1178,7 +1352,18 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */
*/
var $_dms;
function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) {
/**
* SeedDMS_Core_Workflow_Log constructor.
* @param $id
* @param $document
* @param $version
* @param $workflow
* @param $user
* @param $transition
* @param $date
* @param $comment
*/
function __construct($id, $document, $version, $workflow, $user, $transition, $date, $comment) {
$this->_id = $id;
$this->_document = $document;
$this->_version = $version;
@ -1190,27 +1375,45 @@ class SeedDMS_Core_Workflow_Log { /* {{{ */
$this->_dms = null;
}
function setDMS($dms) { /* {{{ */
/**
* @param $dms
*/
function setDMS($dms) { /* {{{ */
$this->_dms = $dms;
} /* }}} */
function getTransition() { /* {{{ */
/**
* @return object
*/
function getTransition() { /* {{{ */
return $this->_transition;
} /* }}} */
function getWorkflow() { /* {{{ */
/**
* @return object
*/
function getWorkflow() { /* {{{ */
return $this->_workflow;
} /* }}} */
function getUser() { /* {{{ */
/**
* @return object
*/
function getUser() { /* {{{ */
return $this->_user;
} /* }}} */
function getComment() { /* {{{ */
/**
* @return string
*/
function getComment() { /* {{{ */
return $this->_comment;
} /* }}} */
function getDate() { /* {{{ */
/**
* @return string
*/
function getDate() { /* {{{ */
return $this->_date;
} /* }}} */

View File

@ -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;
} /* }}} */
}
?>
}

View File

@ -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
@ -122,7 +123,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) {
@ -182,7 +183,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;
@ -258,6 +259,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;
@ -303,7 +305,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Sanitize String used in database operations
*
* @param string text
* @param string $text
* @return string sanitized string
*/
function qstr($text) { /* {{{ */
@ -313,7 +315,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Replace back ticks by '"'
*
* @param string text
* @param string $text
* @return string sanitized string
*/
function rbt($text) { /* {{{ */
@ -326,7 +328,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();
@ -405,7 +408,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')
@ -425,6 +430,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")) {
@ -677,7 +686,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")) {
@ -915,7 +928,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)
@ -929,6 +946,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') { /* {{{ */
@ -997,6 +1015,7 @@ class SeedDMS_Core_DatabaseAccess {
/**
* Return sql statement for returning the current timestamp
*
* @param $field
* @return string sql code
*/
function castToText($field) { /* {{{ */
@ -1008,5 +1027,3 @@ class SeedDMS_Core_DatabaseAccess {
return $field;
} /* }}} */
}
?>

View File

@ -25,25 +25,50 @@
* @version Release: @package_version@
*/
class SeedDMS_Core_File {
static function renameFile($old, $new) { /* {{{ */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameFile($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
static function removeFile($file) { /* {{{ */
/**
* @param $file
* @return bool
*/
static function removeFile($file) { /* {{{ */
return @unlink($file);
} /* }}} */
static function copyFile($source, $target) { /* {{{ */
/**
* @param $source
* @param $target
* @return bool
*/
static function copyFile($source, $target) { /* {{{ */
return @copy($source, $target);
} /* }}} */
static function moveFile($source, $target) { /* {{{ */
if (!@copyFile($source, $target))
/**
* @param $source
* @param $target
* @return bool
*/
static function moveFile($source, $target) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!@copyFile($source, $target))
return false;
return @removeFile($source);
/** @noinspection PhpUndefinedFunctionInspection */
return @removeFile($source);
} /* }}} */
static function fileSize($file) { /* {{{ */
/**
* @param $file
* @return bool|int
*/
static function fileSize($file) { /* {{{ */
if(!$a = fopen($file, 'r'))
return false;
fseek($a, 0, SEEK_END);
@ -52,12 +77,22 @@ class SeedDMS_Core_File {
return $filesize;
} /* }}} */
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
/**
* @param $size
* @param array $sizes
* @return string
*/
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
if ($size == 0) return('0 Bytes');
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
/** @noinspection PhpIllegalArrayKeyTypeInspection */
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
} /* }}} */
static function parse_filesize($str) { /* {{{ */
/**
* @param $str
* @return bool|int
*/
static function parse_filesize($str) { /* {{{ */
preg_replace('/\s\s+/', ' ', $str);
if(strtoupper(substr($str, -1)) == 'B') {
$value = (int) substr($str, 0, -2);
@ -80,18 +115,32 @@ class SeedDMS_Core_File {
return $value;
break;
}
return false;
/** @noinspection PhpUnreachableStatementInspection */
return false;
} /* }}} */
static function checksum($file) { /* {{{ */
/**
* @param $file
* @return string
*/
static function checksum($file) { /* {{{ */
return md5_file($file);
} /* }}} */
static function renameDir($old, $new) { /* {{{ */
/**
* @param $old
* @param $new
* @return bool
*/
static function renameDir($old, $new) { /* {{{ */
return @rename($old, $new);
} /* }}} */
static function makeDir($path) { /* {{{ */
/**
* @param $path
* @return bool
*/
static function makeDir($path) { /* {{{ */
if( !is_dir( $path ) ){
$res=@mkdir( $path , 0777, true);
@ -146,7 +195,11 @@ class SeedDMS_Core_File {
*/
} /* }}} */
static function removeDir($path) { /* {{{ */
/**
* @param $path
* @return bool
*/
static function removeDir($path) { /* {{{ */
$handle = @opendir($path);
while ($entry = @readdir($handle) )
{
@ -167,7 +220,12 @@ class SeedDMS_Core_File {
return @rmdir($path);
} /* }}} */
static function copyDir($sourcePath, $targetPath) { /* {{{ */
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function copyDir($sourcePath, $targetPath) { /* {{{ */
if (mkdir($targetPath, 0777)) {
$handle = @opendir($sourcePath);
while ($entry = @readdir($handle) ) {
@ -189,14 +247,26 @@ class SeedDMS_Core_File {
return true;
} /* }}} */
static function moveDir($sourcePath, $targetPath) { /* {{{ */
if (!copyDir($sourcePath, $targetPath))
/**
* @param $sourcePath
* @param $targetPath
* @return bool
*/
static function moveDir($sourcePath, $targetPath) { /* {{{ */
/** @noinspection PhpUndefinedFunctionInspection */
if (!copyDir($sourcePath, $targetPath))
return false;
return removeDir($sourcePath);
/** @noinspection PhpUndefinedFunctionInspection */
return removeDir($sourcePath);
} /* }}} */
// code by Kioob (php.net manual)
static function gzcompressfile($source,$level=false) { /* {{{ */
/**
* @param $source
* @param bool $level
* @return bool|string
*/
static function gzcompressfile($source, $level=false) { /* {{{ */
$dest=$source.'.gz';
$mode='wb'.$level;
$error=false;
@ -214,5 +284,4 @@ class SeedDMS_Core_File {
if($error) return false;
else return $dest;
} /* }}} */
}
?>
}

View File

@ -1580,6 +1580,7 @@ returns just users which are not disabled
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
add SeedDMS_Core_Folder::getDocumentsMinMax()
add lots of DocBlocks from merge request #8
</notes>
</release>
<release>

View File

@ -24,8 +24,17 @@
*/
class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
/**
* @var string
*/
protected $errormsg;
/**
* @param $cmd
* @param int $timeout
* @return string
* @throws Exception
*/
static function execWithTimeout($cmd, $timeout=2) { /* {{{ */
$descriptorspec = array(
0 => array("pipe", "r"),
@ -71,6 +80,11 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
/**
* Constructor. Creates our indexable document and adds all
* necessary fields to it using the passed in document
* @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) { /* {{{ */
$this->errormsg = '';

View File

@ -1,6 +1,6 @@
--
--
-- Table structure for table `tblACLs`
--
--
CREATE TABLE `tblACLs` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -13,9 +13,9 @@ CREATE TABLE `tblACLs` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblCategory`
--
--
CREATE TABLE `tblCategory` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -24,9 +24,9 @@ CREATE TABLE `tblCategory` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblAttributeDefinitions`
--
--
CREATE TABLE `tblAttributeDefinitions` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -43,9 +43,9 @@ CREATE TABLE `tblAttributeDefinitions` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblUsers`
--
--
CREATE TABLE `tblRoles` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -57,9 +57,9 @@ CREATE TABLE `tblRoles` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblUsers`
--
--
CREATE TABLE `tblUsers` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -83,9 +83,9 @@ CREATE TABLE `tblUsers` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblUserSubstitutes`
--
--
CREATE TABLE `tblUserSubstitutes` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -96,9 +96,9 @@ CREATE TABLE `tblUserSubstitutes` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblUserPasswordRequest`
--
--
CREATE TABLE `tblUserPasswordRequest` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -109,9 +109,9 @@ CREATE TABLE `tblUserPasswordRequest` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblUserPasswordHistory`
--
--
CREATE TABLE `tblUserPasswordHistory` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -122,9 +122,9 @@ CREATE TABLE `tblUserPasswordHistory` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblUserImages`
--
--
CREATE TABLE `tblUserImages` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -135,9 +135,9 @@ CREATE TABLE `tblUserImages` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblFolders`
--
--
CREATE TABLE `tblFolders` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -154,9 +154,9 @@ CREATE TABLE `tblFolders` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblFolderAttributes`
--
--
CREATE TABLE `tblFolderAttributes` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -168,9 +168,9 @@ CREATE TABLE `tblFolderAttributes` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocuments`
--
--
CREATE TABLE `tblDocuments` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -190,9 +190,9 @@ CREATE TABLE `tblDocuments` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentAttributes`
--
--
CREATE TABLE `tblDocumentAttributes` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -204,9 +204,9 @@ CREATE TABLE `tblDocumentAttributes` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentApprovers`
--
--
CREATE TABLE `tblDocumentApprovers` (
`approveID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -220,9 +220,9 @@ CREATE INDEX `indDocumentApproversRequired` ON `tblDocumentApprovers` (`required
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentApproveLog`
--
--
CREATE TABLE `tblDocumentApproveLog` (
`approveLogID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -236,9 +236,9 @@ CREATE INDEX `indDocumentApproveLogReviewID` ON `tblDocumentApproveLog` (`approv
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentContent`
--
--
CREATE TABLE `tblDocumentContent` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -259,9 +259,9 @@ CREATE TABLE `tblDocumentContent` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentContentAttributes`
--
--
CREATE TABLE `tblDocumentContentAttributes` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -273,9 +273,9 @@ CREATE TABLE `tblDocumentContentAttributes` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentLinks`
--
--
CREATE TABLE `tblDocumentLinks` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -287,9 +287,9 @@ CREATE TABLE `tblDocumentLinks` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentFiles`
--
--
CREATE TABLE `tblDocumentFiles` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -308,9 +308,9 @@ CREATE TABLE `tblDocumentFiles` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentLocks`
--
--
CREATE TABLE `tblDocumentLocks` (
`document` INTEGER REFERENCES `tblDocuments` (`id`) ON DELETE CASCADE,
@ -319,9 +319,9 @@ CREATE TABLE `tblDocumentLocks` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentCheckOuts`
--
--
CREATE TABLE `tblDocumentCheckOuts` (
`document` INTEGER REFERENCES `tblDocuments` (`id`) ON DELETE CASCADE,
@ -334,9 +334,9 @@ CREATE TABLE `tblDocumentCheckOuts` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentReviewers`
--
--
CREATE TABLE `tblDocumentReviewers` (
`reviewID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -350,9 +350,9 @@ CREATE INDEX `indDocumentReviewersRequired` ON `tblDocumentReviewers` (`required
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentReviewLog`
--
--
CREATE TABLE `tblDocumentReviewLog` (
`reviewLogID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -366,9 +366,9 @@ CREATE INDEX `indDocumentReviewLogReviewID` ON `tblDocumentReviewLog` (`reviewID
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentRecipients`
--
--
CREATE TABLE `tblDocumentRecipients` (
`receiptID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -382,9 +382,9 @@ CREATE INDEX `indDocumentRecipientsRequired` ON `tblDocumentRecipients` (`requir
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentReceiptLog`
--
--
CREATE TABLE `tblDocumentReceiptLog` (
`receiptLogID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -398,9 +398,9 @@ CREATE INDEX `indDocumentReceiptLogReceiptID` ON `tblDocumentReceiptLog` (`recei
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentRevisors`
--
--
CREATE TABLE `tblDocumentRevisors` (
`revisionID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -415,9 +415,9 @@ CREATE INDEX `indDocumentRevisorsRequired` ON `tblDocumentRevisors` (`required`)
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentRevisionLog`
--
--
CREATE TABLE `tblDocumentRevisionLog` (
`revisionLogID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -431,9 +431,9 @@ CREATE INDEX `indDocumentRevisionLogRevisionID` ON `tblDocumentRevisionLog` (`re
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentStatus`
--
--
CREATE TABLE `tblDocumentStatus` (
`statusID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -444,9 +444,9 @@ CREATE TABLE `tblDocumentStatus` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentStatusLog`
--
--
CREATE TABLE `tblDocumentStatusLog` (
`statusLogID` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -460,9 +460,9 @@ CREATE INDEX `indDocumentStatusLogStatusID` ON `tblDocumentStatusLog` (`StatusID
-- --------------------------------------------------------
--
--
-- Table structure for table `tblGroups`
--
--
CREATE TABLE `tblGroups` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -472,9 +472,9 @@ CREATE TABLE `tblGroups` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblGroupMembers`
--
--
CREATE TABLE `tblGroupMembers` (
`groupID` INTEGER NOT NULL default '0' REFERENCES `tblGroups` (`id`) ON DELETE CASCADE,
@ -485,9 +485,9 @@ CREATE TABLE `tblGroupMembers` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblKeywordCategories`
--
--
CREATE TABLE `tblKeywordCategories` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -497,9 +497,9 @@ CREATE TABLE `tblKeywordCategories` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblKeywords`
--
--
CREATE TABLE `tblKeywords` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -509,9 +509,9 @@ CREATE TABLE `tblKeywords` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblDocumentCategory`
--
--
CREATE TABLE `tblDocumentCategory` (
`categoryID` INTEGER NOT NULL default '0' REFERENCES `tblCategory` (`id`) ON DELETE CASCADE,
@ -520,9 +520,9 @@ CREATE TABLE `tblDocumentCategory` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblNotify`
--
--
CREATE TABLE `tblNotify` (
`target` INTEGER NOT NULL default '0',
@ -534,9 +534,9 @@ CREATE TABLE `tblNotify` (
-- --------------------------------------------------------
--
--
-- Table structure for table `tblSessions`
--
--
CREATE TABLE `tblSessions` (
`id` varchar(50) PRIMARY KEY,
@ -551,9 +551,9 @@ CREATE TABLE `tblSessions` (
-- --------------------------------------------------------
--
-- Table structure for mandatory reviewers
--
--
-- Table structure for table `tblMandatoryReviewers`
--
CREATE TABLE `tblMandatoryReviewers` (
`userID` INTEGER NOT NULL default '0' REFERENCES `tblUsers` (`id`) ON DELETE CASCADE,
@ -564,9 +564,9 @@ CREATE TABLE `tblMandatoryReviewers` (
-- --------------------------------------------------------
--
-- Table structure for mandatory approvers
--
--
-- Table structure for table `tblMandatoryApprovers`
--
CREATE TABLE `tblMandatoryApprovers` (
`userID` INTEGER NOT NULL default '0' REFERENCES `tblUsers` (`id`) ON DELETE CASCADE,
@ -577,9 +577,9 @@ CREATE TABLE `tblMandatoryApprovers` (
-- --------------------------------------------------------
--
-- Table structure for events (calendar)
--
--
-- Table structure for table `tblEvents`
--
CREATE TABLE `tblEvents` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -593,9 +593,9 @@ CREATE TABLE `tblEvents` (
-- --------------------------------------------------------
--
-- Table structure for workflow states
--
--
-- Table structure for table `tblWorkflowStates`
--
CREATE TABLE `tblWorkflowStates` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -608,9 +608,9 @@ CREATE TABLE `tblWorkflowStates` (
-- --------------------------------------------------------
--
-- Table structure for workflow actions
--
--
-- Table structure for table `tblWorkflowActions`
--
CREATE TABLE `tblWorkflowActions` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -619,9 +619,9 @@ CREATE TABLE `tblWorkflowActions` (
-- --------------------------------------------------------
--
-- Table structure for workflows
--
--
-- Table structure for table `tblWorkflows`
--
CREATE TABLE `tblWorkflows` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -632,9 +632,9 @@ CREATE TABLE `tblWorkflows` (
-- --------------------------------------------------------
--
-- Table structure for workflow transitions
--
--
-- Table structure for table `tblWorkflowTransitions`
--
CREATE TABLE `tblWorkflowTransitions` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -647,9 +647,9 @@ CREATE TABLE `tblWorkflowTransitions` (
-- --------------------------------------------------------
--
-- Table structure for workflow transition users
--
--
-- Table structure for table `tblWorkflowTransitionUsers`
--
CREATE TABLE `tblWorkflowTransitionUsers` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -659,9 +659,9 @@ CREATE TABLE `tblWorkflowTransitionUsers` (
-- --------------------------------------------------------
--
-- Table structure for workflow transition groups
--
--
-- Table structure for table `tblWorkflowTransitionGroups`
--
CREATE TABLE `tblWorkflowTransitionGroups` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -672,9 +672,9 @@ CREATE TABLE `tblWorkflowTransitionGroups` (
-- --------------------------------------------------------
--
-- Table structure for workflow log
--
--
-- Table structure for table `tblWorkflowLog`
--
CREATE TABLE `tblWorkflowLog` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -689,9 +689,9 @@ CREATE TABLE `tblWorkflowLog` (
-- --------------------------------------------------------
--
-- Table structure for workflow document relation
--
--
-- Table structure for table `tblWorkflowDocumentContent`
--
CREATE TABLE `tblWorkflowDocumentContent` (
`parentworkflow` INTEGER DEFAULT 0,
@ -704,9 +704,9 @@ CREATE TABLE `tblWorkflowDocumentContent` (
-- --------------------------------------------------------
--
-- Table structure for mandatory workflows
--
--
-- Table structure for table `tblWorkflowMandatoryWorkflow`
--
CREATE TABLE `tblWorkflowMandatoryWorkflow` (
`userid` INTEGER default NULL REFERENCES `tblUsers` (`id`) ON DELETE CASCADE,
@ -716,9 +716,9 @@ CREATE TABLE `tblWorkflowMandatoryWorkflow` (
-- --------------------------------------------------------
--
--
-- Table structure for transmittal
--
--
CREATE TABLE tblTransmittals (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -731,9 +731,9 @@ CREATE TABLE tblTransmittals (
-- --------------------------------------------------------
--
--
-- Table structure for transmittal item
--
--
CREATE TABLE `tblTransmittalItems` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -746,9 +746,9 @@ CREATE TABLE `tblTransmittalItems` (
-- --------------------------------------------------------
--
--
-- Table structure for access request objects
--
--
CREATE TABLE `tblAros` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -761,9 +761,9 @@ CREATE TABLE `tblAros` (
-- --------------------------------------------------------
--
--
-- Table structure for access control objects
--
--
CREATE TABLE `tblAcos` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -775,9 +775,9 @@ CREATE TABLE `tblAcos` (
-- --------------------------------------------------------
--
--
-- Table structure for acos/aros relation
--
--
CREATE TABLE `tblArosAcos` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
@ -792,9 +792,9 @@ CREATE TABLE `tblArosAcos` (
-- --------------------------------------------------------
--
-- Table structure for version
--
--
-- Table structure for table `tblVersion`
--
CREATE TABLE `tblVersion` (
`date` TEXT NOT NULL,

View File

@ -377,6 +377,8 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
break;
case 'video/webm':
case 'video/mp4':
case 'video/avi':
case 'video/msvideo':
case 'video/x-msvideo':
$this->contentHeading(getMLText("preview"));
?>