Documentation

request_functions.php

Table of Contents

Functions

get_request()  : mixed
Retrieve a resource request record
get_user_requests()  : mixed
Fetch a list of all requests for a user
save_request()  : bool
Handle the posted request form, when saving a request in the admin area.
get_requests()  : mixed
Fetch a list of requests assigned to the logged in user
email_collection_request()  : bool
Email a collection request to the team responsible for dealing with requests. Request mode 0 only (non managed).
managed_collection_request()  : bool
Request mode 1 - quests are managed via the administrative interface. Sends an e-mail but also logs the request in the request table.
email_resource_request()  : void|false|string
E-mails a basic resource request for a single resource (posted) to the team (not a managed request)
get_valid_custom_fields()  : array<string|int, mixed>
Get collection of valid custom fields. A valid fields has at least the expected field properties
gen_custom_fields_html_props()  : array<string|int, mixed>
Generate HTML properties for custom fields. These properties can then be used by other functions like render_custom_fields or process_custom_fields_submission
process_custom_fields_submission()  : array<string|int, mixed>
Process posted custom fields
can_use_owner_field()  : bool
Initialisation and system check if configuration is correctly enabled to use the owner field and mappings logic.
get_notification_users_by_owner_field()  : array<string|int, mixed>
Get users to notify for requested resources "owned" by particular groups. Configurable using a metadata field ($owner_field) and a defined map ($owner_field_mappings).
resource_request_visible()  : bool
Can the logged in user see the request specified?

Functions

get_request()

Retrieve a resource request record

get_request(int $request) : mixed
Parameters
$request : int

The request record ID

Return values
mixed

False if not found, the resource record (associative array) if found

get_user_requests()

Fetch a list of all requests for a user

get_user_requests([bool $excludecompleted = false ][, bool $returnsql = false ]) : mixed
Parameters
$excludecompleted : bool = false

Exclude requests that have already been completed

$returnsql : bool = false

Return the SQL for the execution rather than the results

save_request()

Handle the posted request form, when saving a request in the admin area.

save_request(int $request) : bool
Parameters
$request : int

The request record ID

Return values
bool

Was this successful?

get_requests()

Fetch a list of requests assigned to the logged in user

get_requests([bool $excludecompleted = false ][, bool $excludeassigned = false ][, bool $returnsql = false ]) : mixed
Parameters
$excludecompleted : bool = false

Exclude completed requests?

$excludeassigned : bool = false

Exclude assigned requests? (e.g. if the user is able to assign unassigned requests) unless assigned to the logged in user

$returnsql : bool = false

Return SQL query object instead of the results?

Return values
mixed

Resulting array of requests or an SQL query object

email_collection_request()

Email a collection request to the team responsible for dealing with requests. Request mode 0 only (non managed).

email_collection_request(int $ref, mixed $details, mixed $external_email) : bool
Parameters
$ref : int
$details : mixed
$external_email : mixed
Return values
bool

managed_collection_request()

Request mode 1 - quests are managed via the administrative interface. Sends an e-mail but also logs the request in the request table.

managed_collection_request(mixed $ref, mixed $details[, mixed $ref_is_resource = false ]) : bool
Parameters
$ref : mixed
$details : mixed
$ref_is_resource : mixed = false
Return values
bool

email_resource_request()

E-mails a basic resource request for a single resource (posted) to the team (not a managed request)

email_resource_request(mixed $ref, mixed $details) : void|false|string
Parameters
$ref : mixed

The resource ID

$details : mixed

The request details provided by the user

Return values
void|false|string

get_valid_custom_fields()

Get collection of valid custom fields. A valid fields has at least the expected field properties

get_valid_custom_fields(array<string|int, mixed> $fields) : array<string|int, mixed>

IMPORTANT: these fields are not metadata fields - they are configured through config options such as custom_researchrequest_fields

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

List of custom fields. Often this will simply be the global configuration option (e.g custom_researchrequest_fields)

Return values
array<string|int, mixed>

gen_custom_fields_html_props()

Generate HTML properties for custom fields. These properties can then be used by other functions like render_custom_fields or process_custom_fields_submission

gen_custom_fields_html_props(array<string|int, mixed> $fields, array<string|int, mixed> $ctx) : array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

List of custom fields as returned by get_valid_custom_fields(). Note: At this point code assumes fields have been validated

$ctx : array<string|int, mixed>

Contextual information for process_custom_fields_submission()

Return values
array<string|int, mixed>

Returns collection items with the extra "html_properties" key

process_custom_fields_submission()

Process posted custom fields

process_custom_fields_submission(array<string|int, mixed> $fields, bool $submitted, array<string|int, mixed> $ctx) : array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

List of custom fields

$submitted : bool

Processing submitted fields?

$ctx : array<string|int, mixed>

Contextual information (e.g. change the prefix for html tags' identifiers)

Return values
array<string|int, mixed>

Returns collection of items with the extra "html_properties" key

can_use_owner_field()

Initialisation and system check if configuration is correctly enabled to use the owner field and mappings logic.

can_use_owner_field() : bool

IMPORTANT: during init the globals $owner_field & $owner_field_mappings values will be updated for validation purposes

Return values
bool

Return true if the system is configured with a valid $owner_field and numeric $owner_field_mappings, false otherwise.

get_notification_users_by_owner_field()

Get users to notify for requested resources "owned" by particular groups. Configurable using a metadata field ($owner_field) and a defined map ($owner_field_mappings).

get_notification_users_by_owner_field(array<string|int, mixed> $users, array<string|int, mixed> $resources) : array<string|int, mixed>
Parameters
$users : array<string|int, mixed>

List of notification users get_notification_users(). Any array structure where each value contains an array with at least a "ref" and "email" keys.

$resources : array<string|int, mixed>

List of resource IDs

Return values
array<string|int, mixed>

Returns user ID (key) and email (value)

resource_request_visible()

Can the logged in user see the request specified?

resource_request_visible(array<string|int, mixed> $request) : bool
Parameters
$request : array<string|int, mixed>

Array of request details

Return values
bool
On this page

Search results