Skip to:
Content

BuddyPress.org

Ticket #1618: remove-wire-from-core.patch

File remove-wire-from-core.patch, 35.3 KB (added by johnjamesjacoby, 15 years ago)

Remove references to Wire component

  • bp-activity.php

     
    395395                 * array(
    396396                 *      'user_id' => false, // user_id to filter on
    397397                 *      'object' => false, // object to filter on e.g. groups, profile, status, friends
    398                  *      'action' => false, // action to filter on e.g. new_wire_post, new_forum_post, profile_updated
     398                 *      'action' => false, // action to filter on e.g. new_activity_post, profile_updated
    399399                 *      'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    400400                 *      'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
    401401                 * );
     
    432432                'content' => false, // The content of the activity item
    433433                'primary_link' => false, // The primary URL for this item in RSS feeds
    434434                'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent
    435                 'component_action' => false, // The component action e.g. new_wire_post, profile_updated
     435                'component_action' => false, // The component action e.g. new_activity_post, profile_updated
    436436
    437437                'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
    438                 'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id
     438                'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
    439439                'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
    440440                'recorded_time' => time(), // The time that this activity was recorded
    441441                'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
     
    500500                'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
    501501                'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
    502502                'component_name' => $bp->activity->id,
    503                 'component_action' => 'new_wire_post'
     503                'component_action' => 'new_activity_post'
    504504        ) );
    505505
    506506        /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
  • bp-activity/bp-activity-templatetags.php

     
    124124                /* Filtering */
    125125                'user_id' => false, // user_id to filter on
    126126                'object' => false, // object to filter on e.g. groups, profile, status, friends
    127                 'action' => false, // action to filter on e.g. new_wire_post, new_forum_post, profile_updated
     127                'action' => false, // action to filter on e.g. new_activity_post, new_forum_post, profile_updated
    128128                'primary_id' => false, // object ID to filter on e.g. a group_id or forum_id or blog_id etc.
    129129                'secondary_id' => false, // secondary object ID to filter on e.g. a post_id
    130130
     
    732732                if ( ':' == substr( $title, -1 ) )
    733733                        $title = substr( $title, 0, -1 );
    734734
    735                 if ( 'new_wire_post' == $activities_template->activity->component_action ) {
     735                if ( 'new_activity_post' == $activities_template->activity->component_action ) {
    736736                        $content = explode( '<div class="activity-inner">', $activities_template->activity->content );
    737737                        $title .= ': ' . strip_tags( bp_create_excerpt( $content[1], 15 ));
    738738                }
  • bp-core.php

     
    341341         * built in WordPress profile information
    342342         */
    343343        if ( !function_exists( 'xprofile_install' ) ) {
    344                 /* Fallback wire values if xprofile is disabled */
     344                /* Fallback values if xprofile is disabled */
    345345                $bp->core->profile->slug = 'profile';
    346346                $bp->active_components[$bp->core->profile->slug] = $bp->core->profile->slug;
    347347
  • bp-core/bp-core-templatetags.php

     
    10341034        echo apply_filters( 'bp_logout_link', $logout_link );
    10351035}
    10361036
    1037 function bp_profile_wire_can_post() {
    1038         global $bp;
    1039 
    1040         if ( bp_is_home() )
    1041                 return true;
    1042 
    1043         if ( function_exists('friends_install') ) {
    1044                 if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
    1045                         return true;
    1046                 else
    1047                         return false;
    1048         }
    1049 
    1050         return true;
    1051 }
    1052 
    10531037function bp_nav_items() {
    10541038        global $bp;
    10551039        // This is deprecated, you should put these navigation items in your template header.php for easy editing.
     
    13941378        return false;
    13951379}
    13961380
    1397 function bp_is_wire_component() {
    1398         global $bp;
    1399 
    1400         if ( BP_WIRE_SLUG == $bp->current_action || in_array( BP_WIRE_SLUG, (array)$bp->action_variables ) )
    1401                 return true;
    1402 
    1403         return false;
    1404 }
    1405 
    14061381function bp_is_messages_component() {
    14071382        global $bp;
    14081383
     
    15021477        return false;
    15031478}
    15041479
    1505 function bp_is_profile_wire() {
    1506         global $bp;
    1507 
    1508         if ( BP_XPROFILE_SLUG == $bp->current_component && 'wire' == $bp->current_action )
    1509                 return true;
    1510 
    1511         return false;
    1512 }
    1513 
    15141480function bp_is_user_groups() {
    15151481        global $bp;
    15161482
     
    15571523        return false;
    15581524}
    15591525
    1560 function bp_is_group_wire() {
    1561         global $bp;
    1562 
    1563         if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'wire' == $bp->current_action )
    1564                 return true;
    1565 
    1566         return false;
    1567 }
    1568 
    15691526function bp_is_group_forum() {
    15701527        global $bp;
    15711528
     
    17951752                if ( bp_is_blogs_component() && !bp_is_blog_page()  )
    17961753                        $bp_classes[] = 'blogs';
    17971754
    1798                 if ( bp_is_wire_component() && !bp_is_blog_page()  )
    1799                         $bp_classes[] = 'wire';
    1800 
    18011755                if ( bp_is_messages_component() && !bp_is_blog_page()  )
    18021756                        $bp_classes[] = 'messages';
    18031757
     
    18641818                if ( bp_is_group_forum() )
    18651819                        $bp_classes[] = 'group-forum';
    18661820
    1867                 if ( bp_is_group_wire() )
    1868                         $bp_classes[] = 'group-wire';
    1869 
    18701821                if ( bp_is_group_admin_page() )
    18711822                        $bp_classes[] = 'group-admin';
    18721823
     
    18761827                if ( bp_is_group_home() )
    18771828                        $bp_classes[] = 'group-home';
    18781829
    1879                 if ( bp_is_profile_wire() )
    1880                         $bp_classes[] = 'profile-wire';
    1881 
    18821830                if ( bp_is_change_avatar() )
    18831831                        $bp_classes[] = 'change-avatar';
    18841832
  • bp-groups.php

     
    6565        require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    6666        dbDelta($sql);
    6767
    68         if ( function_exists('bp_wire_install') )
    69                 groups_wire_install();
     68        do_action( 'groups_install' );
    7069
    7170        update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
    7271}
    7372
    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 }
    95 
    9673function groups_setup_globals() {
    9774        global $bp, $wpdb;
    9875
     
    10885        /* Register this in the active components array */
    10986        $bp->active_components[$bp->groups->slug] = $bp->groups->id;
    11087
    111         if ( function_exists('bp_wire_install') )
    112                 $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
    113 
    11488        $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
    11589
    11690        $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
     
    238212                        if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') )
    239213                                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' => 'group-forum' ) );
    240214
    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' => 'group-wire'  ) );
    243 
    244215                        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' => 'group-members'  ) );
    245216
    246217                        if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     
    596567        }
    597568}
    598569
    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' ) );
    641                 }
    642         }
    643 }
    644 
    645570function groups_screen_group_members() {
    646571        global $bp;
    647572
     
    10911016                        <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_group_updated') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
    10921017                        <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>
    10931018                </tr>
    1094                 <?php if ( function_exists('bp_wire_install') ) { ?>
    10951019                <tr>
    10961020                        <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                 <tr>
    1103                         <td></td>
    11041021                        <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
    11051022                        <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_admin_promotion') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td>
    11061023                        <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td>
     
    13891306
    13901307        bp_activity_set_action( $bp->groups->id, 'created_group', __( 'Created a group', 'buddypress' ) );
    13911308        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' ) );
    13931309        bp_activity_set_action( $bp->groups->id, 'new_forum_topic', __( 'New group forum topic', 'buddypress' ) );
    13941310        bp_activity_set_action( $bp->groups->id, 'new_forum_post', __( 'New group forum post', 'buddypress' ) );
    13951311
     
    14301346function groups_update_last_activity( $group_id ) {
    14311347        groups_update_groupmeta( $group_id, 'last_activity', time() );
    14321348}
    1433 add_action( 'groups_deleted_wire_post', 'groups_update_last_activity' );
    1434 add_action( 'groups_new_wire_post', 'groups_update_last_activity' );
    14351349add_action( 'groups_joined_group', 'groups_update_last_activity' );
    14361350add_action( 'groups_leave_group', 'groups_update_last_activity' );
    14371351add_action( 'groups_created_group', 'groups_update_last_activity' );
     
    20131927        return $activity_id;
    20141928}
    20151929
    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;
    2062 }
    2063 
    20641930/*** Group Forums **************************************************************/
    20651931
    20661932function groups_new_group_forum( $group_id = false, $group_name = false, $group_desc = false ) {
     
    27162582add_action( 'groups_group_avatar_updated', 'groups_clear_group_object_cache' );
    27172583
    27182584// List actions to clear super cached pages on, if super cache is installed
    2719 add_action( 'groups_new_wire_post', 'bp_core_clear_cache' );
    2720 add_action( 'groups_deleted_wire_post', 'bp_core_clear_cache' );
    27212585add_action( 'groups_join_group', 'bp_core_clear_cache' );
    27222586add_action( 'groups_leave_group', 'bp_core_clear_cache' );
    27232587add_action( 'groups_accept_invite', 'bp_core_clear_cache' );
  • bp-groups/bp-groups-classes.php

     
    204204                        BP_Groups_Member::delete( $user->user_id, $this->id, false );
    205205                }
    206206
    207                 // Delete the wire posts for this group if the wire is installed
    208                 if ( function_exists('bp_wire_install') ) {
    209                         BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire );
    210                 }
     207                do_action( 'bp_groups_delete_group', $this );
    211208
    212209                // Finally remove the group entry from the DB
    213210                if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
  • bp-groups/bp-groups-notifications.php

     
    11<?php
    22
    3 function groups_notification_new_wire_post( $group_id, $wire_post_id ) {
    4         global $bp;
    5 
    6         if ( !isset( $_POST['wire-post-email-notify'] ) )
    7                 return false;
    8 
    9         $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $wire_post_id );
    10         $group = new BP_Groups_Group( $group_id, false, true );
    11 
    12         $poster_name = bp_core_get_user_displayname( $wire_post->user_id );
    13         $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id );
    14 
    15         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
    16 
    17         foreach ( $group->user_dataset as $user ) {
    18                 if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue;
    19 
    20                 $ud = get_userdata( $user->user_id );
    21 
    22                 // Set up and send the message
    23                 $to = $ud->user_email;
    24 
    25                 $wire_link = site_url( $bp->groups->slug . '/' . $group->slug . '/wire/' );
    26                 $group_link = site_url( $bp->groups->slug . '/' . $group->slug . '/' );
    27                 $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/';
    28 
    29                 $message = sprintf( __(
    30 '%s posted on the wire of the group "%s":
    31 
    32 "%s"
    33 
    34 To view the group wire: %s
    35 
    36 To view the group home: %s
    37 
    38 To view %s\'s profile page: %s
    39 
    40 ---------------------
    41 ', 'buddypress' ), $poster_name, stripslashes( attribute_escape( $group->name ) ), stripslashes($wire_post->content), $wire_link, $group_link, $poster_name, $poster_profile_link );
    42 
    43                 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    44 
    45                 // Send it
    46                 wp_mail( $to, $subject, $message );
    47 
    48                 unset( $message, $to );
    49         }
    50 }
    51 
    523function groups_notification_group_updated( $group_id ) {
    534        global $bp;
    545
  • bp-groups/bp-groups-templatetags.php

     
    710710                        return apply_filters( 'bp_get_group_member_count', sprintf( __( '%d members', 'buddypress' ), number_format( (int) $groups_template->group->total_member_count ) ) );
    711711        }
    712712
    713 function bp_group_show_wire_setting( $group = false ) {
    714         global $groups_template;
    715 
    716         if ( !$group )
    717                 $group =& $groups_template->group;
    718 
    719         if ( $group->enable_wire )
    720                 echo ' checked="checked"';
    721 }
    722 
    723 function bp_group_is_wire_enabled( $group = false ) {
    724         global $groups_template;
    725 
    726         if ( !$group )
    727                 $group =& $groups_template->group;
    728 
    729         if ( $group->enable_wire )
    730                 return true;
    731 
    732         return false;
    733 }
    734 
    735713function bp_group_forum_permalink( $deprecated = false ) {
    736714        echo bp_get_group_forum_permalink();
    737715}
     
    16141592                return apply_filters( 'bp_get_new_group_news', $bp->groups->current_group->news );
    16151593        }
    16161594
    1617 function bp_new_group_enable_wire() {
    1618         echo bp_get_new_group_enable_wire();
    1619 }
    1620         function bp_get_new_group_enable_wire() {
    1621                 global $bp;
    1622                 return (int) apply_filters( 'bp_get_new_group_enable_wire', $bp->groups->current_group->enable_wire );
    1623         }
    1624 
    16251595function bp_new_group_enable_forum() {
    16261596        echo bp_get_new_group_enable_forum();
    16271597}
  • bp-xprofile.php

     
    99require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' );
    1010require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-filters.php' );
    1111require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-templatetags.php' );
    12 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-notifications.php' );
    1312require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-cssjs.php' );
    1413
    1514/* Assign the base group and fullname field names to constants to use in SQL statements */
     
    8988        require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    9089        dbDelta($sql);
    9190
    92         if ( function_exists('bp_wire_install') )
    93                 xprofile_wire_install();
     91        do_action( 'xprofile_install' );
    9492
    9593        update_site_option( 'bp-xprofile-db-version', BP_XPROFILE_DB_VERSION );
    9694}
    9795
    98 function xprofile_wire_install() {
    99         global $bp, $wpdb;
    100 
    101         if ( !empty($wpdb->charset) )
    102                 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    103 
    104         $sql[] = "CREATE TABLE {$bp->profile->table_name_wire} (
    105                            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    106                            item_id bigint(20) NOT NULL,
    107                            user_id bigint(20) NOT NULL,
    108                            parent_id bigint(20) NOT NULL,
    109                            content longtext NOT NULL,
    110                            date_posted datetime NOT NULL,
    111                            KEY item_id (item_id),
    112                        KEY user_id (user_id),
    113                        KEY parent_id (parent_id)
    114                        ) {$charset_collate};";
    115 
    116         require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    117         dbDelta($sql);
    118 }
    119 
    12096/**
    12197 * xprofile_setup_globals()
    12298 *
     
    146122        /* Set the support field type ids */
    147123        $bp->profile->field_types = apply_filters( 'xprofile_field_types', array( 'textbox', 'textarea', 'radio', 'checkbox', 'selectbox', 'multiselectbox', 'datebox' ) );
    148124
    149         if ( function_exists( 'bp_wire_install' ) )
    150                 $bp->profile->table_name_wire = $wpdb->base_prefix . 'bp_xprofile_wire';
    151 
    152125        do_action( 'xprofile_setup_globals' );
    153126}
    154127add_action( 'plugins_loaded', 'xprofile_setup_globals', 5 );
     
    424397        bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'members/single/home' ) );
    425398}
    426399
    427 /**
    428  * xprofile_screen_notification_settings()
    429  *
    430  * Loads the notification settings for the xprofile component.
    431  * Settings are hooked into the function: bp_core_screen_notification_settings_content()
    432  * in bp-core/bp-core-settings.php
    433  *
    434  * @package BuddyPress Xprofile
    435  * @global $current_user WordPress global variable containing current logged in user information
    436  */
    437 function xprofile_screen_notification_settings() {
    438         global $current_user; ?>
    439         <?php if ( function_exists('bp_wire_install') ) { ?>
    440         <table class="notification-settings" id="profile-notification-settings">
    441                 <tr>
    442                         <th class="icon"></th>
    443                         <th class="title"><?php _e( 'Profile', 'buddypress' ) ?></th>
    444                         <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    445                         <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    446                 </tr>
    447 
    448                 <tr>
    449                         <td></td>
    450                         <td><?php _e( 'A member posts on your wire', 'buddypress' ) ?></td>
    451                         <td class="yes"><input type="radio" name="notifications[notification_profile_wire_post]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_profile_wire_post' ) || 'yes' == get_usermeta( $current_user->id, 'notification_profile_wire_post' ) ) { ?>checked="checked" <?php } ?>/></td>
    452                         <td class="no"><input type="radio" name="notifications[notification_profile_wire_post]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_profile_wire_post' ) ) { ?>checked="checked" <?php } ?>/></td>
    453                 </tr>
    454 
    455                 <?php do_action( 'xprofile_screen_notification_settings' ) ?>
    456         </table>
    457         <?php } ?>
    458 <?php
    459 }
    460 add_action( 'bp_notification_settings', 'xprofile_screen_notification_settings', 1 );
    461 
    462 
    463400/********************************************************************************
    464401 * Action Functions
    465402 *
     
    503440}
    504441add_action( 'wp', 'xprofile_action_delete_avatar', 3 );
    505442
    506 /**
    507  * xprofile_action_new_wire_post()
    508  *
    509  * Posts a new wire post to the users profile wire.
    510  *
    511  * @package BuddyPress XProfile
    512  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    513  * @uses bp_wire_new_post() Adds a new wire post to a specific wire using the ID of the item passed and the table name.
    514  * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
    515  * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
    516  */
    517 function xprofile_action_new_wire_post() {
    518         global $bp;
    519 
    520         if ( $bp->current_component != $bp->wire->slug )
    521                 return false;
    522 
    523         if ( 'post' != $bp->current_action )
    524                 return false;
    525 
    526         /* Check the nonce */
    527         if ( !check_admin_referer( 'bp_wire_post' ) )
    528                 return false;
    529 
    530         if ( !$wire_post = bp_wire_new_post( $bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->id ) ) {
    531                 bp_core_add_message( __( 'Wire message could not be posted. Please try again.', 'buddypress' ), 'error' );
    532         } else {
    533                 bp_core_add_message( __( 'Wire message successfully posted.', 'buddypress' ) );
    534 
    535                 /* Record the notification for the reciever if it's not on their own wire */
    536                 if ( !bp_is_home() )
    537                         bp_core_add_notification( $bp->loggedin_user->id, $bp->displayed_user->id, $bp->profile->id, 'new_wire_post' );
    538 
    539                 /* Record this on the poster's activity screen */
    540                 if ( ( $wire_post->item_id == $bp->loggedin_user->id && $wire_post->user_id == $bp->loggedin_user->id ) || ( $wire_post->item_id == $bp->displayed_user->id && $wire_post->user_id == $bp->displayed_user->id ) ) {
    541                         $from_user_link = bp_core_get_userlink($wire_post->user_id);
    542                         $content = sprintf( __('%s wrote on their own wire', 'buddypress'), $from_user_link ) . ': <span class="time-since">%s</span>';
    543                         $primary_link = bp_core_get_userlink( $wire_post->user_id, false, true );
    544                 } else if ( ( $wire_post->item_id != $bp->loggedin_user->id && $wire_post->user_id == $bp->loggedin_user->id ) || ( $wire_post->item_id != $bp->displayed_user->id && $wire_post->user_id == $bp->displayed_user->id ) ) {
    545                         $from_user_link = bp_core_get_userlink($wire_post->user_id);
    546                         $to_user_link = bp_core_get_userlink( $wire_post->item_id, false, false, true, true );
    547                         $content = sprintf( __('%s wrote on %s wire', 'buddypress'), $from_user_link, $to_user_link ) . ': <span class="time-since">%s</span>';
    548                         $primary_link = bp_core_get_userlink( $wire_post->item_id, false, true );
    549                 }
    550 
    551                 $content .= '<blockquote>' . bp_create_excerpt($wire_post->content) . '</blockquote>';
    552 
    553                 /* Now write the values */
    554                 xprofile_record_activity( array(
    555                         'user_id' => $bp->loggedin_user->id,
    556                         'content' => apply_filters( 'xprofile_activity_new_wire_post', $content, &$wire_post ),
    557                         'primary_link' => apply_filters( 'xprofile_activity_new_wire_post_primary_link', $primary_link ),
    558                         'component_action' => 'new_wire_post',
    559                         'item_id' => $wire_post->id
    560                 ) );
    561 
    562                 do_action( 'xprofile_new_wire_post', &$wire_post );
    563         }
    564 
    565         if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) {
    566                 bp_core_redirect( $bp->displayed_user->domain );
    567         } else {
    568                 bp_core_redirect( $bp->displayed_user->domain . $bp->wire->slug );
    569         }
    570 }
    571 add_action( 'wp', 'xprofile_action_new_wire_post', 3 );
    572 
    573 /**
    574  * xprofile_action_delete_wire_post()
    575  *
    576  * Deletes a wire post from the users profile wire.
    577  *
    578  * @package BuddyPress XProfile
    579  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    580  * @uses bp_wire_delete_post() Deletes a wire post for a specific wire using the ID of the item passed and the table name.
    581  * @uses xprofile_delete_activity() Deletes an activity item for the xprofile component and a particular user.
    582  * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
    583  * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
    584  */
    585 function xprofile_action_delete_wire_post() {
    586         global $bp;
    587 
    588         if ( $bp->current_component != $bp->wire->slug )
    589                 return false;
    590 
    591         if ( $bp->current_action != 'delete' )
    592                 return false;
    593 
    594         if ( !check_admin_referer( 'bp_wire_delete_link' ) )
    595                 return false;
    596 
    597         $wire_post_id = $bp->action_variables[0];
    598 
    599         if ( bp_wire_delete_post( $wire_post_id, $bp->profile->slug, $bp->profile->table_name_wire ) ) {
    600                 bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
    601 
    602                 /* Delete the post from activity streams */
    603                 xprofile_delete_activity( array( 'item_id' => $wire_post_id, 'component_action' => 'new_wire_post' ) );
    604 
    605                 do_action( 'xprofile_delete_wire_post', $wire_post_id );
    606         } else {
    607                 bp_core_add_message( __('Wire post could not be deleted, please try again.', 'buddypress'), 'error' );
    608         }
    609 
    610         if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) {
    611                 bp_core_redirect( $bp->displayed_user->domain );
    612         } else {
    613                 bp_core_redirect( $bp->displayed_user->domain. $bp->wire->slug );
    614         }
    615 }
    616 add_action( 'wp', 'xprofile_action_delete_wire_post', 3 );
    617 
    618 
    619443/********************************************************************************
    620444 * Activity & Notification Functions
    621445 *
     
    632456        /* Register the activity stream actions for this component */
    633457        bp_activity_set_action( $bp->profile->id, 'new_member', __( 'New member registered', 'buddypress' ) );
    634458        bp_activity_set_action( $bp->profile->id, 'updated_profile', __( 'Updated Profile', 'buddypress' ) );
    635         bp_activity_set_action( $bp->profile->id, 'new_wire_post', __( 'New profile wire post', 'buddypress' ) );
    636459
    637460        do_action( 'xprofile_register_activity_actions' );
    638461}
     
    702525        return apply_filters( 'xprofile_register_activity_action', bp_activity_set_action( $bp->profile->id, $key, $value ), $key, $value );
    703526}
    704527
    705 /**
    706  * xprofile_format_notifications()
    707  *
    708  * Format notifications into something that can be read and displayed
    709  *
    710  * @package BuddyPress Xprofile
    711  * @param $item_id The ID of the specific item for which the activity is recorded (could be a wire post id, user id etc)
    712  * @param $action The component action name e.g. 'new_wire_post' or 'updated_profile'
    713  * @param $total_items The total number of identical notification items (used for grouping)
    714  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    715  * @uses bp_core_global_user_fullname() Returns the display name for the user
    716  * @return The readable notification item
    717  */
    718 function xprofile_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    719         global $bp;
    720528
    721         if ( 'new_wire_post' == $action ) {
    722                 if ( (int)$total_items > 1 ) {
    723                         return apply_filters( 'bp_xprofile_multiple_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __( 'Wire', 'buddypress' ) . '">' . sprintf( __( 'You have %d new posts on your wire', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    724                 } else {
    725                         $user_fullname = bp_core_get_user_displayname( $item_id );
    726                         return apply_filters( 'bp_xprofile_single_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __( 'Wire', 'buddypress' ) . '">' . sprintf( __( '%s posted on your wire', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
    727                 }
    728         }
    729 
    730         do_action( 'xprofile_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    731 
    732         return false;
    733 }
    734 
    735 
    736529/********************************************************************************
    737530 * Business Functions
    738531 *
     
    1093886        global $bp;
    1094887
    1095888        bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->id, 'new_at_mention' );
    1096         bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->id, 'new_wire_post' );
    1097889}
    1098 add_action( 'bp_wire_screen_latest', 'xprofile_remove_screen_notifications' );
    1099890add_action( 'bp_activity_screen_my_activity', 'xprofile_remove_screen_notifications' );
    1100891add_action( 'bp_activity_screen_single_activity_permalink', 'xprofile_remove_screen_notifications' );
    1101892
  • bp-xprofile/bp-xprofile-notifications.php

     
    1 <?php
    2 
    3 /**
    4  * xprofile_record_wire_post_notification() [DEPRECATED]
    5  *
    6  * Records a notification for a new profile wire post to the database and sends out a notification
    7  * email if the user has this setting enabled.
    8  *
    9  * @package BuddyPress XProfile
    10  * @param $wire_post_id The ID of the wire post
    11  * @param $user_id The id of the user that the wire post was sent to
    12  * @param $poster_id The id of the user who wrote the wire post
    13  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    14  * @global $current_user WordPress global variable containing current logged in user information
    15  * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user
    16  * @uses get_usermeta() Get a user meta value based on meta key from wp_usermeta
    17  * @uses BP_Wire_Post Class Creates a new wire post object based on ID.
    18  * @uses site_url Returns the site URL
    19  * @uses wp_mail Sends an email
    20  */
    21 function xprofile_record_wire_post_notification( $wire_post_id, $user_id, $poster_id ) {
    22         global $bp, $current_user;
    23 
    24         if ( $bp->current_component == $bp->wire->slug && !bp_is_home() ) {
    25                 bp_core_add_notification( $poster_id, $user_id, 'xprofile', 'new_wire_post' );
    26 
    27                 if ( !get_usermeta( $user_id, 'notification_profile_wire_post' ) || 'yes' == get_usermeta( $user_id, 'notification_profile_wire_post' ) ) {
    28                         $poster_name = bp_core_get_user_displayname( $poster_id );
    29                         $wire_post = new BP_Wire_Post( $bp->profile->table_name_wire, $wire_post_id, true );
    30                         $ud = get_userdata( $user_id );
    31 
    32                         $wire_link = bp_core_get_user_domain( $user_id ) . 'wire';
    33                         $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications';
    34 
    35                         // Set up and send the message
    36                         $to = $ud->user_email;
    37                         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s posted on your wire.', 'buddypress' ), stripslashes($poster_name) );
    38 
    39 $message = sprintf( __(
    40 '%s posted on your wire:
    41 
    42 "%s"
    43 
    44 To view your wire: %s
    45 
    46 ---------------------
    47 ', 'buddypress' ), $poster_name, stripslashes($wire_post->content), $wire_link );
    48 
    49                         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    50 
    51                         // Send it
    52                         wp_mail( $to, $subject, $message );
    53                 }
    54         }
    55 
    56 }
    57 add_action( 'bp_wire_post_posted', 'xprofile_record_wire_post_notification', 10, 3 );
    58 
    59 ?>
    60  No newline at end of file