Confetti Bits

CB_Participation_Participation
in package

CB Participation Participation

A component that allows users to register their participation in company activities.

Tags
since
2.2.0

Table of Contents

Properties

$admin_id  : int
The ID of the admin associated with the entry.
$applicant_id  : int
The ID of the user associated with the entry.
$columns  : array<string|int, mixed>
The columns available in the database. Used to help build our orderby clause.
$component_action  : string
The component action associated with the entry.
$component_name  : string
The component associated with the entry.
$date_created  : string
The date the entry was created.
$date_modified  : string
The date of the last time the entry was modified.
$event_date  : datetime
The date of the event associated with the entry.
$event_id  : int
The ID of the event object associated with the entry.
$event_note  : string
The date of the event associated with the entry.
$event_type  : string
The type of event associated with the entry.
$id  : int
The ID of the participation entry.
$item_id  : int
The ID of the main item or user associated with the participation entry.
$secondary_item_id  : int
The ID of the secondary item associated with the participation entry.
$status  : string
The last updated status of the entry.
$transaction_id  : int
The transaction_id assigned to the the entry.

Methods

__construct()  : mixed
Constructor.
get_date_query_sql()  : mixed
get_orderby_sql()  : string
Get Orderby SQL
get_participation()  : mixed
get_participation
populate()  : mixed
Populate
save()  : obj|int
Save
update()  : int|false
Update status entry.
update_participation_request_status()  : mixed
Update participation status. Uses our static _update method.
_delete()  : int|false
Delete participation entry.
_insert()  : int|bool
_insert
_update()  : int|false
Update participation entry.
get_paged_sql()  : string
Assemble the LIMIT clause of a get() SQL statement.
get_query_clauses()  : array<string|int, mixed>
Assemble query clauses, based on arguments, to pass to $wpdb methods.
get_where_sql()  : mixed
strip_leading_and()  : mixed

Properties

$columns

The columns available in the database. Used to help build our orderby clause.

public static array<string|int, mixed> $columns = ['id', 'item_id', 'secondary_item_id', 'applicant_id', 'admin_id', 'date_created', 'date_modified', 'event_type', 'event_date', 'event_note', 'event_id']

$item_id

The ID of the main item or user associated with the participation entry.

public int $item_id

We usually use the applicant_id for this. Used for BuddyBoss's Notifications API.

$secondary_item_id

The ID of the secondary item associated with the participation entry.

public int $secondary_item_id

We usually use the admin_id for this. Used for BuddyBoss's Notifications API.

$transaction_id

The transaction_id assigned to the the entry.

public int $transaction_id

Updated after a transaction has been created, to allow the transaction to be tied to a specific participation event.

Methods

get_orderby_sql()

Get Orderby SQL

public static get_orderby_sql([mixed $args = [] ]) : string

Checks against the columns available and order arguments, then spits out usable SQL if everything looks okay.

Parameters
$args : mixed = []
Return values
string

The ORDER BY clause of an SQL query.

get_participation()

get_participation

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

Handles retrieving data from the database. Nice and clean!

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

An array of stuff to get! { @type string $select The database column to get @type array $where A selection of key-value pairs that get evaluated by another method. See self::get_where_sql()

Tags
TODO:

Finish documenting this (sweat emoji) }

populate()

Populate

public populate([int $id = 0 ]) : mixed

Populates object data associated with the given ID.

Parameters
$id : int = 0

The participation ID.

save()

Save

public save() : obj|int

Handles saving data to the database using our static _insert method.

Return values
obj|int

WP_Error on failure, participation ID on success.

update()

Update status entry.

public static update([array<string|int, mixed> $update_args = array() ][, array<string|int, mixed> $where_args = array() ]) : int|false
Parameters
$update_args : array<string|int, mixed> = array()

Associative array of fields to update, and the values to update them to. Of the format array( 'applicant_id' => 4, 'component_action' => 'cb_participation', ).

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

Associative array of columns/values, to determine which rows should be updated. Of the format array( 'item_id' => 7, 'component_action' => 'cb_participation', ).

Return values
int|false

Number of rows updated on success, false on failure.

update_participation_request_status()

Update participation status. Uses our static _update method.

public update_participation_request_status() : mixed

_delete()

Delete participation entry.

protected static _delete([array<string|int, mixed> $where = array() ][, array<string|int, mixed> $where_format = array() ]) : int|false
Parameters
$where : array<string|int, mixed> = array()

Array of WHERE clauses to filter by, passed to . Accepts any property of a CB_Participation_Participation object.

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

See .

Tags
see
wpdb::update()

for further description of paramater formats.

Return values
int|false

The number of rows updated, or false on error.

_insert()

_insert

protected static _insert([mixed $data = array() ][, mixed $data_format = array() ]) : int|bool

Handles the actual insertion into the database.

Parameters
$data : mixed = array()
$data_format : mixed = array()
Return values
int|bool

The inserted ID on success, false on failure.

_update()

Update participation entry.

protected static _update([array<string|int, mixed> $data = array() ][, array<string|int, mixed> $where = array() ][, array<string|int, mixed> $data_format = array() ][, array<string|int, mixed> $where_format = array() ]) : int|false
Parameters
$data : array<string|int, mixed> = array()

Array of participation data to update, passed to . Accepts any property of a Confetti_Bits_Participation_Participation object.

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

The WHERE params as passed to wpdb::update(). Typically consists of array( 'ID' => $id ) to specify the ID of the item being updated. See .

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

See .

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

See .

Tags
see
wpdb::update()

for further description of paramater formats.

Return values
int|false

The number of rows updated, or false on error.

get_paged_sql()

Assemble the LIMIT clause of a get() SQL statement.

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

Used by CB_Participation_Participation::get_participation() to create its LIMIT clause.

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

Array consisting of the page number and items per page. { @type int $page page number @type int $per_page items to return }

Return values
string

$retval LIMIT clause.

get_query_clauses()

Assemble query clauses, based on arguments, to pass to $wpdb methods.

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

The insert(), update(), and delete() methods of expect arguments of the following forms:

  • associative arrays whose key/value pairs are column => value, to be used in WHERE, SET, or VALUES clauses.
  • arrays of "formats", which tell $wpdb->prepare() which type of value to expect when sanitizing (eg, array( '%s', '%d' ))

This utility method can be used to assemble both kinds of params, out of a single set of associative array arguments, such as:

$args = array(
    'applicant_id' => 4,
	   'component_action' => 'cb_participation_new'
);

This will be converted to:

array(
    'data' => array(
        'applicant_id' => 4,

            'component_action' => 'cb_participation_new', ), 'format' => array( '%d', '%s', ), )

which can easily be passed as arguments to the $wpdb methods.

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

Associative array of filter arguments.

Return values
array<string|int, mixed>

Associative array of 'data' and 'format' args.


        
On this page

Search results