cb-requests-functions.php
Table of Contents
Functions
- cb_requests_new_request() : mixed
- CB Requests Create Requests
- cb_requests_new_transaction() : int|string
- CB Requests New Transaction
- cb_requests_get_amount() : int
- Attempts to extract a predetermined value from a request item.
- cb_requests_get_item_name() : string
- Gets the name of a request item.
- cb_requests_get_request_items() : array<string|int, mixed>
- Lists all available request items.
- cb_requests_get_transaction() : array<string|int, mixed>|bool
- Gets a transaction object, if any are associated with a request.
- cb_requests_get_requests() : mixed
- Gets an array of requests from the database.
- cb_requests_get_active_request_total() : int
- Returns the total amount of points the user has in open requests.
- cb_requests_can_request() : bool
- Checks to see if a user can request the given item.
- cb_requests_can_update() : bool
- Checks to see if a user can update their request item.
- cb_requests_new_notifications() : mixed
- Sends a notification email when a request comes in.
Functions
cb_requests_new_request()
CB Requests Create Requests
cb_requests_new_request(array<string|int, mixed> $args) : mixed
Creates a new requests object and saves it to the database.
Parameters
- $args : array<string|int, mixed>
-
Associative array of arguments for saving. All arguments are optional except for media_filepath. { @type int $item_id For BuddyBoss Platform's Notifications API. Registers the primary data for the notification. We'll use the applicant_id for this.
@type int $secondary_item_id For BuddyBoss Platform's Notifications API. Register's the receiver's profile avatar in the notification. We'll use the admin_id for this. @type int $applicant_id The user_id associated with the requests entry. @type int $admin_id The user_id of the last admin that modified the entry. @type string $date_created A mysql datetime entry for when the requests was registered. @type string $date_modified A mysql datetime entry for when the requests was registered. @type string $component_name For BuddyBoss Platform's Notifications API. Helps the API know which notification group to use. @type string $component_action For BuddyBoss Platform's Notifications API. Helps the API know which notification format to use. @type string $status The status of the requests entry. Common statuses include "new", "approved", "denied", or "pending". @type int $request_item_id The ID of the item being requested.
}
Tags
cb_requests_new_transaction()
CB Requests New Transaction
cb_requests_new_transaction([array<string|int, mixed> $args = [] ]) : int|string
Add or subtract Confetti Bits based on request approval status.
Parameters
- $args : array<string|int, mixed> = []
-
An array of parameters for us to work with. { @type int $transaction_id A transaction ID for us to check for. @type int $request_id A requests ID for us to check for. @type int $admin_id An admin ID for us to check for. @type string $status The status of the requests entry. @type string $modified The date of the last modification for the requests entry. }
Tags
Return values
int|string —Transaction ID on success, error on failure.
cb_requests_get_amount()
Attempts to extract a predetermined value from a request item.
cb_requests_get_amount([int $request_item_id = 0 ]) : int
Parameters
- $request_item_id : int = 0
-
The ID of the request item with the request.
Tags
Return values
int —The amount we extracted.
cb_requests_get_item_name()
Gets the name of a request item.
cb_requests_get_item_name([int $request_item_id = 0 ]) : string
Parameters
- $request_item_id : int = 0
-
The ID for the request item we're checking.
Tags
Return values
string —The item name we extracted.
cb_requests_get_request_items()
Lists all available request items.
cb_requests_get_request_items([array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
There's a built-in limit of 15 items, but that can be overridden in the arguments.
Parameters
- $args : array<string|int, mixed> = []
-
{ An optional array of arguments.
@type string|array $select A comma-separated list or array of columns to get. @type int $page The page of request items. @type int $per_page How many request items should appear on each page.
}
Tags
Return values
array<string|int, mixed> —A 2D array of request items, structured like so: { [ [ 'id' => 1, 'item_name' => 'Item 1' ], [ 'id' => 2, 'item_name' => 'Item 2' ], ] }
cb_requests_get_transaction()
Gets a transaction object, if any are associated with a request.
cb_requests_get_transaction([int $transaction_id = 0 ]) : array<string|int, mixed>|bool
Use this to check if a transaction already exists for a given request.
Parameters
- $transaction_id : int = 0
-
The ID for the transaction we're looking for.
Tags
Return values
array<string|int, mixed>|bool —Transaction if the object exists, false if not or we get an error.
cb_requests_get_requests()
Gets an array of requests from the database.
cb_requests_get_requests([array<string|int, mixed> $args = [] ]) : mixed
Parameters
- $args : array<string|int, mixed> = []
-
{ An associative array of arguments. @see CB_Requests_Request::get_requests() }
Tags
cb_requests_get_active_request_total()
Returns the total amount of points the user has in open requests.
cb_requests_get_active_request_total([int $user_id = 0 ]) : int
Parameters
- $user_id : int = 0
-
The ID of the user to check.
Tags
Return values
int —The total amount of points that the user has in open requests.
cb_requests_can_request()
Checks to see if a user can request the given item.
cb_requests_can_request([mixed $applicant_id = 0 ][, int $item_id = 0 ]) : bool
Parameters
- $applicant_id : mixed = 0
- $item_id : int = 0
-
The ID of the item they want
Tags
Return values
bool —True if they have enough to get the item, false otherwise.
cb_requests_can_update()
Checks to see if a user can update their request item.
cb_requests_can_update([int $applicant_id = 0 ][, int $prev_item_id = 0 ][, int $updated_item_id = 0 ]) : bool
It basically subtracts the existing item from the active request total, adds on the cost of the new item, and checks to see if the items cost more than they have to spend on requests.
Parameters
- $applicant_id : int = 0
-
The ID of the user to check.
- $prev_item_id : int = 0
-
The ID of the previous item.
- $updated_item_id : int = 0
-
The ID of the new item that they would like to change to.
Tags
Return values
bool —Whether the item would put the user over their request balance.
cb_requests_new_notifications()
Sends a notification email when a request comes in.
cb_requests_new_notifications([mixed $data = [] ]) : mixed
Parameters
- $data : mixed = []