Documentation

SeedDMS_Core_AttributeDefinition
in package

Class to represent an attribute definition in the document management system

Attribute definitions specify the name, type, object type, minimum and maximum values and a value set. The object type determines the object an attribute may be attached to. If the object type is set to object_all the attribute can be used for documents, document content and folders.

The type of an attribute specifies the skalar data type.

Attributes for which multiple values are allowed must have the multiple flag set to true and specify a value set. A value set is a string consisting of n separated values. The separator is the first char of the value set. A possible value could be '|REV-A|REV-B' If multiple values are allowed, then minvalues and maxvalues may restrict the allowed number of values.

Tags
see
SeedDMS_Core_Attribute
category

DMS

author

Markus Westphal, Malcolm Cowe, Uwe Steinmann uwe@steinmann.cx

copyright

Copyright (C) 2012-2024 Uwe Steinmann

version

Release: @package_version@

Table of Contents

Constants

objtype_all  = 0
objtype_document  = 2
objtype_documentcontent  = 3
objtype_folder  = 1
type_boolean  = 4
type_date  = 7
type_document  = 102
type_email  = 6
type_float  = 2
type_folder  = 101
type_group  = 105
type_int  = 1
type_string  = 3
type_url  = 5
type_user  = 104
val_error_boolean  = 8
val_error_date  = 9
val_error_document  = 10
val_error_email  = 5
val_error_float  = 7
val_error_folder  = 11
val_error_group  = 13
val_error_int  = 6
val_error_max_values  = 2
val_error_min_values  = 1
val_error_none  = 0
val_error_regex  = 3
val_error_url  = 4
val_error_user  = 12
val_error_valueset  = 14

Properties

$_dms  : SeedDMS_Core_DMS
$_id  : int
$_maxvalues  : int
$_minvalues  : int
$_multiple  : bool
$_name  : string
$_objtype  : string
$_regex  : string
$_separator  : string
$_type  : string
$_validation_error  : int
$_valueset  : string

Methods

__construct()  : mixed
Constructor
createValue()  : mixed
Create the value stored in the database
getDMS()  : object
Get dms of attribute definition
getID()  : int
Get internal id of attribute definition
getMaxValues()  : int
Return maximum number of values for attributes
getMinValues()  : int
Return minimum number of values for attributes
getMultipleValues()  : bool
Check if attribute definition allows multi values for attribute
getName()  : string
Get name of attribute definition
getObjects()  : array<string|int, mixed>
Get all documents and folders by a given attribute value
getObjType()  : int
Get object type of attribute definition
getRegex()  : string
Get the regular expression as saved in the database
getStatistics()  : array<string|int, mixed>|bool
Return a list of documents, folders, document contents where this attribute definition is used
getType()  : int
Get type of attribute definition
getValidationError()  : int
Get validation error from last validation
getValueSet()  : string
Get the value set as saved in the database
getValueSetAsArray()  : array<string|int, mixed>
Get the whole value set as an array
getValueSetSeparator()  : string
Get the separator used for the value set
isUsed()  : bool
Check if the attribute definition is used
parseValue()  : array<string|int, mixed>|bool
Parse a given value stored in the database according to attribute definition
remove()  : bool
Remove the attribute definition Removal is only executed when the definition is not used anymore.
removeValue()  : array<string|int, mixed>
Remove a given attribute value from all documents, versions and folders
setDMS()  : mixed
Set reference to dms
setMaxValues()  : mixed
setMinValues()  : mixed
setMultipleValues()  : bool
Set if attribute definition allows multi values for attribute
setName()  : bool
Set name of attribute definition
setObjType()  : bool
Set object type of attribute definition
setRegex()  : bool
Set the regular expression
setType()  : bool
Set type of attribute definition
setValueSet()  : bool
Set the value set
validate()  : bool
Validate value against attribute definition

Constants

Properties

$_maxvalues

protected int $_maxvalues

maximum values of an attribute

Tags
access

protected

$_minvalues

protected int $_minvalues

minimum values of an attribute

Tags
access

protected

$_multiple

protected bool $_multiple

whether an attribute can have multiple values

Tags
access

protected

$_name

protected string $_name

name of attribute definition

Tags
access

protected

$_objtype

protected string $_objtype

type of attribute definition. This can be one of objtype_all, objtype_folder, objtype_document, or objtype_documentcontent.

Tags
access

protected

$_regex

protected string $_regex

regular expression the value must match

Tags
access

protected

$_separator

protected string $_separator

just the separator of a value set (not used)

Tags
access

protected

$_type

protected string $_type

object type of attribute definition. This can be one of type_int, type_float, type_string, type_boolean, type_url, or type_email.

Tags
access

protected

$_validation_error

protected int $_validation_error

validation error

Tags
access

protected

$_valueset

protected string $_valueset

list of possible values of an attribute

Tags
access

protected

Methods

__construct()

Constructor

public __construct(int $id, string $name, int $objtype, int $type, bool $multiple, int $minvalues, int $maxvalues, string $valueset,  $regex) : mixed
Parameters
$id : int

internal id of attribute definition

$name : string

name of attribute

$objtype : int

type of object for which this attribute definition may be used.

$type : int

skalar type of attribute

$multiple : bool

set to true if multiple values are allowed

$minvalues : int

minimum number of values

$maxvalues : int

maximum number of values

$valueset : string

separated list of allowed values, the first char is taken as the separator

$regex :

createValue()

Create the value stored in the database

public createValue(mixed $values) : mixed
Parameters
$values : mixed

getDMS()

Get dms of attribute definition

public getDMS() : object
Return values
object

$dms

getID()

Get internal id of attribute definition

public getID() : int
Return values
int

id

getMaxValues()

Return maximum number of values for attributes

public getMaxValues() : int

Attributes with multiple values may be limited to a range of values. This functions returns the maximum number of values.

Return values
int

maximum number of values

getMinValues()

Return minimum number of values for attributes

public getMinValues() : int

Attributes with multiple values may be limited to a range of values. This functions returns the minimum number of values.

Return values
int

minimum number of values

getMultipleValues()

Check if attribute definition allows multi values for attribute

public getMultipleValues() : bool
Return values
bool

true if attribute may have multiple values

getName()

Get name of attribute definition

public getName() : string
Return values
string

name

getObjects()

Get all documents and folders by a given attribute value

public getObjects(string $attrvalue[, int $limit = 0 ][, mixed $op = O_EQ ]) : array<string|int, mixed>
Parameters
$attrvalue : string

value of attribute

$limit : int = 0

limit number of documents/folders

$op : mixed = O_EQ
Return values
array<string|int, mixed>

array containing list of documents and folders

getObjType()

Get object type of attribute definition

public getObjType() : int

This can be one of objtype_all, objtype_folder, objtype_document, or objtype_documentcontent.

Return values
int

type

getRegex()

Get the regular expression as saved in the database

public getRegex() : string
Return values
string

regular expression

getStatistics()

Return a list of documents, folders, document contents where this attribute definition is used

public getStatistics([int $limit = 0 ]) : array<string|int, mixed>|bool
Parameters
$limit : int = 0

return not more the n objects of each type

Return values
array<string|int, mixed>|bool

getType()

Get type of attribute definition

public getType() : int

This can be one of type_int, type_float, type_string, type_boolean, type_url, type_email.

Return values
int

type

getValidationError()

Get validation error from last validation

public getValidationError() : int
Return values
int

error code

getValueSet()

Get the value set as saved in the database

public getValueSet() : string

This is a string containing the list of valueѕ separated by a delimiter which also precedes the whole string, e.g. '|Yes|No'

Use for a list of values returned as an array.

Return values
string

value set

getValueSetAsArray()

Get the whole value set as an array

public getValueSetAsArray() : array<string|int, mixed>

Each element is trimmed.

Return values
array<string|int, mixed>

values of value set or false if the value set has less than 2 chars

getValueSetSeparator()

Get the separator used for the value set

public getValueSetSeparator() : string

This is the first char of the value set string.

Return values
string

separator or an empty string if a value set is not set

isUsed()

Check if the attribute definition is used

public isUsed() : bool

Checks all documents, folders and document content whether at least one of them referenceѕ this attribute definition

Return values
bool

true if attribute definition is used, otherwise false

parseValue()

Parse a given value stored in the database according to attribute definition

public parseValue( $value) : array<string|int, mixed>|bool

The return value is always an array, even if the attribute is a single value attribute. If the type of attribute is any of document, folder, user, or group then this method will fetch each object from the database and return an array of SeedDMS_Core_Document, SeedDMS_Core_Folder, etc.

Parameters
$value :

string

Return values
array<string|int, mixed>|bool

remove()

Remove the attribute definition Removal is only executed when the definition is not used anymore.

public remove() : bool
Return values
bool

true on success or false in case of an error

removeValue()

Remove a given attribute value from all documents, versions and folders

public removeValue(string $attrvalue) : array<string|int, mixed>
Parameters
$attrvalue : string

value of attribute

Return values
array<string|int, mixed>

array containing list of documents and folders

setMaxValues()

public setMaxValues(mixed $maxvalues) : mixed
Parameters
$maxvalues : mixed

setMinValues()

public setMinValues(mixed $minvalues) : mixed
Parameters
$minvalues : mixed

setMultipleValues()

Set if attribute definition allows multi values for attribute

public setMultipleValues(bool $mv) : bool
Parameters
$mv : bool

true if attribute may have multiple values, otherwise false

Return values
bool

setName()

Set name of attribute definition

public setName(string $name) : bool
Parameters
$name : string

name of attribute definition

Return values
bool

true on success, otherwise false

setObjType()

Set object type of attribute definition

public setObjType(int $objtype) : bool

This can be one of objtype_all, objtype_folder, objtype_document, or objtype_documentcontent.

Parameters
$objtype : int

type

Return values
bool

setRegex()

Set the regular expression

public setRegex(string $regex) : bool

A value of the attribute must match this regular expression.

The methods checks if the regular expression is valid by running preg_match() on an empty string and see if it fails. Trying to set an invalid regular expression will not overwrite the current regular expression.

All leading and trailing spaces of $regex will be removed.

Parameters
$regex : string
Return values
bool

true if regex could be set or is invalid, otherwise false

setType()

Set type of attribute definition

public setType(int $type) : bool

This can be one of type_int, type_float, type_string, type_boolean, type_url, type_email.

Parameters
$type : int

type

Return values
bool

setValueSet()

Set the value set

public setValueSet(string $valueset) : bool

A value set is a list of values allowed for an attribute. The values are separated by a char which must also be the first char of the value set string. The method decomposes the value set, removes all leading and trailing white space from the elements and recombines them into a string.

Parameters
$valueset : string
Return values
bool

true if value set could be set, otherwise false

validate()

Validate value against attribute definition

public validate(string|array<string|int, mixed> $attrvalue[, object $object = null ][, bool $new = false ]) : bool

This function checks if the given value fits the attribute definition. If the validation fails the validation error will be set which can be requested by SeedDMS_Core_Attribute::getValidationError() Set $new to true if the value to be checked isn't saved to the database already. It will just be passed to the callback onAttributeValidate where it could be used to, e.g. check if a value is unique once it is saved to the database. $object is set to a folder, document or documentcontent if the attribute belongs to such an object. This will be null, if a new object is created.

Parameters
$attrvalue : string|array<string|int, mixed>

attribute value

$object : object = null

set if the current attribute is saved for this object (this will only be passed to the onAttributeValidate callback)

$new : bool = false

set to true if the value is new value and not taken from an existing attribute (this will only be passed to the onAttributeValidate callback)

Return values
bool

true if validation succeeds, otherwise false


        
On this page

Search results