\midcom_db_parameter

MidCOM level replacement for the Midgard Parameter record with framework support.

The uplink is the parentguid parameter.

Summary

Methods
Properties
Constants
__construct()
__get()
__set()
new_query_builder()
new_collector()
get_cached()
set_guid()
__isset()
create()
delete()
undelete()
purge()
delete_tree()
get_by_guid()
get_by_id()
get_by_path()
get_metadata()
get_parent()
is_in_parent_tree()
is_in_tree()
has_dependents()
list_children()
parent()
is_object_visible_onsite()
has_attachments()
find_attachments()
delete_attachments()
purge_attachments()
has_parameters()
find_parameters()
delete_parameters()
purge_parameters()
refresh()
update()
is_locked()
lock()
unlock()
is_approved()
approve()
unapprove()
get_properties()
new_reflection_property()
can_do()
can_user_do()
require_do()
require_user_do()
get_class_magic_default_privileges()
_on_created()
_on_creating()
_on_deleted()
_on_deleting()
_on_loaded()
_on_prepare_exec_query_builder()
_on_prepare_new_query_builder()
_on_process_query_result()
_on_prepare_new_collector()
_on_prepare_exec_collector()
_on_process_collector_result()
_on_updated()
_on_updating()
_on_imported()
_on_importing()
disable_rcs()
enable_rcs()
set_rcs_message()
get_rcs_message()
get_parameter()
list_parameters()
set_parameter()
delete_parameter()
get_attachment()
delete_attachment()
create_attachment()
get_attachment_qb()
list_attachments()
get_privileges()
set_privilege()
unset_privilege()
get_privilege()
unset_all_privileges()
create_new_privilege_object()
get_parent_guid_uncached()
get_parent_guid_uncached_static()
get_by_objectguid()
get_label()
$__midcom_class_name__
$__mgdschema_class_name__
$__object
$_use_rcs
$_use_activitystream
$_activitystream_verb
$allow_name_catenate
$autodelete_dependents
$domain
$name
$value
$parentguid
$id
$guid
$metadata
No constants found
No protected methods found
No protected properties found
N/A
_delete_dependents()
list_parameters_domain()
list_parameters_all()
$__metadata
$_rcs_message
$parameter_cache
$parameter_all
N/A

Properties

$__midcom_class_name__

$__midcom_class_name__ : string

MidCOM classname

Type

string

$__mgdschema_class_name__

$__mgdschema_class_name__ : string

Midgard classname

Type

string

$__object

$__object : \midgard\portable\api\mgdobject

MgdSchema object

Type

\midgard\portable\api\mgdobject — MgdSchema object

$_use_rcs

$_use_rcs : boolean

Should the revision control system be enabled for object updates

Type

boolean

$_use_activitystream

$_use_activitystream : boolean

Should the Activity Log be enabled for object actions

Type

boolean

$_activitystream_verb

$_activitystream_verb : string

Verb to use for Activity Log. Should be an URL conforming to activitystrea.ms specification.

If left blank then this will come from the DBA action performed (update, create)

Type

string

$allow_name_catenate

$allow_name_catenate : boolean

Should it be allowed to automatically generate unique name in case of clash

Type

boolean

$autodelete_dependents

$autodelete_dependents : array

May contain a list of dbaclass => field entries. When deleting an object, these dependent objects are automatically deleted beforehand

Type

array

$domain

$domain : string

Namespace of the parameter

Type

string

$name

$name : string

Key of the parameter

Type

string

$value

$value : string

Value of the parameter

Type

string

$parentguid

$parentguid : string

GUID of the object the parameter extends

Type

string

$id

$id : integer

Local non-replication-safe database identifier

Type

integer

$guid

$guid : string

Type

string

$metadata

$metadata : \midcom_helper_metadata

the object's metadata

Type

\midcom_helper_metadata

$__metadata

$__metadata : \midcom_helper_metadata

Metadata object

Type

\midcom_helper_metadata — MidCOM metadata object

$_rcs_message

$_rcs_message : string

Change message used for RCS and the Activity Log summary

Type

string

$parameter_cache

$parameter_cache : 

Type

$parameter_all

$parameter_all : 

Type

Methods

__construct()

__construct(  $id = null) 

Constructor. Creates an abstraction layer for an MgdSchema object.

Parameters

$id

__get()

__get(string  $property) 

Magic getter for object property mapping

Parameters

string $property

Name of the property

__set()

__set(string  $property, mixed  $value) 

Magic setter for object property mapping

Parameters

string $property

Name of the property

mixed $value

Property value

new_query_builder()

new_query_builder() : \midcom_core_querybuilder

Shortcut for accessing MidCOM Query Builder

Returns

\midcom_core_querybuilder

The initialized instance of the query builder.

new_collector()

new_collector(string  $domain = null, mixed  $value = null) : \midcom_core_collector

Shortcut for accessing MidCOM Collector

Parameters

string $domain

The domain property of the collector instance

mixed $value

Value match for the collector instance

Returns

\midcom_core_collector

The initialized instance of the collector.

get_cached()

get_cached(mixed  $src) : static

Shortcut for accessing MidCOM object cache.

Parameters

mixed $src

GUID of object (ids work but are discouraged)

Returns

static —

Reference to the object

set_guid()

set_guid(  $guid) 

Parameters

$guid

__isset()

__isset(string  $property) 

Magic isset test for object property mapping

Parameters

string $property

Name of the property

create()

create() : boolean

API for creating a new object

Returns

boolean —

Indicating success

delete()

delete() : boolean

Delete the current object

Returns

boolean —

Indicating success

undelete()

undelete(  $guid) : boolean

Undelete object defined by a GUID

Parameters

$guid

Returns

boolean —

Indicating success

purge()

purge() : boolean

Purge the current object from database

Returns

boolean —

Indicating success

delete_tree()

delete_tree() : boolean

Delete the current object tree, starting from this object

Returns

boolean —

Indicating success

get_by_guid()

get_by_guid(string  $guid) : boolean

Parameters

string $guid

Returns

boolean —

Indicating success

get_by_id()

get_by_id(integer  $id) : boolean

Parameters

integer $id

Returns

boolean —

Indicating success

get_by_path()

get_by_path(string  $path) : boolean

Parameters

string $path

Returns

boolean —

Indicating success

get_parent()

get_parent() 

is_in_parent_tree()

is_in_parent_tree(  $root,   $id) 

Parameters

$root
$id

is_in_tree()

is_in_tree(  $root,   $id) 

Parameters

$root
$id

has_dependents()

has_dependents() 

list_children()

list_children(  $class_name) 

Parameters

$class_name

parent()

parent() 

is_object_visible_onsite()

is_object_visible_onsite() 

has_attachments()

has_attachments() 

find_attachments()

find_attachments(  $constraints) 

Parameters

$constraints

delete_attachments()

delete_attachments(  $constraints) 

Parameters

$constraints

purge_attachments()

purge_attachments(  $constraints) 

Parameters

$constraints

has_parameters()

has_parameters() 

find_parameters()

find_parameters(  $constraints) 

Parameters

$constraints

delete_parameters()

delete_parameters(  $constraints) 

Parameters

$constraints

purge_parameters()

purge_parameters(  $constraints) 

Parameters

$constraints

refresh()

refresh() 

update()

update() 

is_locked()

is_locked() 

lock()

lock() 

unlock()

unlock() 

is_approved()

is_approved() 

approve()

approve() 

unapprove()

unapprove() 

get_properties()

get_properties() 

new_reflection_property()

new_reflection_property() 

can_do()

can_do(  $privilege,   $user = null) 

Parameters

$privilege
$user

can_user_do()

can_user_do(  $privilege,   $user = null) 

Parameters

$privilege
$user

require_do()

require_do(  $privilege,   $message = null) 

Parameters

$privilege
$message

require_user_do()

require_user_do(  $privilege,   $message = null) 

Parameters

$privilege
$message

get_class_magic_default_privileges()

get_class_magic_default_privileges() 

_on_created()

_on_created() 

_on_creating()

_on_creating() 

_on_deleted()

_on_deleted() 

_on_deleting()

_on_deleting() 

_on_loaded()

_on_loaded() 

_on_prepare_exec_query_builder()

_on_prepare_exec_query_builder(  $qb) 

Parameters

$qb

_on_prepare_new_query_builder()

_on_prepare_new_query_builder(  $qb) 

Parameters

$qb

_on_process_query_result()

_on_process_query_result(  $result) 

Parameters

$result

_on_prepare_new_collector()

_on_prepare_new_collector(  $mc) 

Parameters

$mc

_on_prepare_exec_collector()

_on_prepare_exec_collector(  $mc) 

Parameters

$mc

_on_process_collector_result()

_on_process_collector_result(  $result) 

Parameters

$result

_on_updated()

_on_updated() 

_on_updating()

_on_updating() 

_on_imported()

_on_imported() 

_on_importing()

_on_importing() 

disable_rcs()

disable_rcs() 

enable_rcs()

enable_rcs() 

set_rcs_message()

set_rcs_message(  $msg) 

Parameters

$msg

get_rcs_message()

get_rcs_message() 

get_parameter()

get_parameter(string  $domain, string  $name) : string

Return a parameter from the database.

No event handlers are called here yet.

Parameters

string $domain

The parameter domain.

string $name

The parameter name.

Returns

string —

The parameter value or false otherwise (remember typesafe comparisons to protect against '' strings).

list_parameters()

list_parameters(string  $domain = null) : array

List the parameters of an object. This will either list the parameters of a single domain or the complete set of parameters, depending on the value of $domain.

It delegates the actual execution to two separate helper functions.

No event handlers are called here yet.

In case of a complete query, the result will be an associative array indexed by the domain name and containing another array with parameter name/value pairs. For example:

Array
(
    [Asgard] => Array
    (
        [lang] => en_US
        [act] => view
        [actloc] => tree
    )
    [AsgardTreeHost] => Array
    (
        [selected] => host0
    )
)

If you query only a single domain, the result will be a single associative array containing the parameter name/value pairs. For example:

Array
(
    [lang] => en_US
    [act] => view
    [actloc] => tree
)

In both cases an empty Array will indicate that no parameter was found, while false will indicate a failure while querying the database.

Parameters

string $domain

The parameter domain to query, this may be null to indicate a full listing.

Returns

array —

Parameter list (see above for details) or false on failure.

set_parameter()

set_parameter(string  $domain, string  $name, string  $value) : boolean

Set a parameter to the value specified.

This is either a create or an update operation depending on whether there was already a parameter of that domain/name present, or not.

The user needs both update and parameter manipulation permission on the parent object for updates.

Parameters

string $domain

The Parameter Domain.

string $name

The Parameter name.

string $value

The Parameter value. If this is empty, the corresponding parameter is deleted.

Returns

boolean —

Indicating success.

delete_parameter()

delete_parameter(string  $domain, string  $name) : boolean

Delete a parameter.

Current implementation note: Deletion is not yet implemented in MgdSchema. Therefore we set the parameters to an empty string for now, which should have almost the same effect for most cases and thus is good enough for now. Note, that empty string parameters are filtered in the getter methods until this matter is resolved.

The user needs both update and parameter manipulation permission on the parent object for updates.

Parameters

string $domain

The Parameter Domain.

string $name

The Parameter name.

Returns

boolean —

Indicating success.

get_attachment()

get_attachment(string  $name) : \midcom_db_attachment

Retrieves an attachment by its name.

If multiple attachments match the name (should not happen in reality), the first match will be returned.

Parameters

string $name

The name of the attachment to look up.

Returns

\midcom_db_attachment

The attachment found, or false on failure.

delete_attachment()

delete_attachment(string  $name) : boolean

Delete an attachment by its name.

If multiple attachments match the name (should not happen in reality), the first match will be deleted.

Parameters

string $name

The name of the attachment to delete.

Returns

boolean —

Indicating success.

create_attachment()

create_attachment(string  $name, string  $title, string  $mimetype) : \midcom_db_attachment

Creates a new attachment at the current object and returns it for usage.

Parameters

string $name

The name of the attachment.

string $title

The title of the attachment.

string $mimetype

The MIME-Type of the attachment.

Returns

\midcom_db_attachment

The created attachment or false on failure.

get_attachment_qb()

get_attachment_qb() : \midcom_core_querybuilder

Returns a prepared query builder that is already limited to the attachments of the given object.

Returns

\midcom_core_querybuilder

The initialized instance of the query builder or false on failure.

list_attachments()

list_attachments() : array<mixed,\midcom_db_attachment>

Returns a complete list of attachments for the current object. If there are no attachments, an empty array is returned.

Returns

array<mixed,\midcom_db_attachment> —

A list of attachments

get_privileges()

get_privileges() : array<mixed,\midcom_core_privilege>

Read all privilege records and return them accordingly.

You need privilege access to get this information (midgard:read (tested during construction) and midgard:privileges) otherwise, the call will fail.

Returns

array<mixed,\midcom_core_privilege> —

A list of privilege objects or false on failure.

set_privilege()

set_privilege(mixed  $privilege, mixed  $assignee = null, integer  $value = MIDCOM_PRIVILEGE_ALLOW, string  $classname = '') : boolean

Set a privilege on an object.

This requires both midgard:update and midgard:privileges.

You can either pass a ready made privilege record or a privilege/assignee/value combination suitable for usage with create_new_privilege_object() (see there).

Parameters

mixed $privilege

Either the full privilege object (midcom_core_privilege) to set or the name of the privilege (string). If the name was specified, the other parameters must be specified as well.

mixed $assignee

A valid assignee suitable for midcom_core_privilege::set_privilege(). This defaults to the currently active user if authenticated or to 'EVERYONE' otherwise (invalid if $privilege is a midcom_core_privilege).

integer $value

The privilege value, this defaults to MIDCOM_PRIVILEGE_ALLOW (invalid if $privilege is a midcom_core_privilege).

string $classname

An optional class name to which a SELF privilege gets restricted to. Only valid for SELF privileges (invalid if $privilege is a midcom_core_privilege).

Returns

boolean —

Indicating success.

unset_privilege()

unset_privilege(mixed  $privilege, mixed  $assignee = null, string  $classname = '') : boolean

Unset a privilege on an object (e.g. set it to INHERIT).

Parameters

mixed $privilege

Either the full privilege object (midcom_core_privilege) to set or the name of the privilege (string). If the name was specified, the other parameters must be specified as well.

mixed $assignee

A valid assignee suitable for midcom_core_privilege::set_privilege(). This defaults to the currently active user if authenticated or to 'EVERYONE' otherwise (invalid if $privilege is a midcom_core_privilege).

string $classname

An optional class name to which a SELF privilege gets restricted to. Only valid for SELF privileges (invalid if $privilege is a midcom_core_privilege).

Returns

boolean —

Indicating Success.

get_privilege()

get_privilege(string  $privilege, mixed  $assignee, string  $classname = '') : \midcom_core_privilege

Looks up a privilege by its parameters.

Parameters

string $privilege

The name of the privilege.

mixed $assignee

Either a valid magic assignee (SELF, EVERYONE, USERS, ANONYMOUS), a midcom_core_user or a midcom_core_group object or subtype thereof.

string $classname

An optional class name to which a SELF privilege is restricted to.

Returns

\midcom_core_privilege

The privilege record from the database.

unset_all_privileges()

unset_all_privileges() : boolean

Unsets all privileges

Returns

boolean —

Indicating success.

create_new_privilege_object()

create_new_privilege_object(string  $name, mixed  $assignee = null, integer  $value = MIDCOM_PRIVILEGE_ALLOW, string  $classname = '') : \midcom_core_privilege

Create a new privilege object. The privilege will be initialized with the values given in the arguments, as outlined below.

This call requires the midgard:privileges privilege.

Parameters

string $name

The name of the privilege to add.

mixed $assignee

A valid assignee suitable for midcom_core_privilege::set_privilege(). This defaults to the currently active user if authenticated or to 'EVERYONE' otherwise.

integer $value

The privilege value, this defaults to MIDCOM_PRIVILEGE_ALLOW.

string $classname

An optional class name to which a SELF privilege gets restricted to. Only valid for SELF privileges.

Returns

\midcom_core_privilege

The newly created privilege record or false on failure.

get_parent_guid_uncached()

get_parent_guid_uncached() 

get_parent_guid_uncached_static()

get_parent_guid_uncached_static(  $guid,   $classname = __CLASS__) : string

Returns the Parent of the Parameter.

Parameters

$guid
$classname

Returns

string —

Parent GUID or null if there is none.

get_by_objectguid()

get_by_objectguid(string  $objectguid, string  $domain, string  $name) 

Read a parameter without loading the corresponding object.

This is primarily for improving performance, so the function does not check for privileges.

Parameters

string $objectguid

The object's GUID

string $domain

The parameter's domain

string $name

The parameter to look for

get_label()

get_label() 

_delete_dependents()

_delete_dependents() 

list_parameters_domain()

list_parameters_domain(string  $domain) : array

List the parameters of a single domain of an object.

No event handlers are called here yet.

Parameters

string $domain

The parameter domain to query.

Returns

array —

Parameter listing.

list_parameters_all()

list_parameters_all() : array

List all parameters of an object.

No event handlers are called here yet.

Returns

array —

Parameter listing