\SeedDMS_Core_DMS

Class to represent the complete document management system.

This class is needed to do most of the dms operations. It needs an instance of {@link SeedDMS_Core_DatabaseAccess} to access the underlying database. Many methods are factory functions which create objects representing the entities in the dms, like folders, documents, users, or groups.

Each dms has its own database for meta data and a data store for document content. Both must be specified when creating a new instance of this class. All folders and documents are organized in a hierachy like a regular file system starting with a {@link $rootFolderID}

This class does not enforce any access rights on documents and folders by design. It is up to the calling application to use the methods {@link SeedDMS_Core_Folder::getAccessMode()} and {@link SeedDMS_Core_Document::getAccessMode()} and interpret them as desired. Though, there are two convinient functions to filter a list of documents/folders for which users have access rights for. See {@link SeedDMS_Core_DMS::filterAccess()} and {@link SeedDMS_Core_DMS::filterUsersByAccess()}

Though, this class has two methods to set the currently logged in user ({@link setUser} and {@link login}), none of them need to be called, because there is currently no class within the SeedDMS core which needs the logged in user.

<?php include("inc/inc.ClassDMS.php"); $db = new SeedDMS_Core_DatabaseAccess($type, $hostname, $user, $passwd, $name); $db->connect() or die ("Could not connect to db-server"); $dms = new SeedDMS_Core_DMS($db, $contentDir); $dms->setRootFolderID(1); ... ?>

Summary

Methods
Properties
Constants
checkIfEqual()
filterAccess()
filterUsersByAccess()
filterDocumentLinks()
__construct()
getDB()
getDBVersion()
checkVersion()
setRootFolderID()
setMaxDirID()
getRootFolder()
setEnableConverting()
setConvertFileTypes()
setViewOnlineFileTypes()
login()
setUser()
getDocument()
getDocumentsByUser()
getDocumentsLockedByUser()
getDocumentByName()
getDocumentContent()
makeTimeStamp()
search()
getFolder()
getFolderByName()
checkFolders()
checkDocuments()
getUser()
getUserByLogin()
getUserByEmail()
getAllUsers()
addUser()
getGroup()
getGroupByName()
getAllGroups()
addGroup()
getKeywordCategory()
getKeywordCategoryByName()
getAllKeywordCategories()
getAllUserKeywordCategories()
addKeywordCategory()
getDocumentCategory()
getDocumentCategories()
getDocumentCategoryByName()
addDocumentCategory()
getNotificationsByGroup()
getNotificationsByUser()
createPasswordRequest()
checkPasswordRequest()
deletePasswordRequest()
getAttributeDefinition()
getAttributeDefinitionByName()
getAllAttributeDefinitions()
addAttributeDefinition()
getAllWorkflows()
getWorkflow()
getWorkflowByName()
addWorkflow()
getWorkflowState()
getWorkflowStateByName()
getAllWorkflowStates()
addWorkflowState()
getWorkflowAction()
getWorkflowActionByName()
getAllWorkflowActions()
addWorkflowAction()
getWorkflowTransition()
getUnlinkedDocumentContent()
getNoFileSizeDocumentContent()
getNoChecksumDocumentContent()
getStatisticalData()
setCallback()
$contentDir
$rootFolderID
$enableConverting
$convertFileTypes
$viewOnlineFileTypes
$version
$callbacks
No constants found
No protected methods found
$db
N/A
No private methods found
$user
N/A

Properties

$contentDir

$contentDir : string

Type

string — location in the file system where all the document data is located. This should be an absolute path.

$rootFolderID

$rootFolderID : integer

Type

integer — ID of root folder

$enableConverting

$enableConverting : boolean

Type

boolean — set to true if conversion of content is desired

$convertFileTypes

$convertFileTypes : array

Type

array — list of files types that shall be converted

$viewOnlineFileTypes

$viewOnlineFileTypes : array

Type

array — list of files types that can be viewed online

$version

$version : string

Type

string — version of pear package

$callbacks

$callbacks : array

Type

array — list of methods called when certain operations, like removing a document, are executed. Set a callback with {@link SeedDMS_Core_DMS::setCallback()}. The key of the array is the internal callback function name. Each array element is an array with two elements: the function name and the parameter passed to the function. Currently implemented callbacks are: onPreRemoveDocument($user_param, $document); called before deleting a document. If this function returns false the document will not be deleted. onPostRemoveDocument($user_param, $document_id); called after the successful deletion of a document.

$db

$db : object

Type

object — reference to database object. This must be an instance of {@link SeedDMS_Core_DatabaseAccess}.

$user

$user : object

Type

object — 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}.

Methods

checkIfEqual()

checkIfEqual(object $object1, object $object2) : boolean

Checks if two objects are equal by comparing its ID

The regular php check done by '==' compares all attributes of two objects, which isn't required. The method will first check if the objects are instances of the same class.

Parameters

object $object1
object $object2

Returns

boolean —

true if objects are equal, otherwise false

filterAccess()

filterAccess(array $objArr, object $user, integer $minMode) : array

Filter objects out which are not accessible in a given mode by a user.

Parameters

array $objArr

list of objects (either documents or folders)

object $user

user for which access is checked

integer $minMode

minimum access mode required

Returns

array —

filtered list of objects

filterUsersByAccess()

filterUsersByAccess(object $obj, array $users, integer $minMode) : array

Filter users out which cannot access an object in a given mode.

Parameters

object $obj

object that shall be accessed

array $users

list of users which are to check for sufficient

   access rights
integer $minMode

minimum access right on the object for each user

Returns

array —

filtered list of users

filterDocumentLinks()

filterDocumentLinks(object $user, array $links) : \filtered

Filter document links

Returns a filtered list of links which are accessible by the given user.

Parameters

object $user

user for which access is being checked

array $links

list of objects of type SeedDMS_Core_DocumentLink

Returns

\filtered —

list of links

__construct()

__construct(object $db, string $contentDir) : object

Create a new instance of the dms

Parameters

object $db

object to access the underlying database

string $contentDir

path in filesystem containing the data store

   all document contents is stored

Returns

object —

instance of {@link SeedDMS_Core_DMS}

getDB()

getDB()

getDBVersion()

getDBVersion() : array

Return the database version

Returns

array —

array with elements major, minor, subminor, date

checkVersion()

checkVersion() : boolean

Check if the version in the database is the same as of this package Only the major and minor version number will be checked.

Returns

boolean —

returns false if versions do not match, but returns

    true if version matches or table tblVersion does not exists.

setRootFolderID()

setRootFolderID(\interger $id)

Set id of root folder This function must be called right after creating an instance of {@link SeedDMS_Core_DMS}

Parameters

\interger $id

id of root folder

setMaxDirID()

setMaxDirID(\interger $id)

Set maximum number of subdirectories per directory

The value of maxDirID is quite crucial because, all documents are associated with a directory in the filesystem. Consequently, there is maximum number of documents, because depending on the file system the maximum number of subdirectories is limited. Since version 3.3.0 of SeedDMS an additional directory level has been introduced. All documents from 1 to maxDirID-1 will be saved in 1/, documents from maxDirID to 2*maxDirID-1 are stored in 2/ and so on.

This function must be called right after creating an instance of {@link SeedDMS_Core_DMS}

Parameters

\interger $id

id of root folder

getRootFolder()

getRootFolder() : \object/boolean

Get root folder

Returns

\object/boolean —

return the object of the root folder or false if

   the root folder id was not set before with {@link setRootFolderID}.

setEnableConverting()

setEnableConverting( $enable)

Parameters

$enable

setConvertFileTypes()

setConvertFileTypes( $types)

Parameters

$types

setViewOnlineFileTypes()

setViewOnlineFileTypes( $types)

Parameters

$types

login()

login(string $username, string $password) : object

Login as a user

Checks if the given credentials are valid and returns a user object. It also sets the property $user for later access on the currently logged in user

Parameters

string $username

login name of user

string $password

password of user

Returns

object —

instance of class {@link SeedDMS_Core_User} or false

setUser()

setUser(object $user)

Set the logged in user

If user authentication was done externally, this function can be used to tell the dms who is currently logged in.

Parameters

object $user

getDocument()

getDocument(integer $id) : object

Return a document by its id

This function retrieves a document from the database by its id.

Parameters

integer $id

internal id of document

Returns

object —

instance of {@link SeedDMS_Core_Document} or false

getDocumentsByUser()

getDocumentsByUser(object $user) : array

Returns all documents of a given user

Parameters

object $user

Returns

array —

list of documents

getDocumentsLockedByUser()

getDocumentsLockedByUser(object $user) : array

Returns all documents locked by a given user FIXME: Not full implemented. Do not use, because it still requires the temporary tables!

Parameters

object $user

Returns

array —

list of documents

getDocumentByName()

getDocumentByName(string $name, object $folder) : \object/boolean

Returns a document by its name

This function searches a document by its name and restricts the search to given folder if passed as the second parameter.

Parameters

string $name
object $folder

Returns

\object/boolean —

found document or false

getDocumentContent()

getDocumentContent(integer $id) : object

Return a document content by its id

This function retrieves a document content from the database by its id.

Parameters

integer $id

internal id of document content

Returns

object —

instance of {@link SeedDMS_Core_DocumentContent} or false

makeTimeStamp()

makeTimeStamp( $hour,  $min,  $sec,  $year,  $month,  $day)

Parameters

$hour
$min
$sec
$year
$month
$day

search()

search( $query,  $limit,  $offset,  $logicalmode,  $searchin,  $startFolder,  $owner,  $status,  $creationstartdate,  $creationenddate,  $modificationstartdate,  $modificationenddate,  $categories,  $attributes,  $mode,  $expirationstartdate,  $expirationenddate)

Parameters

$query
$limit
$offset
$logicalmode
$searchin
$startFolder
$owner
$status
$creationstartdate
$creationenddate
$modificationstartdate
$modificationenddate
$categories
$attributes
$mode
$expirationstartdate
$expirationenddate

getFolder()

getFolder(integer $id) : object

Return a folder by its id

This function retrieves a folder from the database by its id.

Parameters

integer $id

internal id of folder

Returns

object —

instance of SeedDMS_Core_Folder or false

getFolderByName()

getFolderByName(string $name, object $folder) : \object/boolean

Return a folder by its name

This function retrieves a folder from the database by its name. The search covers the whole database. If the parameter $folder is not null, it will search for the name only within this parent folder. It will not be done recursively.

Parameters

string $name

name of the folder

object $folder

parent folder

Returns

\object/boolean —

found folder or false

checkFolders()

checkFolders() : array

Returns a list of folders and error message not linked in the tree

This function checks all folders in the database.

Returns

array —

list of errors

checkDocuments()

checkDocuments() : array

Returns a list of documents and error message not linked in the tree

This function checks all documents in the database.

Returns

array —

list of errors

getUser()

getUser(integer $id) : object

Return a user by its id

This function retrieves a user from the database by its id.

Parameters

integer $id

internal id of user

Returns

object —

instance of {@link SeedDMS_Core_User} or false

getUserByLogin()

getUserByLogin(string $login, string $email) : object

Return a user by its login

This function retrieves a user from the database by its login. If the second optional parameter $email is not empty, the user must also have the given email.

Parameters

string $login

internal login of user

string $email

email of user

Returns

object —

instance of {@link SeedDMS_Core_User} or false

getUserByEmail()

getUserByEmail(integer $email) : object

Return a user by its email

This function retrieves a user from the database by its email. It is needed when the user requests a new password.

Parameters

integer $email

email address of user

Returns

object —

instance of {@link SeedDMS_Core_User} or false

getAllUsers()

getAllUsers( $orderby) : array

Return list of all users

Parameters

$orderby

Returns

array —

of instances of {@link SeedDMS_Core_User} or false

addUser()

addUser(string $login, string $pwd,  $fullName, string $email, string $language,  $theme, string $comment, integer $role, integer $isHidden, integer $isDisabled,  $pwdexpiration) : object

Add a new user

Parameters

string $login

login name

string $pwd

password of new user

$fullName
string $email

Email of new user

string $language

language of new user

$theme
string $comment

comment of new user

integer $role

role of new user (can be 0=normal, 1=admin, 2=guest)

integer $isHidden

hide user in all lists, if this is set login

   is still allowed
integer $isDisabled

disable user and prevent login

$pwdexpiration

Returns

object —

of {@link SeedDMS_Core_User}

getGroup()

getGroup(integer $id) : \object/boolean

Get a group by its id

Parameters

integer $id

id of group

Returns

\object/boolean —

group or false if no group was found

getGroupByName()

getGroupByName(string $name) : \object/boolean

Get a group by its name

Parameters

string $name

name of group

Returns

\object/boolean —

group or false if no group was found

getAllGroups()

getAllGroups() : array

Get a list of all groups

Returns

array —

array of instances of {@link SeedDMS_Core_Group}

addGroup()

addGroup(string $name, string $comment) : \object/boolean

Create a new user group

Parameters

string $name

name of group

string $comment

comment of group

Returns

\object/boolean —

instance of {@link SeedDMS_Core_Group} or false in

    case of an error.

getKeywordCategory()

getKeywordCategory( $id)

Parameters

$id

getKeywordCategoryByName()

getKeywordCategoryByName( $name,  $userID)

Parameters

$name
$userID

getAllKeywordCategories()

getAllKeywordCategories( $userIDs)

Parameters

$userIDs

getAllUserKeywordCategories()

getAllUserKeywordCategories( $userID)

This function should be replaced by getAllKeywordCategories()

Parameters

$userID

addKeywordCategory()

addKeywordCategory( $userID,  $name)

Parameters

$userID
$name

getDocumentCategory()

getDocumentCategory( $id)

Parameters

$id

getDocumentCategories()

getDocumentCategories()

getDocumentCategoryByName()

getDocumentCategoryByName(string $name) : object

Get a category by its name

The name of a category is by default unique.

Parameters

string $name

human readable name of category

Returns

object —

instance of {@link SeedDMS_Core_DocumentCategory}

addDocumentCategory()

addDocumentCategory( $name)

Parameters

$name

getNotificationsByGroup()

getNotificationsByGroup(object $group, integer $type) : array

Get all notifications for a group

Parameters

object $group

group for which notifications are to be retrieved

integer $type

type of item (T_DOCUMENT or T_FOLDER)

Returns

array —

array of notifications

getNotificationsByUser()

getNotificationsByUser(object $user, integer $type) : array

Get all notifications for a user

Parameters

object $user

user for which notifications are to be retrieved

integer $type

type of item (T_DOCUMENT or T_FOLDER)

Returns

array —

array of notifications

createPasswordRequest()

createPasswordRequest( $user) : string

Create a token to request a new password.

This function will not delete the password but just creates an entry in tblUserRequestPassword indicating a password request.

Parameters

$user

Returns

string —

hash value of false in case of an error

checkPasswordRequest()

checkPasswordRequest(string $hash)

Check if hash for a password request is valid.

This function searches a previously create password request and returns the user.

Parameters

string $hash

deletePasswordRequest()

deletePasswordRequest(string $hash)

Delete a password request

Parameters

string $hash

getAttributeDefinition()

getAttributeDefinition(integer $id) : object

Return a attribute definition by its id

This function retrieves a attribute definitionr from the database by its id.

Parameters

integer $id

internal id of attribute defintion

Returns

object —

instance of {@link SeedDMS_Core_AttributeDefinition} or false

getAttributeDefinitionByName()

getAttributeDefinitionByName(string $name) : object

Return a attribute definition by its name

This function retrieves an attribute def. from the database by its name.

Parameters

string $name

internal name of attribute def.

Returns

object —

instance of {@link SeedDMS_Core_AttributeDefinition} or false

getAllAttributeDefinitions()

getAllAttributeDefinitions(integer $objtype) : array

Return list of all attributes definitions

Parameters

integer $objtype

select those attributes defined for an object type

Returns

array —

of instances of {@link SeedDMS_Core_AttributeDefinition} or false

addAttributeDefinition()

addAttributeDefinition(string $name,  $objtype, string $type, boolean $multiple, integer $minvalues, integer $maxvalues, string $valueset,  $regex) : object

Add a new attribute definition

Parameters

string $name

name of attribute

$objtype
string $type

type of attribute

boolean $multiple

set to 1 if attribute has multiple attributes

integer $minvalues

minimum number of values

integer $maxvalues

maximum number of values if multiple is set

string $valueset

list of allowed values (csv format)

$regex

Returns

object —

of {@link SeedDMS_Core_User}

getAllWorkflows()

getAllWorkflows() : array

Return list of all workflows

Returns

array —

of instances of {@link SeedDMS_Core_Workflow} or false

getWorkflow()

getWorkflow( $id) : object

Return workflow by its Id

Parameters

$id

Returns

object —

of instances of {@link SeedDMS_Core_Workflow} or false

getWorkflowByName()

getWorkflowByName( $name) : object

Return workflow by its name

Parameters

$name

Returns

object —

of instances of {@link SeedDMS_Core_Workflow} or false

addWorkflow()

addWorkflow( $name,  $initstate)

Parameters

$name
$initstate

getWorkflowState()

getWorkflowState(integer $id) : object

Return a workflow state by its id

This function retrieves a workflow state from the database by its id.

Parameters

integer $id

internal id of workflow state

Returns

object —

instance of {@link SeedDMS_Core_Workflow_State} or false

getWorkflowStateByName()

getWorkflowStateByName(string $name) : object

Return workflow state by its name

Parameters

string $name

name of workflow state

Returns

object —

of instances of {@link SeedDMS_Core_Workflow_State} or false

getAllWorkflowStates()

getAllWorkflowStates() : array

Return list of all workflow states

Returns

array —

of instances of {@link SeedDMS_Core_Workflow_State} or false

addWorkflowState()

addWorkflowState(string $name, integer $docstatus) : object

Add new workflow state

Parameters

string $name

name of workflow state

integer $docstatus

document status when this state is reached

Returns

object —

instance of new workflow state

getWorkflowAction()

getWorkflowAction(integer $id) : object

Return a workflow action by its id

This function retrieves a workflow action from the database by its id.

Parameters

integer $id

internal id of workflow action

Returns

object —

instance of {@link SeedDMS_Core_Workflow_Action} or false

getWorkflowActionByName()

getWorkflowActionByName(string $name) : object

Return a workflow action by its name

This function retrieves a workflow action from the database by its name.

Parameters

string $name

name of workflow action

Returns

object —

instance of {@link SeedDMS_Core_Workflow_Action} or false

getAllWorkflowActions()

getAllWorkflowActions() : array

Return list of workflow action

Returns

array —

list of instances of {@link SeedDMS_Core_Workflow_Action} or false

addWorkflowAction()

addWorkflowAction(string $name) : object

Add new workflow action

Parameters

string $name

name of workflow action

Returns

object —

instance new workflow action

getWorkflowTransition()

getWorkflowTransition(integer $id) : object

Return a workflow transition by its id

This function retrieves a workflow transition from the database by its id.

Parameters

integer $id

internal id of workflow transition

Returns

object —

instance of {@link SeedDMS_Core_Workflow_Transition} or false

getUnlinkedDocumentContent()

getUnlinkedDocumentContent()

Returns document content which is not linked to a document

This method is for finding straying document content without a parent document. In normal operation this should not happen but little checks for database consistency and possible errors in the application may have left over document content though the document is gone already.

getNoFileSizeDocumentContent()

getNoFileSizeDocumentContent()

Returns document content which has no file size set

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.

getNoChecksumDocumentContent()

getNoChecksumDocumentContent()

Returns document content which has no checksum set

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.

getStatisticalData()

getStatisticalData(string $type)

Returns statitical information

This method returns all kind of statistical information like documents or used space per user, recent activity, etc.

Parameters

string $type

type of statistic

setCallback()

setCallback(string $name, mixed $func, mixed $params)

Set a callback function

Parameters

string $name

internal name of callback

mixed $func

function name as expected by {call_user_method}

mixed $params

parameter passed as the first argument to the

   callback