Skip to:
Content

BuddyPress.org

Changeset 12428


Ignore:
Timestamp:
08/12/2019 08:42:30 PM (5 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.

Location:
trunk
Files:
4 added
4 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}
  • trunk/src/bp-core/bp-core-cache.php

    r11864 r12428  
    380380    return wp_cache_delete( 'incrementor', $group );
    381381}
     382
     383/**
     384 * Resets all incremented bp_invitations caches.
     385 *
     386 * @since 5.0.0
     387 */
     388function bp_invitations_reset_cache_incrementor() {
     389    bp_core_reset_incrementor( 'bp_invitations' );
     390}
     391add_action( 'bp_invitation_after_save', 'bp_invitations_reset_cache_incrementor' );
     392add_action( 'bp_invitation_after_delete', 'bp_invitations_reset_cache_incrementor' );
  • trunk/src/bp-core/bp-core-update.php

    r12390 r12428  
    212212        bp_core_add_page_mappings( $default_components, 'delete' );
    213213        bp_core_install_emails();
     214        bp_core_install_invitations();
    214215
    215216    // Upgrades.
     
    552553 *
    553554 * - Make sure the custom visibility is disabled for the default profile field.
     555 * - Create the invitations table.
    554556 *
    555557 * @since 5.0.0
     
    580582        )
    581583    );
     584
     585    bp_core_install_invitations();
    582586}
    583587
  • trunk/src/class-buddypress.php

    r12405 r12428  
    573573            'BP_Walker_Nav_Menu_Checklist' => 'core',
    574574            'BP_Walker_Nav_Menu'           => 'core',
     575            'BP_Invitation_Manager'        => 'core',
     576            'BP_Invitation'                => 'core',
    575577
    576578            'BP_Core_Friends_Widget' => 'friends',
Note: See TracChangeset for help on using the changeset viewer.