Documentation

license_functions.php

Table of Contents

Functions

licensemanager_check_read()  : bool
Check if the user should have read access to a license record
licensemanager_check_write()  : bool
Check if the user should have write access to a license record
licensemanager_get_licenses()  : array<string|int, mixed>|bool
Get a list of licenses for a given resource
licensemanager_delete_license()  : bool
Delete a license record
licensemanager_link_license()  : bool
Link a license record with a resource
licensemanager_get_license()  : array<string|int, mixed>|bool
Retrieve a license record
licensemanager_get_all_licenses()  : array<string|int, mixed>|bool
Fetch all license records, optionally filtered by search text
licensemanager_get_all_licenses_grouped()  : array<string|int, mixed>|bool
Fetch all license records grouped by if they are expiring or not
licensemanager_get_expiring_licenses()  : array<string|int, mixed>|bool
Fetch all expiring license records
licensemanager_set_license_expiration_notice()  : bool
Sets expiration notice sent flag on license records
licensemanager_get_expired_license_resources()  : array<string|int, mixed>|bool
Fetch expired license records
licensemanager_process_expiry_notifications()  : bool
Process expiring license records and send a notification/email
licensemanager_process_expired_auto_archive()  : bool
Process expired license records and archive them

Functions

licensemanager_check_read()

Check if the user should have read access to a license record

licensemanager_check_read([int|null $resource = null ]) : bool

Determines if the user has read access for a specific resource or general read permissions.

Parameters
$resource : int|null = null

The ID of the resource to check read access for. If null, checks for general read permissions.

Return values
bool

Returns true if the user has the required permissions; false otherwise.

licensemanager_check_write()

Check if the user should have write access to a license record

licensemanager_check_write([int|null $resource = null ]) : bool

Determines if the user has write access for a specific resource or general write permissions.

Parameters
$resource : int|null = null

The ID of the resource to check write access for. If null, checks for general write permissions.

Return values
bool

Returns true if the user has the required permissions; false otherwise.

licensemanager_get_licenses()

Get a list of licenses for a given resource

licensemanager_get_licenses(int $resource) : array<string|int, mixed>|bool

This function retrieves a list of license records associated with a specified resource. Each record includes the license details, expiration date, and consent usage.

Parameters
$resource : int

The ID of the resource for which to retrieve associated licenses.

Return values
array<string|int, mixed>|bool

Returns an array of licenses associated with the resource if the user has read access; otherwise, returns false.

licensemanager_delete_license()

Delete a license record

licensemanager_delete_license(int $ref) : bool

This function deletes a license record and its associations with resources by removing entries from the license and resource_license tables.

Parameters
$ref : int

The ID of the license record to be deleted.

Return values
bool

Returns true if the license record was successfully deleted, or false if the user does not have write access to the resource.

Link a license record with a resource

licensemanager_link_license(int $license, int $resource) : bool

This function links a license record to a specified resource by inserting an entry in the resource_license table. It also logs this action in the resource's log.

Parameters
$license : int

The ID of the license record to be linked to the resource.

$resource : int

The ID of the resource to which the license is being linked.

Return values
bool

Returns true if the license was successfully linked, false if the user does not have write access to the resource.

licensemanager_get_license()

Retrieve a license record

licensemanager_get_license(int $license) : array<string|int, mixed>|bool

This function retrieves the details of a specified license record It also fetches a list of resources associated with the license.

Parameters
$license : int

The ID of the license record to fetch.

Return values
array<string|int, mixed>|bool

Returns an associative array containing license details and associated resources if the user has read access; returns false if access is denied or the license record does not exist.

licensemanager_get_all_licenses()

Fetch all license records, optionally filtered by search text

licensemanager_get_all_licenses([string $findtext = "" ][, string $license_status = "all" ]) : array<string|int, mixed>|bool

This function retrieves all license records from the database. If a search string is provided, it filters the results based on licensor/licensee/medium/description It can also filter based on license status e.g all, active (non-expired), expiring (expiring within a configured amount of days), expired. Defaults to returning all.

Parameters
$findtext : string = ""

Optional. A search string to filter the results by the licensor/licensee/medium/description of the license. If empty, returns all records.

$license_status : string = "all"

Status of license records to return

Return values
array<string|int, mixed>|bool

Returns an array of license records if the user has read access; otherwise, returns false.

licensemanager_get_all_licenses_grouped()

Fetch all license records grouped by if they are expiring or not

licensemanager_get_all_licenses_grouped() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|bool

Returns an array of license records if the user has read access; otherwise, returns false.

licensemanager_get_expiring_licenses()

Fetch all expiring license records

licensemanager_get_expiring_licenses(int $expires_within[, bool $unsent_only = true ]) : array<string|int, mixed>|bool

This function returns an array of license records that are expiring within so many days. It can optionally be filtered to include records that have not been flagged as having an expiration notification already sent

Parameters
$expires_within : int

Number of days that the records are expiring within

$unsent_only : bool = true

Include only records where an expiration notification hasn't been sent

Return values
array<string|int, mixed>|bool

Returns an array of expiring license records if the user has read access; otherwise, returns false.

licensemanager_set_license_expiration_notice()

Sets expiration notice sent flag on license records

licensemanager_set_license_expiration_notice(array<string|int, mixed> $licenses) : bool

This function takes an array of license record references and sets the expiration_notice_sent flag on each one.

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

An array of license references

Return values
bool

Returns true if the flags were set; otherwise, returns false

licensemanager_get_expired_license_resources()

Fetch expired license records

licensemanager_get_expired_license_resources(int $archive_status) : array<string|int, mixed>|bool

This function returns expired license records that are not deleted and are not in the passed archive_state

Parameters
$archive_status : int
Return values
array<string|int, mixed>|bool

Returns an array of expired license records; otherwise, returns false.

licensemanager_process_expiry_notifications()

Process expiring license records and send a notification/email

licensemanager_process_expiry_notifications() : bool
Return values
bool

Returns true if the notification process completes

licensemanager_process_expired_auto_archive()

Process expired license records and archive them

licensemanager_process_expired_auto_archive() : bool
Return values
bool

Returns true if the auto archiving process completes

On this page

Search results