Event HooksΒΆ

Event hooks allow studios to add custom code to predefined actions in NIM.

An example file nim_event_hooks.example is included on the NIM VM in the /var/www/html/_custom/event_hooks folder. Copy this file to nim_event_hooks.php in the same folder to use as a starting point for custom event hooks.

Important

This example file may be overwritten in subsequence NIM updates.

The data passed to this file comes through 2 POST variables:

action

A string value representing the unique action that was triggered

data

An array containing data available with the item(s) being affected

Tip

The data is returned as a json string. To decode the json string into a PHP object use json_decode()

In addition to the event hooks, the function nimAPI() is included to build context for internal api queries.

Example Event Hook:

This example shows how to use the nimAPI function included in this file to communicate internally with the nimAPI

if($action == "onShotUpdate"){
        error_log("nim_event_hooks: onShotUpdate");
        error_log(print_r($data, true));

        # Multiple Items Selected
        if (array_key_exists('shotIDs',$data)){
                foreach($data['shotIDs'] as $id) {
                        $result = nimAPI("q=getShotInfo&ID=".$id);
                        error_log($result);
                }
        }
        else {
                # Single Item Selected
                if (array_key_exists('ID',$data)){
                        $id = $data['ID'];
                        $result = nimAPI("q=getShotInfo&ID=".$id);
                        error_log($result);
                }
        }
}

List of available event hooks:

Event Hook

Description

JOBS

onJobCreate

Called when a job is added from the job list

onJobUpdate

Called when job information is edited from the job info panel, the job overview, or the job config panel

onJobDelete

Called when the job is deleted from the job list

onJobStatusChange

Called when the status of a job is changed

onJobPreOnline

Called when bring job online is triggered - prior to making folders

onJobPostOnline

Called when bring job online is triggered - after all job folders are created

USER

onUserCreate

Called when a user is created from the user list

onUserUpdate

Called when a user is updated in the user info panel

onUserDelete

Called when a user is deleted from the user list

JOB CREW

onJobCrewAdd

Called when a user is added to the crew of a job

onJobCrewUpdate

Called when a crew member of a job is updated

onJobCrewRemove

Called when a user is removed from the crew of a job

ASSETS

onAssetCreate

Called when an asset is created

onAssetUpdate

Called when an asset is updated

onAssetDelete

Called when an asset is deleted

onAssetStatusChange

Called when the status of an asset is changed

SHOWS

onShowCreate

Called when a show is created

onShowUpdate

Called when show information is updated

onShowDelete

Called when a show is deleted

SHOT

onShotCreate

Called when a shot is created

onShotUpdate

Called when an shot is updated

onShotDelete

Called when an shot is deleted

onShotStatusChange

Called when the status of a shot is changed

TASKS

onTaskCreate

Called when an task is added to an asset or shot

onTaskUpdate

Called when an task is updated on an asset or shot

onTaskDelete

Called when an task is deleted from an asset or shot

onTaskStatusChange

Called when the status of a task is changed

onTaskUserChange

Called when the user assigned to a task is changed

REVIEW

onDailiesCreate

Called when a review item is added to a task

onDailiesUpdate

Called when a review item is updated

onDailiesRemove

Called when a review item is deleted

NOTES

onNoteCreate

Called when an note is created for any object

onNoteUpdate

Called when an note is updated for any object

onNoteDelete

Called when an note is deleted for any object

BIDS

onBidCreate

Called when a bid is created

onBidVersion

Called when a bid version is created

onBidCopy

Called when a bid is copied

onBidUpdate

Called when a bid is updated

onBidStatusChange

Called when the status of a Bid is changed

onBidDelete

Called when a bid is deleted