Documentation

museumplus_functions.php

Table of Contents

Functions

do_http_request()  : array<string|int, mixed>
Execute a cURL request
mplus_get_connection_data()  : array<string|int, mixed>
Helper function to ensure required connection data was provided
mplus_notify()  : bool
Send notifications to users regarding MuseumPlus events (e.g script failed)
mplus_generate_module_record_url()  : string
Generate a MuseumPlus URL for any module records without having to know the form name
mplus_save_module_config()  : void
Save MuseumPlus modules configuration
mplus_get_associated_module_conf()  : array<string|int, mixed>
For a list of resources, obtain the associated modules' configuration.
mplus_get_cfg_by_module_name()  : array<string|int, mixed>
Find the module configuration using the module name.
mplus_validate_association()  : array<string|int, mixed>
Validate a modules' record ID (technical or virtual)
mplus_flip_struct_by_module()  : array<string|int, mixed>
Transpose a resource associated module config array to one ready to be used for batch searching via MuseumPlus API.
mplus_compute_data_md5()  : array<string|int, mixed>
Compute the MD5 hash for the association between a resource and the combination of "module name - MpID (virtual or technical).
mplus_log_event()  : void
Log events related to MuseumPlus integration. Any information that can be useful (even a user trying to save a resource)
mplus_validate_resource_association_filters()  : array<string|int, mixed>
Validate a list of filter names that can be used by {@see mplus_resource_get_association_data()}.

Functions

do_http_request()

Execute a cURL request

do_http_request(string $url, string $basic_auth, string $content_type, string $request_method, string $data) : array<string|int, mixed>
Parameters
$url : string

URL

$basic_auth : string

Username and password used for basic authentication. MUST follow the "username:password" syntax to work!

$content_type : string

Content type header value (e.g application/xml)

$request_method : string

HTTP request methods (e.g GET, POST, PUT, DELETE)

$data : string

Posted data (e.g XML)

Return values
array<string|int, mixed>

Response information such status code (e.g 200), headers and actual body

mplus_get_connection_data()

Helper function to ensure required connection data was provided

mplus_get_connection_data() : array<string|int, mixed>
Tags
see
http://docs.zetcom.com/ws/
Return values
array<string|int, mixed>

mplus_notify()

Send notifications to users regarding MuseumPlus events (e.g script failed)

mplus_notify(array<string|int, mixed> $users, string $message) : bool
Parameters
$users : array<string|int, mixed>

List of users' IDs

$message : string

Notification message

Tags
uses
message_add()
Return values
bool

TRUE on success FALSE on failure

mplus_generate_module_record_url()

Generate a MuseumPlus URL for any module records without having to know the form name

mplus_generate_module_record_url(string $module, int $id) : string
Parameters
$module : string

Module name

$id : int

Module record technical (internal) ID

Return values
string

Returns the generated URL or empty string on failure

mplus_save_module_config()

Save MuseumPlus modules configuration

mplus_save_module_config(array<string|int, mixed> $cf) : void
Parameters
$cf : array<string|int, mixed>

Modules configuration to save

mplus_get_associated_module_conf()

For a list of resources, obtain the associated modules' configuration.

mplus_get_associated_module_conf(array<string|int, mixed> $resource_refs, bool $with_values) : array<string|int, mixed>

IMPORTANT: make sure the return of this function is not exposed to the end user when called using the $with_values param.

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

List of resource IDs

$with_values : bool

Should associated module configurations include the RS metadata fields values (this applies to module configurations that are using a metadata field - e.g. rs_uid_field or the field mappings).

Return values
array<string|int, mixed>

The associated modules' configuration for each of the resources in the list -or- an empty array.

mplus_get_cfg_by_module_name()

Find the module configuration using the module name.

mplus_get_cfg_by_module_name(string $n) : array<string|int, mixed>
Parameters
$n : string

Module name to search by in the plugin configuration

Return values
array<string|int, mixed>

Returns the module configuration record found. @see $museumplus_modules_saved_config elements for the array structure

mplus_validate_association()

Validate a modules' record ID (technical or virtual)

mplus_validate_association(array<string|int, mixed> $ramc, bool $use_technical_id, bool $force) : array<string|int, mixed>
Parameters
$ramc : array<string|int, mixed>

Resources associated module configurations. mplus_get_associated_module_conf()

$use_technical_id : bool

Validate using the technical ID (ie __id) fieldPath.

$force : bool

Force re-validation even if association state is already known.

Return values
array<string|int, mixed>

Returns the valid resources that have a valid combination of "module name - MpID (virtual or technical)". IMPORTANT: Each returned resource associated module configuration will get mutated with an additional "__id" key which will always hold the technical ID of the module item "linked" to that resource - always use MPLUS_FIELD_ID constant to find this key. An optional "errors" key may be added to the return array to hold any errors the end user should be aware of.

mplus_flip_struct_by_module()

Transpose a resource associated module config array to one ready to be used for batch searching via MuseumPlus API.

mplus_flip_struct_by_module(array<string|int, mixed> $ramc) : array<string|int, mixed>

Utility function for validation & syncing.

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

Resources associated module configurations. mplus_get_associated_module_conf()

Return values
array<string|int, mixed>

Returns array structure where the key is the module name and value contains information useful for validation/syncing data from MuseumPlus

mplus_compute_data_md5()

Compute the MD5 hash for the association between a resource and the combination of "module name - MpID (virtual or technical).

mplus_compute_data_md5(array<string|int, mixed> $resources_data, string $module_name) : array<string|int, mixed>

Utility function which is used to save the data in the resource table, column "museumplus_data_md5" and used to determine if either of the data of interest (module name or MpID) have changed in order to revalidate the association.

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

Resources data array - key is the resource ref and value is the module item ID (virtual or technical). Example: [23 => '2423432', 24 => 'OB3223-N']

$module_name : string

Module name

Return values
array<string|int, mixed>

mplus_log_event()

Log events related to MuseumPlus integration. Any information that can be useful (even a user trying to save a resource)

mplus_log_event(string $msg[, array<string|int, mixed> $ctx = array() ][, string $lvl = 'info' ]) : void
Parameters
$msg : string

Log message. Max size 255 characters.

$ctx : array<string|int, mixed> = array()

Contextual data relevant to the event. Try namespacing the data if needed using keys (e.g http_request - and then the body could contain different aspects: header, body, url etc.). IMPORTANT: make sure to never log sensitive information (e.g MuseumPlus authentication credentials)

$lvl : string = 'info'

Logging level (Options could be: Trace, Debug, Info, Warn, Error, Fatal). Max size 10 characters.

mplus_validate_resource_association_filters()

Validate a list of filter names that can be used by {@see mplus_resource_get_association_data()}.

mplus_validate_resource_association_filters(array<string|int, mixed> $f) : array<string|int, mixed>
Parameters
$f : array<string|int, mixed>

List of filters. Key is the filter name. The value of a filter is any data type required by that particular filters' parameter (e.g for "byref" filter, the input is a list of refs => array).

Return values
array<string|int, mixed>
On this page

Search results