api_bindings.php
Table of Contents
Functions
- api_do_search() : mixed
- api_search_get_previews() : mixed
- api_get_resource_field_data() : mixed
- api_create_resource() : mixed
- api_update_field() : mixed
- Provides simple way to update field by passing in simple string values for text fields, comma separated values for fixed list (node) fields, using double quotes to enclose strings and backslash as escape character Uses update_field and add_resource_nodes/delete_resource_nodes
- api_delete_resource() : mixed
- api_copy_resource() : mixed
- api_get_resource_log() : mixed
- api_update_resource_type() : mixed
- api_get_resource_path() : mixed
- {@see get_resource_path()}
- api_get_resource_data() : mixed
- api_put_resource_data() : mixed
- api_get_alternative_files() : mixed
- api_get_resource_types() : mixed
- api_add_alternative_file() : mixed
- api_delete_access_keys() : mixed
- api_delete_alternative_file() : mixed
- api_upload_file() : mixed
- api_upload_file_by_url() : mixed
- api_get_related_resources() : mixed
- api_get_field_options() : mixed
- api_get_nodes() : mixed
- api_get_user_collections() : mixed
- api_add_resource_to_collection() : mixed
- api_collection_add_resources() : mixed
- api_remove_resource_from_collection() : mixed
- api_collection_remove_resources() : mixed
- api_create_collection() : mixed
- api_delete_collection() : mixed
- api_search_public_collections() : mixed
- api_set_node() : mixed
- api_add_resource_nodes() : mixed
- api_add_resource_nodes_multi() : mixed
- api_resource_log_last_rows() : mixed
- api_get_resource_all_image_sizes() : mixed
- api_get_node_id() : mixed
- api_replace_resource_file() : mixed
- api_get_data_by_field() : bool|array<string|int, mixed>
- API binding to get_data_by_field function.
- api_get_resource_collections() : bool|array<string|int, mixed>
- API binding to modified get_resource_collections function, as we only want to pass collection ID, name, and description for security purposes.
- api_update_related_resource() : mixed
- api_get_collections_resource_count() : mixed
- api_get_users() : mixed
- api_save_collection() : mixed
- api_get_collection() : mixed
- api_send_user_message() : mixed
- api_get_profile_image() : mixed
- api_get_system_status() : mixed
- api_relate_all_resources() : mixed
- api_show_hide_collection() : mixed
- api_send_collection_to_admin() : mixed
- api_reorder_featured_collections() : mixed
- api_get_dash_search_data() : mixed
- api_reorder_tabs() : mixed
- api_delete_tabs() : mixed
- api_save_tab() : mixed
- api_mark_email_as_invalid() : mixed
- api_get_user_message() : mixed
- api_get_users_by_permission() : mixed
- api_upload_multipart() : array<string|int, mixed>
- Upload files using HTTP multipart.
- api_get_resource_type_fields() : array<string|int, mixed>
- Get metadata field information for all (matching) fields.
- api_create_resource_type_field() : array<string|int, mixed>
- Create metadata field
- api_get_featured_collections() : array<string|int, mixed>
- Expose {@see get_featured_collections} to the API
- api_get_edit_access() : bool
- api_toggle_active_state_for_nodes() : array<string|int, mixed>
- Toggle active state for nodes
- api_get_processing_message() : false|array<string|int, mixed>
- Expose {@see get_processing_message} to the API
- api_checkperm() : bool
- Expose {@see checkperm} to the API
- api_get_resource_access() : false|int
- Expose {@see get_resource_access} to the API
- api_resource_file_readonly() : array<string|int, mixed>
- Exposing {@see resource_file_readonly} to the API
- api_delete_resources_in_collection() : bool
- Exposing {@see delete_resources_in_collection} to the API
- api_new_user() : array<string|int, mixed>
- Exposing {@see new_user} to the API
- api_save_user() : array<string|int, mixed>
- Exposing {@see save_user} to the API
- api_get_resource_comments() : array<string|int, mixed>
- Make resource comments available to the API.
- api_delete_comment() : bool
- Allow comment to be deleted via the API.
- api_get_reports() : array<string|int, mixed>
- Return a list of reports using the API.
- api_do_report() : array<string|int, mixed>|bool
- Run report via the API.
Functions
api_do_search()
api_do_search(mixed $search[, mixed $restypes = "" ][, mixed $order_by = "relevance" ][, mixed $archive = 0 ][, mixed $fetchrows = -1 ][, mixed $sort = "desc" ][, mixed $offset = 0 ]) : mixed
Parameters
- $search : mixed
- $restypes : mixed = ""
- $order_by : mixed = "relevance"
- $archive : mixed = 0
- $fetchrows : mixed = -1
- $sort : mixed = "desc"
- $offset : mixed = 0
api_search_get_previews()
api_search_get_previews(mixed $search[, mixed $restypes = "" ][, mixed $order_by = "relevance" ][, mixed $archive = 0 ][, mixed $fetchrows = -1 ][, mixed $sort = "desc" ][, mixed $recent_search_daylimit = "" ][, mixed $getsizes = "" ][, mixed $previewext = "jpg" ]) : mixed
Parameters
- $search : mixed
- $restypes : mixed = ""
- $order_by : mixed = "relevance"
- $archive : mixed = 0
- $fetchrows : mixed = -1
- $sort : mixed = "desc"
- $recent_search_daylimit : mixed = ""
- $getsizes : mixed = ""
- $previewext : mixed = "jpg"
api_get_resource_field_data()
api_get_resource_field_data(mixed $resource) : mixed
Parameters
- $resource : mixed
api_create_resource()
api_create_resource(mixed $resource_type[, mixed $archive = 999 ][, mixed $url = "" ][, mixed $no_exif = false ][, mixed $revert = false ][, mixed $autorotate = false ][, mixed $metadata = "" ]) : mixed
Parameters
- $resource_type : mixed
- $archive : mixed = 999
- $url : mixed = ""
- $no_exif : mixed = false
- $revert : mixed = false
- $autorotate : mixed = false
- $metadata : mixed = ""
api_update_field()
Provides simple way to update field by passing in simple string values for text fields, comma separated values for fixed list (node) fields, using double quotes to enclose strings and backslash as escape character Uses update_field and add_resource_nodes/delete_resource_nodes
api_update_field(mixed $resource, mixed $field, mixed $value[, mixed $nodevalues = false ]) : mixed
Parameters
- $resource : mixed
- $field : mixed
- $value : mixed
- $nodevalues : mixed = false
api_delete_resource()
api_delete_resource(mixed $resource) : mixed
Parameters
- $resource : mixed
api_copy_resource()
api_copy_resource(mixed $from[, mixed $resource_type = -1 ]) : mixed
Parameters
- $from : mixed
- $resource_type : mixed = -1
api_get_resource_log()
api_get_resource_log(mixed $resource[, mixed $fetchrows = -1 ]) : mixed
Parameters
- $resource : mixed
- $fetchrows : mixed = -1
api_update_resource_type()
api_update_resource_type(mixed $resource, mixed $type) : mixed
Parameters
- $resource : mixed
- $type : mixed
api_get_resource_path()
{@see get_resource_path()}
api_get_resource_path(mixed $ref[, mixed $not_used = null ][, mixed $size = "" ][, mixed $generate = true ][, mixed $extension = "jpg" ][, mixed $page = 1 ][, mixed $watermarked = false ][, mixed $alternative = -1 ][, bool $write_metadata = false ]) : mixed
Parameters
- $ref : mixed
- $not_used : mixed = null
- $size : mixed = ""
- $generate : mixed = true
- $extension : mixed = "jpg"
- $page : mixed = 1
- $watermarked : mixed = false
- $alternative : mixed = -1
- $write_metadata : bool = false
-
Specify if embedded metadata should be written to the requested file (if applicable).
api_get_resource_data()
api_get_resource_data(mixed $resource) : mixed
Parameters
- $resource : mixed
api_put_resource_data()
api_put_resource_data(mixed $resource, array<string|int, mixed> $data) : mixed
Parameters
- $resource : mixed
- $data : array<string|int, mixed>
api_get_alternative_files()
api_get_alternative_files(mixed $resource[, mixed $order_by = "" ][, mixed $sort = "" ][, mixed $type = "" ]) : mixed
Parameters
- $resource : mixed
- $order_by : mixed = ""
- $sort : mixed = ""
- $type : mixed = ""
api_get_resource_types()
api_get_resource_types() : mixed
api_add_alternative_file()
api_add_alternative_file(mixed $resource, mixed $name[, mixed $description = '' ][, mixed $file_name = '' ][, mixed $file_extension = '' ][, mixed $file_size = 0 ][, mixed $alt_type = '' ][, mixed $file = '' ]) : mixed
Parameters
- $resource : mixed
- $name : mixed
- $description : mixed = ''
- $file_name : mixed = ''
- $file_extension : mixed = ''
- $file_size : mixed = 0
- $alt_type : mixed = ''
- $file : mixed = ''
api_delete_access_keys()
api_delete_access_keys(mixed $access_keys, mixed $resources, mixed $collections) : mixed
Parameters
- $access_keys : mixed
- $resources : mixed
- $collections : mixed
api_delete_alternative_file()
api_delete_alternative_file(mixed $resource, mixed $ref) : mixed
Parameters
- $resource : mixed
- $ref : mixed
api_upload_file()
api_upload_file(mixed $ref[, mixed $no_exif = false ][, mixed $revert = false ][, mixed $autorotate = false ][, mixed $file_path = "" ]) : mixed
Parameters
- $ref : mixed
- $no_exif : mixed = false
- $revert : mixed = false
- $autorotate : mixed = false
- $file_path : mixed = ""
api_upload_file_by_url()
api_upload_file_by_url(mixed $ref[, mixed $no_exif = false ][, mixed $revert = false ][, mixed $autorotate = false ][, mixed $url = "" ]) : mixed
Parameters
- $ref : mixed
- $no_exif : mixed = false
- $revert : mixed = false
- $autorotate : mixed = false
- $url : mixed = ""
api_get_related_resources()
api_get_related_resources(mixed $ref) : mixed
Parameters
- $ref : mixed
api_get_field_options()
api_get_field_options(mixed $ref[, mixed $nodeinfo = false ]) : mixed
Parameters
- $ref : mixed
- $nodeinfo : mixed = false
api_get_nodes()
api_get_nodes(mixed $ref[, mixed $parent = null ][, mixed $recursive = false ][, mixed $offset = null ][, mixed $rows = null ][, mixed $name = "" ][, mixed $use_count = false ][, mixed $order_by_translated_name = false ]) : mixed
Parameters
- $ref : mixed
- $parent : mixed = null
- $recursive : mixed = false
- $offset : mixed = null
- $rows : mixed = null
- $name : mixed = ""
- $use_count : mixed = false
- $order_by_translated_name : mixed = false
api_get_user_collections()
api_get_user_collections() : mixed
api_add_resource_to_collection()
api_add_resource_to_collection(mixed $resource[, mixed $collection = '' ][, mixed $search = '' ]) : mixed
Parameters
- $resource : mixed
- $collection : mixed = ''
- $search : mixed = ''
api_collection_add_resources()
api_collection_add_resources([mixed $collection = '' ][, mixed $resources = '' ][, mixed $search = '' ][, mixed $selected = false ]) : mixed
Parameters
- $collection : mixed = ''
- $resources : mixed = ''
- $search : mixed = ''
- $selected : mixed = false
api_remove_resource_from_collection()
api_remove_resource_from_collection(mixed $resource[, mixed $collection = '' ]) : mixed
Parameters
- $resource : mixed
- $collection : mixed = ''
api_collection_remove_resources()
api_collection_remove_resources([mixed $collection = '' ][, mixed $resources = '' ][, mixed $removeall = false ][, mixed $selected = false ]) : mixed
Parameters
- $collection : mixed = ''
- $resources : mixed = ''
- $removeall : mixed = false
- $selected : mixed = false
api_create_collection()
api_create_collection(mixed $name[, mixed $forupload = false ]) : mixed
Parameters
- $name : mixed
- $forupload : mixed = false
api_delete_collection()
api_delete_collection(mixed $ref) : mixed
Parameters
- $ref : mixed
api_search_public_collections()
api_search_public_collections([mixed $search = "" ][, mixed $order_by = "name" ][, mixed $sort = "ASC" ][, mixed $exclude_themes = true ][, mixed $exclude_public = false ]) : mixed
Parameters
- $search : mixed = ""
- $order_by : mixed = "name"
- $sort : mixed = "ASC"
- $exclude_themes : mixed = true
- $exclude_public : mixed = false
api_set_node()
api_set_node(mixed $ref, mixed $resource_type_field, mixed $name[, mixed $parent = '' ][, mixed $order_by = 0 ][, mixed $returnexisting = false ]) : mixed
Parameters
- $ref : mixed
- $resource_type_field : mixed
- $name : mixed
- $parent : mixed = ''
- $order_by : mixed = 0
- $returnexisting : mixed = false
api_add_resource_nodes()
api_add_resource_nodes(mixed $resource, mixed $nodestring) : mixed
Parameters
- $resource : mixed
- $nodestring : mixed
api_add_resource_nodes_multi()
api_add_resource_nodes_multi(mixed $resources, mixed $nodestring) : mixed
Parameters
- $resources : mixed
- $nodestring : mixed
api_resource_log_last_rows()
api_resource_log_last_rows([mixed $minref = 0 ][, mixed $days = 7 ][, mixed $maxrecords = 0 ][, string $field = '' ][, string $log_code = '' ]) : mixed
Parameters
- $minref : mixed = 0
- $days : mixed = 7
- $maxrecords : mixed = 0
- $field : string = ''
- $log_code : string = ''
api_get_resource_all_image_sizes()
api_get_resource_all_image_sizes(mixed $resource) : mixed
Parameters
- $resource : mixed
api_get_node_id()
api_get_node_id(mixed $value, mixed $resource_type_field) : mixed
Parameters
- $value : mixed
- $resource_type_field : mixed
api_replace_resource_file()
api_replace_resource_file(mixed $ref, mixed $file_location[, mixed $no_exif = false ][, mixed $autorotate = false ][, mixed $keep_original = true ]) : mixed
Parameters
- $ref : mixed
- $file_location : mixed
- $no_exif : mixed = false
- $autorotate : mixed = false
- $keep_original : mixed = true
api_get_data_by_field()
API binding to get_data_by_field function.
api_get_data_by_field(int $ref, int $field) : bool|array<string|int, mixed>
Parameters
- $ref : int
-
Resource ref
- $field : int
-
Resource type field ref
Return values
bool|array<string|int, mixed>api_get_resource_collections()
API binding to modified get_resource_collections function, as we only want to pass collection ID, name, and description for security purposes.
api_get_resource_collections(int $ref) : bool|array<string|int, mixed>
Parameters
- $ref : int
-
Resource ref
Return values
bool|array<string|int, mixed>api_update_related_resource()
api_update_related_resource(mixed $ref, mixed $related[, mixed $add = 1 ]) : mixed
Parameters
- $ref : mixed
- $related : mixed
- $add : mixed = 1
api_get_collections_resource_count()
api_get_collections_resource_count(string $refs) : mixed
Parameters
- $refs : string
api_get_users()
api_get_users([mixed $find = "" ][, mixed $exact_username_match = false ]) : mixed
Parameters
- $find : mixed = ""
- $exact_username_match : mixed = false
api_save_collection()
api_save_collection(int $ref, array<string|int, mixed> $coldata) : mixed
Parameters
- $ref : int
- $coldata : array<string|int, mixed>
api_get_collection()
api_get_collection(int $ref) : mixed
Parameters
- $ref : int
api_send_user_message()
api_send_user_message(mixed $users, mixed $text) : mixed
Parameters
- $users : mixed
- $text : mixed
api_get_profile_image()
api_get_profile_image(mixed $user) : mixed
Parameters
- $user : mixed
api_get_system_status()
api_get_system_status([mixed $basic = false ]) : mixed
Parameters
- $basic : mixed = false
api_relate_all_resources()
api_relate_all_resources(mixed $related) : mixed
Parameters
- $related : mixed
api_show_hide_collection()
api_show_hide_collection(mixed $collection, mixed $show, mixed $user) : mixed
Parameters
- $collection : mixed
- $show : mixed
- $user : mixed
api_send_collection_to_admin()
api_send_collection_to_admin(mixed $collection) : mixed
Parameters
- $collection : mixed
api_reorder_featured_collections()
api_reorder_featured_collections(mixed $refs) : mixed
Parameters
- $refs : mixed
api_get_dash_search_data()
api_get_dash_search_data(mixed $link, mixed $promimg) : mixed
Parameters
- $link : mixed
- $promimg : mixed
api_reorder_tabs()
api_reorder_tabs(mixed $refs) : mixed
Parameters
- $refs : mixed
api_delete_tabs()
api_delete_tabs(mixed $refs) : mixed
Parameters
- $refs : mixed
api_save_tab()
api_save_tab(mixed $tab) : mixed
Parameters
- $tab : mixed
api_mark_email_as_invalid()
api_mark_email_as_invalid(mixed $email) : mixed
Parameters
- $email : mixed
api_get_user_message()
api_get_user_message(mixed $ref) : mixed
Parameters
- $ref : mixed
api_get_users_by_permission()
api_get_users_by_permission(mixed $permissions) : mixed
Parameters
- $permissions : mixed
api_upload_multipart()
Upload files using HTTP multipart.
api_upload_multipart(int $ref, bool $no_exif, bool $revert[, bool $previewonly = false ][, int $alternative = 0 ][, bool $autorotate = false ]) : array<string|int, mixed>
Parameters
- $ref : int
-
Resource ID
- $no_exif : bool
-
Do not extract embedded metadata
- $revert : bool
-
Delete all data and re-extract embedded data
- $previewonly : bool = false
-
Will use the uploaded file to replace preview image only
- $alternative : int = 0
-
Use the uploaded file to replace the alternative file with the given ID Note that api_add_alternative_file() must be called first if creating a new alternative file If an $alternative identifier is specified then $previewonly is ignored and set to false
- $autorotate : bool = false
-
Automatically rotate (correct) images
Return values
array<string|int, mixed> —Returns JSend data back ajax_functions.php if upload failed, otherwise 204 HTTP status
api_get_resource_type_fields()
Get metadata field information for all (matching) fields.
api_get_resource_type_fields([string $by_resource_types = '' ][, string $find = '' ][, string $by_types = '' ]) : array<string|int, mixed>
Parameters
- $by_resource_types : string = ''
-
Filter result by resource type. If multiple, use a CSV of resource types.
- $find : string = ''
-
Filter result by fuzzy searching in different properties (e.g name, title, ref, help text etc)
- $by_types : string = ''
-
Filter result by field type (FIELD_TYPE_* constants). If multiple, use a CSV of field types.
Return values
array<string|int, mixed> —Returns the matching fields' information or 403 HTTP status if not authorised
api_create_resource_type_field()
Create metadata field
api_create_resource_type_field(string $name, string $resource_types, int $type) : array<string|int, mixed>
Parameters
- $name : string
-
Field name
- $resource_types : string
-
CSV of applicable resource types for this field. Use 0 (zero) for global, for others \API
- $type : int
-
Metadata field type. For values, FIELD_TYPE_* constants
Return values
array<string|int, mixed> —Returns JSend data back ajax_functions.php and 200 HTTP status or 403 HTTP status if not authorised
api_get_featured_collections()
Expose {@see get_featured_collections} to the API
api_get_featured_collections(int $parent) : array<string|int, mixed>
Parameters
- $parent : int
-
The feature collection parent's ref. Use 0 for obtaining the root ones.
Return values
array<string|int, mixed>api_get_edit_access()
api_get_edit_access(int $resource) : bool
Parameters
- $resource : int
Return values
boolapi_toggle_active_state_for_nodes()
Toggle active state for nodes
api_toggle_active_state_for_nodes(array<string|int, mixed> $refs) : array<string|int, mixed>
Parameters
- $refs : array<string|int, mixed>
-
List of node IDs
Tags
Return values
array<string|int, mixed> —Returns the affected nodes' active state (including empty list) and 403 HTTP status if not authorised.
api_get_processing_message()
Expose {@see get_processing_message} to the API
api_get_processing_message() : false|array<string|int, mixed>
Return values
false|array<string|int, mixed>api_checkperm()
Expose {@see checkperm} to the API
api_checkperm(string $perm) : bool
Parameters
- $perm : string
-
The permissions string to check for.
Return values
boolapi_get_resource_access()
Expose {@see get_resource_access} to the API
api_get_resource_access(int $resource) : false|int
Parameters
- $resource : int
-
The reference ID of the resource.
Return values
false|int —The access level for the resource, or false if a number was not supplied.
api_resource_file_readonly()
Exposing {@see resource_file_readonly} to the API
api_resource_file_readonly(int|numeric-string $ref) : array<string|int, mixed>
Parameters
- $ref : int|numeric-string
-
Resource ID
Tags
Return values
array<string|int, mixed>api_delete_resources_in_collection()
Exposing {@see delete_resources_in_collection} to the API
api_delete_resources_in_collection(int $collection) : bool
Parameters
- $collection : int
-
ID of collection containing resources to be deleted.
Return values
boolapi_new_user()
Exposing {@see new_user} to the API
api_new_user(string $username[, int $usergroup = 0 ]) : array<string|int, mixed>
Parameters
- $username : string
-
- username to create
- $usergroup : int = 0
-
- optional usergroup to assign
Return values
array<string|int, mixed> —Returns JSend data back ajax_functions.php with the ref value (id of new user or false if user already exists / permission denied, or -2 if user limit reached) and 200 HTTP status or 409 HTTP status if an issue is detected.
api_save_user()
Exposing {@see save_user} to the API
api_save_user(string $ref, string $data) : array<string|int, mixed>
Parameters
- $ref : string
-
ID of the user
- $data : string
-
Data to save in JSON format (optional, will use posted data otherwise)
Return values
array<string|int, mixed> —Returns JSend data back ajax_functions.php and 200 HTTP status or 409 HTTP status with reason in the response
api_get_resource_comments()
Make resource comments available to the API.
api_get_resource_comments(int $resource_ref[, bool $flat_view = false ]) : array<string|int, mixed>
Parameters
- $resource_ref : int
-
ID of resource to get comments for.
- $flat_view : bool = false
-
Provide comments as nested tree view (this is the default mode) or a flat list most recent first. See config: $comments_flat_view
Return values
array<string|int, mixed> —Array of resource comment data. Array will be empty if comments are not enabled on the system or user has insufficient permissions to view comments.
api_delete_comment()
Allow comment to be deleted via the API.
api_delete_comment(int $comment_ref) : bool
Not for comments linked to annotations.
Parameters
- $comment_ref : int
-
ID of the comment to be deleted.
Return values
bool —False if comments are not enabled on the system, user has insufficient permissions or the comment being deleted is linked to an annotation - this will delete only standard comments.
api_get_reports()
Return a list of reports using the API.
api_get_reports() : array<string|int, mixed>
Return values
array<string|int, mixed> —Reports (name and ID) ordered by name asc. The array will be empty if user has insufficient permissions.
api_do_report()
Run report via the API.
api_do_report(int $report_ref[, string $from_date = '' ][, string $to_date = '' ]) : array<string|int, mixed>|bool
Where report includes a "thumbnail" column which would normally display an image on the report, the thumbnail key will contain a base64 encoded thumbnail image in jpg format. A "thumbnail_view_link" key will also be added containing a link to the resource.
Parameters
- $report_ref : int
-
ID of the report to run.
- $from_date : string = ''
-
Start date for the report period in format YYYY-MM-DD.
- Optional here - not all reports use a date range but some may need it. Check report SQL. If not set $from_date will default to 7 days ago as when running a report in RS.
- $to_date : string = ''
-
End date for the report period in format YYYY-MM-DD.
- Optional here - not all reports use a date range but some may need it. Check report SQL. If not set $to_date will default to today as when running a report in RS.
Return values
array<string|int, mixed>|bool —Array of report data on success or false if user has insufficient permissions or there was an input error.