\

Functions

createRow()

createRow(string  $table, array  $values = array()) 

Creates a row in the database. e.g.

createRow('answers', array( 'agent_id' => get_login_id(), 'question' => $questionID, 'answer' => $value ));

Parameters

string $table

Table name

array $values

Associative array of table columns and the values to set.

dashboard_add_item()

dashboard_add_item(array  $params, boolean  $addToFront = false) 

Adds an item to the end of the dashboard. The dashboard context depends on the event hooked into. For example, if called after hooking into the 'homescreen_dashboard' event, you will affect the homescreen dashboard, whereas if you call it after hooking into the 'dispute_dashboard' event, it will affect the dispute dashboard.

Parameters

array $params

Item to add to the dashboard. string $params['title'] Title of the dashboard item. string $params['image'] Icon to use. string $params['href'] URL to link to.

boolean $addToFront

(Optional) If set to true, item will be added to beginning of dashboard. If false, it will be added to the end. Defaults to false.

dashboard_add_items()

dashboard_add_items(  $items,   $addToFront = false) 

Adds multiple items to the end of the dashboard, in the order passed.

Parameters

$items
$addToFront

declare_module()

declare_module(array  $config, \Function  $moduleDefinitionFunction) 

Defines the module in the system.

Parameters

array $config

Parameters: string $config['key'] Module unique ID, e.g. 'maritime_collision' string $config['title'] Module name, e.g. 'Maritime Collision' string $config['description'] Module description.

\Function $moduleDefinitionFunction

The module definition. This function should hook into events exposed by the SmartResolution platform and specify which functions to call on those events.

declare_table()

declare_table(string  $tableName, array  $columns) 

Creates a module-specific table in the database, if the table does not already exist. If the table already exists, you'll need to manually delete it before your new declaration takes effect.

No need to worry about namespacing: SmartResolution does this automatically, so that your table name becomes module__[module_name]__[table_name] internally. This could change, however, and you should not ever need to know this.

Parameters

string $tableName

The name of the table you'd like to create.

array $columns

Array of columns describing your table, in the format 'column_name' => 'type', e.g. 'question_number' => 'INTEGER'

declare_tables()

declare_tables(array  $tables) 

Creates a number of module-specific tables in the database.

Parameters

array $tables

Array of tables to create, in the form array('table_name' => array(columns))

get()

get(string  $tableAndColumn, array  $andClause = array()) : \Unknown|boolean

Gets the value of a column in a module-specific table.

Parameters

string $tableAndColumn

Dot-separated table and column, e.g. 'table_name.column_name'

array $andClause

(Optional) Specify additional constraints, e.g. array('verified' => true). In this example, we'd get the value of table_name.column_name WHERE verified = true.

Returns

\Unknown|boolean —

Returns the value as it is stored in the database. Beware: this does not cast to integer or boolean, so you'll need to manually cast type where appropriate. Returns boolean false if no record is found.

get_dispute_id()

get_dispute_id() : integer

Gets the ID of the dispute that the module is hooked into.

Returns

integer —

Dispute ID.

get_dispute_url()

get_dispute_url() : string

Gets the URL of the dispute that the module is hooked into.

Returns

string —

Dispute URL.

get_login_id()

get_login_id() : integer

Gets the login ID of the currently logged in user.

Returns

integer —

User's login ID.

get_module_url()

get_module_url() : string

Gets the URL of the module directory. Useful for linking to module-specific assets.

Example: get_module_url() . '/assets/my_image.png';

Returns

string —

URL to the module directory.

get_multiple()

get_multiple(  $tableAndColumn,   $andClause = array()) 

Gets the values of a column in a module-specific table. This should be called over `get` if multiple rows are expected.

Parameters

$tableAndColumn
$andClause

notify()

notify(integer  $loginID, string  $message, string  $url) 

Creates a notification.

Parameters

integer $loginID

The ID of the recipient of the notification.

string $message

The notification message.

string $url

The notification's associated URL.

on()

on(string  $eventName, String|\function  $action, String|Int  $priority = 'medium') 

Subscribes an anonymous function (defined within a module) to a given event.

Parameters

string $eventName

Name of the event to hook into.

String|\function $action

Action to perform. This can be a global function, e.g. 'hello' -> hello(). Or it can be a public function inside a named class, e.g. 'MyClass->hello' -> new MyClass(); hello(); Or it can be an anonymous function, e.g. function () { // do something }

String|Int $priority

(optional) The priority of the hooked function. If multiple functions hook into the event, the functions marked as the highest priority are executed first, e.g. in the case of on('event', 'a', 'medium') and on('event', 'b', 'high'), function b would be executed before function a, even though function a was the first to hook into the event. Possible values: 'low', 'medium', 'high', or an integer between 1 and 100 (where 1 is low priority and 100 is high).

other_agent_to()

other_agent_to(integer  $loginID) : integer

Returns the login ID of the opposing agent.

Parameters

integer $loginID

e.g. Login ID of Agent A

Returns

integer —

e.g. Login ID of Agent B

render()

render(string  $template, array  $variables = array()) 

Renders a HTML template.

Parameters

string $template

Path to the template, e.g. get_module_url() . '/views/index.html'

array $variables

(optional) Values to pass to the template, e.g. array('foo' => 'bar'), which would be accessible as $foo in the template.

render_markdown()

render_markdown(string  $template) 

Renders a markdown file, within the website template.

Parameters

string $template

Path to the markdown file, e.g. get_module_url() . '/docs/about.md'

route()

route(string  $route, String|\Function  $handler) 

Defines a route relative to the current dispute. E.g. if you specify '/example', you'll actually create a route for '/disputes/DISPUTE_ID/example'. If you want to define a top-level route (i.e. simply '/example' without the disputes prefix), you should use `top_level_route`.

Parameters

string $route

GET|POST route relative to the dispute, e.g. '/example', which would correspond to '/disputes/DISPUTE_ID/example'

String|\Function $handler

If String, should be the name of function to call (e.g. 'helloWorld') or the class name and public function, e.g. 'foo->helloWorld'. Could instead pass an anonymous function, e.g. function () {}

set()

set(string  $tableAndColumn, \Unknown  $value) : boolean

Sets a value in the database.

Parameters

string $tableAndColumn

Dot-separated table and column, e.g. 'table_name.column_name'

\Unknown $value

The value to set. Depending on the field type, you may pass a string, integer, etc.

Returns

boolean —

Returns true if successful, false if not.

top_level_route()

top_level_route(string  $route, String|\Function  $handler) 

Defines a top-level route, e.g. '/example', and what to do when a user accesses that route via GET or POST.

If you want to define a route relative to the current dispute, e.g. '/disputes/1371/example', you should use the route function.

Parameters

string $route

GET|POST route relative to the root directory, e.g. '/example'

String|\Function $handler

If String, should be the name of function to call (e.g. 'helloWorld') or the class name and public function, e.g. 'foo->helloWorld'. Could instead pass an anonymous function, e.g. function () {}