Confetti Bits

Transactions

Table of Contents

Packages

SpotBonuses
Volunteers
Templates
Notifications

Classes

CB_Transactions_Component
Adds component globals and includes related files.
CB_Transactions_Spot_Bonus
A component that allows certain users to schedule spot bonuses.
CB_Transactions_Transaction
CB Transactions Transaction

Functions

cb_dev_func_add_spot_bonuses()  : mixed
cb_ajax_update_volunteers()  : mixed
cb_ajax_get_volunteers()  : mixed
cb_ajax_delete_volunteers()  : mixed
cb_bits_request_sender_email_notification()  : mixed
CB Bits Request Sender Email Notification
cb_transactions_get_history_for_user()  : mixed
CB Transactions Get History for User
cb_csv_send_headers()  : mixed
CB CSV Send Headers
cb_generate_csv()  : mixed
CB Generate CSV
cb_export()  : mixed
CB Export
cb_activity_bits()  : mixed
CB Activity Bits
cb_transactions_get_total_sent_today()  : int
CB Transactions Get Total Sent Today
cb_transactions_get_request_balance()  : int
CB Transactions Get Request Balance
cb_transactions_get_transfer_balance()  : int
CB Transactions Get Transfer Balance
cb_transactions_check_activity_bits()  : mixed
CB Transactions Check Activity Bits
cb_transactions_get_activity_posts()  : array<string|int, mixed>
CB Transactions Get Activity Posts
cb_transactions_get_activity_transactions()  : array<string|int, mixed>
CB Transactions Get Activity Transactions
cb_transactions_calculate_activity_bits()  : array<string|int, mixed>
CB Transactions Calculate Activity Bits
cb_transactions_has_bits()  : bool
CB Transactions Has Bits
cb_transactions_birthday_bits()  : mixed
CB Transactions Birthday Bits
cb_transactions_anniversary_bits()  : mixed
CB Transactions Anniversary Bits
cb_transactions_get_amount_from_anniversary()  : int
CB Transactions Get Amount From Anniversary
cb_transactions_get_leaderboard()  : array<string|int, mixed>
CB Transactions Get Leaderboard
cb_transactions_delete_transaction()  : int
CB Transactions Delete Transaction
cb_transactions_new_transaction()  : mixed
CB Transactions New Transaction
cb_transactions_remove_bits()  : mixed
CB Transactions Remove Bits
cb_transactions_new_events_transaction()  : int|bool|string
A supplemental helper function that will let us process event-based transactions without modifying existing API stuff too much.
cb_transactions_new_contests_transaction()  : int|bool|string
A supplemental helper function that will let us process contest-based transactions without modifying existing API stuff too much.
cb_import_bits()  : mixed
CB Import Bits
cb_importer()  : mixed
Confetti Bits Importer
cb_import_bda()  : mixed
CB Import BDA
cb_bda_importer()  : mixed
CB BDA Importer
cb_setup_transactions()  : mixed
CB Setup Transactions

Functions

cb_bits_request_sender_email_notification()

CB Bits Request Sender Email Notification

cb_bits_request_sender_email_notification([array<string|int, mixed> $args = array() ]) : mixed

This function sends an email notification to the request sender

Parameters
$args : array<string|int, mixed> = array()

The arguments for the email notification.

Tags
since
1.0.0

cb_transactions_get_history_for_user()

CB Transactions Get History for User

cb_transactions_get_history_for_user([mixed $user_id = 0 ][, mixed $export_type = '' ]) : mixed

Handles the logic behind getting the right data from the database.

Parameters
$user_id : mixed = 0
$export_type : mixed = ''
Tags
todo:

Fix this tomfoolery. And type check your variables for the love of god

since
1.0.0

cb_csv_send_headers()

CB CSV Send Headers

cb_csv_send_headers([mixed $file_name = '' ]) : mixed

Manually alters headers to allow for us to modify how a csv reaches an end user, and to ensure safe passage for our noble data wizards.

Parameters
$file_name : mixed = ''
Tags
since
1.0.0

cb_generate_csv()

CB Generate CSV

cb_generate_csv([array<string|int, mixed> $user_transactions = array() ][, string $export_type = '' ]) : mixed

Responsible for generating csv files for users that request an export of their data.

Parameters
$user_transactions : array<string|int, mixed> = array()

A 2D array of transactions

$export_type : string = ''

The type of export the user requested.

Tags
since
1.0.0

cb_export()

CB Export

cb_export() : mixed

Checks to see if export parameters are set on a POST request, exports transactions from the database based on parameters.

Tags
since
1.0.0

cb_activity_bits()

CB Activity Bits

cb_activity_bits(string $content, int $user_id, int $activity_id) : mixed

This hooks onto the BP Activity Posted Update action to give someone Confetti Bits when they post an update.

Parameters
$content : string

The content of the activity post.

$user_id : int

The id of the user associated with the activity post.

$activity_id : int

The id of the activity post.

Tags
since
1.0.0

cb_transactions_get_total_sent_today()

CB Transactions Get Total Sent Today

cb_transactions_get_total_sent_today() : int

This function gets the total number of Confetti Bits that have been sent for the current day.

Tags
since
1.0.0
Return values
int

$total The total number of Confetti Bits sent for the current day.

cb_transactions_get_request_balance()

CB Transactions Get Request Balance

cb_transactions_get_request_balance([int $user_id = 0 ]) : int

Get the balance available to a user for the current spending cycle. The request balance resets 1 month after users are done earning for the year.

So the balance that is returned is a calculation based on the following timeline:

  1. When the earning cycle starts, the available balance for requests is accrued for one year. They may then spend those for an additional month after that.
  2. date_sent >= $cb->earn_start, date_sent <= earn_end, amount > 0
  3. date_sent >= $cb->earn_start, date_sent <= spend_end, amount < 0
Parameters
$user_id : int = 0

The ID for the user whose balance we want.

Tags
since
1.3.0
Return values
int

The calculated balance available for requests.

cb_transactions_get_transfer_balance()

CB Transactions Get Transfer Balance

cb_transactions_get_transfer_balance([int $user_id = 0 ]) : int

Get the balance available to a user for the current earning cycle.

Parameters
$user_id : int = 0

The ID for the user whose balance we want.

Tags
since
1.3.0
Return values
int

The calculated balance available for transfers.

cb_transactions_check_activity_bits()

CB Transactions Check Activity Bits

cb_transactions_check_activity_bits([int $user_id = 0 ]) : mixed

Checks to see if there were any days throughout the cycle where the user might have posted on the BuddyBoss activity feed, and didn't receive any points for it. Helps cover our tail if we accidentally push some breaking changes or do something silly with how activity bits are registered.

Parameters
$user_id : int = 0

The ID for the user we want to check.

Tags
since
1.3.0

cb_transactions_get_activity_posts()

CB Transactions Get Activity Posts

cb_transactions_get_activity_posts([int $user_id = 0 ]) : array<string|int, mixed>

Returns an array of activity posts for the given user. Uses BuddyBoss's global value for the activities table name.

Parameters
$user_id : int = 0

The ID of the user whose posts we want.

Tags
since
1.3.0
Return values
array<string|int, mixed>

An array of activity posts, if any.

cb_transactions_get_activity_transactions()

CB Transactions Get Activity Transactions

cb_transactions_get_activity_transactions([int $user_id = 0 ]) : array<string|int, mixed>

Retrieves a list of all transactions from the current earning cycle that were registered by a user posting on the BuddyBoss activity feed.

Parameters
$user_id : int = 0

The user's ID. Default current user ID.

Tags
since
1.3.0
Return values
array<string|int, mixed>

An array of transactions, if there are any.

cb_transactions_calculate_activity_bits()

CB Transactions Calculate Activity Bits

cb_transactions_calculate_activity_bits([array<string|int, mixed> $activities = array() ][, array<string|int, mixed> $transactions = array() ]) : array<string|int, mixed>

Calculates how many points a user should receive according to the number of unaccounted for activity posts they've sent out, that don't have an accompanying Confetti Bits transaction on that same day.

Parameters
$activities : array<string|int, mixed> = array()

An array of activity posts

$transactions : array<string|int, mixed> = array()

An array of transactions

Tags
since
1.3.0
Return values
array<string|int, mixed>

An array of activity posts that are missing an accompanying transaction on a given day.

cb_transactions_has_bits()

CB Transactions Has Bits

cb_transactions_has_bits([string $action = '' ]) : bool

Checks whether the user has gotten Confetti Bits for a specific action this year.

Parameters
$action : string = ''

The action to check the database for. Usually either "birthday" or "anniversary".

Tags
since
1.3.0
Return values
bool

Whether we found an entry for the given action within the past year.

cb_transactions_birthday_bits()

CB Transactions Birthday Bits

cb_transactions_birthday_bits() : mixed

Gives the user Confetti Bits on their birthday.

Tags
since
1.3.0

cb_transactions_anniversary_bits()

CB Transactions Anniversary Bits

cb_transactions_anniversary_bits() : mixed

Gives the user Confetti Bits on their anniversary.

Tags
since
1.3.0

cb_transactions_get_amount_from_anniversary()

CB Transactions Get Amount From Anniversary

cb_transactions_get_amount_from_anniversary(DateTime $date) : int
Parameters
$date : DateTime
Tags
since
1.3.0
Return values
int

The transaction amount appropriate for the anniversary date

cb_transactions_get_leaderboard()

CB Transactions Get Leaderboard

cb_transactions_get_leaderboard([mixed $limit = true ][, mixed $previous = false ]) : array<string|int, mixed>

Queries the database for the top 15 users by Confetti Bits balance Also includes the current user if they aren't in the top 15

Parameters
$limit : mixed = true
$previous : mixed = false
Tags
since
1.3.0
Return values
array<string|int, mixed>

$results The top 15 users by Confetti Bits balance, or the top 15 users by Confetti Bits balance with the current user included

cb_transactions_delete_transaction()

CB Transactions Delete Transaction

cb_transactions_delete_transaction([array<string|int, mixed> $args = [] ]) : int

Delete a transaction from the database. Do this at your own risk, you cannot undo this action.

Parameters
$args : array<string|int, mixed> = []

{ An associative array of keys and values to check the database for. Accepts any property of a CB_Transactions_Transaction object. Example: ['recipient_id' => 5, 'component_action' => 'cb_activity_bits'] Passing the above will delete all transactions where the recipient_id is 5, and the component_action is cb_activity_bits. }

Tags
since
2.3.0
Return values
int

The number of rows affected. @see $wpdb::delete()

cb_transactions_new_transaction()

CB Transactions New Transaction

cb_transactions_new_transaction([array<string|int, mixed> $args = [] ]) : mixed

Manages sending bits between users. Yikes.

Parameters
$args : array<string|int, mixed> = []

An array of arguments that get merged into a set of default values. {

@var int $item_id The item ID associated with the transaction. Used with BuddyBoss's Notifications API to help format some dynamic information in the notifications. We use the sender_id for this.

@var int $secondary_item_id The secondary item ID associated with the transaction. Used with BuddyBoss's Notifications API to help format some dynamic information in the notifications. We use the recipient_id for this.

@var int $sender_id The ID of the user sending the bits.

@var int $recipient_id The ID of the user recieving the bits.

@var datetime $date_sent The date and time of the transaction.

@var string $log_entry A note that usually references the purpose for the transaction.

@TODO: Make log entries optional?

@var string $component_name The name associated with the component that is sending the bits. Used with BuddyBoss's Notifications API. This will almost always just be 'confetti_bits'.

@var string $component_action The action associated with the transaction. We use this to differentiate transaction types to easily categorize them and run calculations. It is also used with BuddyBoss's Notifications API to send certain notifications that are associated with certain actions. }

Tags
since
3.0.0

cb_transactions_remove_bits()

CB Transactions Remove Bits

cb_transactions_remove_bits(mixed $id, mixed $reassign, mixed $user) : mixed

This is hooked into the delete_user action, so that transactions get deleted whenever a user is.

Parameters
$id : mixed
$reassign : mixed
$user : mixed
Tags
TODO:

Still need to implement this... Yikes. Also. why send negative bits, instead of deleting from the DB? This program doesn't need analytics based on that type of stuff, just delete from the DB.

since
2.3.0

cb_transactions_new_events_transaction()

A supplemental helper function that will let us process event-based transactions without modifying existing API stuff too much.

cb_transactions_new_events_transaction([array<string|int, mixed> $args = [] ]) : int|bool|string

We'll likely add more robust error handling later on. It's just getting down to the wire and we gotta push this out ASAP.

Parameters
$args : array<string|int, mixed> = []

{ An array of arguments. All required.

	@type int $event_id The ID of the event object.
	@type int $recipient_id The ID of the recipient user.

}

Tags
since
3.0.0
Return values
int|bool|string

Transaction ID on full success, false if something is missing, an error message if something when wrong.

cb_transactions_new_contests_transaction()

A supplemental helper function that will let us process contest-based transactions without modifying existing API stuff too much.

cb_transactions_new_contests_transaction([array<string|int, mixed> $args = [] ]) : int|bool|string

We'll likely add more robust error handling later on. It's just getting down to the wire and we gotta push this out ASAP.

Parameters
$args : array<string|int, mixed> = []

{ An array of arguments. All required.

	@type int $event_id The ID of the event object.
	@type int $recipient_id The ID of the recipient user.

}

Tags
since
3.0.0
Return values
int|bool|string

Transaction ID on full success, false if something is missing, an error message if something when wrong.

cb_import_bits()

CB Import Bits

cb_import_bits([mixed $args = [] ]) : mixed

This is going to allow an admin user to bulk import Confetti Bits transactions from a CSV file.

Parameters
$args : mixed = []
Tags
since
1.0.0

cb_importer()

Confetti Bits Importer

cb_importer() : mixed

This is going to allow an admin user to bulk import a whole list of Confetti Bits transactions using PHP's built-in csv parser. We've included a lot of sanitization and error-handling here, but it could always be improved upon.

Some explanatory comments throughout, but the gist is: Make sure it's a post request, on the confetti bits page, from the import panel Get the wp importer Set the redirect path so we can P-R-G after it's finished, Set some variables to display after the import Set where the files go Open the filestream Start the import process Read each line, validate each field Make sure nothing insane is going into our database Compile the feedback and shove it into a session token Redirect Get the messages, kick back and enjoy

Tags
since
1.0.0

cb_import_bda()

CB Import BDA

cb_import_bda([mixed $args = '' ]) : mixed

This is going to allow an admin user to bulk import birthdays and anniversaries from a CSV file.

Parameters
$args : mixed = ''
Tags
since
1.0.0

cb_bda_importer()

CB BDA Importer

cb_bda_importer() : mixed

This is going to allow an admin user to bulk import a whole list of birthdays and anniversaries using PHP's built-in csv parser.

Some explanatory comments throughout, but the gist is: Make sure it's a post request, on the confetti bits page, from the import panel Get the wp importer Set the redirect path so we can P-R-G after it's finished, Set some variables to display after the import Set where the files go Open the filestream Start the import process Read each line, validate each field Make sure nothing insane is going into our database Compile the feedback and shove it into a session token Redirect Get the messages, kick back and enjoy

Tags
since
1.0.0

cb_setup_transactions()

CB Setup Transactions

cb_setup_transactions() : mixed

Sets up our transactions component, so we have easy access to component globals.

Tags
since
1.0.0

        
On this page

Search results