Skip to:
Content

BuddyPress.org

Changeset 2343 for trunk/bp-xprofile.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-xprofile.php

    r2333 r2343  
    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
     
    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 );
    96 }
    97 
    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);
    11894}
    11995
     
    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' ) );
    148 
    149     if ( function_exists( 'bp_wire_install' ) )
    150         $bp->profile->table_name_wire = $wpdb->base_prefix . 'bp_xprofile_wire';
    151124
    152125    do_action( 'xprofile_setup_globals' );
     
    420393}
    421394
    422 /**
    423  * xprofile_screen_notification_settings()
    424  *
    425  * Loads the notification settings for the xprofile component.
    426  * Settings are hooked into the function: bp_core_screen_notification_settings_content()
    427  * in bp-core/bp-core-settings.php
    428  *
    429  * @package BuddyPress Xprofile
    430  * @global $current_user WordPress global variable containing current logged in user information
    431  */
    432 function xprofile_screen_notification_settings() {
    433     global $current_user; ?>
    434     <?php if ( function_exists('bp_wire_install') ) { ?>
    435     <table class="notification-settings" id="profile-notification-settings">
    436         <tr>
    437             <th class="icon"></th>
    438             <th class="title"><?php _e( 'Profile', 'buddypress' ) ?></th>
    439             <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    440             <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    441         </tr>
    442 
    443         <tr>
    444             <td></td>
    445             <td><?php _e( 'A member posts on your wire', 'buddypress' ) ?></td>
    446             <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>
    447             <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>
    448         </tr>
    449 
    450         <?php do_action( 'xprofile_screen_notification_settings' ) ?>
    451     </table>
    452     <?php } ?>
    453 <?php
    454 }
    455 add_action( 'bp_notification_settings', 'xprofile_screen_notification_settings', 1 );
    456 
    457 
    458395/********************************************************************************
    459396 * Action Functions
     
    499436add_action( 'wp', 'xprofile_action_delete_avatar', 3 );
    500437
    501 /**
    502  * xprofile_action_new_wire_post()
    503  *
    504  * Posts a new wire post to the users profile wire.
    505  *
    506  * @package BuddyPress XProfile
    507  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    508  * @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.
    509  * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
    510  * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
    511  */
    512 function xprofile_action_new_wire_post() {
    513     global $bp;
    514 
    515     if ( $bp->current_component != $bp->wire->slug )
    516         return false;
    517 
    518     if ( 'post' != $bp->current_action )
    519         return false;
    520 
    521     /* Check the nonce */
    522     if ( !check_admin_referer( 'bp_wire_post' ) )
    523         return false;
    524 
    525     if ( !$wire_post = bp_wire_new_post( $bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->id ) ) {
    526         bp_core_add_message( __( 'Wire message could not be posted. Please try again.', 'buddypress' ), 'error' );
    527     } else {
    528         bp_core_add_message( __( 'Wire message successfully posted.', 'buddypress' ) );
    529 
    530         /* Record the notification for the reciever if it's not on their own wire */
    531         if ( !bp_is_home() )
    532             bp_core_add_notification( $bp->loggedin_user->id, $bp->displayed_user->id, $bp->profile->id, 'new_wire_post' );
    533 
    534         /* Record this on the poster's activity screen */
    535         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 ) ) {
    536             $from_user_link = bp_core_get_userlink($wire_post->user_id);
    537             $content = sprintf( __('%s wrote on their own wire', 'buddypress'), $from_user_link ) . ': <span class="time-since">%s</span>';
    538             $primary_link = bp_core_get_userlink( $wire_post->user_id, false, true );
    539         } 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 ) ) {
    540             $from_user_link = bp_core_get_userlink($wire_post->user_id);
    541             $to_user_link = bp_core_get_userlink( $wire_post->item_id, false, false, true, true );
    542             $content = sprintf( __('%s wrote on %s wire', 'buddypress'), $from_user_link, $to_user_link ) . ': <span class="time-since">%s</span>';
    543             $primary_link = bp_core_get_userlink( $wire_post->item_id, false, true );
    544         }
    545 
    546         $content .= '<blockquote>' . bp_create_excerpt($wire_post->content) . '</blockquote>';
    547 
    548         /* Now write the values */
    549         xprofile_record_activity( array(
    550             'user_id' => $bp->loggedin_user->id,
    551             'content' => apply_filters( 'xprofile_activity_new_wire_post', $content, &$wire_post ),
    552             'primary_link' => apply_filters( 'xprofile_activity_new_wire_post_primary_link', $primary_link ),
    553             'component_action' => 'new_wire_post',
    554             'item_id' => $wire_post->id
    555         ) );
    556 
    557         do_action( 'xprofile_new_wire_post', &$wire_post );
    558     }
    559 
    560     if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) {
    561         bp_core_redirect( $bp->displayed_user->domain );
    562     } else {
    563         bp_core_redirect( $bp->displayed_user->domain . $bp->wire->slug );
    564     }
    565 }
    566 add_action( 'wp', 'xprofile_action_new_wire_post', 3 );
    567 
    568 /**
    569  * xprofile_action_delete_wire_post()
    570  *
    571  * Deletes a wire post from the users profile wire.
    572  *
    573  * @package BuddyPress XProfile
    574  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    575  * @uses bp_wire_delete_post() Deletes a wire post for a specific wire using the ID of the item passed and the table name.
    576  * @uses xprofile_delete_activity() Deletes an activity item for the xprofile component and a particular user.
    577  * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load.
    578  * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function
    579  */
    580 function xprofile_action_delete_wire_post() {
    581     global $bp;
    582 
    583     if ( $bp->current_component != $bp->wire->slug )
    584         return false;
    585 
    586     if ( $bp->current_action != 'delete' )
    587         return false;
    588 
    589     if ( !check_admin_referer( 'bp_wire_delete_link' ) )
    590         return false;
    591 
    592     $wire_post_id = $bp->action_variables[0];
    593 
    594     if ( bp_wire_delete_post( $wire_post_id, $bp->profile->slug, $bp->profile->table_name_wire ) ) {
    595         bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
    596 
    597         /* Delete the post from activity streams */
    598         xprofile_delete_activity( array( 'item_id' => $wire_post_id, 'component_action' => 'new_wire_post' ) );
    599 
    600         do_action( 'xprofile_delete_wire_post', $wire_post_id );
    601     } else {
    602         bp_core_add_message( __('Wire post could not be deleted, please try again.', 'buddypress'), 'error' );
    603     }
    604 
    605     if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) {
    606         bp_core_redirect( $bp->displayed_user->domain );
    607     } else {
    608         bp_core_redirect( $bp->displayed_user->domain. $bp->wire->slug );
    609     }
    610 }
    611 add_action( 'wp', 'xprofile_action_delete_wire_post', 3 );
    612 
    613 
    614438/********************************************************************************
    615439 * Activity & Notification Functions
     
    628452    bp_activity_set_action( $bp->profile->id, 'new_member', __( 'New member registered', 'buddypress' ) );
    629453    bp_activity_set_action( $bp->profile->id, 'updated_profile', __( 'Updated Profile', 'buddypress' ) );
    630     bp_activity_set_action( $bp->profile->id, 'new_wire_post', __( 'New profile wire post', 'buddypress' ) );
    631454
    632455    do_action( 'xprofile_register_activity_actions' );
     
    696519
    697520    return apply_filters( 'xprofile_register_activity_action', bp_activity_set_action( $bp->profile->id, $key, $value ), $key, $value );
    698 }
    699 
    700 /**
    701  * xprofile_format_notifications()
    702  *
    703  * Format notifications into something that can be read and displayed
    704  *
    705  * @package BuddyPress Xprofile
    706  * @param $item_id The ID of the specific item for which the activity is recorded (could be a wire post id, user id etc)
    707  * @param $action The component action name e.g. 'new_wire_post' or 'updated_profile'
    708  * @param $total_items The total number of identical notification items (used for grouping)
    709  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    710  * @uses bp_core_global_user_fullname() Returns the display name for the user
    711  * @return The readable notification item
    712  */
    713 function xprofile_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    714     global $bp;
    715 
    716     if ( 'new_wire_post' == $action ) {
    717         if ( (int)$total_items > 1 ) {
    718             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 );
    719         } else {
    720             $user_fullname = bp_core_get_user_displayname( $item_id );
    721             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 );
    722         }
    723     }
    724 
    725     do_action( 'xprofile_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    726 
    727     return false;
    728521}
    729522
     
    1089882
    1090883    bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->id, 'new_at_mention' );
    1091     bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->id, 'new_wire_post' );
    1092 }
    1093 add_action( 'bp_wire_screen_latest', 'xprofile_remove_screen_notifications' );
     884}
    1094885add_action( 'bp_activity_screen_my_activity', 'xprofile_remove_screen_notifications' );
    1095886add_action( 'bp_activity_screen_single_activity_permalink', 'xprofile_remove_screen_notifications' );
Note: See TracChangeset for help on using the changeset viewer.