SeedDMS_Core_Document
extends SeedDMS_Core_Object
in package
Class to represent a document in the document management system
A document in SeedDMS is a collection of content elements which are similar to a file in a regular file system. Documents may have any number of content elements (SeedDMS_Core_DocumentContent). These content elements are often called versions ordered in a timely manner. The most recent content element is the current version of the document.
Documents can be linked to other documents, can have attached files, can be assigned to a category and have additional attributes. The document content can be anything that can be stored in a regular file.
Tags
Table of Contents
Properties
- $_dms : SeedDMS_Core_DMS
- $_notifyList : array<string|int, mixed>
- $_accessList : array<string|int, mixed>
- $_attributes : array<string|int, mixed>
- $_categories : array<string|int, SeedDMS_Core_DocumentCategory>
- $_comment : string
- $_content : array<string|int, mixed>
- $_date : int
- $_defaultAccess : int
- $_documentFiles : array<string|int, mixed>
- $_documentLinks : array<string|int, mixed>
- $_expires : int
- $_folder : SeedDMS_Core_Folder
- $_folderID : int
- $_id : int
- $_inheritAccess : bool
- $_keywords : string
- $_latestContent : SeedDMS_Core_DocumentContent
- $_locked : bool
- $_name : string
- $_owner : object
- $_ownerID : int
- $_parent : object
- $_readAccessList : array<string|int, mixed>
- $_sequence : int
Methods
- __construct() : mixed
- SeedDMS_Core_Object constructor.
- addAccess() : bool
- Add access right to document
- addCategories() : mixed
- Add a list of categories to the document
- addContent() : bool|SeedDMS_Core_AddContentResultSet
- Add content to a document
- addDocumentFile() : mixed
- Add an attachment to the document
- addDocumentLink() : SeedDMS_Core_DocumentLink|bool
- Add a link to a target document
- addNotify() : int
- Add a user/group to the notification list
- applyDecorators() : object
- Apply decorators
- cancelCheckOut() : bool
- Cancel check out of document
- changeAccess() : bool
- Change access right of document
- checkForDueRevisionWorkflow() : bool
- Check if latest content of the document has a scheduled revision workflow.
- checkIn() : bool|object
- Check in document
- checkOut() : object
- Check out document
- checkOutStatus() : int
- Return the check out status of the document
- cleanNotifyList() : mixed
- Make sure only users/groups with read access are in the notify list
- clearAccessList() : bool
- Delete all entries for this document from the access control list
- clearCache() : mixed
- Clear cache of this instance.
- expires() : bool
- Check if document expires
- getAccessList() : bool|array<string|int, mixed>
- Returns a list of access privileges
- getAccessMode() : int
- Returns the greatest access privilege for a given user
- getAttribute() : array<string|int, mixed>|string
- Returns an attribute of the object for the given attribute definition
- getAttributes() : array<string|int, mixed>|bool
- Returns all attributes set for the object
- getAttributeValue() : array<string|int, mixed>|string
- Returns an attribute value of the object for the given attribute definition
- getAttributeValueAsArray() : array<string|int, mixed>|bool
- Returns an attribute value of the object for the given attribute definition
- getAttributeValueAsString() : string
- Returns an attribute value of the object for the given attribute definition
- getCategories() : bool|array<string|int, SeedDMS_Core_DocumentCategory>
- Retrieve a list of all categories this document belongs to
- getCheckOutInfo() : array<string|int, mixed>
- Get checkout info for document
- getComment() : string
- Return the comment of the document
- getContent() : bool|array<string|int, SeedDMS_Core_DocumentContent>
- Return all content elements of a document
- getContentByVersion() : SeedDMS_Core_DocumentContent|null|bool
- Return the content element of a document with a given version number
- getDate() : int
- Return creation date of the document
- getDefaultAccess() : bool|int
- getDir() : string
- Return the directory of the document in the file system relativ to the contentDir
- getDMS() : SeedDMS_Core_DMS
- Returns instance of dms
- getDocumentFile() : object
- Get attached file by its id
- getDocumentFiles() : array<string|int, mixed>
- Get list of files attached to document
- getDocumentLink() : SeedDMS_Core_DocumentLink|bool
- Return a certain document link
- getDocumentLinks() : array<string|int, mixed>
- Return all document links
- getExpires() : int
- Get expiration time of document
- getFolder() : SeedDMS_Core_Folder
- Return the parent folder of the document
- getFolderList() : string
- Get the internally used folderList which stores the ids of folders from the root folder to the parent folder.
- getGroupAccessMode() : int
- Returns the greatest access privilege for a given group
- getID() : int
- Returns the internal id of the object
- getInheritAccess() : bool
- This is supposed to be a replacement for inheritsAccess()
- getInstance() : bool|SeedDMS_Core_Document
- Return an document by its id
- getInstanceByData() : SeedDMS_Core_Folder|bool
- Return a folder by its database record
- getKeywords() : string
- getLatestContent() : bool|SeedDMS_Core_DocumentContent
- Get the latest version of document
- getLockingUser() : SeedDMS_Core_User|bool
- Get the user currently locking the document
- getName() : string
- Return the name of the document
- getNotifyList() : array<string|int, mixed>|bool
- Returns a list of all notifications
- getOwner() : SeedDMS_Core_User
- Return owner of document
- getParent() : SeedDMS_Core_Folder
- Return the parent folder of the document
- getReadAccessList() : array<string|int, mixed>
- Returns a list of groups and users with read access on the document
- getReverseDocumentLinks() : array<string|int, mixed>
- Return all document having a link on this document
- getSearchFields() : array<string|int, mixed>
- Return an array of database fields which are used for searching a term entered in the database search form
- getSequence() : float
- getTimeline() : array<string|int, mixed>
- Returns a list of events happend during the life of the document
- getUsedDiskSpace() : int
- Calculate the disk space including all versions of the document
- hasCategory() : bool
- Check if document has a given category
- hasExpired() : bool
- Check if the document has expired
- inheritsAccess() : bool
- isCheckedOut() : bool
- Check if document is checked out
- isDescendant() : bool
- Check, if this document is a child of a given folder
- isLatestContent() : SeedDMS_Core_DocumentContent|bool
- Check if a given version is the latest version of the document
- isLocked() : bool
- Check if document is locked
- isType() : mixed
- Check if this object is of type 'document'.
- remove() : bool
- Remove a document completly
- removeAccess() : bool
- Remove access rights for a user or group
- removeAttribute() : bool
- Remove an attribute of the object for the given attribute definition
- removeCategories() : mixed
- Remove a list of categories from the document
- removeContent() : bool|mixed
- Call callback onPreRemoveDocument before deleting content
- removeDocumentFile() : mixed
- removeDocumentLink() : mixed
- removeNotify() : int
- Remove a user or group from the notification list
- repair() : bool
- Checks the internal data of the document and repairs it.
- replaceContent() : bool
- Replace a version of a document
- setAttributeValue() : bool
- Set an attribute of the object for the given attribute definition
- setCategories() : bool
- Set a list of categories for the document
- setComment() : bool
- Set the comment of the document
- setDate() : bool
- Set creation date of the document
- setDefaultAccess() : bool
- Set default access mode
- setDMS() : mixed
- Set dms this object belongs to.
- setExpires() : bool
- Set expiration date as unix timestamp
- setFolder() : bool
- Set folder of a document
- setInheritAccess() : bool
- Set inherited access mode
- setKeywords() : bool
- setLocked() : bool
- Lock or unlock document
- setName() : bool
- Set the name of the document
- setOwner() : bool
- Set owner of a document
- setParent() : bool
- Set folder of a document
- setSequence() : bool
- transferToUser() : bool
- Transfers the document to a new user
- verifyLastestContentExpriry() : bool
- Check if the document has expired and set the status accordingly
- __getApproversList() : mixed
- Get List of users and groups which have read access on the document.
- __getLatestContent() : bool|null|SeedDMS_Core_DocumentContent
- _removeContent() : bool
- Remove version of document
Properties
$_dms
public
SeedDMS_Core_DMS
$_dms
back reference to document management system
$_notifyList
public
array<string|int, mixed>
$_notifyList
list of notifications for users and groups
$_accessList
protected
array<string|int, mixed>
$_accessList
of SeedDMS_Core_UserAccess and SeedDMS_Core_GroupAccess
$_attributes
protected
array<string|int, mixed>
$_attributes
list of attributes
$_categories
protected
array<string|int, SeedDMS_Core_DocumentCategory>
$_categories
list of categories
$_comment
protected
string
$_comment
comment of document
$_content
protected
array<string|int, mixed>
$_content
temp. storage for content
$_date
protected
int
$_date
unix timestamp of creation date
$_defaultAccess
protected
int
$_defaultAccess
default access if access rights are not inherited
$_documentFiles
protected
array<string|int, mixed>
$_documentFiles
$_documentLinks
protected
array<string|int, mixed>
$_documentLinks
$_expires
protected
int
$_expires
timestamp of expiration date
$_folder
protected
SeedDMS_Core_Folder
$_folder
$_folderID
protected
int
$_folderID
id of folder this document belongs to
$_id
protected
int
$_id
unique id of object
$_inheritAccess
protected
bool
$_inheritAccess
true if access is inherited, otherwise false
$_keywords
protected
string
$_keywords
list of keywords
$_latestContent
protected
SeedDMS_Core_DocumentContent
$_latestContent
temp. storage for latestcontent
$_locked
protected
bool
$_locked
true if document is locked, otherwise false
$_name
protected
string
$_name
name of document
$_owner
protected
object
$_owner
user who is the owner
$_ownerID
protected
int
$_ownerID
id of user who is the owner
$_parent
protected
object
$_parent
parent folder this document belongs to
$_readAccessList
protected
array<string|int, mixed>
$_readAccessList
list of notifications for users and groups
$_sequence
protected
int
$_sequence
position of document within the parent folder
Methods
__construct()
SeedDMS_Core_Object constructor.
public
__construct(mixed $id, mixed $name, mixed $comment, mixed $date, mixed $expires, mixed $ownerID, mixed $folderID, mixed $inheritAccess, mixed $defaultAccess, mixed $locked, mixed $keywords, mixed $sequence) : mixed
Parameters
- $id : mixed
- $name : mixed
- $comment : mixed
- $date : mixed
- $expires : mixed
- $ownerID : mixed
- $folderID : mixed
- $inheritAccess : mixed
- $defaultAccess : mixed
- $locked : mixed
- $keywords : mixed
- $sequence : mixed
addAccess()
Add access right to document
public
addAccess(int $mode, int $userOrGroupID, int $isUser) : bool
This method may change in the future. Instead of passing a flag and a user/group id a user or group object will be expected. Starting with version 5.1.25 this method will first check if there is already an access right for the user/group.
Parameters
- $mode : int
-
access mode
- $userOrGroupID : int
-
id of user or group
- $isUser : int
-
set to 1 if $userOrGroupID is the id of a user otherwise it will be considered a group id
Return values
bool —true on success, otherwise false
addCategories()
Add a list of categories to the document
public
addCategories(array<string|int, mixed> $newCategories) : mixed
This method will add a list of new categories to the document.
Parameters
- $newCategories : array<string|int, mixed>
-
list of category objects
addContent()
Add content to a document
public
addContent(string $comment, object $user, string $tmpFile, string $orgFileName, string $fileType, string $mimeType[, array<string|int, mixed> $reviewers = array() ][, array<string|int, mixed> $approvers = array() ][, int $version = 0 ][, array<string|int, mixed> $attributes = array() ][, object $workflow = null ][, int $initstate = S_RELEASED ]) : bool|SeedDMS_Core_AddContentResultSet
Each document may have any number of content elements attached to it. Each content element has a version number. Newer versions (greater version number) replace older versions.
Parameters
- $comment : string
-
comment
- $user : object
-
user who shall be the owner of this content
- $tmpFile : string
-
file containing the actuall content
- $orgFileName : string
-
original file name
- $fileType : string
- $mimeType : string
-
MimeType of the content
- $reviewers : array<string|int, mixed> = array()
-
list of reviewers
- $approvers : array<string|int, mixed> = array()
-
list of approvers
- $version : int = 0
-
version number of content or 0 if next higher version shall be used.
- $attributes : array<string|int, mixed> = array()
-
list of version attributes. The element key must be the id of the attribute definition.
- $workflow : object = null
- $initstate : int = S_RELEASED
-
intial document status
Return values
bool|SeedDMS_Core_AddContentResultSetaddDocumentFile()
Add an attachment to the document
public
addDocumentFile(mixed $name, mixed $comment, mixed $user, mixed $tmpFile, mixed $orgFileName, mixed $fileType, mixed $mimeType[, mixed $version = 0 ][, mixed $public = 1 ]) : mixed
Parameters
- $name : mixed
- $comment : mixed
- $user : mixed
- $tmpFile : mixed
- $orgFileName : mixed
- $fileType : mixed
- $mimeType : mixed
- $version : mixed = 0
- $public : mixed = 1
addDocumentLink()
Add a link to a target document
public
addDocumentLink(int $targetID, int $userID, mixed $public) : SeedDMS_Core_DocumentLink|bool
Parameters
- $targetID : int
-
Id of target document
- $userID : int
-
Id of user adding the link
- $public : mixed
Return values
SeedDMS_Core_DocumentLink|booladdNotify()
Add a user/group to the notification list
public
addNotify( $userOrGroupID, $isUser) : int
This method does not check if the currently logged in user is allowed to add a notification. This must be checked by the calling application.
Parameters
- $userOrGroupID :
-
integer id of user or group to add
- $isUser :
-
integer 1 if $userOrGroupID is a user, 0 if $userOrGroupID is a group
Return values
int —0: Update successful. -1: Invalid User/Group ID. -2: Target User / Group does not have read access. -3: User is already subscribed. -4: Database / internal error.
applyDecorators()
Apply decorators
public
applyDecorators() : object
Return values
object —final object after all decorators has been applied
cancelCheckOut()
Cancel check out of document
public
cancelCheckOut() : bool
This function will cancel a check out in progress by removing the check out record from the database and removing the file from the check out folder.
Return values
bool —true if cancelation was successful
changeAccess()
Change access right of document
public
changeAccess(int $newMode, int $userOrGroupID, int $isUser) : bool
This method may change in the future. Instead of passing a flag and a user/group id a user or group object will be expected.
Parameters
- $newMode : int
-
access mode
- $userOrGroupID : int
-
id of user or group
- $isUser : int
-
set to 1 if $userOrGroupID is the id of a user otherwise it will be considered a group id
Return values
bool —true on success, otherwise false
checkForDueRevisionWorkflow()
Check if latest content of the document has a scheduled revision workflow.
public
checkForDueRevisionWorkflow(object $user[, string $next = '' ]) : bool
This method was moved into SeedDMS_Core_DocumentContent and the original method in SeedDMS_Core_Document now uses it for the latest version.
Parameters
- $user : object
-
user requesting the possible automatic change
- $next : string = ''
-
next date for review
Return values
bool —true if status has changed
checkIn()
Check in document
public
checkIn(string $comment, object $user[, array<string|int, mixed> $reviewers = array() ][, array<string|int, mixed> $approvers = array() ][, int $version = 0 ][, array<string|int, mixed> $attributes = array() ][, object $workflow = null ][, int $initstate = S_RELEASED ]) : bool|object
Τhis function is similar to SeedDMS_Core_Document::addContent() but reads the content from the file which was previously checked out. Internal this method calls SeedDMS_Core_Document::addContent() but takes over the original filename, filetype and mimetype from the checked out version. No matter in which state the current checked out file is, the document will be checked back in afterwards.
There are various reason why a check in may fail. In those cases this method will return false, but if the checked out document has disappeared, the checkout will be ended and the method returns true without creating a new version.
The check in may not be done by the user who has done the check out, but if it is a different user, this user must have unlimited access on the document.
Parameters
- $comment : string
- $user : object
- $reviewers : array<string|int, mixed> = array()
- $approvers : array<string|int, mixed> = array()
- $version : int = 0
- $attributes : array<string|int, mixed> = array()
- $workflow : object = null
- $initstate : int = S_RELEASED
-
intial document status
Return values
bool|object —false in case of error, true if no error occurs but the document remains unchanged (because the checked out file has not changed or it has disappeared and couldnt't be checked in), or an instance of class SeedDMS_Core_AddContentResultSet if the document was updated.
checkOut()
Check out document
public
checkOut(object $user, string $checkoutdir) : object
Creates a check out record for the document and copies the latest version of the document into the given checkout dir.
Parameters
- $user : object
-
object of user doing the checkout
- $checkoutdir : string
-
directory where the file will be placed
Return values
object —object of class SeedDMS_Core_DocumentCheckOut
checkOutStatus()
Return the check out status of the document
public
checkOutStatus([mixed $index = 0 ]) : int
This method returns the checkout status of a previosly checked out document. If a document was checked out more then once, the parameter $index can be passed to retrieve a certain checkout info.
Parameters
- $index : mixed = 0
Return values
int —1=The checked out file doesn't exists anymore, 2=The checked out version doesn't exists anymore 3=The checked out file has not been modified yet 4=new check out record in database found 0=The checked out file is modified and check in will create a new version
cleanNotifyList()
Make sure only users/groups with read access are in the notify list
public
cleanNotifyList() : mixed
clearAccessList()
Delete all entries for this document from the access control list
public
clearAccessList([bool $noclean = false ]) : bool
Parameters
- $noclean : bool = false
-
set to true if notifier list shall not be clean up
Return values
bool —true if operation was successful otherwise false
clearCache()
Clear cache of this instance.
public
clearCache() : mixed
The result of some expensive database actions (e.g. get all subfolders or documents) will be saved in a class variable to speed up consecutive calls of the same method. If a second call of the same method shall not use the cache, then it must be cleared.
expires()
Check if document expires
public
expires() : bool
Return values
bool —true if document has expiration date set, otherwise false
getAccessList()
Returns a list of access privileges
public
getAccessList([int $mode = M_ANY ][, int|string $op = O_EQ ]) : bool|array<string|int, mixed>
If the document inherits the access privileges from the parent folder those will be returned. $mode and $op can be set to restrict the list of returned access privileges. If $mode is set to M_ANY no restriction will apply regardless of the value of $op. The returned array contains a list of SeedDMS_Core_UserAccess and SeedDMS_Core_GroupAccess objects. Even if the document has no access list the returned array contains the two elements 'users' and 'groups' which are than empty. The methode returns false if the function fails.
Parameters
- $mode : int = M_ANY
-
access mode (defaults to M_ANY)
- $op : int|string = O_EQ
-
operation (defaults to O_EQ)
Return values
bool|array<string|int, mixed>getAccessMode()
Returns the greatest access privilege for a given user
public
getAccessMode( $user[, string $context = '' ]) : int
This method returns the access mode for a given user. An administrator and the owner of the folder has unrestricted access. A guest user has read only access or no access if access rights are further limited by access control lists. All other users have access rights according to the access control lists or the default access. This method will recursive check for access rights of parent folders if access rights are inherited.
The function searches the access control list for entries of user $user. If it finds more than one entry it will return the one allowing the greatest privileges, but user rights will always precede group rights. If there is no entry in the access control list, it will return the default access mode. The function takes inherited access rights into account. For a list of possible access rights see @file inc.AccessUtils.php
Having access on a document does not necessarily mean the document content is accessible too. Accessing the content is checked by SeedDMS_Core_DocumentContent::getAccessMode() which calls a callback function defined by the application. If the callback function is not set, access on the content is always granted.
Before checking the access in the method itself a callback 'onCheckAccessDocument' is called. If it returns a value > 0, then this will be returned by this method without any further checks. The optional paramater $context will be passed as a third parameter to the callback. It contains the operation for which the access mode is retrieved. It is for example set to 'removeDocument' if the access mode is used to check for sufficient permission on deleting a document.
Parameters
- $user :
-
object instance of class SeedDMS_Core_User
- $context : string = ''
-
context in which the access mode is requested
Return values
int —access mode
getAttribute()
Returns an attribute of the object for the given attribute definition
public
getAttribute(SeedDMS_Core_AttributeDefinition $attrdef) : array<string|int, mixed>|string
Parameters
- $attrdef : SeedDMS_Core_AttributeDefinition
Return values
array<string|int, mixed>|string —value of attritbute or false. The value is an array if the attribute is defined as multi value
getAttributes()
Returns all attributes set for the object
public
getAttributes() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|boolgetAttributeValue()
Returns an attribute value of the object for the given attribute definition
public
getAttributeValue(SeedDMS_Core_AttributeDefinition $attrdef) : array<string|int, mixed>|string
Parameters
- $attrdef : SeedDMS_Core_AttributeDefinition
Return values
array<string|int, mixed>|string —value of attritbute or false. The value is an array if the attribute is defined as multi value
getAttributeValueAsArray()
Returns an attribute value of the object for the given attribute definition
public
getAttributeValueAsArray(SeedDMS_Core_AttributeDefinition $attrdef) : array<string|int, mixed>|bool
This is a short cut for getAttribute($attrdef)->getValueAsArray() but first checks if the object has an attribute for the given attribute definition.
Parameters
- $attrdef : SeedDMS_Core_AttributeDefinition
Return values
array<string|int, mixed>|bool —even if the attribute is not defined as multi value
getAttributeValueAsString()
Returns an attribute value of the object for the given attribute definition
public
getAttributeValueAsString(SeedDMS_Core_AttributeDefinition $attrdef) : string
This is a short cut for getAttribute($attrdef)->getValueAsString() but first checks if the object has an attribute for the given attribute definition.
Parameters
- $attrdef : SeedDMS_Core_AttributeDefinition
Return values
string —value of attritbute or false. The value is always a string even if the attribute is defined as multi value
getCategories()
Retrieve a list of all categories this document belongs to
public
getCategories() : bool|array<string|int, SeedDMS_Core_DocumentCategory>
Return values
bool|array<string|int, SeedDMS_Core_DocumentCategory>getCheckOutInfo()
Get checkout info for document
public
getCheckOutInfo() : array<string|int, mixed>
This returns the checkouts for a document. There could be several checkouts for one document, but usually there is just one.
Return values
array<string|int, mixed> —records from table tblDocumentCheckOuts or false in case of an error.
getComment()
Return the comment of the document
public
getComment() : string
Return values
string —comment of document
getContent()
Return all content elements of a document
public
getContent() : bool|array<string|int, SeedDMS_Core_DocumentContent>
This method returns an array of content elements ordered by version. Version which are not accessible because of its status, will be filtered out. Access rights based on the document status are calculated for the currently logged in user.
Return values
bool|array<string|int, SeedDMS_Core_DocumentContent>getContentByVersion()
Return the content element of a document with a given version number
public
getContentByVersion(int $version) : SeedDMS_Core_DocumentContent|null|bool
This method will check if the version is accessible and return false if not. Access rights based on the document status are calculated for the currently logged in user.
Parameters
- $version : int
-
version number of content element
Return values
SeedDMS_Core_DocumentContent|null|bool —object of class SeedDMS_Core_DocumentContent, null if not content was found, false in case of an error
getDate()
Return creation date of the document
public
getDate() : int
Return values
int —unix timestamp of creation date
getDefaultAccess()
public
getDefaultAccess() : bool|int
Return values
bool|intgetDir()
Return the directory of the document in the file system relativ to the contentDir
public
getDir() : string
Return values
string —directory of document
getDMS()
Returns instance of dms
public
getDMS() : SeedDMS_Core_DMS
Return values
SeedDMS_Core_DMSgetDocumentFile()
Get attached file by its id
public
getDocumentFile(mixed $ID) : object
Parameters
- $ID : mixed
Return values
object —instance of SeedDMS_Core_DocumentFile, null if file is not accessible, false in case of an sql error
getDocumentFiles()
Get list of files attached to document
public
getDocumentFiles([int $version = 0 ][, bool $incnoversion = true ]) : array<string|int, mixed>
Parameters
- $version : int = 0
-
get only attachments for this version
- $incnoversion : bool = true
-
include attachments without a version
Return values
array<string|int, mixed> —list of files, false in case of an sql error
getDocumentLink()
Return a certain document link
public
getDocumentLink(int $linkID) : SeedDMS_Core_DocumentLink|bool
Parameters
- $linkID : int
-
id of link
Return values
SeedDMS_Core_DocumentLink|bool —of SeedDMS_Core_DocumentLink or false in case of an error.
getDocumentLinks()
Return all document links
public
getDocumentLinks([bool $publiconly = false ][, SeedDMS_Core_User $user = null ]) : array<string|int, mixed>
The list may contain all links to other documents, even those which may not be visible by certain users, unless you pass appropriate parameters to filter out public links and those created by the given user. The two parameters are or'ed. If $publiconly is set the method will return all public links disregarding the user. If $publiconly is not set but a user is set, the method will return all links of that user (public and none public). Setting a user and $publiconly to true will not return the public links of that user but all links which are public or owned by that user.
The application must call SeedDMS_Core_DMS::filterDocumentLinks() afterwards to filter out those links pointing to a document not accessible by a given user.
Parameters
- $publiconly : bool = false
-
return all publically visible links
- $user : SeedDMS_Core_User = null
-
return also private links of this user
Return values
array<string|int, mixed> —list of objects of class SeedDMS_Core_DocumentLink
getExpires()
Get expiration time of document
public
getExpires() : int
Return values
int —expiration date as unix timestamp or false
getFolder()
Return the parent folder of the document
public
getFolder() : SeedDMS_Core_Folder
Return values
SeedDMS_Core_Folder —parent folder
getFolderList()
Get the internally used folderList which stores the ids of folders from the root folder to the parent folder.
public
getFolderList() : string
Return values
string —column separated list of folder ids
getGroupAccessMode()
Returns the greatest access privilege for a given group
public
getGroupAccessMode(SeedDMS_Core_Group $group) : int
This method searches the access control list for entries of group $group. If it finds more than one entry it will return the one allowing the greatest privileges. If there is no entry in the access control list, it will return the default access mode. The function takes inherited access rights into account. For a list of possible access rights see @file inc.AccessUtils.php
Parameters
- $group : SeedDMS_Core_Group
-
object instance of class SeedDMS_Core_Group
Return values
int —access mode
getID()
Returns the internal id of the object
public
getID() : int
Return values
int —id of document/folder
getInheritAccess()
This is supposed to be a replacement for inheritsAccess()
public
getInheritAccess() : bool
Return values
boolgetInstance()
Return an document by its id
public
static getInstance(int $id, SeedDMS_Core_DMS $dms) : bool|SeedDMS_Core_Document
Parameters
- $id : int
-
id of document
- $dms : SeedDMS_Core_DMS
Return values
bool|SeedDMS_Core_Document —instance of SeedDMS_Core_Document if document exists, null if document does not exist, false in case of error
getInstanceByData()
Return a folder by its database record
public
static getInstanceByData(array<string|int, mixed> $resArr, SeedDMS_Core_DMS $dms) : SeedDMS_Core_Folder|bool
Parameters
- $resArr : array<string|int, mixed>
-
array of folder data as returned by database
- $dms : SeedDMS_Core_DMS
Return values
SeedDMS_Core_Folder|bool —instance of SeedDMS_Core_Folder if document exists
getKeywords()
public
getKeywords() : string
Return values
stringgetLatestContent()
Get the latest version of document
public
getLatestContent() : bool|SeedDMS_Core_DocumentContent
This method returns the latest accessible version of a document. If content access has been restricted by setting SeedDMS_Core_DMS::noReadForStatus the function will go backwards in history until an accessible version is found. If none is found null will be returned. Access rights based on the document status are calculated for the currently logged in user.
Return values
bool|SeedDMS_Core_DocumentContent —object of class SeedDMS_Core_DocumentContent
getLockingUser()
Get the user currently locking the document
public
getLockingUser() : SeedDMS_Core_User|bool
Return values
SeedDMS_Core_User|bool —user have a lock
getName()
Return the name of the document
public
getName() : string
Return values
string —name of document
getNotifyList()
Returns a list of all notifications
public
getNotifyList([int $type = 0 ][, bool $incdisabled = false ]) : array<string|int, mixed>|bool
The returned list has two elements called 'users' and 'groups'. Each one is an array itself countaining objects of class SeedDMS_Core_User and SeedDMS_Core_Group.
Parameters
- $type : int = 0
-
type of notification (not yet used)
- $incdisabled : bool = false
-
set to true if disabled user shall be included
Return values
array<string|int, mixed>|boolgetOwner()
Return owner of document
public
getOwner() : SeedDMS_Core_User
Return values
SeedDMS_Core_User —owner of document as an instance of SeedDMS_Core_User
getParent()
Return the parent folder of the document
public
getParent() : SeedDMS_Core_Folder
Tags
Return values
SeedDMS_Core_Folder —parent folder
getReadAccessList()
Returns a list of groups and users with read access on the document
public
getReadAccessList([bool $listadmin = 0 ][, bool $listowner = 0 ][, bool $listguest = 0 ]) : array<string|int, mixed>
Parameters
- $listadmin : bool = 0
-
if set to true any admin will be listed too
- $listowner : bool = 0
-
if set to true the owner will be listed too
- $listguest : bool = 0
-
if set to true any guest will be listed too
Return values
array<string|int, mixed> —list of users and groups
getReverseDocumentLinks()
Return all document having a link on this document
public
getReverseDocumentLinks([bool $publiconly = false ][, SeedDMS_Core_User $user = null ]) : array<string|int, mixed>
The list contains all documents which have a link to the current document. The list contains even those documents which may not be accessible by the user, unless you pass appropriate parameters to filter out public links and those created by the given user. This method is basically the reverse of SeedDMS_Core_Document::getDocumentLinks()
The application must call SeedDMS_Core_DMS::filterDocumentLinks() afterwards to filter out those links pointing to a document not accessible by a given user.
Parameters
- $publiconly : bool = false
-
return all publically visible links
- $user : SeedDMS_Core_User = null
-
return also private links of this user
Return values
array<string|int, mixed> —list of objects of class SeedDMS_Core_DocumentLink
getSearchFields()
Return an array of database fields which are used for searching a term entered in the database search form
public
static getSearchFields(SeedDMS_Core_DMS $dms, array<string|int, mixed> $searchin) : array<string|int, mixed>
Parameters
- $dms : SeedDMS_Core_DMS
- $searchin : array<string|int, mixed>
-
integer list of search scopes (2=name, 3=comment, 4=attributes)
Return values
array<string|int, mixed> —list of database fields
getSequence()
public
getSequence() : float
Return values
floatgetTimeline()
Returns a list of events happend during the life of the document
public
getTimeline() : array<string|int, mixed>
This includes the creation of new versions, approval and reviews, etc.
Return values
array<string|int, mixed> —list of events
getUsedDiskSpace()
Calculate the disk space including all versions of the document
public
getUsedDiskSpace() : int
This is done by using the internal database field storing the filesize of a document version.
Return values
int —total disk space in Bytes
hasCategory()
Check if document has a given category
public
hasCategory(SeedDMS_Core_DocumentCategory $cat) : bool
Parameters
Return values
bool —true if document has category, otherwise false
hasExpired()
Check if the document has expired
public
hasExpired() : bool
The method expects to database field 'expired' to hold the timestamp of the start of day at which end the document expires. The document will expire if that day is over. Hence, a document will not be expired during the day of expiration but at the end of that day
Return values
bool —true if document has expired otherwise false
inheritsAccess()
public
inheritsAccess() : bool
Return values
boolisCheckedOut()
Check if document is checked out
public
isCheckedOut() : bool
Return values
bool —true if checked out otherwise false
isDescendant()
Check, if this document is a child of a given folder
public
isDescendant(object $folder) : bool
Parameters
- $folder : object
-
parent folder
Return values
bool —true if document is a direct child of the given folder
isLatestContent()
Check if a given version is the latest version of the document
public
isLatestContent(int $version) : SeedDMS_Core_DocumentContent|bool
Parameters
- $version : int
-
version number of content element
Return values
SeedDMS_Core_DocumentContent|bool —object of class SeedDMS_Core_DocumentContent or false
isLocked()
Check if document is locked
public
isLocked() : bool
Return values
bool —true if locked otherwise false
isType()
Check if this object is of type 'document'.
public
isType(string $type) : mixed
Parameters
- $type : string
-
type of object
remove()
Remove a document completly
public
remove() : bool
This methods calls the callback 'onPreRemoveDocument' before removing the document. The current document will be passed as the second parameter to the callback function. After successful deletion the 'onPostRemoveDocument' callback will be used. The current document id will be passed as the second parameter. If onPreRemoveDocument fails the whole function will fail and the document will not be deleted. The return value of 'onPostRemoveDocument' will be disregarded.
Return values
bool —true on success, otherwise false
removeAccess()
Remove access rights for a user or group
public
removeAccess(int $userOrGroupID, bool $isUser) : bool
Parameters
- $userOrGroupID : int
-
ID of user or group
- $isUser : bool
-
true if $userOrGroupID is a user id, false if it is a group id.
Return values
bool —true on success, otherwise false
removeAttribute()
Remove an attribute of the object for the given attribute definition
public
removeAttribute(SeedDMS_Core_AttributeDefinition $attrdef) : bool
FIXME: shouldn't this rather be setAttributeValue() with an empty value?
Parameters
- $attrdef : SeedDMS_Core_AttributeDefinition
Return values
bool —true if operation was successful, otherwise false
removeCategories()
Remove a list of categories from the document
public
removeCategories(mixed $categories) : mixed
This method will remove a list of assigned categories to the document.
Parameters
- $categories : mixed
removeContent()
Call callback onPreRemoveDocument before deleting content
public
removeContent(SeedDMS_Core_DocumentContent $version) : bool|mixed
Parameters
- $version : SeedDMS_Core_DocumentContent
-
version number of content
Return values
bool|mixedremoveDocumentFile()
public
removeDocumentFile(mixed $ID) : mixed
Parameters
- $ID : mixed
removeDocumentLink()
public
removeDocumentLink(mixed $linkID) : mixed
Parameters
- $linkID : mixed
removeNotify()
Remove a user or group from the notification list
public
removeNotify(int $userOrGroupID, bool $isUser[, int $type = 0 ]) : int
This method does not check if the currently logged in user is allowed to remove a notification. This must be checked by the calling application.
Parameters
- $userOrGroupID : int
-
id of user or group
- $isUser : bool
-
boolean true if a user is passed in $userOrGroupID, false if a group is passed in $userOrGroupID
- $type : int = 0
-
type of notification (0 will delete all) Not used yet!
Return values
int —0 if operation was succesful -1 if the userid/groupid is invalid -3 if the user/group is already subscribed -4 in case of an internal database error
repair()
Checks the internal data of the document and repairs it.
public
repair() : bool
Currently, this function only repairs an incorrect folderList
Return values
bool —true on success, otherwise false
replaceContent()
Replace a version of a document
public
replaceContent(int $version, object $user, string $tmpFile, string $orgFileName, string $fileType, string $mimeType[, mixed $allowoverride = [] ]) : bool
Each document may have any number of content elements attached to it. This method replaces the file content of a given version. Using this function is highly discourage, because it undermines the idea of keeping all versions of a document as originally saved. Content will only be replaced if the mimetype, filetype, user and original filename are identical to the version being updated.
This method was introduced for the webdav server because any saving of a document created a new version.
Parameters
- $version : int
-
version number of content or 0 if latest version shall be replaced.
- $user : object
-
user who shall be the owner of this content
- $tmpFile : string
-
file containing the actuall content
- $orgFileName : string
-
original file name
- $fileType : string
- $mimeType : string
-
MimeType of the content
- $allowoverride : mixed = []
Return values
bool —false in case of an error or a result set
setAttributeValue()
Set an attribute of the object for the given attribute definition
public
setAttributeValue(SeedDMS_Core_AttributeDefinition $attrdef, array<string|int, mixed>|string $value) : bool
Parameters
- $attrdef : SeedDMS_Core_AttributeDefinition
-
definition of attribute
- $value : array<string|int, mixed>|string
-
value of attribute, for multiple values this must be an array
Return values
bool —true if operation was successful, otherwise false
setCategories()
Set a list of categories for the document
public
setCategories(array<string|int, SeedDMS_Core_DocumentCategory> $newCategories) : bool
This method will delete currently assigned categories and sets new categories.
Parameters
- $newCategories : array<string|int, SeedDMS_Core_DocumentCategory>
-
list of category objects
Return values
boolsetComment()
Set the comment of the document
public
setComment( $newComment) : bool
Parameters
Return values
boolsetDate()
Set creation date of the document
public
setDate(int $date) : bool
Parameters
- $date : int
-
timestamp of creation date. If false then set it to the current timestamp
Return values
bool —true on success
setDefaultAccess()
Set default access mode
public
setDefaultAccess(int $mode[, bool|string $noclean = false ]) : bool
This method sets the default access mode and also removes all notifiers which will not have read access anymore. Setting a default access mode will only have an immediate effect if the access rights are not inherited, otherwise it just updates the database record of the document and once the inheritance is turn off the default access mode will take effect.
Parameters
- $mode : int
-
access mode
- $noclean : bool|string = false
-
set to true if notifier list shall not be clean up
Return values
boolsetDMS()
Set dms this object belongs to.
public
setDMS(SeedDMS_Core_DMS $dms) : mixed
Each object needs a reference to the dms it belongs to. It will be set when the object is created. The dms has a references to the currently logged in user and the database connection.
Parameters
- $dms : SeedDMS_Core_DMS
-
reference to dms
setExpires()
Set expiration date as unix timestamp
public
setExpires(int $expires) : bool
Parameters
- $expires : int
-
unix timestamp of expiration date
Return values
boolsetFolder()
Set folder of a document
public
setFolder(SeedDMS_Core_Folder $newFolder) : bool
This method basically moves a document from a folder to another folder.
Parameters
- $newFolder : SeedDMS_Core_Folder
Return values
bool —false in case of an error, otherwise true
setInheritAccess()
Set inherited access mode
public
setInheritAccess(bool $inheritAccess[, bool $noclean = false ]) : bool
Setting inherited access mode will set or unset the internal flag which controls if the access mode is inherited from the parent folder or not. It will not modify the access control list for the current object. It will remove all notifications of users which do not even have read access anymore after setting or unsetting inherited access.
Parameters
- $inheritAccess : bool
-
set to true for setting and false for unsetting inherited access mode
- $noclean : bool = false
-
set to true if notifier list shall not be clean up
Return values
bool —true if operation was successful otherwise false
setKeywords()
public
setKeywords(string $newKeywords) : bool
Parameters
- $newKeywords : string
Return values
boolsetLocked()
Lock or unlock document
public
setLocked(SeedDMS_Core_User|bool $falseOrUser) : bool
Parameters
- $falseOrUser : SeedDMS_Core_User|bool
-
user object for locking or false for unlocking
Return values
bool —true if operation was successful otherwise false
setName()
Set the name of the document
public
setName( $newName) : bool
Parameters
Return values
boolsetOwner()
Set owner of a document
public
setOwner(SeedDMS_Core_User $newOwner) : bool
Parameters
- $newOwner : SeedDMS_Core_User
-
new owner
Return values
bool —true if successful otherwise false
setParent()
Set folder of a document
public
setParent(SeedDMS_Core_Folder $newFolder) : bool
This method basically moves a document from a folder to another folder.
Parameters
- $newFolder : SeedDMS_Core_Folder
Return values
bool —false in case of an error, otherwise true
setSequence()
public
setSequence(float $seq) : bool
Parameters
- $seq : float
Return values
booltransferToUser()
Transfers the document to a new user
public
transferToUser(mixed $newuser) : bool
This method not just sets a new owner of the document but also transfers the document links, attachments and locks to the new user.
Parameters
- $newuser : mixed
Return values
bool —true if successful, otherwise false
verifyLastestContentExpriry()
Check if the document has expired and set the status accordingly
public
verifyLastestContentExpriry() : bool
It will also recalculate the status if the current status is set to S_EXPIRED but the document isn't actually expired. The method will update the document status log database table if needed. FIXME: some left over reviewers/approvers are in the way if no workflow is set and traditional workflow mode is on. In that case the status is set to S_DRAFT_REV or S_DRAFT_APP
Return values
bool —true if status has changed
__getApproversList()
Get List of users and groups which have read access on the document.
protected
__getApproversList() : mixed
The list will not include any guest users, administrators and the owner of the document.
This method is deprecated. Use SeedDMS_Core_Document::getReadAccessList() instead.
__getLatestContent()
private
__getLatestContent() : bool|null|SeedDMS_Core_DocumentContent
Return values
bool|null|SeedDMS_Core_DocumentContent_removeContent()
Remove version of document
private
_removeContent(SeedDMS_Core_DocumentContent $version) : bool
Parameters
- $version : SeedDMS_Core_DocumentContent
-
version number of content
Return values
bool —true if successful, otherwise false