Skip to:
Content

BuddyPress.org

Ticket #8141: 8141.patch

File 8141.patch, 5.1 KB (added by shanebp, 6 years ago)
  • src/bp-core/admin/bp-core-admin-tools.php

     src/bp-core/admin/bp-core-admin-tools.php | 77 ++++++++++++++++++++++++++-----
     1 file changed, 65 insertions(+), 12 deletions(-)
    
    diff --git a/src/bp-core/admin/bp-core-admin-tools.php b/src/bp-core/admin/bp-core-admin-tools.php
    index 0ad810e0d..47eb04785 100644
    a b function bp_admin_repair_list() { 
    147147                'bp_admin_reinstall_emails',
    148148        );
    149149
     150        // Invitations
     151        // - maybe create the database table
     152        $repair_list[110] = array(
     153                'bp-invitations-table',
     154                __( 'Create the database table for Invitations.', 'buddypress' ),
     155                'bp_admin_invitations_table',
     156        );
     157
    150158        ksort( $repair_list );
    151159
    152160        /**
    function bp_admin_repair_list() { 
    159167        return (array) apply_filters( 'bp_repair_list', $repair_list );
    160168}
    161169
     170
     171/**
     172 * Create the invitations database table if it does not exist.
     173 *
     174 * @since 6.0.0
     175 *
     176 * @return array
     177 */
     178function bp_admin_invitations_table() {
     179        global $wpdb;
     180
     181        $statement = __( 'Creating the Invitations database table if it does not exist… %s', 'buddypress' );
     182        $result    = __( 'Failed!', 'buddypress' );
     183
     184        $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
     185        $bp_prefix       = bp_core_get_table_prefix();
     186        $table_name      = $bp_prefix . 'bp_invitations';
     187
     188        $sql = "CREATE TABLE $table_name (
     189                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     190                user_id bigint(20) NOT NULL,
     191                inviter_id bigint(20) NOT NULL,
     192                invitee_email varchar(100) DEFAULT NULL,
     193                class varchar(120) NOT NULL,
     194                item_id bigint(20) NOT NULL,
     195                secondary_item_id bigint(20) DEFAULT NULL,
     196                type varchar(12) NOT NULL DEFAULT 'invite',
     197                content longtext DEFAULT '',
     198                date_modified datetime NOT NULL,
     199                invite_sent tinyint(1) NOT NULL DEFAULT '0',
     200                accepted tinyint(1) NOT NULL DEFAULT '0',
     201                KEY user_id (user_id),
     202                KEY inviter_id (inviter_id),
     203                KEY invitee_email (invitee_email),
     204                KEY class (class),
     205                KEY item_id (item_id),
     206                KEY secondary_item_id (secondary_item_id),
     207                KEY type (type),
     208                KEY invite_sent (invite_sent),
     209                KEY accepted (accepted)
     210                ) {$charset_collate};";
     211
     212
     213        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     214
     215        $db_result = maybe_create_table( $table_name, $sql );
     216
     217        if ( ! $db_result ) {
     218                return array( 2, sprintf( $statement, $result ) );
     219        } else {
     220                return array( 0, sprintf( $statement, __( 'Finished!', 'buddypress' ) ) );
     221        }
     222
     223}
     224
    162225/**
    163226 * Recalculate friend counts for each user.
    164227 *
    function bp_admin_repair_friend_count() { 
    173236                return;
    174237        }
    175238
    176         /* translators: %s: the result of the action performed by the repair tool */
    177239        $statement = __( 'Counting the number of friends for each user… %s', 'buddypress' );
    178240        $result    = __( 'Failed!', 'buddypress' );
    179241
    function bp_admin_repair_group_count() { 
    232294                return;
    233295        }
    234296
    235         /* translators: %s: the result of the action performed by the repair tool */
    236297        $statement = __( 'Counting the number of groups for each user… %s', 'buddypress' );
    237298        $result    = __( 'Failed!', 'buddypress' );
    238299
    function bp_admin_repair_group_count() { 
    275336 */
    276337function bp_admin_repair_blog_records() {
    277338
    278         /* translators: %s: the result of the action performed by the repair tool */
     339        // Description of this tool, displayed to the user.
    279340        $statement = __( 'Repopulating Blogs records… %s', 'buddypress' );
    280341
    281342        // Default to failure text.
    function bp_admin_repair_blog_records() { 
    304365 * @since 2.0.0
    305366 */
    306367function bp_admin_repair_count_members() {
    307         /* translators: %s: the result of the action performed by the repair tool */
    308368        $statement = __( 'Counting the number of active members on the site… %s', 'buddypress' );
    309369        delete_transient( 'bp_active_member_count' );
    310370        bp_core_get_active_member_count();
    function bp_admin_repair_count_members() { 
    319379 * @since 2.0.0
    320380 */
    321381function bp_admin_repair_last_activity() {
    322         /* translators: %s: the result of the action performed by the repair tool */
    323382        $statement = __( 'Determining last activity dates for each user… %s', 'buddypress' );
    324383        bp_last_activity_migrate();
    325384        return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
    function bp_core_admin_available_tools_intro() { 
    411470                <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
    412471                <p>
    413472                        <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
    414                         <?php
    415                         printf(
    416                                 /* translators: %s: the link to the BuddyPress repair tools */
    417                                 esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ),
    418                                 '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>'
    419                         );
    420                         ?>
     473                        <?php printf( esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ), '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>' ); ?>
    421474                </p>
    422475        </div>
    423476        <?php