Skip to:
Content

BuddyPress.org

Changeset 2343 for trunk/bp-groups.php


Ignore:
Timestamp:
01/18/2010 08:00:33 PM (15 years ago)
Author:
johnjamesjacoby
Message:

Remove all references to Wire component (addresses #1618). This code has been moved to backpat.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r2339 r2343  
    2424            slug varchar(100) NOT NULL,
    2525            description longtext NOT NULL,
    26             news longtext NOT NULL,
    2726            status varchar(10) NOT NULL DEFAULT 'public',
    28             enable_wire tinyint(1) NOT NULL DEFAULT '1',
    2927            enable_forum tinyint(1) NOT NULL DEFAULT '1',
    3028            date_created datetime NOT NULL,
     
    6664    dbDelta($sql);
    6765
    68     if ( function_exists('bp_wire_install') )
    69         groups_wire_install();
     66    do_action( 'groups_install' );
    7067
    7168    update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
    72 }
    73 
    74 function groups_wire_install() {
    75     global $wpdb, $bp;
    76 
    77     if ( !empty($wpdb->charset) )
    78         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    79 
    80     $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} (
    81             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    82             item_id bigint(20) NOT NULL,
    83             user_id bigint(20) NOT NULL,
    84             parent_id bigint(20) NOT NULL,
    85             content longtext NOT NULL,
    86             date_posted datetime NOT NULL,
    87             KEY item_id (item_id),
    88             KEY user_id (user_id),
    89             KEY parent_id (parent_id)
    90            ) {$charset_collate};";
    91 
    92     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    93     dbDelta($sql);
    9469}
    9570
     
    10883    /* Register this in the active components array */
    10984    $bp->active_components[$bp->groups->slug] = $bp->groups->id;
    110 
    111     if ( function_exists('bp_wire_install') )
    112         $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
    11385
    11486    $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
     
    239211                bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => 'forum', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_forum', 'position' => 40, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums' ) );
    240212
    241             if ( $bp->groups->current_group->enable_wire && function_exists('bp_wire_install') )
    242                 bp_core_new_subnav_item( array( 'name' => __( 'Wire', 'buddypress' ), 'slug' => BP_WIRE_SLUG, 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_wire', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'wire'  ) );
    243 
    244213            bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'members'  ) );
    245214
     
    593562
    594563            bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/home' ) );
    595         }
    596     }
    597 }
    598 
    599 function groups_screen_group_wire() {
    600     global $bp;
    601 
    602     $wire_action = $bp->action_variables[0];
    603 
    604     if ( $bp->is_single_item ) {
    605         if ( 'post' == $wire_action && ( is_site_admin() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ) {
    606             /* Check the nonce first. */
    607             if ( !check_admin_referer( 'bp_wire_post' ) )
    608                 return false;
    609 
    610             if ( !groups_new_wire_post( $bp->groups->current_group->id, $_POST['wire-post-textarea'] ) )
    611                 bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' );
    612             else
    613                 bp_core_add_message( __('Wire message successfully posted.', 'buddypress') );
    614 
    615             if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
    616                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    617             else
    618                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . $bp->wire->slug );
    619 
    620         } else if ( 'delete' == $wire_action && ( is_site_admin() || groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ) {
    621             $wire_message_id = $bp->action_variables[1];
    622 
    623             /* Check the nonce first. */
    624             if ( !check_admin_referer( 'bp_wire_delete_link' ) )
    625                 return false;
    626 
    627             if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) )
    628                 bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' );
    629             else
    630                 bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
    631 
    632             if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
    633                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    634             else
    635                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . $bp->wire->slug );
    636 
    637         } else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) {
    638             bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/single/wire' ) );
    639         } else {
    640             bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    641564        }
    642565    }
     
    10921015            <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
    10931016        </tr>
    1094         <?php if ( function_exists('bp_wire_install') ) { ?>
    1095         <tr>
    1096             <td></td>
    1097             <td><?php _e( 'A member posts on the wire of a group you belong to', 'buddypress' ) ?></td>
    1098             <td class="yes"><input type="radio" name="notifications[notification_groups_wire_post]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_wire_post') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_wire_post') ) { ?>checked="checked" <?php } ?>/></td>
    1099             <td class="no"><input type="radio" name="notifications[notification_groups_wire_post]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_wire_post') ) { ?>checked="checked" <?php } ?>/></td>
    1100         </tr>
    1101         <?php } ?>
    11021017        <tr>
    11031018            <td></td>
     
    13901305    bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) );
    13911306    bp_activity_set_action( $bp->groups->id, 'joined_group', __( 'Joined a group', 'buddypress' ) );
    1392     bp_activity_set_action( $bp->groups->id, 'new_wire_post', __( 'New group wire post', 'buddypress' ) );
    13931307    bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) );
    13941308    bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) );
     
    14311345    groups_update_groupmeta( $group_id, 'last_activity', time() );
    14321346}
    1433 add_action( 'groups_deleted_wire_post', 'groups_update_last_activity' );
    1434 add_action( 'groups_new_wire_post', 'groups_update_last_activity' );
    14351347add_action( 'groups_joined_group', 'groups_update_last_activity' );
    14361348add_action( 'groups_leave_group', 'groups_update_last_activity' );
     
    15791491        $group = new BP_Groups_Group;
    15801492
    1581     if ( $creator_id ) {
     1493    if ( $creator_id )
    15821494        $group->creator_id = $creator_id;
    1583     } else {
     1495    else
    15841496        $group->creator_id = $bp->loggedin_user->id;
    1585     }
    15861497
    15871498    if ( isset( $name ) )
     
    20121923
    20131924    return $activity_id;
    2014 }
    2015 
    2016 /*** Group Wire [DEPRECATED] ****************************************************************/
    2017 
    2018 function groups_new_wire_post( $group_id, $content ) {
    2019     global $bp;
    2020 
    2021     if ( !function_exists( 'bp_wire_new_post' ) )
    2022         return false;
    2023 
    2024     if ( $wire_post = bp_wire_new_post( $group_id, $content, 'groups' ) ) {
    2025 
    2026         /* Post an email notification if settings allow */
    2027         require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    2028         groups_notification_new_wire_post( $group_id, $wire_post->id );
    2029 
    2030         /* Record this in activity streams */
    2031         $activity_content = sprintf( __( '%s wrote on the wire of the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    2032         $activity_content .= '<blockquote>' . bp_create_excerpt( $content ) . '</blockquote>';
    2033 
    2034         groups_record_activity( array(
    2035             'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ),
    2036             'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    2037             'component_action' => 'new_wire_post',
    2038             'item_id' => $bp->groups->current_group->id,
    2039             'secondary_item_id' => $wire_post->item_id
    2040         ) );
    2041 
    2042         do_action( 'groups_new_wire_post', $group_id, $wire_post->id );
    2043 
    2044         return true;
    2045     }
    2046 
    2047     return false;
    2048 }
    2049 
    2050 function groups_delete_wire_post( $wire_post_id, $table_name ) {
    2051     if ( bp_wire_delete_post( $wire_post_id, 'groups', $table_name ) ) {
    2052         /* Delete the activity stream item */
    2053         if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
    2054             bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) );
    2055         }
    2056 
    2057         do_action( 'groups_deleted_wire_post', $wire_post_id );
    2058         return true;
    2059     }
    2060 
    2061     return false;
    20621925}
    20631926
     
    27162579
    27172580// List actions to clear super cached pages on, if super cache is installed
    2718 add_action( 'groups_new_wire_post', 'bp_core_clear_cache' );
    2719 add_action( 'groups_deleted_wire_post', 'bp_core_clear_cache' );
    27202581add_action( 'groups_join_group', 'bp_core_clear_cache' );
    27212582add_action( 'groups_leave_group', 'bp_core_clear_cache' );
Note: See TracChangeset for help on using the changeset viewer.