Skip to:
Content

BuddyPress.org

Changeset 6280


Ignore:
Timestamp:
08/31/2012 02:29:29 AM (14 years ago)
Author:
boonebgorges
Message:

Improves Group Deletion process in Dashboard

  • Introduces confirmation screen in place of confirmation alert box, since BP Group deletion is permanent
  • Fixes bulk delete

See #4414

Location:
trunk/bp-groups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/admin/css/admin.css

    r6267 r6280  
    1515        margin-bottom: 15px;
    1616}
     17ul.bp-group-delete-list {
     18        list-style-type: disc;
     19        margin: 4px 26px;
     20}
  • trunk/bp-groups/bp-groups-admin.php

    r6267 r6280  
    6262
    6363        // Edit screen
    64         if ( 'delete' == $doaction && ! empty( $_GET['gid'] ) ) {
     64        if ( 'do_delete' == $doaction && ! empty( $_GET['gid'] ) ) {
    6565
    6666                check_admin_referer( 'bp-groups-delete' );
    … …  
    372372        $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
    373373
    374         // Display the single activity edit screen
     374        // Display the single group edit screen
    375375        if ( 'edit' == $doaction && ! empty( $_GET['gid'] ) ) {
    376376                bp_groups_admin_edit();
    377377
    378         // Otherwise, display the Activity index screen
     378        // Display the group deletion confirmation screen
     379        } else if ( 'delete' == $doaction && ! empty( $_GET['gid'] ) ) {
     380                bp_groups_admin_delete();
     381
     382        // Otherwise, display the groups index screen
    379383        } else {
    380384                bp_groups_admin_index();
    … …  
    391395        global $screen_layout_columns;
    392396
    393         // @todo: Check if user is allowed to edit activity items
    394         // if ( ! current_user_can( 'bp_edit_activity' ) )
    395397        if ( ! is_super_admin() )
    396398                die( '-1' );
    … …  
    502504
    503505<?php
     506}
     507
     508/**
     509 * Display the Group delete confirmation screen
     510 *
     511 * We include a separate confirmation because group deletion is truly
     512 * irreversible.
     513 *
     514 * @since (BuddyPress) 1.7
     515 */
     516function bp_groups_admin_delete() {
     517
     518        if ( ! is_super_admin() )
     519                die( '-1' );
     520
     521        $group_ids = isset( $_REQUEST['gid'] ) ? $_REQUEST['gid'] : 0;
     522        if ( ! is_array( $group_ids ) ) {
     523                $group_ids = explode( ',', $group_ids );
     524        }
     525        $group_ids = wp_parse_id_list( $group_ids );
     526        $groups    = groups_get_groups( array( 'include' => $group_ids ) );
     527
     528        // Create a new list of group ids, based on those that actually exist
     529        $gids = array();
     530        foreach ( $groups['groups'] as $group ) {
     531                $gids[] = $group->id;
     532        }
     533
     534        $base_url  = remove_query_arg( array( 'action', 'action2', 'paged', 's', '_wpnonce', 'gid' ), $_SERVER['REQUEST_URI'] );
     535
     536        ?>
     537
     538        <div class="wrap">
     539                <?php screen_icon( 'buddypress-groups' ); ?>
     540                <h2><?php _e( 'Delete Groups', 'buddypress' ) ?></h2>
     541                <p><?php _e( 'You are about to delete the following groups:', 'buddypress' ) ?></p>
     542
     543                <ul class="bp-group-delete-list">
     544                <?php foreach ( $groups['groups'] as $group ) : ?>
     545                        <li><?php echo esc_html( $group->name ) ?></li>
     546                <?php endforeach; ?>
     547                </ul>
     548
     549                <p><strong><?php _e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p>
     550
     551                <a class="button-primary" href="<?php echo wp_nonce_url( add_query_arg( array( 'action' => 'do_delete', 'gid' => implode( ',', $gids ) ), $base_url ), 'bp-groups-delete' ) ?>"><?php _e( 'Delete Permanently', 'buddypress' ) ?></a>
     552                <a class="button" href="<?php echo $base_url ?>"><?php _e( 'Cancel', 'buddypress' ) ?></a>
     553        </div>
     554
     555        <?php
    504556}
    505557
    … …  
    754806                <div id="major-publishing-actions">
    755807                        <div id="delete-action">
    756                                 <a onclick="javascript:return confirm('<?php echo esc_js( __( 'Are you sure?', 'buddypress' ) ) ?>');" class="submitdelete deletion" href="<?php echo wp_nonce_url( add_query_arg( 'action', 'delete', $base_url ), 'bp-groups-delete' ) ?>"><?php _e( 'Delete', 'buddypress' ) ?></a>
     808                                <a class="submitdelete deletion" href="<?php echo wp_nonce_url( add_query_arg( 'action', 'delete', $base_url ), 'bp-groups-delete' ) ?>"><?php _e( 'Delete Group', 'buddypress' ) ?></a>
    757809                        </div>
    758810
    … …  
    10571109        function get_bulk_actions() {
    10581110                $actions = array();
    1059                 $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
     1111                $actions['delete'] = __( 'Delete', 'buddypress' );
    10601112
    10611113                return apply_filters( 'bp_groups_list_table_get_bulk_actions', $actions );
    … …  
    11041156         */
    11051157        function column_cb( $item ) {
    1106                 printf( '<input type="checkbox" name="aid[]" value="%d" />', (int) $item['id'] );
     1158                printf( '<input type="checkbox" name="gid[]" value="%d" />', (int) $item['id'] );
    11071159        }
    11081160
    … …  
    11291181        function column_comment( $item ) {
    11301182
    1131                 // Preorder items: Visit | Edit | Delete Permanently
     1183                // Preorder items: Visit | Edit | Delete
    11321184                $actions = array(
    11331185                        'visit'  => '',
    … …  
    11411193                // Build actions URLs
    11421194                $base_url   = network_admin_url( 'admin.php?page=bp-groups&amp;gid=' . $item['id'] );
    1143                 $spam_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'spam-groups_' . $item['id'] ) );
    1144 
    1145                 $delete_url = $base_url . "&amp;action=delete&amp;$spam_nonce";
     1195
     1196                $delete_url = wp_nonce_url( $base_url . "&amp;action=delete", 'bp-groups-delete' );
    11461197                $edit_url   = $base_url . '&amp;action=edit';
    11471198                $visit_url  = bp_get_group_permalink( $item_obj );
    … …  
    11561207
    11571208                // Delete
    1158                 $actions['delete'] = sprintf( '<a href="%s" onclick="%s">%s</a>', $delete_url, "javascript:return confirm('" . esc_js( __( 'Are you sure?', 'buddypress' ) ) . "'); ", __( 'Delete Permanently', 'buddypress' ) );
     1209                $actions['delete'] = sprintf( '<a href="%s">%s</a>', $delete_url, __( 'Delete', 'buddypress' ) );
    11591210
    11601211                // Other plugins can filter which actions are shown
Note: See TracChangeset for help on using the changeset viewer.