\SeedDMS_Core_Document

Class to represent a document in the document management system

A document in SeedDMS is similar to files in a regular file system. Documents may have any number of content elements ({@link SeedDMS_Core_DocumentContent}). These content elements are often called versions ordered in a timely manner. The most recent content element is the current version.

Documents can be linked to other documents and can have attached files. The document content can be anything that can be stored in a regular file.

Summary

Methods
Properties
Constants
SeedDMS_Core_Object()
setDMS()
getID()
getAttributes()
getAttributeValue()
setAttributeValue()
removeAttribute()
SeedDMS_Core_Document()
getDir()
getName()
setName()
getComment()
setComment()
getKeywords()
setKeywords()
getCategories()
setCategories()
getDate()
getFolder()
setFolder()
getOwner()
setOwner()
getDefaultAccess()
setDefaultAccess()
inheritsAccess()
setInheritAccess()
expires()
getExpires()
setExpires()
hasExpired()
verifyLastestContentExpriry()
isLocked()
setLocked()
getLockingUser()
getSequence()
setSequence()
clearAccessList()
getAccessList()
addAccess()
changeAccess()
removeAccess()
getAccessMode()
getGroupAccessMode()
getNotifyList()
addNotify()
removeNotify()
addContent()
getContent()
getContentByVersion()
getLatestContent()
removeContent()
getDocumentLink()
getDocumentLinks()
getReverseDocumentLinks()
addDocumentLink()
removeDocumentLink()
getDocumentFile()
getDocumentFiles()
addDocumentFile()
removeDocumentFile()
remove()
getApproversList()
getReadAccessList()
getFolderList()
repair()
getUsedDiskSpace()
$_dms
$_notifyList
No constants found
No protected methods found
$_id
$_attributes
$_name
$_comment
$_date
$_ownerID
$_folderID
$_expires
$_inheritAccess
$_defaultAccess
$_readAccessList
$_locked
$_keywords
$_categories
$_sequence
N/A
No private methods found
No private properties found
N/A

Properties

$_dms

$_dms : object

Type

object — back reference to document management system

$_notifyList

$_notifyList : array

Type

array — list of notifications for users and groups

$_id

$_id : integer

Type

integer — unique id of object

$_attributes

$_attributes : array

Type

array — list of attributes

$_name

$_name : string

Type

string — name of document

$_comment

$_comment : string

Type

string — comment of document

$_date

$_date : integer

Type

integer — unix timestamp of creation date

$_ownerID

$_ownerID : integer

Type

integer — id of user who is the owner

$_folderID

$_folderID : integer

Type

integer — id of folder this document belongs to

$_expires

$_expires : integer

Type

integer — timestamp of expiration date

$_inheritAccess

$_inheritAccess : boolean

Type

boolean — true if access is inherited, otherwise false

$_defaultAccess

$_defaultAccess : integer

Type

integer — default access if access rights are not inherited

$_readAccessList

$_readAccessList : array

Type

array — list of notifications for users and groups

$_locked

$_locked : boolean

Type

boolean — true if document is locked, otherwise false

$_keywords

$_keywords : string

Type

string — list of keywords

$_categories

$_categories : array

Type

array — list of categories

$_sequence

$_sequence : integer

Type

integer — position of document within the parent folder

Methods

SeedDMS_Core_Object()

SeedDMS_Core_Object( $id)

Parameters

$id

setDMS()

setDMS( $dms)

Parameters

$dms

getID()

getID()

getAttributes()

getAttributes() : array

Returns all attributes set for the object

Returns

array —

list of objects of class SeedDMS_Core_Attribute

getAttributeValue()

getAttributeValue( $attrdef) : array|string

Returns an attribute of the object for the given attribute definition

Parameters

$attrdef

Returns

array|string —

value of attritbute or false. The value is an array if the attribute is defined as multi value

setAttributeValue()

setAttributeValue(object $attrdef, array|\sting $value) : boolean

Set an attribute of the object for the given attribute definition

Parameters

object $attrdef

definition of attribute

array|\sting $value

value of attribute, for multiple values this must be an array

Returns

boolean —

true if operation was successful, otherwise false

removeAttribute()

removeAttribute( $attrdef) : boolean

Remove an attribute of the object for the given attribute definition

Parameters

$attrdef

Returns

boolean —

true if operation was successful, otherwise false

SeedDMS_Core_Document()

SeedDMS_Core_Document( $id,  $name,  $comment,  $date,  $expires,  $ownerID,  $folderID,  $inheritAccess,  $defaultAccess,  $locked,  $keywords,  $sequence)

Parameters

$id
$name
$comment
$date
$expires
$ownerID
$folderID
$inheritAccess
$defaultAccess
$locked
$keywords
$sequence

getDir()

getDir()

getName()

getName()

setName()

setName( $newName)

Parameters

$newName

getComment()

getComment()

setComment()

setComment( $newComment)

Parameters

$newComment

getKeywords()

getKeywords()

setKeywords()

setKeywords( $newKeywords)

Parameters

$newKeywords

getCategories()

getCategories() : array

Retrieve a list of all categories this document belongs to

Returns

array —

list of category objects

setCategories()

setCategories(array $newCategories)

Set a list of categories for the document This function will delete currently assigned categories and sets new categories.

Parameters

array $newCategories

list of category objects

getDate()

getDate() : integer

Return creation date of the document

Returns

integer —

unix timestamp of creation date

getFolder()

getFolder() : object

Return the parent folder of the document

Returns

object —

parent folder

setFolder()

setFolder(object $newFolder) : boolean

Set folder of a document

This function basically moves a document from a folder to another folder.

Parameters

object $newFolder

Returns

boolean —

false in case of an error, otherwise true

getOwner()

getOwner() : object

Return owner of document

Returns

object —

owner of document as an instance of {@link SeedDMS_Core_User}

setOwner()

setOwner(object $newOwner) : boolean

Set owner of a document

Parameters

object $newOwner

new owner

Returns

boolean —

true if successful otherwise false

getDefaultAccess()

getDefaultAccess()

setDefaultAccess()

setDefaultAccess( $mode)

Parameters

$mode

inheritsAccess()

inheritsAccess()

setInheritAccess()

setInheritAccess(boolean $inheritAccess) : boolean

Set inherited access mode 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

boolean $inheritAccess

set to true for setting and false for

   unsetting inherited access mode

Returns

boolean —

true if operation was successful otherwise false

expires()

expires() : boolean

Check if document expires

Returns

boolean —

true if document has expiration date set, otherwise false

getExpires()

getExpires() : \integer/boolean

Get expiration time of document

Returns

\integer/boolean —

expiration date as unix timestamp or false

setExpires()

setExpires( $expires)

Set expiration date as unix timestamp

Parameters

$expires

hasExpired()

hasExpired() : boolean

Check if the document has expired

Returns

boolean —

true if document has expired otherwise false

verifyLastestContentExpriry()

verifyLastestContentExpriry() : boolean

Check if the document has expired and set the status accordingly 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

Returns

boolean —

true if status has changed

isLocked()

isLocked() : boolean

Check if document is locked

Returns

boolean —

true if locked otherwise false

setLocked()

setLocked(mixed $falseOrUser) : boolean

Lock or unlock document

Parameters

mixed $falseOrUser

user object for locking or false for unlocking

Returns

boolean —

true if operation was successful otherwise false

getLockingUser()

getLockingUser() : object

Get the user currently locking the document

Returns

object —

user have a lock

getSequence()

getSequence()

setSequence()

setSequence( $seq)

Parameters

$seq

clearAccessList()

clearAccessList() : boolean

Delete all entries for this document from the access control list

Returns

boolean —

true if operation was successful otherwise false

getAccessList()

getAccessList(integer $mode, integer $op) : array

Returns a list of access privileges

If the document inherits the access privileges from the parent folder those will be returned. $mode and $op can be set to restrict the list of returned access privileges. If $mode is set to M_ANY no restriction will apply regardless of the value of $op. The returned array contains a list of {@link SeedDMS_Core_UserAccess} and {@link SeedDMS_Core_GroupAccess} objects. Even if the document has no access list the returned array contains the two elements 'users' and 'groups' which are than empty. The methode returns false if the function fails.

Parameters

integer $mode

access mode (defaults to M_ANY)

integer $op

operation (defaults to O_EQ)

Returns

array —

multi dimensional array

addAccess()

addAccess(integer $mode, integer $userOrGroupID, integer $isUser)

Add access right to folder This function may change in the future. Instead of passing the a flag and a user/group id a user or group object will be expected.

Parameters

integer $mode

access mode

integer $userOrGroupID

id of user or group

integer $isUser

set to 1 if $userOrGroupID is the id of a

   user

changeAccess()

changeAccess(integer $newMode, integer $userOrGroupID, integer $isUser)

Change access right of document This function may change in the future. Instead of passing the a flag and a user/group id a user or group object will be expected.

Parameters

integer $newMode

access mode

integer $userOrGroupID

id of user or group

integer $isUser

set to 1 if $userOrGroupID is the id of a

   user

removeAccess()

removeAccess(integer $userOrGroupID, boolean $isUser) : boolean

Remove access rights for a user or group

Parameters

integer $userOrGroupID

ID of user or group

boolean $isUser

true if $userOrGroupID is a user id, false if it

   is a group id.

Returns

boolean —

true on success, otherwise false

getAccessMode()

getAccessMode(mixed $user) : integer

Returns the greatest access privilege for a given user

This function returns the access mode for a given user. An administrator and the owner of the folder has unrestricted access. A guest user has read only access or no access if access rights are further limited by access control lists. All other users have access rights according to the access control lists or the default access. This function will recursive check for access rights of parent folders if access rights are inherited.

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

Parameters

mixed $user

object instance of class SeedDMS_Core_User

Returns

integer —

access mode

getGroupAccessMode()

getGroupAccessMode(mixed $group) : integer

Returns the greatest access privilege for a given group

This function 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

mixed $group

object instance of class SeedDMS_Core_Group

Returns

integer —

access mode

getNotifyList()

getNotifyList(integer $type) : array

Returns a list of all notifications

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

integer $type

type of notification (not yet used)

Returns

array —

list of notifications

addNotify()

addNotify(mixed $userOrGroupID, mixed $isUser) : integer

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 application.

Parameters

mixed $userOrGroupID

integer id of user or group to add

mixed $isUser

integer 1 if $userOrGroupID is a user,

           0 if $userOrGroupID is a group

Returns

integer —

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.

removeNotify()

removeNotify(mixed $userOrGroupID, mixed $isUser, mixed $type) : integer

Remove a user or group from the notification list This function does not check if the currently logged in user is allowed to remove a notification. This must be checked by the calling application.

Parameters

mixed $userOrGroupID

id of user or group

mixed $isUser

boolean true if a user is passed in $userOrGroupID, false

   if a group is passed in $userOrGroupID
mixed $type

type of notification (0 will delete all) Not used yet!

Returns

integer —

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

addContent()

addContent(string $comment, object $user, string $tmpFile, string $orgFileName,  $fileType, string $mimeType, array $reviewers, array $approvers, integer $version, array $attributes,  $workflow) : \bool/array

Add content to a document

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

string $comment

comment

object $user

user who shall be the owner of this content

string $tmpFile

file containing the actuall content

string $orgFileName

original file name

$fileType
string $mimeType

MimeType of the content

array $reviewers

list of reviewers

array $approvers

list of approvers

integer $version

version number of content or 0 if next higher version shall be used.

array $attributes

list of version attributes. The element key

   must be the id of the attribute definition.
$workflow

Returns

\bool/array —

false in case of an error or a result set

getContent()

getContent() : array

Return all content elements of a document

This functions returns an array of content elements ordered by version

Returns

array —

list of objects of class SeedDMS_Core_DocumentContent

getContentByVersion()

getContentByVersion(integer $version) : object

Return the content element of a document with a given version number

Parameters

integer $version

version number of content element

Returns

object —

object of class SeedDMS_Core_DocumentContent

getLatestContent()

getLatestContent()

removeContent()

removeContent( $version)

Parameters

$version

getDocumentLink()

getDocumentLink(integer $linkID) : object

Return a certain document link

Parameters

integer $linkID

id of link

Returns

object —

instance of SeedDMS_Core_DocumentLink or false in case of

    an error.

getDocumentLinks()

getDocumentLinks(boolean $publiconly, object $user) : array

Return all document links

The list may contain all links to other documents, even those which may not be visible by certain users, unless you pass appropriate parameters to filter out public links and those created by the given user. The application may call SeedDMS_Core_DMS::filterDocumentLinks() afterwards.

Parameters

boolean $publiconly

return on publically visible links

object $user

return also private links of this user

Returns

array —

list of objects of class SeedDMS_Core_DocumentLink

getReverseDocumentLinks()

getReverseDocumentLinks(boolean $publiconly, object $user) : array

Return all document having a link on this document

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 functions is basically the reverse of SeedDMS_Core_Document::getDocumentLinks()

The application may call SeedDMS_Core_DMS::filterDocumentLinks() afterwards.

Parameters

boolean $publiconly

return on publically visible links

object $user

return also private links of this user

Returns

array —

list of objects of class SeedDMS_Core_DocumentLink

addDocumentLink()

addDocumentLink( $targetID,  $userID,  $public)

Parameters

$targetID
$userID
$public

removeDocumentLink()

removeDocumentLink( $linkID)

Parameters

$linkID

getDocumentFile()

getDocumentFile( $ID)

Parameters

$ID

getDocumentFiles()

getDocumentFiles()

addDocumentFile()

addDocumentFile( $name,  $comment,  $user,  $tmpFile,  $orgFileName,  $fileType,  $mimeType)

Parameters

$name
$comment
$user
$tmpFile
$orgFileName
$fileType
$mimeType

removeDocumentFile()

removeDocumentFile( $ID)

Parameters

$ID

remove()

remove() : boolean

Remove a document completly

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.

Returns

boolean —

true on success, otherwise false

getApproversList()

getApproversList()

Get List of users and groups which have read access on the document The list will not include any guest users, administrators and the owner of the folder unless $listadmin resp.

$listowner is set to true.

This function is deprecated. Use {@see SeedDMS_Core_Document::getReadAccessList()} instead.

getReadAccessList()

getReadAccessList(boolean $listadmin, boolean $listowner) : array

Returns a list of groups and users with read access on the document

Parameters

boolean $listadmin

if set to true any admin will be listed too

boolean $listowner

if set to true the owner will be listed too

Returns

array —

list of users and groups

getFolderList()

getFolderList() : string

Get the internally used folderList which stores the ids of folders from the root folder to the parent folder.

Returns

string —

column separated list of folder ids

repair()

repair() : boolean

Checks the internal data of the document and repairs it.

Currently, this function only repairs an incorrect folderList

Returns

boolean —

true on success, otherwise false

getUsedDiskSpace()

getUsedDiskSpace() : integer

Calculate the disk space including all versions of the document

This is done by using the internal database field storing the filesize of a document version.

Returns

integer —

total disk space in Bytes