Skip to:
Content

BuddyPress.org

Changeset 2460


Ignore:
Timestamp:
01/26/2010 05:49:48 PM (17 years ago)
Author:
apeatling
Message:

Fixed forum post activity tracking, now links directly to the forum post. Only show post form on the last page of posts.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs.php

    r2424 r2460  
    253253                'item_id' => false,
    254254                'secondary_item_id' => false,
     255                'recorded_time' => gmdate( "Y-m-d H:i:s" ),
    255256                'hide_sitewide' => false
    256257        );
    … …  
    278279        ) );
    279280
    280         return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'hide_sitewide' => $hide_sitewide ) );
     281        return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    281282}
    282283
  • trunk/bp-core.php

    r2451 r2460  
    14631463                $last_active = __( 'not recently active', 'buddypress' );
    14641464        } else {
    1465                 if ( strstr( $last_activity_date, '-' ) ) {
    1466                         $last_active = bp_core_time_since( strtotime( $last_activity_date ) );
    1467                 } else {
    1468                         $last_active = bp_core_time_since( $last_activity_date );
    1469                 }
    1470 
    1471                 $last_active = sprintf( $string, $last_active );
     1465                $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
    14721466        }
    14731467
  • trunk/bp-core/bp-core-templatetags.php

    r2455 r2460  
    253253                global $members_template;
    254254
    255                 $last_activity = attribute_escape( bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s ago', 'buddypress' ) ) );
     255                $last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s ago', 'buddypress' ) );
    256256
    257257                return apply_filters( 'bp_member_last_active', $last_activity );
  • trunk/bp-forums/bp-forums-templatetags.php

    r2448 r2460  
    738738                        'mid_size' => 1
    739739                ));
     740                $this->pag->total_pages = ceil($this->total_post_count / $this->pag_num);
    740741        }
    741742
    … …  
    914915                extract( $r, EXTR_SKIP );
    915916
    916                 $links  = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . 'edit/post/' . $topic_template->post->post_id, 'bp_forums_edit_post' ) . '">' . __( 'Edit Post', 'buddypress' ) . '</a> ' . $seperator . ' ';
    917                 $links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete/post/' . $topic_template->post->post_id, 'bp_forums_delete_post' ) . '">' . __( 'Delete Post', 'buddypress' ) . '</a>';
     917                if ( $_SERVER['QUERY_STRING'] )
     918                        $query_vars = '?' . $_SERVER['QUERY_STRING'];
     919
     920                $links  = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . 'edit/post/' . $topic_template->post->post_id . '/' . $query_vars, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';
     921                $links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete/post/' . $topic_template->post->post_id, 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a> | ';
    918922
    919923                return $links;
    … …  
    950954<?php
    951955}
     956
     957function bp_the_topic_is_last_page() {
     958        echo bp_get_the_topic_is_last_page();
     959}
     960        function bp_get_the_topic_is_last_page() {
     961                global $topic_template;
     962
     963                return apply_filters( 'bp_get_the_topic_is_last_page', $topic_template->pag_page == $topic_template->pag->total_pages );
     964        }
    952965
    953966function bp_directory_forums_search_form() {
  • trunk/bp-friends.php

    r2416 r2460  
    276276                'item_id' => false,
    277277                'secondary_item_id' => false,
     278                'recorded_time' => gmdate( "Y-m-d H:i:s" ),
    278279                'hide_sitewide' => false
    279280        );
    … …  
    282283        extract( $r, EXTR_SKIP );
    283284
    284         return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'hide_sitewide' => $hide_sitewide ) );
     285        return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    285286}
    286287
  • trunk/bp-groups.php

    r2424 r2460  
    375375                                        groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    376376
    377                                 if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) )
     377                                if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $_GET['topic_page'] ) )
    378378                                        bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
    379379                                else
    … …  
    383383                                        $query_vars = '?' . $_SERVER['QUERY_STRING'];
    384384
    385                                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars );
     385                                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );
    386386                        }
    387387
    … …  
    522522                                        check_admin_referer( 'bp_forums_edit_post' );
    523523
    524                                         if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) )
     524                                        if ( !$post_id = groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id, $_GET['topic_page'] ) )
    525525                                                bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
    526526                                        else
    527527                                                bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
    528528
     529                                        if ( $_SERVER['QUERY_STRING'] )
     530                                                $query_vars = '?' . $_SERVER['QUERY_STRING'];
     531
    529532                                        do_action( 'groups_edit_forum_post', $post_id );
    530                                         bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' );
     533                                        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );
    531534                                }
    532535
    … …  
    13181321
    13191322        $defaults = array(
     1323                'id' => false,
    13201324                'user_id' => $bp->loggedin_user->id,
    13211325                'action' => '',
    … …  
    13261330                'item_id' => false,
    13271331                'secondary_item_id' => false,
     1332                'recorded_time' => gmdate( "Y-m-d H:i:s" ),
    13281333                'hide_sitewide' => $hide_sitewide
    13291334        );
    … …  
    13321337        extract( $r, EXTR_SKIP );
    13331338
    1334         return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'hide_sitewide' => $hide_sitewide ) );
     1339        return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    13351340}
    13361341
    … …  
    19291934}
    19301935
    1931 function groups_new_group_forum_post( $post_text, $topic_id ) {
     1936function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
    19321937        global $bp;
    19331938
    … …  
    19381943        $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
    19391944
    1940         if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
     1945        if ( $post_id = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
    19411946                $topic = bp_forums_get_topic_details( $topic_id );
    19421947
    19431948                $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    19441949                $activity_content = '<blockquote>' . bp_create_excerpt( $post_text ) . '</blockquote>';
     1950                $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     1951
     1952                if ( $page )
     1953                        $primary_link .= "?topic_page=" . $page;
    19451954
    19461955                /* Record this in activity streams */
    19471956                groups_record_activity( array(
    1948                         'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
    1949                         'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
    1950                         'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/' ),
     1957                        'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_id, $post_text, &$topic ),
     1958                        'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_id, $post_text, &$topic ),
     1959                        'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
    19511960                        'type' => 'new_forum_post',
    19521961                        'item_id' => $bp->groups->current_group->id,
    1953                         'secondary_item_id' => $forum_post
     1962                        'secondary_item_id' => $post_id
    19541963                ) );
    19551964
    1956                 do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $forum_post );
    1957 
    1958                 return $forum_post;
     1965                do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $post_id );
     1966
     1967                return $post_id;
    19591968        }
    19601969
    … …  
    20202029                        'user_id' => (int)$topic->topic_poster,
    20212030                        'secondary_item_id' => $topic->topic_id,
    2022                         'recorded_time' => strtotime( $topic->topic_time )
     2031                        'recorded_time' => $topic->topic_time
    20232032                ) );
    20242033
    20252034                do_action( 'groups_update_group_forum_topic', &$topic );
    20262035
    2027                 return true;
     2036                return $topic;
    20282037        }
    20292038
    … …  
    20312040}
    20322041
    2033 function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) {
     2042function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
    20342043        global $bp;
    20352044
    … …  
    20422051                $topic = bp_forums_get_topic_details( $topic_id );
    20432052
    2044                 /* Update the activity stream item */
    2045                 if ( function_exists( 'bp_activity_delete_by_item_id' ) )
    2046                         bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post' ) );
    2047 
    20482053                $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
    20492054                $activity_content = '<blockquote>' . bp_create_excerpt( $post_text ) . '</blockquote>';
    2050 
    2051                 /* Record this in activity streams */
     2055                $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     2056
     2057                if ( $page )
     2058                        $primary_link .= "?topic_page=" . $page;
     2059
     2060                /* Fetch an existing entry and update if one exists. */
     2061                if ( function_exists( 'bp_activity_get_activity_id' ) )
     2062                        $id = bp_activity_get_activity_id( array( 'user_id' => $post->poster_id, 'component' => $bp->groups->id, 'type' => 'new_forum_post', 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id ) );
     2063
     2064                /* Update the entry in activity streams */
    20522065                groups_record_activity( array(
     2066                        'id' => $id,
    20532067                        'action' => apply_filters( 'groups_activity_new_forum_post_action', $activity_action, $post_text, &$topic, &$forum_post ),
    20542068                        'content' => apply_filters( 'groups_activity_new_forum_post_content', $activity_content, $post_text, &$topic, &$forum_post ),
    2055                         'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
     2069                        'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
    20562070                        'type' => 'new_forum_post',
    20572071                        'item_id' => (int)$bp->groups->current_group->id,
    20582072                        'user_id' => (int)$post->poster_id,
    20592073                        'secondary_item_id' => $post_id,
    2060                         'recorded_time' => strtotime( $post->post_time )
     2074                        'recorded_time' => $post->post_time
    20612075                ) );
    20622076
    20632077                do_action( 'groups_update_group_forum_post', &$post, &$topic );
    20642078
    2065                 return true;
     2079                return $post_id;
    20662080        }
    20672081
  • trunk/bp-themes/bp-default/_inc/css/default.css

    r2453 r2460  
    15301530                margin: 5px 0 25px 0;
    15311531        }
    1532                 div.navigation .alignright {
     1532                .alignright {
    15331533                        float: right;
    1534                 }
    1535 
    1536                 div.navigation .alignleft {
     1534                        margin-left: 15px;
     1535                }
     1536
     1537                .alignleft {
    15371538                        float: left;
     1539                        margin-right: 15px;
    15381540                }
    15391541
  • trunk/bp-themes/bp-default/_inc/global.js

    r2449 r2460  
    671671                                var el = j('li.filter select');
    672672
     673                        alert(el.attr('id'));
     674
    673675                        var page_number = 1;
    674676                        var css_id = el.attr('id').split( '-' );
  • trunk/bp-themes/bp-default/groups/single/forum.php

    r2455 r2460  
    2727                                <?php endif; ?>
    2828
    29                                 <a name="post-new"></a>
    30                                 <h3><?php _e( 'Post a New Topic:', 'buddypress' ) ?></h3>
     29                                <p id="post-new"></p>
     30                                <h4><?php _e( 'Post a New Topic:', 'buddypress' ) ?></h4>
    3131
    3232                                <label><?php _e( 'Title:', 'buddypress' ) ?></label>
  • trunk/bp-themes/bp-default/groups/single/forum/topic.php

    r2170 r2460  
    33        <form action="<?php bp_forum_topic_action() ?>" method="post" id="forum-topic-form" class="standard-form">
    44
    5                 <div class="pagination">
     5                <div class="pagination no-ajax">
    66
    77                        <div id="post-count" class="pag-count">
    … …  
    3737                                        </div>
    3838
    39                                         <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_post_is_mine() ) : ?>
    40                                                 <div class="admin-links"><?php bp_the_topic_post_admin_links() ?></div>
    41                                         <?php endif; ?>
     39                                        <div class="admin-links">
     40                                                <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_post_is_mine() ) : ?>
     41                                                        <?php bp_the_topic_post_admin_links() ?>
     42                                                <?php endif; ?>
     43                                                <a href="#post-<?php bp_the_topic_post_id() ?>" title="<?php _e( 'Permanent link to this post', 'buddypress' ) ?>">#</a>
     44                                        </div>
    4245                                </li>
    4346
    … …  
    4548                </ul>
    4649
     50                <div class="pagination no-ajax">
     51
     52                        <div id="post-count" class="pag-count">
     53                                <?php bp_the_topic_pagination_count() ?>
     54                        </div>
     55
     56                        <div class="pagination-links" id="topic-pag">
     57                                <?php bp_the_topic_pagination() ?>
     58                        </div>
     59
     60                </div>
     61
    4762                <?php if ( ( is_user_logged_in() && 'public' == bp_get_group_status() ) || bp_group_is_member() ) : ?>
    4863
    49                         <?php if ( bp_get_the_topic_is_topic_open() ) : ?>
     64                        <?php if ( bp_get_the_topic_is_last_page() ) : ?>
    5065
    51                                 <div id="post-topic-reply">
    52                                         <a name="post-reply"></a>
     66                                <?php if ( bp_get_the_topic_is_topic_open() ) : ?>
    5367
    54                                         <?php if ( !bp_group_is_member() ) : ?>
    55                                                 <p><?php _e( 'You will auto join this group when you reply to this topic.', 'buddypress' ) ?></p>
    56                                         <?php endif; ?>
     68                                        <div id="post-topic-reply">
     69                                                <p id="post-reply"></p>
    5770
    58                                         <?php do_action( 'groups_forum_new_reply_before' ) ?>
     71                                                <?php if ( !bp_group_is_member() ) : ?>
     72                                                        <p><?php _e( 'You will auto join this group when you reply to this topic.', 'buddypress' ) ?></p>
     73                                                <?php endif; ?>
    5974
    60                                         <p><strong><?php _e( 'Add a reply:', 'buddypress' ) ?></strong></p>
     75                                                <?php do_action( 'groups_forum_new_reply_before' ) ?>
    6176
    62                                         <textarea name="reply_text" id="reply_text"></textarea>
     77                                                <h4><?php _e( 'Add a reply:', 'buddypress' ) ?></h4>
    6378
    64                                         <div class="submit">
    65                                                 <input type="submit" name="submit_reply" id="submit" value="<?php _e( 'Post Reply', 'buddypress' ) ?>" />
     79                                                <textarea name="reply_text" id="reply_text"></textarea>
     80
     81                                                <div class="submit">
     82                                                        <input type="submit" name="submit_reply" id="submit" value="<?php _e( 'Post Reply', 'buddypress' ) ?>" />
     83                                                </div>
     84
     85                                                <?php do_action( 'groups_forum_new_reply_after' ) ?>
     86
     87                                                <?php wp_nonce_field( 'bp_forums_new_reply' ) ?>
    6688                                        </div>
    6789
    68                                         <?php do_action( 'groups_forum_new_reply_after' ) ?>
     90                                <?php else : ?>
    6991
    70                                         <?php wp_nonce_field( 'bp_forums_new_reply' ) ?>
    71                                 </div>
     92                                        <div id="message" class="info">
     93                                                <p><?php _e( 'This topic is closed, replies are no longer accepted.', 'buddypress' ) ?></p>
     94                                        </div>
    7295
    73                         <?php else : ?>
    74 
    75                                 <div id="message" class="info">
    76                                         <p><?php _e( 'This topic is closed, replies are no longer accepted.', 'buddypress' ) ?></p>
    77                                 </div>
     96                                <?php endif; ?>
    7897
    7998                        <?php endif; ?>
  • trunk/bp-xprofile.php

    r2416 r2460  
    490490                'item_id' => false,
    491491                'secondary_item_id' => false,
     492                'recorded_time' => gmdate( "Y-m-d H:i:s" ),
    492493                'hide_sitewide' => false
    493494        );
    … …  
    496497        extract( $r, EXTR_SKIP );
    497498
    498         return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'hide_sitewide' => $hide_sitewide ) );
     499        return bp_activity_add( array( 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    499500}
    500501
Note: See TracChangeset for help on using the changeset viewer.