Requests
Table of Contents
Packages
Classes
- CB_Requests_Component
- A component class that gives us access to important globals throughout the app.
- CB_Requests_Request_Item
- A component that allows users to submit requests to cash in their points.
- CB_Requests_Request
- A component that allows users to submit requests to cash in their points.
Functions
- cb_ajax_update_request_items() : mixed
- Handles HTTP PATCH request_items to update request_items entries.
- cb_ajax_delete_request_items() : int
- Deletes request items from the request items table.
- cb_ajax_update_requests() : mixed
- Handles HTTP PATCH requests to update requests entries.
- cb_ajax_new_requests() : mixed
- CB Ajax New Requests
- cb_ajax_get_requests() : mixed
- CB AJAX Get Requests
- cb_ajax_delete_requests() : int
- Deletes requests from the requests table.
- 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.
- cb_setup_requests() : mixed
- CB Setup Requests
- cb_requests_nav() : mixed
- CB Requests Nav
- cb_requests_format_nav_data() : array<string|int, mixed>
- CB Requests Format Nav Data
- cb_requests_get_nav() : string
- CB Requests Get Nav
- cb_requests_admin_nav() : mixed
- CB Requests Admin Nav
- cb_requests_admin_get_nav() : string
- CB Requests Admin Get Nav
Functions
cb_ajax_update_request_items()
Handles HTTP PATCH request_items to update request_items entries.
cb_ajax_update_request_items() : mixed
Processes standard and bulk request_items updates from an HTTP PATCH request.
Tags
cb_ajax_delete_request_items()
Deletes request items from the request items table.
cb_ajax_delete_request_items() : int
Tags
Return values
int —The number of rows affected, or false on failure.
cb_ajax_update_requests()
Handles HTTP PATCH requests to update requests entries.
cb_ajax_update_requests() : mixed
Processes standard and bulk requests updates from an HTTP PATCH request.
Tags
cb_ajax_new_requests()
CB Ajax New Requests
cb_ajax_new_requests() : mixed
We'll use this to process the new requests entries sent via ajax.
Tags
cb_ajax_get_requests()
CB AJAX Get Requests
cb_ajax_get_requests() : mixed
Our REST API handler for the endpoint at "/wp-json/cb-ajax/v1/requests/get"
Tags
cb_ajax_delete_requests()
Deletes requests from the requests table.
cb_ajax_delete_requests() : int
Tags
Return values
int —The number of rows affected, or false on failure.
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 = []
Tags
cb_setup_requests()
CB Setup Requests
cb_setup_requests() : mixed
Sets up our requests component, so we have easy access to component globals.
Tags
cb_requests_nav()
CB Requests Nav
cb_requests_nav() : mixed
Outputs the requests nav.
Tags
cb_requests_format_nav_data()
CB Requests Format Nav Data
cb_requests_format_nav_data([mixed $component = '' ][, array<string|int, mixed> $items = array() ]) : array<string|int, mixed>
Formats the nav data for the requests component. We need a pretty complicated set of arguments for cb_templates_get_nav() and cb_templates_get_nav_items() and this helps us achieve that in a structured way.
Parameters
- $component : mixed = ''
- $items : array<string|int, mixed> = array()
-
A collection of key => value pairs
Tags
Return values
array<string|int, mixed> —The list of formatted nav data.
cb_requests_get_nav()
CB Requests Get Nav
cb_requests_get_nav() : string
Returns the nav for the requests filtering system.
Tags
Return values
string —The nav markup.
cb_requests_admin_nav()
CB Requests Admin Nav
cb_requests_admin_nav() : mixed
Outputs the requests admin nav.
Tags
cb_requests_admin_get_nav()
CB Requests Admin Get Nav
cb_requests_admin_get_nav() : string
Returns the nav for the requests admin filtering system.
Tags
Return values
string —The nav markup.