Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/12/2019 08:42:30 PM (6 years ago)
Author:
dcavins
Message:

Introduce BP_Invitation and BP_Invitation_Manager.

  • Add BP_Invitation, a new class describing generic invitation objects with methods for adding, updating and deleting invitations and membership requests.
  • Add a creation routine for the new table that will contain invitations data.
  • Add BP_Invitation_Manager, a new class that offers helper functions for managing BP_Invitation objects. For most use cases, this class will be extended for new invitation types, like group invitations.
  • Add unit tests for the new classes.

See #6210.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-schema.php

    r12390 r12428  
    541541    do_action( 'bp_core_install_emails' );
    542542}
     543
     544/**
     545 * Install database tables for the Invitations API
     546 *
     547 * @since 5.0.0
     548 *
     549 * @uses bp_core_set_charset()
     550 * @uses bp_core_get_table_prefix()
     551 * @uses dbDelta()
     552 */
     553function bp_core_install_invitations() {
     554    $sql             = array();
     555    $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
     556    $bp_prefix       = bp_core_get_table_prefix();
     557    $sql[] = "CREATE TABLE {$bp_prefix}bp_invitations (
     558        id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     559        user_id bigint(20) NOT NULL,
     560        inviter_id bigint(20) NOT NULL,
     561        invitee_email varchar(100) DEFAULT NULL,
     562        class varchar(120) NOT NULL,
     563        item_id bigint(20) NOT NULL,
     564        secondary_item_id bigint(20) DEFAULT NULL,
     565        type varchar(12) NOT NULL DEFAULT 'invite',
     566        content longtext DEFAULT '',
     567        date_modified datetime NOT NULL,
     568        invite_sent tinyint(1) NOT NULL DEFAULT '0',
     569        accepted tinyint(1) NOT NULL DEFAULT '0',
     570        KEY user_id (user_id),
     571        KEY inviter_id (inviter_id),
     572        KEY invitee_email (invitee_email),
     573        KEY class (class),
     574        KEY item_id (item_id),
     575        KEY secondary_item_id (secondary_item_id),
     576        KEY type (type),
     577        KEY invite_sent (invite_sent),
     578        KEY accepted (accepted)
     579        ) {$charset_collate};";
     580    dbDelta( $sql );
     581
     582    /**
     583     * Fires after BuddyPress adds the invitations table.
     584     *
     585     * @since 5.0.0
     586     */
     587    do_action( 'bp_core_install_invitations' );
     588}
Note: See TracChangeset for help on using the changeset viewer.