Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/12/2010 01:17:56 AM (17 years ago)
Author:
apeatling
Message:

Fixed support for specific actions such as new update, new reply and favoriting activities when JS is turned off.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r2666 r2692  
    1111
    1212/***
    13  * Each object loop (activity/members/groups/blogs/forums) contains parameters to
     13 * This function looks scarier than it actually is. :)
     14 * Each object loop (activity/members/groups/blogs/forums) contains default parameters to
    1415 * show specific information based on the page we are currently looking at.
    1516 * The following function will take into account any cookies set in the JS and allow us
    1617 * to override the parameters sent. That way we can change the results returned without reloading the page.
     18 * By using cookies we can also make sure that user settings are retained across page loads.
    1719 */
    1820function bp_dtheme_ajax_querystring( $object = false ) {
    … …  
    6163}
    6264
     65/* This function will simply load the template loop for the current object. On an AJAX request */
    6366function bp_dtheme_object_template_loader() {
    6467        $object = esc_attr( $_POST['object'] );
    … …  
    7073add_action( 'wp_ajax_forums_filter', 'bp_dtheme_object_template_loader' );
    7174
     75/* This function will load the activity loop template when activity is requested via AJAX */
    7276function bp_dtheme_activity_template_loader() {
    7377        global $bp;
    … …  
    104108add_action( 'wp_ajax_activity_get_older_updates', 'bp_dtheme_activity_template_loader' );
    105109
     110/* AJAX update posting */
    106111function bp_dtheme_post_update() {
    107112        global $bp;
    … …  
    120125        }
    121126
    122         if ( empty( $_POST['object'] ) ) {
    123                 $activity_id = bp_activity_post_update( array(
    124                         'content' => $_POST['content']
    125                 ));
     127        if ( empty( $_POST['object'] ) && function_exists( 'bp_activity_post_update' ) ) {
     128                $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) );
    126129        } elseif ( $_POST['object'] == 'groups' ) {
    127                 if ( !empty( $_POST['item_id'] ) ) {
    128                 $activity_id = groups_post_update( array(
    129                         'content' => $_POST['content'],
    130                                 'group_id' => $_POST['item_id']
    131                 ));
    132                 }
    133         } else {
     130                if ( !empty( $_POST['item_id'] ) && function_exists( 'groups_post_update' ) )
     131                        $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
     132        } else
    134133                $activity_id = apply_filters( 'bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content'] );
    135         }
    136134
    137135        if ( !$activity_id ) {
    … …  
    148146add_action( 'wp_ajax_post_update', 'bp_dtheme_post_update' );
    149147
     148/* AJAX activity comment posting */
    150149function bp_dtheme_new_activity_comment() {
    151150        global $bp;
    … …  
    202201add_action( 'wp_ajax_new_activity_comment', 'bp_dtheme_new_activity_comment' );
    203202
     203/* AJAX delete an activity */
    204204function bp_dtheme_delete_activity() {
    205205        global $bp;
    … …  
    228228add_action( 'wp_ajax_delete_activity', 'bp_dtheme_delete_activity' );
    229229
     230/* AJAX delete an activity comment */
    230231function bp_dtheme_delete_activity_comment() {
    231232        global $bp;
    … …  
    254255add_action( 'wp_ajax_delete_activity_comment', 'bp_dtheme_delete_activity_comment' );
    255256
     257/* AJAX mark an activity as a favorite */
    256258function bp_dtheme_mark_activity_favorite() {
    257259        global $bp;
    … …  
    262264add_action( 'wp_ajax_activity_mark_fav', 'bp_dtheme_mark_activity_favorite' );
    263265
     266/* AJAX mark an activity as not a favorite */
    264267function bp_dtheme_unmark_activity_favorite() {
    265268        global $bp;
    … …  
    270273add_action( 'wp_ajax_activity_mark_unfav', 'bp_dtheme_unmark_activity_favorite' );
    271274
     275/* AJAX invite a friend to a group functionality */
    272276function bp_dtheme_ajax_invite_user() {
    273277        global $bp;
    … …  
    313317add_action( 'wp_ajax_groups_invite_user', 'bp_dtheme_ajax_invite_user' );
    314318
     319/* AJAX add/remove a user as a friend when clicking the button */
    315320function bp_dtheme_ajax_addremove_friend() {
    316321        global $bp;
    … …  
    343348add_action( 'wp_ajax_addremove_friend', 'bp_dtheme_ajax_addremove_friend' );
    344349
     350/* AJAX accept a user as a friend when clicking the "accept" button */
    345351function bp_dtheme_ajax_accept_friendship() {
    346352        check_admin_referer( 'friends_accept_friendship' );
    … …  
    353359add_action( 'wp_ajax_accept_friendship', 'bp_dtheme_ajax_accept_friendship' );
    354360
     361/* AJAX reject a user as a friend when clicking the "reject" button */
    355362function bp_dtheme_ajax_reject_friendship() {
    356363        check_admin_referer( 'friends_reject_friendship' );
    … …  
    363370add_action( 'wp_ajax_reject_friendship', 'bp_dtheme_ajax_reject_friendship' );
    364371
     372/* AJAX join or leave a group when clicking the "join/leave" button */
    365373function bp_dtheme_ajax_joinleave_group() {
    366374        global $bp;
    … …  
    415423add_action( 'wp_ajax_joinleave_group', 'bp_dtheme_ajax_joinleave_group' );
    416424
     425/* AJAX close and keep closed site wide notices from an admin in the sidebar */
    417426function bp_dtheme_ajax_close_notice() {
    418427        global $userdata;
    … …  
    430439add_action( 'wp_ajax_messages_close_notice', 'bp_dtheme_ajax_close_notice' );
    431440
     441/* AJAX send a private message reply to a thread */
    432442function bp_dtheme_ajax_messages_send_reply() {
    433443        global $bp;
    … …  
    465475add_action( 'wp_ajax_messages_send_reply', 'bp_dtheme_ajax_messages_send_reply' );
    466476
     477/* AJAX mark a private message as unread in your inbox */
    467478function bp_dtheme_ajax_message_markunread() {
    468479        global $bp;
    … …  
    480491add_action( 'wp_ajax_messages_markunread', 'bp_dtheme_ajax_message_markunread' );
    481492
     493/* AJAX mark a private message as read in your inbox */
    482494function bp_dtheme_ajax_message_markread() {
    483495        global $bp;
    … …  
    495507add_action( 'wp_ajax_messages_markread', 'bp_dtheme_ajax_message_markread' );
    496508
     509/* AJAX delete a private message or array of messages in your inbox */
    497510function bp_dtheme_ajax_messages_delete() {
    498511        global $bp;
    … …  
    511524add_action( 'wp_ajax_messages_delete', 'bp_dtheme_ajax_messages_delete' );
    512525
     526/* AJAX autocomplete your friends names on the compose screen */
    513527function bp_dtheme_ajax_messages_autocomplete_results() {
    514528        global $bp;
Note: See TracChangeset for help on using the changeset viewer.