Menu

## SeedDMS_Core_AttributeDefinition
in package

inc.ClassAttribute.php : 304

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

#### objtype_all

inc.ClassAttribute.php : 414
`public mixed objtype_all = 0`

#### objtype_document

inc.ClassAttribute.php : 416
`public mixed objtype_document = 2`

#### objtype_documentcontent

inc.ClassAttribute.php : 417
`public mixed objtype_documentcontent = 3`

#### objtype_folder

inc.ClassAttribute.php : 415
`public mixed objtype_folder = 1`

#### type_boolean

inc.ClassAttribute.php : 397
`public mixed type_boolean = 4`

#### type_date

inc.ClassAttribute.php : 400
`public mixed type_date = 7`

#### type_document

inc.ClassAttribute.php : 406
`public mixed type_document = 102`

#### type_email

inc.ClassAttribute.php : 399
`public mixed type_email = 6`

#### type_float

inc.ClassAttribute.php : 395
`public mixed type_float = 2`

#### type_folder

inc.ClassAttribute.php : 405
`public mixed type_folder = 101`

#### type_group

inc.ClassAttribute.php : 409
`public mixed type_group = 105`

#### type_int

inc.ClassAttribute.php : 394
`public mixed type_int = 1`

#### type_string

inc.ClassAttribute.php : 396
`public mixed type_string = 3`

#### type_url

inc.ClassAttribute.php : 398
`public mixed type_url = 5`

#### type_user

inc.ClassAttribute.php : 408
`public mixed type_user = 104`

#### val_error_boolean

inc.ClassAttribute.php : 425
`public mixed val_error_boolean = 8`

#### val_error_date

inc.ClassAttribute.php : 427
`public mixed val_error_date = 9`

#### val_error_document

inc.ClassAttribute.php : 432
`public mixed val_error_document = 10`

#### val_error_email

inc.ClassAttribute.php : 430
`public mixed val_error_email = 5`

#### val_error_float

inc.ClassAttribute.php : 428
`public mixed val_error_float = 7`

#### val_error_folder

inc.ClassAttribute.php : 433
`public mixed val_error_folder = 11`

#### val_error_group

inc.ClassAttribute.php : 435
`public mixed val_error_group = 13`

#### val_error_int

inc.ClassAttribute.php : 426
`public mixed val_error_int = 6`

#### val_error_max_values

inc.ClassAttribute.php : 424
`public mixed val_error_max_values = 2`

#### val_error_min_values

inc.ClassAttribute.php : 423
`public mixed val_error_min_values = 1`

#### val_error_none

inc.ClassAttribute.php : 422
`public mixed val_error_none = 0`

#### val_error_regex

inc.ClassAttribute.php : 429
`public mixed val_error_regex = 3`

#### val_error_url

inc.ClassAttribute.php : 431
`public mixed val_error_url = 4`

#### val_error_user

inc.ClassAttribute.php : 434
`public mixed val_error_user = 12`

#### val_error_valueset

inc.ClassAttribute.php : 436
`public mixed val_error_valueset = 14`

### Properties

#### $_dms

inc.ClassAttribute.php : 382
`protected SeedDMS_Core_DMS $_dms`

reference to the dms instance this attribute definition belongs to

##### Tags

access

  protected

#### $_id

inc.ClassAttribute.php : 310
`protected int $_id`

id of attribute definition

##### Tags

access

  protected

#### $_maxvalues

inc.ClassAttribute.php : 354
`protected int $_maxvalues`

maximum values of an attribute

##### Tags

access

  protected

#### $_minvalues

inc.ClassAttribute.php : 347
`protected int $_minvalues`

minimum values of an attribute

##### Tags

access

  protected

#### $_multiple

inc.ClassAttribute.php : 340
`protected bool $_multiple`

whether an attribute can have multiple values

##### Tags

access

  protected

#### $_name

inc.ClassAttribute.php : 317
`protected string $_name`

name of attribute definition

##### Tags

access

  protected

#### $_objtype

inc.ClassAttribute.php : 333
`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

inc.ClassAttribute.php : 368
`protected string $_regex`

regular expression the value must match

##### Tags

access

  protected

#### $_separator

inc.ClassAttribute.php : 389
`protected string $_separator`

just the separator of a value set (not used)

##### Tags

access

  protected

#### $_type

inc.ClassAttribute.php : 325
`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

inc.ClassAttribute.php : 375
`protected int $_validation_error`

validation error

##### Tags

access

  protected

#### $_valueset

inc.ClassAttribute.php : 361
`protected string $_valueset`

list of possible values of an attribute

##### Tags

access

  protected

### Methods

#### __construct()

inc.ClassAttribute.php : 453

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()

inc.ClassAttribute.php : 912

Create the value stored in the database

`public createValue(mixed $values) : mixed`

##### Parameters

$values : mixed

#### getDMS()

inc.ClassAttribute.php : 482

Get dms of attribute definition

`public getDMS() : object`

##### Return values

object —

$dms

#### getID()

inc.ClassAttribute.php : 489

Get internal id of attribute definition

`public getID() : int`

##### Return values

int —

id

#### getMaxValues()

inc.ClassAttribute.php : 634

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()

inc.ClassAttribute.php : 612

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()

inc.ClassAttribute.php : 583

Check if attribute definition allows multi values for attribute

`public getMultipleValues() : bool`

##### Return values

bool —

true if attribute may have multiple values

#### getName()

inc.ClassAttribute.php : 496

Get name of attribute definition

`public getName() : string`

##### Return values

string —

name

#### getObjects()

inc.ClassAttribute.php : 1111

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()

inc.ClassAttribute.php : 524

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()

inc.ClassAttribute.php : 762

Get the regular expression as saved in the database

`public getRegex() : string`

##### Return values

string —

regular expression

#### getStatistics()

inc.ClassAttribute.php : 958

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()

inc.ClassAttribute.php : 555

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()

inc.ClassAttribute.php : 1420

Get validation error from last validation

`public getValidationError() : int`

##### Return values

int —

error code

#### getValueSet()

inc.ClassAttribute.php : 659

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()

inc.ClassAttribute.php : 691

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()

inc.ClassAttribute.php : 670

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()

inc.ClassAttribute.php : 805

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()

inc.ClassAttribute.php : 836

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

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

The return value is an array, if the attribute allows multiple values. Otherwise it is a single value. 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()

inc.ClassAttribute.php : 1091

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()

inc.ClassAttribute.php : 1169

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

#### setDMS()

inc.ClassAttribute.php : 473

Set reference to dms

`public setDMS(SeedDMS_Core_DMS $dms) : mixed`

##### Parameters

$dms : SeedDMS_Core_DMS

#### setMaxValues()

inc.ClassAttribute.php : 636
`public setMaxValues(mixed $maxvalues) : mixed`

##### Parameters

$maxvalues : mixed

#### setMinValues()

inc.ClassAttribute.php : 614
`public setMinValues(mixed $minvalues) : mixed`

##### Parameters

$minvalues : mixed

#### setMultipleValues()

inc.ClassAttribute.php : 592

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()

inc.ClassAttribute.php : 504

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()

inc.ClassAttribute.php : 535

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()

inc.ClassAttribute.php : 781

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()

inc.ClassAttribute.php : 566

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()

inc.ClassAttribute.php : 729

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()

inc.ClassAttribute.php : 1251

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

## Search results