\SeedDMS_Core_DocumentContent

Class to represent content of a document

Each document has content attached to it, often called a 'version' of the document. The document content represents a file on the disk with some meta data stored in the database. A document content has a version number which is incremented with each replacement of the old content. Old versions are kept unless they are explicitly deleted by {@link SeedDMS_Core_Document::removeContent()}.

Summary

Methods
Properties
Constants
SeedDMS_Core_Object()
setDMS()
getID()
getAttributes()
getAttributeValue()
setAttributeValue()
removeAttribute()
verifyStatus()
SeedDMS_Core_DocumentContent()
getVersion()
getComment()
getDate()
getOriginalFileName()
getFileType()
getFileName()
getDir()
getMimeType()
getDocument()
getUser()
getPath()
setDate()
getFileSize()
setFileSize()
getChecksum()
setChecksum()
setComment()
convert()
viewOnline()
wasConverted()
getURL()
getStatus()
getStatusLog()
setStatus()
getAccessMode()
getReviewStatus()
getApprovalStatus()
addIndReviewer()
addGrpReviewer()
setReviewByInd()
setReviewByGrp()
addIndApprover()
addGrpApprover()
setApprovalByInd()
setApprovalByGrp()
delIndReviewer()
delGrpReviewer()
delIndApprover()
delGrpApprover()
setWorkflowState()
getWorkflowState()
setWorkflow()
getWorkflow()
rewindWorkflow()
removeWorkflow()
getParentWorkflow()
runSubWorkflow()
returnFromSubWorkflow()
triggerWorkflowTransitionIsAllowed()
executeWorkflowTransitionIsAllowed()
triggerWorkflowTransition()
enterNextState()
getWorkflowLog()
getLastWorkflowTransition()
needsWorkflowAction()
$_dms
No constants found
No protected methods found
$_id
$_attributes
N/A
No private methods found
No private properties found
N/A

Properties

$_dms

$_dms : object

Type

object — back reference to document management system

$_id

$_id : integer

Type

integer — unique id of object

$_attributes

$_attributes : array

Type

array — list of attributes

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

verifyStatus()

verifyStatus(boolean $ignorecurrentstatus, object $user)

Recalculate the status of a document The methods checks the review and approval status and sets the status of the document accordingly.

If status is S_RELEASED and version has workflow set status to S_IN_WORKFLOW If status is S_RELEASED and there are reviewers set status S_DRAFT_REV If status is S_RELEASED or S_DRAFT_REV and there are approvers set status S_DRAFT_APP If status is draft and there are no approver and no reviewers set status to S_RELEASED The status of a document with the current status S_OBSOLETE, S_REJECTED, or S_EXPIRED will not be changed unless the parameter $ignorecurrentstatus is set to true.

Parameters

boolean $ignorecurrentstatus

ignore the current status and

   recalculate a new status in any case
object $user

the user initiating this method

SeedDMS_Core_DocumentContent()

SeedDMS_Core_DocumentContent( $id,  $document,  $version,  $comment,  $date,  $userID,  $dir,  $orgFileName,  $fileType,  $mimeType,  $fileSize,  $checksum)

Parameters

$id
$document
$version
$comment
$date
$userID
$dir
$orgFileName
$fileType
$mimeType
$fileSize
$checksum

getVersion()

getVersion()

getComment()

getComment()

getDate()

getDate()

getOriginalFileName()

getOriginalFileName()

getFileType()

getFileType()

getFileName()

getFileName()

getDir()

getDir()

getMimeType()

getMimeType()

getDocument()

getDocument()

getUser()

getUser()

getPath()

getPath()

setDate()

setDate( $date)

Parameters

$date

getFileSize()

getFileSize()

setFileSize()

setFileSize()

Set file size by reading the file

getChecksum()

getChecksum()

setChecksum()

setChecksum()

Set checksum by reading the file

setComment()

setComment( $newComment)

Parameters

$newComment

convert()

convert()

This function is deprecated

viewOnline()

viewOnline()

wasConverted()

wasConverted()

getURL()

getURL()

This function is deprecated

getStatus()

getStatus( $limit)

Get the latest status of the content

The status of the content reflects its current review, approval or workflow state. A status can be a negative or positive number or 0. A negative numbers indicate a missing approval, review or an obsolete content. Positive numbers indicate some kind of approval or workflow being active, but not necessarily a release. S_DRAFT_REV, 0 S_DRAFT_APP, 1 S_RELEASED, 2 S_IN_WORKFLOW, 3 S_REJECTED, -1 S_OBSOLETE, -2 S_EXPIRED, -3 When a content is inserted and does not need approval nor review, then its status is set to S_RELEASED immediately. Any change of the status is monitored in the table tblDocumentStatusLog. This function will always return the latest entry for the content.

Parameters

$limit

getStatusLog()

getStatusLog(integer $limit) : array

Get current and former states of the document content

Parameters

integer $limit

if not set all log entries will be returned

Returns

array —

list of status changes

setStatus()

setStatus(integer $status, string $comment, object $updateUser) : boolean

Set the status of the content Setting the status means to add another entry into the table tblDocumentStatusLog. The method returns also false if the status is already set on the value passed to the method.

Parameters

integer $status

new status of content

string $comment

comment for this status change

object $updateUser

user initiating the status change

Returns

boolean —

true on success, otherwise false

getAccessMode()

getAccessMode( $u) : integer

Returns the access mode similar to a document There is no real access mode for document content, so this is more like a virtual access mode, derived from the status or workflow of the document content. The idea is to return an access mode M_NONE if the user is still in a workflow or under review/approval.

In such a case only those user involved in the workflow/review/approval process should be allowed to see the document. This method could be called by any function that returns the content e.g. getLatestContent() It may as well be used by SeedDMS_Core_Document::getAccessMode() to prevent access on the whole document if there is just one version. The return value is planed to be either M_NONE or M_READ.

Parameters

$u

Returns

integer —

mode

getReviewStatus()

getReviewStatus(integer $limit) : array

Get the current review status of the document content The review status is a list of reviews and its current status

Parameters

integer $limit

the number of recent status changes per reviewer

Returns

array —

list of review status

getApprovalStatus()

getApprovalStatus(integer $limit) : array

Get the current approval status of the document content The approval status is a list of approvals and its current status

Parameters

integer $limit

the number of recent status changes per approver

Returns

array —

list of approval status

addIndReviewer()

addIndReviewer( $user,  $requestUser,  $listadmin)

Parameters

$user
$requestUser
$listadmin

addGrpReviewer()

addGrpReviewer( $group,  $requestUser)

Parameters

$group
$requestUser

setReviewByInd()

setReviewByInd(object $user, object $requestUser, integer $status, string $comment) : integer

Add a review to the document content

This method will add an entry to the table tblDocumentReviewLog. It will first check if the user is ment to review the document version. It not the return value is -3. Next it will check if the users has been removed from the list of reviewers. In that case -4 will be returned. If the given review status has been set by the user before, it cannot be set again and 0 will be returned. Іf the review could be succesfully added, the review log id will be returned.

Parameters

object $user

user doing the review

object $requestUser

user asking for the review, this is mostly the user currently logged in.

integer $status

status of review

string $comment

comment for review

Returns

integer —

new review log id

setReviewByGrp()

setReviewByGrp(object $group, object $requestUser, integer $status, string $comment) : integer

Add a review to the document content

This method is similar to {@see SeedDMS_Core_DocumentContent::setReviewByInd()} but adds a review for a group instead of a user.

Parameters

object $group

group doing the review

object $requestUser

user asking for the review, this is mostly the user currently logged in.

integer $status

status of review

string $comment

comment for review

Returns

integer —

new review log id

addIndApprover()

addIndApprover( $user,  $requestUser,  $listadmin)

Parameters

$user
$requestUser
$listadmin

addGrpApprover()

addGrpApprover( $group,  $requestUser)

Parameters

$group
$requestUser

setApprovalByInd()

setApprovalByInd(object $user, object $requestUser, integer $status, string $comment) : integer

Sets approval status of a document content for a user

This function can be used to approve or reject a document content, or to reset its approval state. In most cases this function will be called by an user, but an admin may set the approval for somebody else. It is first checked if the user is in the list of approvers at all. Then it is check if the approval status is already -2. In both cases the function returns with an error.

Parameters

object $user

user in charge for doing the approval

object $requestUser

user actually calling this function

integer $status

the status of the approval, possible values are

   0=unprocessed (maybe used to reset a status)
   1=approved,
  -1=rejected,
  -2=user is deleted (use {link
  SeedDMS_Core_DocumentContent::delIndApprover} instead)
string $comment

approval comment

Returns

integer —

0 on success, < 0 in case of an error

setApprovalByGrp()

setApprovalByGrp( $group,  $requestUser,  $status,  $comment)

Sets approval status of a document content for a group The functions behaves like {link SeedDMS_Core_DocumentContent::setApprovalByInd} but does it for group instead of a user

Parameters

$group
$requestUser
$status
$comment

delIndReviewer()

delIndReviewer( $user,  $requestUser)

Parameters

$user
$requestUser

delGrpReviewer()

delGrpReviewer( $group,  $requestUser)

Parameters

$group
$requestUser

delIndApprover()

delIndApprover( $user,  $requestUser)

Parameters

$user
$requestUser

delGrpApprover()

delGrpApprover( $group,  $requestUser)

Parameters

$group
$requestUser

setWorkflowState()

setWorkflowState(object $state)

Set state of workflow assigned to the document content

Parameters

object $state

getWorkflowState()

getWorkflowState() : \object/boolean

Get state of workflow assigned to the document content

Returns

\object/boolean —

an object of class SeedDMS_Core_Workflow_State

    or false in case of error, e.g. the version has not a workflow

setWorkflow()

setWorkflow(object $workflow,  $user)

Assign a workflow to a document

Parameters

object $workflow
$user

getWorkflow()

getWorkflow() : \object/boolean

Get workflow assigned to the document content

The method returns the last workflow if one was assigned. If a the document version is in a sub workflow, it will have a never date and therefore will be found first.

Returns

\object/boolean —

an object of class SeedDMS_Core_Workflow

    or false in case of error, e.g. the version has not a workflow

rewindWorkflow()

rewindWorkflow() : boolean

Restart workflow from its initial state

Returns

boolean —

true if workflow could be restarted

    or false in case of error

removeWorkflow()

removeWorkflow(object $user, boolean $unlink) : boolean

Remove workflow

Fully removing a workflow including entries in the workflow log is only allowed if the workflow is still its initial state. At a later point of time only unlinking the document from the workflow is allowed. It will keep any log entries. A workflow is unlinked from a document when enterNextState() succeeds.

Parameters

object $user

user doing initiating the removal

boolean $unlink

if true, just unlink the workflow from the

   document but do not remove the workflow log. The $unlink
   flag has been added to detach the workflow from the document
   when it has reached a valid end state

(see SeedDMS_Core_DocumentContent::enterNextState())

Returns

boolean —

true if workflow could be removed

    or false in case of error

getParentWorkflow()

getParentWorkflow()

Run a sub workflow

runSubWorkflow()

runSubWorkflow(object $subworkflow)

Run a sub workflow

Parameters

object $subworkflow

returnFromSubWorkflow()

returnFromSubWorkflow(object $user,  $transition,  $comment)

Return from sub workflow to parent workflow.

The method will trigger the given transition

FIXME: Needs much better checking if this is allowed

Parameters

object $user

intiating the return

$transition
$comment

triggerWorkflowTransitionIsAllowed()

triggerWorkflowTransitionIsAllowed(object $user,  $transition) : boolean

Check if the user is allowed to trigger the transition A user is allowed if either the user itself or a group of which the user is a member of is registered for triggering a transition. This method does not change the workflow state of the document content.

Parameters

object $user
$transition

Returns

boolean —

true if user may trigger transaction

executeWorkflowTransitionIsAllowed()

executeWorkflowTransitionIsAllowed( $transition) : boolean

Check if all conditions are met to change the workflow state of a document content (run the transition).

The conditions are met if all explicitly set users and a sufficient number of users of the groups have acknowledged the content.

Parameters

$transition

Returns

boolean —

true if transaction maybe executed

triggerWorkflowTransition()

triggerWorkflowTransition(object $user, object $transition, string $comment) : \boolean/object

Trigger transition

This method will be deprecated

The method will first check if the user is allowed to trigger the transition. If the user is allowed, an entry in the workflow log will be added, which is later used to check if the transition can actually be processed. The method will finally call executeWorkflowTransitionIsAllowed() which checks all log entries and does the transitions post function if all users and groups have triggered the transition. Finally enterNextState() is called which will try to enter the next state.

Parameters

object $user
object $transition
string $comment

user comment

Returns

\boolean/object —

next state if transition could be triggered and

    then next state could be entered,
    true if the transition could just be triggered or
    false in case of an error

enterNextState()

enterNextState(object $user, object $nextstate) : boolean

Enter next state of workflow if possible

The method will check if one of the following states in the workflow can be reached. It does it by running the precondition function of that state. The precondition function gets a list of all transitions leading to the state. It will determine, whether the transitions has been triggered and if that is sufficient to enter the next state. If no pre condition function is set, then 1 of n transtions are enough to enter the next state.

If moving in the next state is possible and this state has a corresponding document state, then the document state will be updated and the workflow will be detached from the document.

Parameters

object $user
object $nextstate

Returns

boolean —

true if the state could be reached

    false if not

getWorkflowLog()

getWorkflowLog( $transition) : array

Get the so far logged operations on the document content within the workflow

Parameters

$transition

Returns

array —

list of operations

getLastWorkflowTransition()

getLastWorkflowTransition() : array

Get the latest logged transition for the document content within the workflow

Returns

array —

list of operations

needsWorkflowAction()

needsWorkflowAction(\SeedDMS_Core_User $user) : boolean

Check if the document content needs an action by a user

This method will return true if document content is in a transition which can be triggered by the given user.

Parameters

\SeedDMS_Core_User $user

Returns

boolean —

true is action is needed