Changeset 2343 for trunk/bp-groups.php
- Timestamp:
- 01/18/2010 08:00:33 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups.php
r2339 r2343 24 24 slug varchar(100) NOT NULL, 25 25 description longtext NOT NULL, 26 news longtext NOT NULL,27 26 status varchar(10) NOT NULL DEFAULT 'public', 28 enable_wire tinyint(1) NOT NULL DEFAULT '1',29 27 enable_forum tinyint(1) NOT NULL DEFAULT '1', 30 28 date_created datetime NOT NULL, … … 66 64 dbDelta($sql); 67 65 68 if ( function_exists('bp_wire_install') ) 69 groups_wire_install(); 66 do_action( 'groups_install' ); 70 67 71 68 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);94 69 } 95 70 … … 108 83 /* Register this in the active components array */ 109 84 $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';113 85 114 86 $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) ); … … 239 211 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' ) ); 240 212 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 244 213 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' ) ); 245 214 … … 593 562 594 563 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 else613 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 else618 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 else630 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 else635 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' ) );641 564 } 642 565 } … … 1092 1015 <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> 1093 1016 </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 } ?>1102 1017 <tr> 1103 1018 <td></td> … … 1390 1305 bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) ); 1391 1306 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' ) );1393 1307 bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) ); 1394 1308 bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) ); … … 1431 1345 groups_update_groupmeta( $group_id, 'last_activity', time() ); 1432 1346 } 1433 add_action( 'groups_deleted_wire_post', 'groups_update_last_activity' );1434 add_action( 'groups_new_wire_post', 'groups_update_last_activity' );1435 1347 add_action( 'groups_joined_group', 'groups_update_last_activity' ); 1436 1348 add_action( 'groups_leave_group', 'groups_update_last_activity' ); … … 1579 1491 $group = new BP_Groups_Group; 1580 1492 1581 if ( $creator_id ) {1493 if ( $creator_id ) 1582 1494 $group->creator_id = $creator_id; 1583 } else {1495 else 1584 1496 $group->creator_id = $bp->loggedin_user->id; 1585 }1586 1497 1587 1498 if ( isset( $name ) ) … … 2012 1923 2013 1924 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_id2040 ) );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;2062 1925 } 2063 1926 … … 2716 2579 2717 2580 // 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' );2720 2581 add_action( 'groups_join_group', 'bp_core_clear_cache' ); 2721 2582 add_action( 'groups_leave_group', 'bp_core_clear_cache' );
Note: See TracChangeset
for help on using the changeset viewer.