Skip to:
Content

BuddyPress.org

Changeset 4147


Ignore:
Timestamp:
03/23/2011 08:36:24 PM (15 years ago)
Author:
boonebgorges
Message:

Adds tag editing field to Topic Edit screen. References #2281

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-functions.php

    r4010 r4147  
    186186                'topic_id'    => false,
    187187                'topic_title' => '',
    188                 'topic_text'  => ''
    189         );
    190 
    191         $r = wp_parse_args( $args, $defaults );
    192         extract( $r, EXTR_SKIP );
    193 
    194         if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
     188                'topic_text'  => '',
     189                'topic_tags'  => false
     190        );
     191
     192        $r = wp_parse_args( $args, $defaults );
     193        extract( $r, EXTR_SKIP );
     194
     195        if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ), 'tags' => $topic_tags ) ) )
    195196                return false;
    196197
  • trunk/bp-forums/bp-forums-template.php

    r4124 r4147  
    11741174}
    11751175
     1176/**
     1177 * Echo the current topic's tag list, comma-separated
     1178 *
     1179 * @package BuddyPress
     1180 * @since 1.3
     1181 */
     1182function bp_forum_topic_tag_list() {
     1183        echo bp_get_forum_topic_tag_list();
     1184}
     1185        /**
     1186         * Get the current topic's tag list
     1187         *
     1188         * @package BuddyPress
     1189         * @since 1.3
     1190         *
     1191         * @param str $format 'string' returns comma-separated string; otherwise returns array
     1192         * @return mixed $tags
     1193         */
     1194        function bp_get_forum_topic_tag_list( $format = 'string' ) {
     1195                do_action( 'bbpress_init' );
     1196               
     1197                // Pull up the tag objects
     1198                $tags_data = bb_get_topic_tags( bp_get_the_topic_id() );
     1199               
     1200                // Convert them to a comma-separated string
     1201                $tags = array();
     1202                foreach( $tags_data as $tag_data ) {
     1203                        $tags[] = $tag_data->name;
     1204                }
     1205               
     1206                if ( 'string' == $format )
     1207                        $tags = implode( ', ', $tags );
     1208                       
     1209                return apply_filters( 'bp_forum_topic_tag_list', $tags, $format );
     1210        }
     1211
    11761212function bp_forum_action() {
    11771213        echo bp_get_forum_action();
  • trunk/bp-groups/bp-groups-forums.php

    r4137 r4147  
    112112}
    113113
    114 function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) {
     114function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text, $topic_tags = false ) {
    115115        global $bp;
    116116
     
    118118        $topic_text  = apply_filters( 'group_forum_topic_text_before_save',  $topic_text  );
    119119
    120         if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
     120        if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id, 'topic_tags' => $topic_tags ) ) ) {
    121121                // Update the activity stream item
    122122                if ( bp_is_active( 'activity' ) )
  • trunk/bp-groups/bp-groups-screens.php

    r4137 r4147  
    232232                                        check_admin_referer( 'bp_forums_edit_topic' );
    233233
    234                                         if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) )
     234                                        $topic_tags = !empty( $_POST['topic_tags'] ) ? $_POST['topic_tags'] : false;
     235
     236                                        if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'], $topic_tags ) )
    235237                                                bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' );
    236238                                        else
  • trunk/bp-themes/bp-default/groups/single/forum/edit.php

    r3912 r4147  
    5252                                        <label for="topic_text"><?php _e( 'Content:', 'buddypress' ); ?></label>
    5353                                        <textarea name="topic_text" id="topic_text"><?php bp_the_topic_text(); ?></textarea>
     54                                       
     55                                        <label><?php _e( 'Tags (comma separated):', 'buddypress' ) ?></label>
     56                                        <input type="text" name="topic_tags" id="topic_tags" value="<?php bp_forum_topic_tag_list() ?>" />
    5457
    5558                                        <?php do_action( 'bp_group_after_edit_forum_topic' ); ?>
Note: See TracChangeset for help on using the changeset viewer.