Changeset 1621
- Timestamp:
- 07/21/2009 09:45:28 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 2 deleted
- 16 edited
-
bp-activity.php (modified) (3 diffs)
-
bp-activity/bp-activity-classes.php (modified) (3 diffs)
-
bp-blogs.php (modified) (2 diffs)
-
bp-core.php (modified) (1 diff)
-
bp-core/css/structure.css (modified) (1 diff)
-
bp-forums (modified) (1 prop)
-
bp-forums.php (modified) (3 diffs)
-
bp-forums/bbpress-plugins (deleted)
-
bp-forums/bp-forums-admin.php (modified) (2 diffs)
-
bp-forums/bp-forums-bbpress-live.php (deleted)
-
bp-forums/bp-forums-bbpress.php (added)
-
bp-forums/bp-forums-classes.php (added)
-
bp-forums/bp-forums-cssjs.php (added)
-
bp-forums/bp-forums-filters.php (modified) (3 diffs)
-
bp-forums/bp-forums-templatetags.php (modified) (19 diffs)
-
bp-forums/images (added)
-
bp-forums/images/closed.png (added)
-
bp-forums/installation-readme.txt (modified) (1 diff)
-
bp-groups.php (modified) (20 diffs)
-
bp-groups/bp-groups-cssjs.php (modified) (1 diff)
-
bp-groups/bp-groups-templatetags.php (modified) (19 diffs)
-
bp-status/bp-status-filters.php (modified) (2 diffs)
-
bp-wire.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity.php
r1599 r1621 189 189 extract( $r, EXTR_SKIP ); 190 190 191 /* Insert the "time-since" placeholder */ 192 if ( $content ) { 193 if ( !$pos = strpos( $content, '<blockquote' ) ) { 194 if ( !$pos = strpos( $content, '<div' ) ) { 195 if ( !$pos = strpos( $content, '<ul' ) ) { 196 $content .= ' <span class="time-since">%s</span>'; 197 } 198 } 199 } 200 201 if ( $pos ) { 202 $before = substr( $content, 0, $pos ); 203 $after = substr( $content, $pos, strlen( $content ) ); 204 205 $content = $before . ' <span class="time-since">%s</span>' . $after; 206 } 207 } 208 191 209 $activity = new BP_Activity_Activity; 192 210 $activity->user_id = $user_id; … … 208 226 } 209 227 210 function bp_activity_update( $args = '' ) { 211 global $bp, $wpdb; 212 213 extract( $args );214 228 /* There are multiple ways to delete activity items, depending on the information you have at the time. */ 229 230 function bp_activity_delete_by_item_id( $args = '' ) { 231 global $bp; 232 215 233 $defaults = array( 216 'user_id' => $bp->loggedin_user->id, 217 'content' => false, 234 'item_id' => false, 218 235 'component_name' => false, 219 236 'component_action' => false, 220 'item_id' => false, 221 'secondary_item_id' => false, 222 'recorded_time' => time(), 223 'hide_sitewide' => false 237 'user_id' => false, // optional 238 'secondary_item_id' => false // optional 224 239 ); 225 240 226 241 $r = wp_parse_args( $args, $defaults ); 227 242 extract( $r, EXTR_SKIP ); 228 229 $activity = new BP_Activity_Activity( $user_id, $component_name, $component_action, $item_id, $secondary_item_id ); 230 $activity->user_id = $user_id; 231 $activity->content = $content; 232 $activity->primary_link = $primary_link; 233 $activity->component_name = $component_name; 234 $activity->component_action = $component_action; 235 $activity->item_id = $item_id; 236 $activity->secondary_item_id = $secondary_item_id; 237 $activity->date_recorded = $recorded_time; 238 $activity->hide_sitewide = $hide_sitewide; 239 240 if ( !$activity->save() ) 241 return false; 242 243 do_action( 'bp_activity_update', $args ); 244 245 return true; 246 } 247 248 /* There are multiple ways to delete activity items, depending on the information you have at the time. */ 249 250 function bp_activity_delete_by_item_id( $user_id, $component_name, $component_action, $item_id, $secondary_item_id = false ) { 251 if ( !BP_Activity_Activity::delete_by_item_id( $user_id, $component_name, $component_action, $item_id, $secondary_item_id ) ) 252 return false; 253 254 do_action( 'bp_activity_delete_by_item_id', $user_id, $component_name, $component_action, $item_id, $secondary_item_id ); 243 244 if ( !BP_Activity_Activity::delete_by_item_id( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) ) 245 return false; 246 247 do_action( 'bp_activity_delete_by_item_id', $item_id, $component_name, $component_action, $user_id, $secondary_item_id ); 255 248 256 249 return true; … … 345 338 /* DEPRECATED - use bp_activity_delete_by_item_id() */ 346 339 function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) { 347 if ( !bp_activity_delete_by_item_id( $user_id, $component_name, $component_action, $item_id, $secondary_item_id) )340 if ( !bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ) ) 348 341 return false; 349 342 -
trunk/bp-activity/bp-activity-classes.php
r1595 r1621 15 15 global $bp; 16 16 17 if ( $args ) {17 if ( $args && is_array($args) ) { 18 18 extract( $args ); 19 19 … … 106 106 /* Static Functions */ 107 107 108 function delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id = false ) { 109 global $wpdb, $bp; 110 111 if ( !$user_id ) 112 return false; 108 function delete( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) { 109 global $wpdb, $bp; 113 110 114 111 if ( $secondary_item_id ) … … 116 113 117 114 if ( $component_action ) 118 $component_action_sql = $wpdb->prepare( "AND component_action = %s AND user_id = %d", $component_action, $user_id ); 119 120 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %d {$secondary_sql} AND component_name = %s {$cached_component_action_sql}", $user_id, $item_id, $component_name ) ); 121 } 122 123 function delete_by_item_id( $user_id, $component_name, $component_action, $item_id, $secondary_item_id = false ) { 115 $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action ); 116 117 if ( $user_id ) 118 $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id ); 119 120 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %d {$secondary_sql} AND component_name = %s {$component_action_sql} {$user_sql}", $item_id, $component_name ) ); 121 } 122 123 function delete_by_item_id( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) { 124 124 return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ); 125 125 } -
trunk/bp-blogs.php
r1599 r1621 408 408 $recorded_post->blog_id = $blog_id; 409 409 $recorded_post->post_id = $post_id; 410 $recorded_post->date_created = strtotime( $post->post_date );410 $recorded_post->date_created = strtotime( $post->post_date_gmt ); 411 411 412 412 $recorded_post_id = $recorded_post->save(); 413 413 414 414 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() ); 415 bp_blogs_record_activity( array( 'item_id' => $recorded_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post', 'is_private' => bp_blogs_is_blog_hidden( $recorded_post->blog_id ), 'user_id' => $recorded_post->user_id, 'recorded_time' => strtotime( $post->post_date ) ) );415 bp_blogs_record_activity( array( 'item_id' => $recorded_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post', 'is_private' => bp_blogs_is_blog_hidden( $recorded_post->blog_id ), 'user_id' => $recorded_post->user_id, 'recorded_time' => strtotime( $post->post_date_gmt ) ) ); 416 416 } 417 417 } else { … … 439 439 /* Delete and re-add the activity stream item to reflect potential content changes. */ 440 440 bp_blogs_delete_activity( array( 'item_id' => $recorded_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post', 'user_id' => $recorded_post->user_id ) ); 441 bp_blogs_record_activity( array( 'item_id' => $recorded_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post', 'is_private' => bp_blogs_is_blog_hidden( $recorded_post->blog_id ), 'user_id' => $recorded_post->user_id, 'recorded_time' => strtotime( $post->post_date ) ) );441 bp_blogs_record_activity( array( 'item_id' => $recorded_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post', 'is_private' => bp_blogs_is_blog_hidden( $recorded_post->blog_id ), 'user_id' => $recorded_post->user_id, 'recorded_time' => strtotime( $post->post_date_gmt ) ) ); 442 442 } 443 443 -
trunk/bp-core.php
r1619 r1621 1540 1540 global $wpdb; 1541 1541 ?> 1542 <!-- Generated in <?php timer_stop(1); ?> seconds. -->1542 <!-- Generated in <?php timer_stop(1); ?> seconds. <?php echo $wpdb->num_queries; ?> queries.--> 1543 1543 <?php 1544 1544 } -
trunk/bp-core/css/structure.css
r1366 r1621 85 85 } 86 86 87 div.info-group h4 a{87 div.info-group h4 span { 88 88 position: absolute; 89 89 top: 0.31em; -
trunk/bp-forums
- Property svn:externals set to
-
trunk/bp-forums.php
r1547 r1621 5 5 define ( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 6 6 7 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress-live.php' ); 7 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' ); 8 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-classes.php' ); 8 9 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-templatetags.php' ); 9 10 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php' ); 10 11 if ( is_admin() ) 12 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 11 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-cssjs.php' ); 13 12 14 13 function bp_forums_setup() { 15 global $bp, $bbpress_live; 16 17 if ( '' == get_usermeta( $bp->loggedin_user->id, 'bb_capabilities' ) ) 18 bp_forums_make_user_active_member( $bp->loggedin_user->id ); 19 20 $bp->version_numbers->forums = BP_FORUMS_VERSION; 14 global $bp; 15 16 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 17 $bp->forums->bbconfig = get_site_option( 'bb-config-location' ); 21 18 } 22 19 add_action( 'plugins_loaded', 'bp_forums_setup', 5 ); … … 24 21 25 22 function bp_forums_is_installed_correctly() { 26 global $bbpress_live; 27 28 if ( !is_object( $bbpress_live ) ) { 29 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 30 $bbpress_live = new bbPress_Live(); 31 } 32 33 if ( !$bbpress_live->fetch->endpoint ) 34 return false; 35 36 return true; 37 } 38 39 function bp_forums_get_forum( $parent = 0, $depth = 0 ) { 40 global $bbpress_live; 41 42 if ( !is_object( $bbpress_live ) ) { 43 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 44 $bbpress_live = new bbPress_Live(); 45 } 46 47 if ( $forum = $bbpress_live->get_forums( $parent, $depth ) ) { 48 do_action( 'bp_forums_get_forum', $forum ); 49 return $forum; 50 } 23 global $bp; 24 25 if ( file_exists( $bp->forums->bbconfig ) ) 26 return true; 51 27 52 28 return false; 53 29 } 54 30 55 function bp_forums_get_topics( $forum_id = 0, $number = 0, $page = 1 ) { 56 global $bbpress_live; 57 58 if ( !is_object( $bbpress_live ) ) { 59 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 60 $bbpress_live = new bbPress_Live(); 61 } 62 63 if ( $topics = $bbpress_live->get_topics( $forum_id, $number, $page ) ) { 64 do_action( 'bp_forums_get_topics', $topics ); 65 return $topics; 66 } 67 31 function bp_forums_add_admin_menu() { 32 global $bp; 33 34 if ( !is_site_admin() ) 35 return false; 36 37 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 38 39 /* Add the administration tab under the "Site Admin" tab for site administrators */ 40 add_submenu_page( 'bp-core.php', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 2, __FILE__, "bp_forums_bbpress_admin" ); 41 } 42 add_action( 'admin_menu', 'bp_forums_add_admin_menu' ); 43 44 function bp_forums_get_forum( $forum_id ) { 45 do_action( 'bbpress_init' ); 46 return bb_get_forum( $forum_id ); 47 } 48 49 function bp_forums_get_forum_topics( $args = '' ) { 50 do_action( 'bbpress_init' ); 51 52 $defaults = array( 53 'forum_id' => false, 54 'page' => 1, 55 'per_page' => 15, 56 'exclude' => false 57 ); 58 59 $r = wp_parse_args( $args, $defaults ); 60 extract( $r, EXTR_SKIP ); 61 62 return get_latest_topics( array( 'forum' => $forum_id, 'page' => $page_num, 'number' => $per_page, 'exclude' => $exclude ) ); 63 } 64 65 function bp_forums_get_topic_details( $topic_id ) { 66 do_action( 'bbpress_init' ); 67 return get_topic( $topic_id ); 68 } 69 70 function bp_forums_get_topic_id_from_slug( $topic_slug ) { 71 do_action( 'bbpress_init' ); 72 return bb_get_id_from_slug( 'topic', $topic_slug ); 73 } 74 75 function bp_forums_get_topic_posts( $args = '' ) { 76 do_action( 'bbpress_init' ); 77 78 $defaults = array( 79 'topic_id' => false, 80 'page' => 1, 81 'per_page' => 15, 82 'order' => 'ASC' 83 ); 84 85 $args = wp_parse_args( $args, $defaults ); 86 87 $query = new BB_Query( 'post', $args, 'get_thread' ); 88 return $query->results; 89 } 90 91 function bp_forums_get_post( $post_id ) { 92 do_action( 'bbpress_init' ); 93 return bb_get_post( $post_id ); 94 } 95 96 function bp_forums_new_forum( $args = '' ) { 97 do_action( 'bbpress_init' ); 98 99 $defaults = array( 100 'forum_name' => '', 101 'forum_desc' => '', 102 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 103 'forum_order' => false, 104 'forum_is_category' => 0 105 ); 106 107 $r = wp_parse_args( $args, $defaults ); 108 extract( $r, EXTR_SKIP ); 109 110 return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 111 } 112 113 function bp_forums_new_topic( $args = '' ) { 114 global $bp; 115 116 do_action( 'bbpress_init' ); 117 118 $defaults = array( 119 'topic_title' => '', 120 'topic_slug' => '', 121 'topic_poster' => $bp->loggedin_user->id, // accepts ids 122 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names 123 'topic_last_poster' => $bp->loggedin_user->id, // accepts ids 124 'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names 125 'topic_start_time' => bb_current_time( 'mysql' ), 126 'topic_time' => bb_current_time( 'mysql' ), 127 'topic_open' => 1, 128 'forum_id' => 0 // accepts ids or slugs 129 ); 130 131 $r = wp_parse_args( $args, $defaults ); 132 extract( $r, EXTR_SKIP ); 133 134 if ( empty( $topic_slug ) ) 135 $topic_slug = sanitize_title( $topic_title ); 136 137 if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id ) ) ) 138 return false; 139 140 /* Now insert the first post. */ 141 if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) ) 142 return false; 143 144 return $topic_id; 145 } 146 147 function bp_forums_update_topic( $args = '' ) { 148 global $bp; 149 150 do_action( 'bbpress_init' ); 151 152 $defaults = array( 153 'topic_id' => false, 154 'topic_title' => '', 155 'topic_text' => '' 156 ); 157 158 $r = wp_parse_args( $args, $defaults ); 159 extract( $r, EXTR_SKIP ); 160 161 if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) ) 162 return false; 163 164 if ( !$post = bb_get_first_post( $topic_id ) ) 165 return false; 166 167 /* Update the first post */ 168 if ( !$post = bb_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) ) 169 return false; 170 171 return bp_forums_get_topic_details( $topic_id ); 172 } 173 174 function bp_forums_sticky_topic( $args = '' ) { 175 global $bp; 176 177 do_action( 'bbpress_init' ); 178 179 $defaults = array( 180 'topic_id' => false, 181 'mode' => 'stick' // stick/unstick 182 ); 183 184 $r = wp_parse_args( $args, $defaults ); 185 extract( $r, EXTR_SKIP ); 186 187 if ( 'stick' == $mode ) 188 return bb_stick_topic( $topic_id ); 189 else if ( 'unstick' == $mode ) 190 return bb_unstick_topic( $topic_id ); 191 68 192 return false; 69 193 } 70 194 71 function bp_forums_get_topic_details( $topic_id = 0 ) { 72 global $bbpress_live; 73 74 if ( !is_object( $bbpress_live ) ) { 75 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 76 $bbpress_live = new bbPress_Live(); 77 } 78 79 if ( $topic = $bbpress_live->get_topic_details( $topic_id ) ) { 80 do_action( 'bp_forums_get_topic_details', $topic ); 81 return $topic; 82 } 83 195 function bp_forums_openclose_topic( $args = '' ) { 196 global $bp; 197 198 do_action( 'bbpress_init' ); 199 200 $defaults = array( 201 'topic_id' => false, 202 'mode' => 'close' // stick/unstick 203 ); 204 205 $r = wp_parse_args( $args, $defaults ); 206 extract( $r, EXTR_SKIP ); 207 208 if ( 'close' == $mode ) 209 return bb_close_topic( $topic_id ); 210 else if ( 'open' == $mode ) 211 return bb_open_topic( $topic_id ); 212 84 213 return false; 85 214 } 86 215 87 function bp_forums_get_posts( $topic_id = 0, $number = 0, $page = 1 ) { 88 global $bbpress_live; 89 90 if ( !is_object( $bbpress_live ) ) { 91 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 92 $bbpress_live = new bbPress_Live(); 93 } 94 95 if ( $posts = $bbpress_live->get_posts( $topic_id, $number, $page ) ) { 96 do_action( 'bp_forums_get_posts', $posts ); 97 return $posts; 98 } 99 100 return false; 101 } 102 103 function bp_forums_get_post( $post_id = 0 ) { 104 global $bbpress_live; 105 106 if ( !is_object( $bbpress_live ) ) { 107 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 108 $bbpress_live = new bbPress_Live(); 109 } 110 111 if ( $post = $bbpress_live->get_post( $post_id ) ) { 112 do_action( 'bp_forums_get_post', $post ); 113 return $post; 114 } 115 116 return false; 117 } 118 119 function bp_forums_new_forum( $name = '', $desc = '', $parent = BP_FORUMS_PARENT_FORUM_ID, $order = 0, $is_category = false ) { 120 global $bbpress_live; 121 122 if ( !is_object( $bbpress_live ) ) { 123 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 124 $bbpress_live = new bbPress_Live(); 125 } 126 127 if ( $forum = $bbpress_live->new_forum( $name, $desc, $parent, $order, $is_category ) ) { 128 do_action( 'bp_forums_new_forum', $forum ); 129 return $forum; 130 } 131 132 return false; 133 } 134 135 function bp_forums_new_topic( $title = '', $topic_text = '', $topic_tags = '', $forum_id = 0 ) { 136 global $bbpress_live; 137 138 if ( !is_object( $bbpress_live ) ) { 139 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 140 $bbpress_live = new bbPress_Live(); 141 } 142 143 $topic_text = apply_filters( 'bp_forums_new_post_text', $topic_text ); 144 $title = apply_filters( 'bp_forums_new_post_title', $title ); 145 $topic_tags = apply_filters( 'bp_forums_new_post_tags', $topic_tags ); 146 147 if ( $topic = $bbpress_live->new_topic( $title, $topic_text, $topic_tags, (int)$forum_id ) ) { 148 do_action( 'bp_forums_new_topic', $topic ); 149 return $topic; 150 } 151 152 return false; 153 } 154 155 function bp_forums_new_post( $post_text = '', $topic_id = 0 ) { 156 global $bbpress_live; 157 158 if ( !is_object( $bbpress_live ) ) { 159 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 160 $bbpress_live = new bbPress_Live(); 161 } 162 163 $post_text = apply_filters( 'bp_forums_new_post_text', $post_text ); 164 165 if ( $post = $bbpress_live->new_post( $post_text, (int)$topic_id ) ) { 166 do_action( 'bp_forums_new_post', $post ); 167 return $post; 168 } 169 170 return false; 216 function bp_forums_delete_topic( $args = '' ) { 217 global $bp; 218 219 do_action( 'bbpress_init' ); 220 221 $defaults = array( 222 'topic_id' => false 223 ); 224 225 $r = wp_parse_args( $args, $defaults ); 226 extract( $r, EXTR_SKIP ); 227 228 return bb_delete_topic( $topic_id, 1 ); 229 } 230 231 function bp_forums_insert_post( $args = '' ) { 232 global $bp; 233 234 do_action( 'bbpress_init' ); 235 236 $defaults = array( 237 'post_id' => false, 238 'topic_id' => false, 239 'post_text' => '', 240 'post_time' => bb_current_time( 'mysql' ), 241 'poster_id' => $bp->loggedin_user->id, // accepts ids or names 242 'poster_ip' => $_SERVER['REMOTE_ADDR'], 243 'post_status' => 0, // use bb_delete_post() instead 244 'post_position' => false 245 ); 246 247 $r = wp_parse_args( $args, $defaults ); 248 extract( $r, EXTR_SKIP ); 249 250 if ( !$post = bp_forums_get_post( $post_id ) ) 251 $post_id = false; 252 253 if ( !isset( $topic_id ) ) 254 $topic_id = $post->topic_id; 255 256 if ( empty( $post_text ) ) 257 $post_text = $post->post_text; 258 259 if ( !isset( $post_time ) ) 260 $post_time = $post->post_time; 261 262 if ( !isset( $post_position ) ) 263 $post_position = $post->post_position; 264 265 return bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( $post_text ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) ); 171 266 } 172 267 … … 189 284 add_action( 'bp_forums_new_post', 'bp_core_clear_cache' ); 190 285 191 192 286 function bb_forums_filter_caps( $allcaps ) { 287 global $bp, $wp_roles, $bb_table_prefix; 288 289 $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' ); 290 291 if ( empty( $bb_cap ) ) 292 return $allcaps; 293 294 $bb_cap = array_keys($bb_cap); 295 $bb_cap = $wp_roles->get_role( $bb_cap[0] ); 296 $bb_cap = $bb_cap->capabilities; 297 298 return array_merge( (array) $allcaps, (array) $bb_cap ); 299 } 300 add_filter( 'user_has_cap', 'bb_forums_filter_caps' ); 193 301 ?> -
trunk/bp-forums/bp-forums-admin.php
r1366 r1621 1 1 <?php 2 function bp_forums_add_admin_menu() {3 global $wpdb, $bp;4 5 if ( is_site_admin() ) {6 /* Add the administration tab under the "Site Admin" tab for site administrators */7 add_submenu_page( 'bp-core.php', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 2, __FILE__, "bp_forums_bbpress_admin" );8 }9 }10 add_action( 'admin_menu', 'bp_forums_add_admin_menu' );11 2 12 3 function bp_forums_bbpress_admin() { 13 global $bp, $bbpress_live; 14 15 if ( !is_object( $bbpress_live ) ) { 16 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 17 $bbpress_live = new bbPress_Live(); 18 } 19 20 if ( isset( $_POST['submit'] ) ) { 21 check_admin_referer('bbpress-settings'); 22 23 $_fetch_options = array( 24 'target_uri' => stripslashes((string) $_POST['target_uri']), 25 'username' => stripslashes((string) $_POST['username']), 26 'password' => stripslashes((string) $_POST['password']), 27 'always_use_auth' => (bool) $_POST['always_use_auth'] 28 ); 29 update_option( 'bbpress_live_fetch', $_fetch_options ); 30 31 $_options = array( 32 'cache_enabled' => (bool) $_POST['cache_enabled'], 33 'cache_timeout' => (int) $_POST['cache_timeout'], 34 'widget_forums' => (bool) $_POST['widget_forums'], 35 'widget_topics' => (bool) $_POST['widget_topics'], 36 'post_to_topic' => (bool) $_POST['post_to_topic'], 37 'post_to_topic_forum' => stripslashes((string) $_POST['post_to_topic_forum']), 38 'post_to_topic_delay' => (int) $_POST['post_to_topic_delay'] 39 ); 40 update_option( 'bbpress_live', $_options ); 41 42 $fetch_options = $_fetch_options; 43 $options = $_options; 44 45 do_action( 'bp_forums_bbpress_admin', $_fetch_options, $_options ); 46 47 } else { 48 $fetch_options = $bbpress_live->fetch->options; 49 $options = $bbpress_live->options; 50 } 4 global $bp; 51 5 ?> 52 6 <div class="wrap"> … … 59 13 </div> 60 14 <?php endif; ?> 61 <br /> 15 16 <?php 62 17 63 <?php if ( isset($path_success) ) : ?><?php echo "<p id='message' class='updated fade'>$path_success</p>" ?><?php endif; ?> 64 65 <p><?php _e( 'To enable forums for each group in a BuddyPress installation, you must first download, install, and setup bbPress and integrate it with WordPress MU.', 'buddypress' ) ?></p> 66 <p><?php _e( 'Once you have bbPress set up correctly, enter the options below so that BuddyPress can connect.', 'buddypress' ) ?></p> 67 68 <form action="<?php echo site_url() . '/wp-admin/admin.php?page=' . BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ?>" name="bbpress-path-form" id="bbpress-path-form" method="post"> 69 <input type="hidden" name="option_page" value="bbpress-live" /> 70 71 <table class="form-table"> 72 <tr valign="top"> 73 <th scope="row"><label for="target_uri"><?php _e( 'bbPress URL', 'buddypress' ) ?></label></th> 74 <td> 75 <input name="target_uri" type="text" id="target_uri" value="<?php echo attribute_escape( $fetch_options['target_uri'] ); ?>" size="60" /><br /> 76 <?php _e( 'The URL of the location you installed bbPress. For example, http://example.com/forums/', 'buddypress' ); ?> 77 </td> 78 </tr> 79 <tr valign="top"> 80 <th scope="row"><label for="username"><?php _e( 'bbPress username', 'buddypress' ) ?></label></th> 81 <td> 82 <input name="username" type="text" id="username" value="<?php echo attribute_escape( $fetch_options['username'] ); ?>" size="20" /><br /> 83 <?php _e( 'The username for the user (with admin rights) that you created for BuddyPress integration', 'buddypress' ); ?> 84 </td> 85 </tr> 86 <tr valign="top"> 87 <th scope="row"><label for="password"><?php _e( 'bbPress password', 'buddypress' ) ?></label></th> 88 <td> 89 <input name="password" type="password" id="password" value="<?php echo attribute_escape( $fetch_options['password'] ); ?>" size="20" /><br /> 90 <?php _e( 'The password for the user (with admin rights) that you created for BuddyPress integration', 'buddypress' ); ?> 91 </td> 92 </tr> 93 </table> 94 <br /> 95 <h3><?php _e( 'Cache requests', 'buddypress' ) ?></h3> 96 <table class="form-table"> 97 <tr valign="top"> 98 <th scope="row"><label for="cache_enabled"><?php _e( 'Caching enabled', 'buddypress' ) ?></label></th> 99 <td> 100 <input name="cache_enabled" type="checkbox" id="cache_enabled" value="1"<?php echo( $options['cache_enabled'] ? ' checked="checked"' : '' ); ?> /> 101 <?php _e( 'Turn on caching of requests to reduce latency and load.', 'buddypress' ); ?> 102 </td> 103 </tr> 104 <tr valign="top"> 105 <th scope="row"><label for="cache_timeout"><?php _e( 'Cache timeout', 'buddypress' ) ?></label></th> 106 <td> 107 <input name="cache_timeout" type="text" id="cache_timeout" value="<?php echo attribute_escape( $options['cache_timeout'] ); ?>" size="10" /> <?php _e( '(seconds)', 'buddypress' ) ?><br /> 108 <?php _e( 'The amount of time in seconds that a cached request is valid for.', 'buddypress' ); ?> 109 </td> 110 </tr> 111 </table> 112 <br /> 113 <p class="submit"> 114 <input class="button-primary" type="submit" name="submit" value="<?php _e('Save Settings', 'buddypress') ?>"/> 115 </p> 116 <?php wp_nonce_field('bbpress-settings') ?> 117 </form> 18 if ( !bp_forums_is_installed_correctly() ) 19 bp_forums_bbpress_install_wizard(); 20 else { ?> 21 22 <p>In development:<br />This screen will allow you to manage the relationships between existing groups and forums.</p> 23 24 <?php 25 } 26 ?> 118 27 </div> 119 28 <?php 120 29 } 30 31 function bp_forums_bbpress_install_wizard() { 32 $post_url = site_url( 'wp-admin/admin.php?page=' . 'buddypress/bp-forums.php' ); 33 34 switch( $_REQUEST['step'] ) { 35 case 'existing': 36 if ( 1 == (int)$_REQUEST['doinstall'] ) { 37 if ( !bp_forums_configure_existing_install() ) 38 echo "no go"; 39 } 40 ?> 41 <form action="" method="post"> 42 <h3><?php _e( 'Existing bbPress Installation', 'buddypress' ) ?></h3> 43 <p><?php _e( "BuddyPress can make use of your existing bbPress install. Just provide the location of your <code>bb-config.php</code> file, and BuddyPress will do the rest.", 'buddypress' ) ?></p> 44 <p><label><code>bb-config.php</code> file location:</label><br /><input style="width: 50%" type="text" name="bbconfigloc" id="bbconfigloc" value="<?php echo str_replace( 'buddypress', '', $_SERVER['DOCUMENT_ROOT'] ) ?>" /></p> 45 <p><input type="submit" class="button-primary" value="<?php _e( 'Complete Installation', 'buddypress' ) ?>" /></p> 46 <input type="hidden" name="step" value="existing" /> 47 <input type="hidden" name="doinstall" value="1" /> 48 <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?> 49 </form> 50 <?php 51 break; 52 53 case 'new': 54 if ( 1 == (int)$_REQUEST['doinstall'] ) { 55 $result = bp_forums_bbpress_install(); 56 57 switch ( $result ) { 58 case 1: 59 _e( 'All done! Configuration settings have been saved to the file <code>bb-config.php</code> in the root of your WordPress install.' ); 60 break; 61 default: 62 // Just write the contents to screen 63 _e( 'A configuration file could not be created. No problem, but you will need to save the text shown below into a file named <code>bb-config.php</code> in the root directory of your WordPress installation before you can start using the forum functionality.' ); 64 ?><code style="display:block; margin-top: 30px;"><pre><?php echo htmlspecialchars( $result ) ?></pre></code><?php 65 break; 66 } 67 } else { 68 ?> 69 <h3><?php _e( 'New bbPress Installation', 'buddypress' ) ?></h3> 70 <p><?php _e( "You've decided to set up a new installation of bbPress for forum management in BuddyPress. This is very simple and is usually just a one click 71 process. When you're ready, hit the link below.", 'buddypress' ) ?></p> 72 <p><a class="button-primary" href="<?php echo wp_nonce_url( $post_url . '&step=new&doinstall=1', 'bp_forums_new_install_init' ) ?>"><?php _e( 'Complete Installation', 'buddypress' ) ?></a></p> 73 <?php 74 } 75 break; 76 77 default: ?> 78 <p><?php _e( 'Forums in BuddyPress make use of a bbPress installation to function. You can choose to either let BuddyPress set up a new bbPress install, or use an already existing bbPress install. Please choose one of the options below.', 'buddypress' ) ?></p> 79 80 <a class="button" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Set up a new bbPress installation', 'buddypress' ) ?></a> 81 <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use an existing bbPress installation', 'buddypress' ) ?></a> 82 83 <?php 84 break; 85 } 86 } 87 88 function bp_forums_configure_existing_install() { 89 global $wpdb, $bbdb; 90 91 check_admin_referer( 'bp_forums_existing_install_init' ); 92 93 if ( false === strpos( $_REQUEST['bbconfigloc'], 'bp-config.php' ) ) { 94 if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) ) 95 $_REQUEST['bbconfigloc'] .= '/'; 96 97 $_REQUEST['bbconfigloc'] .= 'bp-config.php'; 98 } 99 100 var_dump( $_REQUEST['bbconfigloc'], file_exists( $_REQUEST['bbconfigloc'] ) ); 101 102 if ( !file_exists( $_REQUEST['bbconfigloc'] ) ) 103 return false; 104 105 update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] ); 106 107 return true; 108 } 109 110 function bp_forums_bbpress_install() { 111 global $wpdb, $bbdb; 112 113 check_admin_referer( 'bp_forums_new_install_init' ); 114 115 /* Create the bb-config.php file */ 116 $initial_write = bp_forums_bbpress_write( 117 BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-config-sample.php', 118 ABSPATH . 'bb-config.php', 119 array( 120 "define( 'BBDB_NAME'," => array( "'bbpress'", "'" . DB_NAME . "'" ), 121 "define( 'BBDB_USER'," => array( "'username'", "'" . DB_USER . "'" ), 122 "define( 'BBDB_PASSWO" => array( "'password'", "'" . DB_PASSWORD . "'" ), 123 "define( 'BBDB_HOST'," => array( "'localhost'", "'" . DB_HOST . "'" ), 124 "define( 'BBDB_CHARSE" => array( "'utf8'", "'" . DB_CHARSET . "'" ), 125 "define( 'BBDB_COLLAT" => array( "''", "'" . DB_COLLATE . "'" ), 126 "define( 'BB_AUTH_KEY" => array( "'put your unique phrase here'", "'" . AUTH_KEY . "'" ), 127 "define( 'BB_SECURE_A" => array( "'put your unique phrase here'", "'" . SECURE_AUTH_KEY . "'" ), 128 "define( 'BB_LOGGED_I" => array( "'put your unique phrase here'", "'" . LOGGED_IN_KEY . "'" ), 129 "define( 'BB_NONCE_KE" => array( "'put your unique phrase here'", "'" . NONCE_KEY . "'" ), 130 "\$bb_table_prefix = '" => array( "'bb_'", "'" . $wpdb->base_prefix . "bb_'" ), 131 "define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" ) 132 ) 133 ); 134 135 /* Add the custom user and usermeta entries to the config file */ 136 if ( $initial_write == 1 ) { 137 $file = file_get_contents( ABSPATH . 'bb-config.php' ); 138 } else { 139 $file = &$initial_write; 140 } 141 142 $file = substr( $file, 0, -2 ); 143 $file .= "\n" . '$bb->custom_user_table = "' . $wpdb->users . '";'; 144 $file .= "\n" . '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";'; 145 $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";'; 146 $file .= "\n" . '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";'; 147 $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';'; 148 $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");'; 149 $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");'; 150 $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");'; 151 $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 152 $file .= "\n\n" . '?>'; 153 154 if ( $initial_write == 1 ) { 155 $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' ); 156 fwrite( $file_handle, $file ); 157 fclose( $file_handle ); 158 } else { 159 $initial_write = $file; 160 } 161 162 update_site_option( 'bb-config-location', ABSPATH . 'bb-config.php' ); 163 return $initial_write; 164 } 165 166 function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 167 if ( !$file_source || !file_exists( $file_source ) || !is_file( $file_source ) ) { 168 return -1; 169 } 170 171 if ( !$file_target ) { 172 $file_target = $file_source; 173 } 174 175 if ( !$alterations || !is_array( $alterations ) ) { 176 return -2; 177 } 178 179 // Get the existing lines in the file 180 $lines = file( $file_source ); 181 182 // Initialise an array to store the modified lines 183 $modified_lines = array(); 184 185 // Loop through the lines and modify them 186 foreach ( $lines as $line ) { 187 if ( isset( $alterations[substr( $line, 0, 20 )] ) ) { 188 $alteration = $alterations[substr( $line, 0, 20 )]; 189 $modified_lines[] = str_replace( $alteration[0], $alteration[1], $line ); 190 } else { 191 $modified_lines[] = $line; 192 } 193 } 194 195 $writable = true; 196 if ( file_exists( $file_target ) ) { 197 if ( !is_writable( $file_target ) ) { 198 $writable = false; 199 } 200 } else { 201 $dir_target = dirname( $file_target ); 202 203 if ( file_exists( $dir_target ) ) { 204 @chmod( $dir_target, 0777 ); 205 206 if ( !is_writable( $dir_target ) || !is_dir( $dir_target ) ) { 207 $writable = false; 208 } 209 210 @chmod( $dir_target, 0666 ); 211 } else { 212 $writable = false; 213 } 214 } 215 216 if ( !$writable ) 217 return trim( join( null, $modified_lines ) ); 218 219 // Open the file for writing - rewrites the whole file 220 $file_handle = fopen( $file_target, 'w' ); 221 222 // Write lines one by one to avoid OS specific newline hassles 223 foreach ( $modified_lines as $modified_line ) { 224 if ( false !== strpos( $modified_line, '?>' ) ) { 225 $modified_line = '?>'; 226 } 227 fwrite( $file_handle, $modified_line ); 228 if ( $modified_line == '?>' ) { 229 break; 230 } 231 } 232 233 // Close the config file 234 fclose( $file_handle ); 235 236 @chmod( $file_target, 0666 ); 237 238 return 1; 239 } 121 240 ?> -
trunk/bp-forums/bp-forums-filters.php
r1608 r1621 1 1 <?php 2 3 /* BuddyPress filters */4 add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_create_excerpt' );5 2 6 3 /* Apply WordPress defined filters */ … … 28 25 add_filter( 'bp_get_the_topic_post_content', 'make_clickable' ); 29 26 30 add_filter( 'bp_get_activity_content', 'bp_forums_filter_decode' );31 add_filter( 'bp_forums_new_post_text', 'bp_forums_filter_encode' );32 33 add_filter( 'bp_get_the_topic_post_content', 'bp_forums_filter_decode' );34 add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_filter_decode' );35 36 27 function bp_forums_add_allowed_tags( $allowedtags ) { 37 28 $allowedtags['p'] = array(); … … 42 33 add_filter( 'edit_allowedtags', 'bp_forums_add_allowed_tags' ); 43 34 44 function bp_forums_filter_encode( $content ) {45 $content = htmlentities( $content, ENT_COMPAT, "UTF-8" );46 $content = str_replace( '&', '/amp/', $content );47 48 return $content;49 }50 51 function bp_forums_filter_decode( $content ) {52 $content = str_replace( '/amp/', '&', $content );53 $content = @html_entity_decode( $content, ENT_COMPAT, "UTF-8" );54 $content = str_replace( '[', '<', $content );55 $content = str_replace( ']', '>', $content );56 $content = stripslashes( wp_filter_kses( $content ) );57 58 return $content;59 }60 61 35 ?> -
trunk/bp-forums/bp-forums-templatetags.php
r1538 r1621 19 19 var $order; 20 20 21 function BP_Forums_Template_Forum( $forum_id, $per_page, $max ) {22 global $bp , $current_user;21 function BP_Forums_Template_Forum( $forum_id, $per_page, $max, $no_stickies ) { 22 global $bp; 23 23 24 24 $this->pag_page = isset( $_REQUEST['forum_page'] ) ? intval( $_REQUEST['forum_page'] ) : 1; 25 25 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 26 26 27 $this->topics = bp_forums_get_ topics( $forum_id, $this->pag_num, $this->pag_page);28 29 if ( ! $this->topics ) {27 $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) ); 28 29 if ( !(int)$this->topics ) { 30 30 $this->topic_count = 0; 31 31 $this->total_topic_count = 0; 32 32 } else { 33 $forum_count = count( bp_forums_get_topics( $forum_id ) ); 33 $topic_count = bp_forums_get_forum( $forum_id ); 34 $topic_count = (int)$topic_count->topics; 34 35 35 if ( !$max || $max >= $ forum_count )36 $this->total_topic_count = $ forum_count;36 if ( !$max || $max >= $topic_count ) 37 $this->total_topic_count = $topic_count; 37 38 else 38 39 $this->total_topic_count = (int)$max; … … 46 47 $this->topic_count = count( $this->topics ); 47 48 } 49 } 50 51 if ( !$no_stickies) { 52 /* Place stickies at the top - not sure why bbPress doesn't do this? */ 53 foreach( (array)$this->topics as $topic ) { 54 if ( 1 == (int)$topic->topic_sticky ) 55 $stickies[] = $topic; 56 else 57 $standard[] = $topic; 58 } 59 $this->topics = array_merge( (array)$stickies, (array)$standard ); 48 60 } 49 61 … … 107 119 function bp_has_topics( $args = '' ) { 108 120 global $forum_template, $bp; 109 global $group_obj;110 121 111 122 $defaults = array( 112 123 'forum_id' => false, 113 'per_page' => 10, 114 'max' => false 124 'per_page' => 15, 125 'max' => false, 126 'no_stickies' => false 115 127 ); 116 128 … … 118 130 extract( $r, EXTR_SKIP ); 119 131 120 if ( !$forum_id && $bp->current_component == $bp->groups->slug && 'forum' == $bp->current_action)121 $forum_id = groups_get_groupmeta( $ group_obj->id, 'forum_id' );132 if ( !$forum_id && $bp->current_component == $bp->groups->slug ) 133 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 122 134 123 135 if ( is_numeric( $forum_id ) ) 124 $forum_template = new BP_Forums_Template_Forum( $forum_id, $per_page, $max);136 $forum_template = new BP_Forums_Template_Forum( (int)$forum_id, $per_page, $max, $no_stickies ); 125 137 else 126 138 return false; … … 166 178 } 167 179 180 function bp_the_topic_text() { 181 echo bp_get_the_topic_text(); 182 } 183 function bp_get_the_topic_text() { 184 global $forum_template; 185 186 $post = bb_get_first_post( $forum_template->topic->topic_id ); 187 return apply_filters( 'bp_get_the_topic_text', $post->post_text ); 188 } 189 168 190 function bp_the_topic_poster_id() { 169 191 echo bp_get_the_topic_poster_id(); … … 175 197 } 176 198 177 function bp_the_topic_poster_avatar() { 178 echo bp_get_the_topic_poster_avatar(); 179 } 180 function bp_get_the_topic_poster_avatar() { 181 global $forum_template; 182 183 return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_get_avatar( $forum_template->topic->topic_poster, 1 ) ); 199 function bp_the_topic_poster_avatar( $args = '' ) { 200 echo bp_get_the_topic_poster_avatar( $args ); 201 } 202 function bp_get_the_topic_poster_avatar( $args = '' ) { 203 global $forum_template; 204 205 $defaults = array( 206 'type' => 'thumb', 207 'width' => false, 208 'height' => false, 209 ); 210 211 $r = wp_parse_args( $args, $defaults ); 212 extract( $r, EXTR_SKIP ); 213 214 if ( 'thumb' == $type ) 215 $size = 1; 216 else 217 $size = 2; 218 219 if ( $width && $height ) 220 $av = bp_core_get_avatar( $forum_template->topic->topic_poster, $size, $width, $height ); 221 else 222 $av = bp_core_get_avatar( $forum_template->topic->topic_poster, $size ); 223 224 return apply_filters( 'bp_get_the_topic_poster_avatar', $av ); 184 225 } 185 226 … … 202 243 } 203 244 204 function bp_the_topic_last_poster_avatar() { 205 echo bp_get_the_topic_last_poster_avatar(); 206 } 207 function bp_get_the_topic_last_poster_avatar() { 208 global $forum_template; 209 210 return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_get_avatar( $forum_template->topic->topic_last_poster, 1 ) ); 245 function bp_the_topic_last_poster_avatar( $args = '' ) { 246 echo bp_get_the_topic_last_poster_avatar( $args ); 247 } 248 function bp_get_the_topic_last_poster_avatar( $args = '' ) { 249 global $forum_template; 250 251 $defaults = array( 252 'type' => 'thumb', 253 'width' => false, 254 'height' => false, 255 ); 256 257 $r = wp_parse_args( $args, $defaults ); 258 extract( $r, EXTR_SKIP ); 259 260 if ( 'thumb' == $type ) 261 $size = 1; 262 else 263 $size = 2; 264 265 if ( $width && $height ) 266 $av = bp_core_get_avatar( $forum_template->topic->topic_last_poster, $size, $width, $height ); 267 else 268 $av = bp_core_get_avatar( $forum_template->topic->topic_last_poster, $size ); 269 270 return apply_filters( 'bp_get_the_topic_last_poster_avatar', $av ); 211 271 } 212 272 … … 299 359 } 300 360 function bp_get_the_topic_permalink() { 301 global $forum_template, $bbpress_live, $group_obj; 302 303 $target_uri = $bbpress_live->fetch->options['target_uri']; 304 305 return apply_filters( 'bp_get_the_topic_permalink', bp_get_group_permalink( $group_obj ) . '/forum/topic/' . $forum_template->topic->topic_id ); 361 global $forum_template, $bp; 362 363 if ( $bp->is_single_item ) 364 $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/'; 365 else 366 $permalink = $bp->root_domain . $bp->current_component . '/' . $bp->current_action . '/'; 367 368 return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug ); 306 369 } 307 370 … … 312 375 global $forum_template; 313 376 314 return apply_filters( 'bp_get_the_topic_time_since_created', $forum_template->topic->topic_start_time_since ); 315 } 316 317 function bp_the_topic_latest_post_excerpt() { 318 echo bp_get_the_topic_latest_post_excerpt(); 319 } 320 function bp_get_the_topic_latest_post_excerpt() { 321 global $forum_template; 377 return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( bb_gmtstrtotime( $forum_template->topic->topic_start_time ) ) ); 378 } 379 380 function bp_the_topic_latest_post_excerpt( $args = '' ) { 381 echo bp_get_the_topic_latest_post_excerpt( $args ); 382 } 383 function bp_get_the_topic_latest_post_excerpt( $args = '' ) { 384 global $forum_template; 385 386 $defaults = array( 387 'length' => 10 388 ); 389 390 $r = wp_parse_args( $args, $defaults ); 391 extract( $r, EXTR_SKIP ); 322 392 323 393 $post = bp_forums_get_post( $forum_template->topic->topic_last_post_id ); 324 return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post['post_text'] ); 394 $post = bp_create_excerpt( $post->post_text, $length ); 395 return apply_filters( 'bp_get_the_topic_latest_post_excerpt', $post ); 325 396 } 326 397 … … 336 407 global $forum_template; 337 408 338 return apply_filters( 'bp_get_the_topic_time_since_last_post', $forum_template->topic->topic_time_since ); 339 } 409 return apply_filters( 'bp_get_the_topic_time_since_last_post', bp_core_time_since( bb_gmtstrtotime( $forum_template->topic->topic_time ) ) ); 410 } 411 412 function bp_the_topic_admin_links( $args = '' ) { 413 echo bp_get_the_topic_admin_links( $args ); 414 } 415 function bp_get_the_topic_admin_links( $args = '' ) { 416 global $forum_template; 417 418 $defaults = array( 419 'seperator' => '|' 420 ); 421 422 $r = wp_parse_args( $args, $defaults ); 423 extract( $r, EXTR_SKIP ); 424 425 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' '; 426 427 if ( 0 == (int)$forum_template->topic->topic_sticky ) 428 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky', 'buddypress' ) . '</a> ' . $seperator . ' '; 429 else 430 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/unstick', 'bp_forums_unstick_topic' ) . '">' . __( 'Un-stick', 'buddypress' ) . '</a> ' . $seperator . ' '; 431 432 if ( 0 == (int)$forum_template->topic->topic_open ) 433 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/open', 'bp_forums_open_topic' ) . '">' . __( 'Open', 'buddypress' ) . '</a> ' . $seperator . ' '; 434 else 435 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/close', 'bp_forums_close_topic' ) . '">' . __( 'Close', 'buddypress' ) . '</a> ' . $seperator . ' '; 436 437 $links .= '<a id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>'; 438 439 return $links; 440 } 441 442 function bp_the_topic_css_class() { 443 echo bp_get_the_topic_css_class(); 444 } 445 446 function bp_get_the_topic_css_class() { 447 global $forum_template; 448 449 $class = false; 450 451 if ( 1 == (int)$forum_template->topic->topic_sticky ) { 452 $class .= 'sticky'; 453 } 454 455 if ( 0 == (int)$forum_template->topic->topic_open ) { 456 $class .= ' closed'; 457 } 458 459 return trim( $class ); 460 } 461 340 462 341 463 function bp_forum_pagination() { … … 358 480 <img id="ajax-loader-groups" src="<?php echo $bp->core->image_base ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" /> 359 481 <?php 482 } 483 484 function bp_is_edit_topic() { 485 global $bp; 486 487 if ( in_array( 'post', (array)$bp->action_variables ) && in_array( 'edit', (array)$bp->action_variables ) ) 488 return false; 489 490 return true; 360 491 } 361 492 … … 391 522 $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id ); 392 523 393 $this->posts = bp_forums_get_ posts( $this->topic_id, $this->pag_num, $this->pag_page);524 $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) ); 394 525 395 526 if ( !$this->posts ) { … … 474 605 $defaults = array( 475 606 'topic_id' => false, 476 'per_page' => 1 0,607 'per_page' => 15, 477 608 'max' => false 478 609 ); … … 482 613 483 614 if ( !$topic_id && $bp->current_component == $bp->groups->slug && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] ) 484 $topic_id = $bp->action_variables[1];615 $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] ); 485 616 486 617 if ( is_numeric( $topic_id ) ) … … 520 651 } 521 652 522 function bp_the_topic_post_poster_avatar( ) {523 echo bp_get_the_topic_post_poster_avatar( );524 } 525 function bp_get_the_topic_post_poster_avatar( ) {653 function bp_the_topic_post_poster_avatar( $args = '' ) { 654 echo bp_get_the_topic_post_poster_avatar( $args ); 655 } 656 function bp_get_the_topic_post_poster_avatar( $args = '' ) { 526 657 global $topic_template; 527 658 528 return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_get_avatar( $topic_template->post->poster_id, 1, 20, 20 ) ); 659 $defaults = array( 660 'type' => 'thumb', 661 'width' => 20, 662 'height' => 20, 663 ); 664 665 $r = wp_parse_args( $args, $defaults ); 666 extract( $r, EXTR_SKIP ); 667 668 if ( 'thumb' == $type ) 669 $size = 1; 670 else 671 $size = 2; 672 673 if ( $width && $height ) 674 $av = bp_core_get_avatar( $topic_template->post->poster_id, $size, $width, $height ); 675 else 676 $av = bp_core_get_avatar( $topic_template->post->poster_id, $size ); 677 678 return apply_filters( 'bp_get_the_topic_post_poster_avatar', $av ); 529 679 } 530 680 … … 550 700 global $topic_template; 551 701 552 return apply_filters( 'bp_get_the_topic_post_time_since', $topic_template->post->post_time_since ); 702 return apply_filters( 'bp_get_the_topic_post_time_since', bp_core_time_since( bb_gmtstrtotime( $topic_template->post->post_time ) ) ); 703 } 704 705 function bp_the_topic_post_is_mine() { 706 echo bp_the_topic_post_is_mine(); 707 } 708 function bp_get_the_topic_post_is_mine() { 709 global $bp, $topic_template; 710 711 return $bp->loggedin_user->id == $topic_template->post->poster_id; 712 } 713 714 function bp_the_topic_post_admin_links( $args = '' ) { 715 echo bp_get_the_topic_post_admin_links( $args ); 716 } 717 function bp_get_the_topic_post_admin_links( $args = '' ) { 718 global $topic_template; 719 720 $defaults = array( 721 'seperator' => '|' 722 ); 723 724 $r = wp_parse_args( $args, $defaults ); 725 extract( $r, EXTR_SKIP ); 726 727 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . '/post/' . $topic_template->post->post_id . '/edit/', 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' '; 728 $links .= '<a id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . '/post/' . $topic_template->post->post_id . '/delete/', 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>'; 729 730 return $links; 731 } 732 733 function bp_the_topic_post_edit_text() { 734 echo bp_get_the_topic_post_edit_text(); 735 } 736 function bp_get_the_topic_post_edit_text() { 737 global $bp; 738 739 $post = bp_forums_get_post( $bp->action_variables[3] ); 740 return attribute_escape( $post->post_text ); 553 741 } 554 742 … … 578 766 } 579 767 function bp_get_forum_permalink() { 580 global $group_obj; 581 582 return apply_filters( 'bp_get_forum_permalink', bp_get_group_permalink( $group_obj ) . '/forum' ); 768 global $bp; 769 770 if ( $bp->is_single_item ) 771 $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/'; 772 else 773 $permalink = $bp->root_domain . $bp->current_component . '/' . $bp->current_action . '/'; 774 775 return apply_filters( 'bp_get_forum_permalink', $permalink . 'forum' ); 583 776 } 584 777 … … 589 782 global $topic_template; 590 783 591 return apply_filters( 'bp_get_forum_action', bp_get_group_permalink( $group_obj ) . '/forum');784 return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 592 785 } 593 786 … … 596 789 } 597 790 function bp_get_forum_topic_action() { 598 global $ topic_template;599 600 return apply_filters( 'bp_get_forum_topic_action', bp_get_group_permalink( $group_obj ) . '/forum/topic/' . $topic_template->topic_id);791 global $bp; 792 793 return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 601 794 } 602 795 -
trunk/bp-forums/installation-readme.txt
r1608 r1621 2 2 ''''''''''''''''''''''''''''''''''' 3 3 4 The bp-forums component provides a link between bbPress and BuddyPress so forums can be 5 created and manipulated directly in BuddyPress. 6 7 Forum functionality is currently quite basic and limited to creating forums, creating topics and posting. 8 More advanced integration including moderation, searching and tagging support will come in later 9 versions of the component. 10 11 *** Please Note *** 12 13 You *must* be running the latest alpha of bbPress and at least WPMU version 2.7 for forum integration to 14 work. 15 16 ************************************************ 17 Follow these steps to get forums up and running: 18 ************************************************ 19 20 1. Run the bbPress installer by browsing to the location that you uploaded bbPress. 21 22 2. On Step 2 you will need to integrate bbPress with WordPress 23 24 - Check the "Add integration settings" box 25 26 - Leave "Add cookie integration settings" unchecked 27 28 - Check the "Add user database integration settings" box 29 - Add your table prefix (usually always 'wp_') 30 - Add your WordPress database settings found in wp-config.php 31 - You can usually ignore the "character set" and "collation" boxes 32 - Leave the "Custom user tables" section blank. 33 34 3. On Step 3 enter anything you like for your site name and first forum name. Select "Admin" from the 35 dropdown to use as your keymaster user. 36 37 4. Head to your new bbPress install and log in with your WordPress administrator account (admin). 38 39 5. Head to the Admin area (/bb-admin) and then the settings menu. Check the "Enable XML-RPC" option. 40 Also check the "Enable Pingbacks" option just below. 41 42 6. In the bp-forums component there is a /bbpress-plugins/ folder. Copy the 'buddypress-enable.php' 43 plugin file from that folder into your bbpress plugins folder (eg domain/bbpress/bb-plugins/) 44 45 7. Enable the plugin in the bbPress admin area under the plugins menu. 46 47 8. Head back to your BuddyPress installation and sign up as a new user. Once you have 48 activated the new user, make a note of the username and password given. 49 50 9. Log back into your bbPress installation as the administrator, and head back to the admin panel (/bb-admin). 51 Go to the "Users" tab and look for the new user you signed up in step 8 in the list. Hit the "Edit" 52 link for that user, on the end of the row. 53 54 10. On the edit user screen there is a drop down menu called "User Type". Select "Administrator" as the user 55 type for this user. Hit the "Update Profile" button. 56 57 11. Enable user switching in bbPress by copying the following line of code into your bbPress bb-config.php 58 file: 59 60 $bb->bb_xmlrpc_allow_user_switching = true; 61 62 12. Log into your WPMU admin interface and head to "BuddyPress > Forums Setup" fill in the details on that 63 page. Make sure you don't leave out the ending slash on your bbPress URL. (http://example.com/bbpress/) 64 Enter the username and password for the user that you signed up in step 8. 65 66 13. Once you have saved those details you can create group forums. Existing groups you will need to head 67 to the group admin settings page, disable then enable the group forum setting to generate a new forum. 68 New groups will work fine. 69 70 *** NOTE *** 71 72 Group forums are public, even if a group is private its forum will be accessable through the bbPress interface. 73 This will change eventually, but please be aware of the public status of forums before posting. 4 Please sign in to WordPress as a site admin and head to "BuddyPress > Forums Setup" to install. -
trunk/bp-groups.php
r1599 r1621 106 106 $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta'; 107 107 $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/images'; 108 $bp->groups->format_activity_function = 'groups_format_activity';109 108 $bp->groups->format_notification_function = 'groups_format_notifications'; 110 109 $bp->groups->slug = BP_GROUPS_SLUG; … … 250 249 251 250 if ( $bp->groups->current_group->enable_forum && function_exists('bp_forums_setup') ) 252 bp_core_new_subnav_item( array( 'name' => __( 'Forum', 'buddypress' ), 'slug' => ' group-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) );251 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' ) ); 253 252 254 253 if ( $bp->groups->current_group->enable_wire && function_exists('bp_wire_install') ) 255 bp_core_new_subnav_item( array( 'name' => __( 'Wire', 'buddypress' ), 'slug' => ' group-wire', '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) );256 257 bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => ' group-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) );254 bp_core_new_subnav_item( array( 'name' => __( 'Wire', 'buddypress' ), 'slug' => 'wire', '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' ) ); 255 256 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' ) ); 258 257 259 258 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) { … … 319 318 320 319 /* Record this in activity streams */ 321 groups_record_activity( array( 'item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0 ) ); 320 $group = new BP_Groups_Group( $group_id, false, false ); 321 322 groups_record_activity( array( 323 'content' => sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), 324 'primary_link' => bp_get_group_permalink( $group ), 325 'component_action' => 'joined_group', 326 'item_id' => $group->id 327 ) ); 322 328 } 323 329 … … 377 383 378 384 /* Set the ID of the new group, if it has already been created in a previous step */ 379 if ( isset( $_COOKIE['bp_new_group_id'] ) ) 385 if ( isset( $_COOKIE['bp_new_group_id'] ) ) { 380 386 $bp->groups->new_group_id = $_COOKIE['bp_new_group_id']; 387 $bp->groups->current_group = new BP_Groups_Group( $bp->groups->new_group_id, false, false ); 388 } 381 389 382 390 /* If the save button is hit, lets calculate what we need to save */ … … 424 432 else if ( 'hidden' == $_POST['group-status'] ) 425 433 $group_status = 'hidden'; 426 434 435 /* Once we get to the second step, record the group creation in the activity stream. As we now know the actual status of the group */ 436 groups_record_activity( array( 437 'content' => sprintf( __( '%s created 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>' ), 438 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 439 'component_action' => 'created_group', 440 'item_id' => $bp->groups->current_group->id, 441 'user_id' => $user_id 442 ) ); 443 427 444 if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $group_enable_forum ) ) ) { 428 445 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' ); … … 475 492 unset( $bp->groups->completed_create_steps ); 476 493 477 $group = new BP_Groups_Group( $bp->groups->new_group_id, false, false ); 478 479 bp_core_redirect( bp_get_group_permalink( $group ) ); 494 bp_core_redirect( bp_get_group_permalink( $bp->groups->new_group ) ); 480 495 } else { 481 496 /** … … 500 515 } 501 516 502 $bp->groups->new_group = new BP_Groups_Group( $bp->groups->new_group_id, false, false );503 517 bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) ); 504 518 } 519 505 520 506 521 function groups_screen_group_home() { … … 529 544 global $bp; 530 545 531 if ( $bp->is_single_item ) { 532 $topic_id = $bp->action_variables[1]; 546 if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) { 547 $topic_slug = $bp->action_variables[1]; 548 $topic_id = bp_forums_get_topic_id_from_slug( $topic_slug ); 533 549 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 534 550 535 if ( $topic_ id ) {551 if ( $topic_slug && $topic_id ) { 536 552 537 553 /* Posting a reply */ 538 if ( isset( $_POST['submit_reply'] ) && function_exists( 'bp_forums_new_post') ) {554 if ( !$bp->action_variables[2] && isset( $_POST['submit_reply'] ) ) { 539 555 /* Check the nonce */ 540 if ( !check_admin_referer( 'bp_forums_new_reply' ) ) 541 return false; 542 543 groups_new_group_forum_post( $_POST['reply_text'], $topic_id ); 544 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_id ); 545 } 546 547 do_action( 'groups_screen_group_forum_topic' ); 548 549 // If we are viewing a topic, load it. 550 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/topic' ) ); 556 check_admin_referer( 'bp_forums_new_reply' ); 557 558 if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) ) 559 bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' ); 560 else 561 bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') ); 562 563 if ( $_SERVER['QUERY_STRING'] ) 564 $query_vars = '?' . $_SERVER['QUERY_STRING']; 565 566 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars ); 567 } 568 569 /* Sticky a topic */ 570 else if ( 'stick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 571 /* Check the nonce */ 572 check_admin_referer( 'bp_forums_stick_topic' ); 573 574 if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id ) ) ) 575 bp_core_add_message( __( 'There was an error when making that topic a sticky', 'buddypress' ), 'error' ); 576 else 577 bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) ); 578 579 do_action( 'groups_stick_topic', $topic_id ); 580 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 581 } 582 583 /* Un-Sticky a topic */ 584 else if ( 'unstick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 585 /* Check the nonce */ 586 check_admin_referer( 'bp_forums_unstick_topic' ); 587 588 if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id, 'mode' => 'unstick' ) ) ) 589 bp_core_add_message( __( 'There was an error when unsticking that topic', 'buddypress'), 'error' ); 590 else 591 bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') ); 592 593 do_action( 'groups_unstick_topic', $topic_id ); 594 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 595 } 596 597 /* Close a topic */ 598 else if ( 'close' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 599 /* Check the nonce */ 600 check_admin_referer( 'bp_forums_close_topic' ); 601 602 if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id ) ) ) 603 bp_core_add_message( __( 'There was an error when closing that topic', 'buddypress'), 'error' ); 604 else 605 bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') ); 606 607 do_action( 'groups_close_topic', $topic_id ); 608 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 609 } 610 611 /* Open a topic */ 612 else if ( 'open' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 613 /* Check the nonce */ 614 check_admin_referer( 'bp_forums_open_topic' ); 615 616 if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id, 'mode' => 'open' ) ) ) 617 bp_core_add_message( __( 'There was an error when opening that topic', 'buddypress'), 'error' ); 618 else 619 bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') ); 620 621 do_action( 'groups_open_topic', $topic_id ); 622 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 623 } 624 625 /* Delete a topic */ 626 else if ( 'delete' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 627 /* Check the nonce */ 628 check_admin_referer( 'bp_forums_delete_topic' ); 629 630 if ( !groups_delete_forum_topic( $topic_id ) ) 631 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' ); 632 else 633 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 634 635 do_action( 'groups_delete_topic', $topic_id ); 636 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 637 } 638 639 /* Editing a topic */ 640 else if ( 'edit' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 641 if ( isset( $_POST['save_changes'] ) ) { 642 /* Check the nonce */ 643 check_admin_referer( 'bp_forums_edit_topic' ); 644 645 if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) ) 646 bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' ); 647 else 648 bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') ); 649 650 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 651 } 652 653 /* Check that the user has access to edit this topic, if not, redirect. */ 654 $topic = bp_forums_get_topic_details( $topic_id ); 655 if ( ( !$bp->is_item_admin && !$bp->is_item_mod ) && $bp->loggedin_user->id != $topic->topic_poster ) 656 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 657 658 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) ); 659 } 660 661 /* Delete a post */ 662 else if ( 'delete' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 663 /* Check the nonce */ 664 check_admin_referer( 'bp_forums_delete_topic' ); 665 666 if ( !groups_delete_forum_topic( $topic_id ) ) 667 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' ); 668 else 669 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 670 671 do_action( 'groups_delete_topic', $topic_id ); 672 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 673 } 674 675 676 /* Editing a post */ 677 else if ( 'edit' == $bp->action_variables[4] && $post_id = $bp->action_variables[3] ) { 678 if ( isset( $_POST['save_changes'] ) ) { 679 /* Check the nonce */ 680 check_admin_referer( 'bp_forums_edit_post' ); 681 682 if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) ) 683 bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' ); 684 else 685 bp_core_add_message( __( 'The post was edited successfully', 'buddypress') ); 686 687 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 688 } 689 690 /* Check that the user has access to edit this post, if not, redirect. */ 691 $post = bp_forums_get_post( $post_id ); 692 if ( ( !$bp->is_item_admin && !$bp->is_item_mod ) && $bp->loggedin_user->id != $post->poster_id ) 693 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' ); 694 695 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) ); 696 } 697 698 /* Standard topic display */ 699 else { 700 if ( file_exists( TEMPLATEPATH . '/groups/single/forum/topic.php' ) ) 701 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/single/forum/topic' ) ); 702 else 703 bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) ); 704 } 551 705 } else { 552 706 … … 554 708 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) { 555 709 /* Check the nonce */ 556 if ( !check_admin_referer( 'bp_forums_new_topic' ) ) 557 return false; 710 check_admin_referer( 'bp_forums_new_topic' ); 558 711 559 groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ); 712 if ( !groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) 713 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' ); 714 else 715 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') ); 716 560 717 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 561 718 } … … 1181 1338 */ 1182 1339 1183 function groups_record_activity( $args = true ) { 1184 global $bp; 1185 1186 if ( function_exists('bp_activity_record') ) { 1187 extract($args); 1188 1189 if ( !$bp->groups->current_group ) { 1190 if ( !$bp->groups->current_group = wp_cache_get( 'groups_group_nouserdata_' . $item_id, 'bp' ) ) { 1191 $bp->groups->current_group = new BP_Groups_Group( $item_id, false, false ); 1192 wp_cache_set( 'groups_group_nouserdata_' . $item_id, $bp->groups->current_group, 'bp' ); 1193 } 1194 } 1195 1196 if ( 'public' == $bp->groups->current_group->status ) 1197 bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id ); 1198 } 1199 } 1200 1201 function groups_delete_activity( $args = true ) { 1202 if ( function_exists('bp_activity_delete') ) { 1203 extract($args); 1204 bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ); 1205 } 1206 } 1207 1208 function groups_format_activity( $item_id, $user_id, $action, $secondary_item_id = false, $for_secondary_user = false ) { 1209 global $bp; 1210 1211 switch( $action ) { 1212 case 'joined_group': 1213 $group = new BP_Groups_Group( $item_id, false, false ); 1214 1215 if ( !$group ) 1216 return false; 1217 1218 $user_link = bp_core_get_userlink( $user_id ); 1219 $group_link = bp_get_group_permalink( $group ); 1220 1221 return array( 1222 'primary_link' => $group_link, 1223 'content' => apply_filters( 'bp_groups_joined_group_activity', sprintf( __('%s joined the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name ) 1224 ); 1225 break; 1226 case 'created_group': 1227 $group = new BP_Groups_Group( $item_id, false, false ); 1228 1229 if ( !$group ) 1230 return false; 1231 1232 $user_link = bp_core_get_userlink( $user_id ); 1233 $group_link = bp_get_group_permalink( $group ); 1234 1235 return array( 1236 'primary_link' => $group_link, 1237 'content' => apply_filters( 'bp_groups_created_group_activity', sprintf( __('%s created the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>') . ' <span class="time-since">%s</span>', $user_link, $group_link, $group->name ) 1238 ); 1239 break; 1240 case 'new_wire_post': 1241 $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $item_id ); 1242 $group = new BP_Groups_Group( $wire_post->item_id, false, false ); 1243 1244 if ( !$group || !$wire_post || !$wire_post->content ) 1245 return false; 1246 1247 $user_link = bp_core_get_userlink( $user_id ); 1248 $group_link = bp_get_group_permalink( $group ); 1249 $post_excerpt = bp_create_excerpt( $wire_post->content ); 1250 1251 $content = sprintf ( __('%s wrote on the wire of the group %s', 'buddypress'), $user_link, '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>'; 1252 $content .= '<blockquote>' . $post_excerpt . '</blockquote>'; 1253 1254 $content = apply_filters( 'bp_groups_new_wire_post_activity', $content, $user_link, $group_link, $group->name, $post_excerpt ); 1255 1256 return array( 1257 'primary_link' => $group_link, 1258 'content' => $content 1259 ); 1260 break; 1261 case 'new_forum_post': 1262 if ( function_exists('bp_forums_setup') ) { 1263 $group = new BP_Groups_Group( $item_id, false, false ); 1264 $forum_post = bp_forums_get_post( $secondary_item_id ); 1265 $forum_topic = bp_forums_get_topic_details( $forum_post['topic_id'] ); 1266 1267 if ( !$group || !$forum_post || !$forum_topic ) 1268 return false; 1269 1270 $user_link = bp_core_get_userlink($user_id); 1271 $group_link = bp_get_group_permalink( $group ); 1272 1273 $post_content = apply_filters( 'bp_the_topic_post_content', bp_create_excerpt( stripslashes( $forum_post['post_text'] ), 55, false ) ); 1274 1275 $content = sprintf ( __('%s posted on the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>'; 1276 $content .= '<blockquote>' . $post_content . '</blockquote>'; 1277 1278 $content = apply_filters( 'bp_groups_new_forum_post_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content ); 1279 1280 return array( 1281 'primary_link' => $group_link, 1282 'content' => $content 1283 ); 1284 } 1285 break; 1286 case 'new_forum_topic': 1287 if ( function_exists('bp_forums_setup') ) { 1288 $group = new BP_Groups_Group( $item_id, false, false ); 1289 $forum_topic = bp_forums_get_topic_details( $secondary_item_id ); 1290 $forum_post = bp_forums_get_post( $forum_topic['topic_last_post_id'] ); 1291 1292 if ( !$group || !$forum_post || !$forum_topic ) 1293 return false; 1294 1295 $user_link = bp_core_get_userlink($user_id); 1296 $group_link = bp_get_group_permalink( $group ); 1297 1298 $post_content = apply_filters( 'bp_the_topic_post_content', bp_create_excerpt( stripslashes( $forum_post['post_text'] ), 55, false ) ); 1299 1300 $content = sprintf ( __('%s created the forum topic %s in the group %s:', 'buddypress'), $user_link, '<a href="' . $group_link . '/forum/topic/' . $forum_topic['topic_id'] . '">' . $forum_topic['topic_title'] . '</a>', '<a href="' . $group_link . '">' . $group->name . '</a>' ) . ' <span class="time-since">%s</span>'; 1301 $content .= '<blockquote>' . $post_content . '</blockquote>'; 1302 1303 $content = apply_filters( 'bp_groups_new_forum_topic_activity', $content, $user_link, $group_link, $forum_topic['topic_id'], $forum_topic['topic_title'], $group_link, $group->name, $post_content ); 1304 1305 return array( 1306 'primary_link' => $group_link, 1307 'content' => $content 1308 ); 1309 } 1310 break; 1311 } 1312 1313 do_action( 'groups_format_activity', $action, $item_id, $user_id, $action, $secondary_item_id, $for_secondary_user ); 1314 1315 return false; 1340 function groups_record_activity( $args = '' ) { 1341 global $bp; 1342 1343 if ( !function_exists( 'bp_activity_add' ) ) 1344 return false; 1345 1346 if ( 'public' != $bp->groups->current_group->status ) 1347 return false; 1348 1349 $defaults = array( 1350 'user_id' => $bp->loggedin_user->id, 1351 'content' => false, 1352 'primary_link' => false, 1353 'component_name' => 'groups', 1354 'component_action' => false, 1355 'item_id' => false, 1356 'secondary_item_id' => false, 1357 'recorded_time' => time(), 1358 'hide_sitewide' => false 1359 ); 1360 1361 $r = wp_parse_args( $args, $defaults ); 1362 extract( $r, EXTR_SKIP ); 1363 1364 return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); 1316 1365 } 1317 1366 … … 1587 1636 if ( !$group->delete() ) 1588 1637 return false; 1589 1590 // Remove the activity stream item 1591 groups_delete_activity( array( 'item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'user_id' => $bp->loggedin_user->id ) ); 1638 1639 /* Delete the activity stream item */ 1640 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 1641 bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => 'groups', 'component_action' => 'created_group' ) ); 1642 } 1592 1643 1593 1644 // Remove all outstanding invites for this group … … 1679 1730 1680 1731 /* Record this in activity streams */ 1681 groups_record_activity( array( 'item_id' => $new_member->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0 ) ); 1682 1732 groups_record_activity( array( 1733 'content' => sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ), 1734 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 1735 'component_action' => 'joined_group', 1736 'item_id' => $bp->groups->current_group->id 1737 ) ); 1738 1683 1739 /* Modify group meta */ 1684 1740 groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 ); … … 1911 1967 1912 1968 function groups_new_wire_post( $group_id, $content ) { 1913 $bp; 1914 1915 $private = false; 1916 if ( $bp->groups->current_group->status != 'public' ) 1917 $private = true; 1918 1919 if ( $wire_post_id = bp_wire_new_post( $group_id, $content, $bp->groups->slug, $private ) ) { 1969 global $bp; 1970 1971 if ( !function_exists( 'bp_wire_new_post' ) ) 1972 return false; 1973 1974 if ( $wire_post_id = bp_wire_new_post( $group_id, $content, 'groups' ) ) { 1975 $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>' ); 1976 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>'; 1977 1978 groups_record_activity( array( 1979 'content' => $activity_content, 1980 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 1981 'component_action' => 'new_wire_post', 1982 'item_id' => $wire_post_id, 1983 'secondary_item_id' => $bp->groups->current_group->id 1984 ) ); 1985 1920 1986 do_action( 'groups_new_wire_post', $group_id, $wire_post_id ); 1921 1987 … … 1927 1993 1928 1994 function groups_delete_wire_post( $wire_post_id, $table_name ) { 1929 global $bp; 1930 1931 if ( bp_wire_delete_post( $wire_post_id, $bp->groups->slug, $table_name ) ) { 1995 if ( bp_wire_delete_post( $wire_post_id, 'groups', $table_name ) ) { 1996 /* Delete the activity stream item */ 1997 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 1998 bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) ); 1999 } 2000 1932 2001 do_action( 'groups_deleted_wire_post', $wire_post_id ); 1933 2002 return true; … … 1941 2010 function groups_new_group_forum( $group_id = false, $group_name = false, $group_desc = false ) { 1942 2011 global $bp; 1943 2012 1944 2013 if ( !$group_id ) 1945 2014 $group_id = $bp->groups->current_group->id; … … 1951 2020 $group_desc = $bp->groups->current_group->description; 1952 2021 1953 $forum = bp_forums_new_forum( apply_filters( 'groups_new_group_forum_name', $group_name . ' - ' . __( 'Forum', 'buddypress' ), $group_name ), apply_filters( 'groups_new_group_forum_desc',$group_desc ) );1954 1955 groups_update_groupmeta( $group_id, 'forum_id', $forum ['forum_id']);2022 $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_description' => $group_desc ) ); 2023 2024 groups_update_groupmeta( $group_id, 'forum_id', $forum_id ); 1956 2025 1957 2026 do_action( 'groups_new_group_forum', $forum, $group_id ); … … 1961 2030 global $bp; 1962 2031 1963 if ( $forum_post = bp_forums_new_post( $post_text, $topic_id ) ) { 1964 bp_core_add_message( __( 'Reply posted successfully!', 'buddypress') ); 1965 1966 /* Record in activity streams */ 1967 groups_record_activity( array( 'item_id' => $bp->groups->current_group->id, 'component_name' => $bp->groups->slug, 'component_action' => 'new_forum_post', 'is_private' => 0, 'secondary_item_id' => $forum_post['post_id'] ) ); 1968 2032 if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) { 2033 $topic = bp_forums_get_topic_details( $topic_id ); 2034 2035 $activity_content = 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>' ); 2036 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>'; 2037 2038 /* Record this in activity streams */ 2039 groups_record_activity( array( 2040 'content' => $activity_content, 2041 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 2042 'component_action' => 'new_forum_post', 2043 'item_id' => $topic_id, 2044 'secondary_item_id' => $forum_post->id 2045 ) ); 2046 1969 2047 do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $forum_post ); 1970 2048 … … 1972 2050 } 1973 2051 1974 bp_core_add_message( __( 'There was an error posting that reply.', 'buddypress'), 'error' );1975 2052 return false; 1976 2053 } … … 1979 2056 global $bp; 1980 2057 1981 if ( $topic = bp_forums_new_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) ) { 1982 bp_core_add_message( __( 'Topic posted successfully!', 'buddypress') ); 1983 1984 /* Record in activity streams */ 1985 groups_record_activity( array( 'item_id' => $bp->groups->current_group->id, 'component_name' => $bp->groups->slug, 'component_action' => 'new_forum_topic', 'is_private' => 0, 'secondary_item_id' => $topic['topic_id'] ) ); 1986 1987 do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, $topic ); 2058 if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) { 2059 $topic = bp_forums_get_topic_details( $topic_id ); 2060 2061 $activity_content = sprintf( __( '%s started 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>' ); 2062 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>'; 2063 2064 /* Record this in activity streams */ 2065 groups_record_activity( array( 2066 'content' => $activity_content, 2067 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 2068 'component_action' => 'new_forum_topic', 2069 'item_id' => $topic->topic_id, 2070 'secondary_item_id' => $bp->groups->current_group->id 2071 ) ); 2072 2073 do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, &$topic ); 1988 2074 1989 2075 return $topic; 1990 2076 } 1991 1992 bp_core_add_message( __( 'There was an error posting that topic.', 'buddypress'), 'error' ); 2077 1993 2078 return false; 1994 2079 } 2080 2081 function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) { 2082 global $bp; 2083 2084 if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) { 2085 /* Update the activity stream item */ 2086 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) ); 2087 2088 $activity_content = sprintf( __( '%s started the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<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>' ); 2089 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>'; 2090 2091 /* Record this in activity streams */ 2092 groups_record_activity( array( 2093 'content' => $activity_content, 2094 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 2095 'component_action' => 'new_forum_topic', 2096 'item_id' => (int)$topic->topic_id, 2097 'user_id' => (int)$topic->topic_poster, 2098 'secondary_item_id' => $bp->groups->current_group->id, 2099 'recorded_time' => bb_gmtstrtotime( $topic->topic_time ) 2100 ) ); 2101 2102 do_action( 'groups_update_group_forum_topic', &$topic ); 2103 2104 return true; 2105 } 2106 2107 return false; 2108 } 2109 2110 function groups_delete_forum_topic( $topic_id ) { 2111 global $bp; 2112 2113 if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2114 /* Delete the activity stream item */ 2115 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2116 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) ); 2117 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2118 } 2119 2120 do_action( 'groups_delete_forum_topic', $topic_id ); 2121 2122 return true; 2123 } 2124 2125 return false; 2126 } 2127 2128 function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) { 2129 global $bp; 2130 2131 $post = bp_forums_get_post( $post_id ); 2132 2133 if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id ) ) ) { 2134 $topic = bp_forums_get_topic_details( $topic_id ); 2135 2136 /* Update the activity stream item */ 2137 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'secondary_item_id' => $post_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2138 2139 $activity_content = 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>' ); 2140 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>'; 2141 2142 /* Record this in activity streams */ 2143 groups_record_activity( array( 2144 'content' => $activity_content, 2145 'primary_link' => bp_get_group_permalink( $bp->groups->current_group ), 2146 'component_action' => 'new_forum_post', 2147 'item_id' => $topic_id, 2148 'secondary_item_id' => $post_id, 2149 'recorded_time' => bb_gmtstrtotime( $post->post_time ) 2150 ) ); 2151 2152 do_action( 'groups_update_group_forum_post', &$post, &$topic ); 2153 2154 return true; 2155 } 2156 2157 return false; 2158 } 2159 2160 // function groups_delete_forum_post( $post_id, $topic_id ) { 2161 // global $bp; 2162 // 2163 // if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2164 // /* Delete the activity stream item */ 2165 // if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2166 // bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'secondary_item_id' => $post_id 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2167 // } 2168 // 2169 // do_action( 'groups_delete_forum_topic', $topic_id ); 2170 // 2171 // return true; 2172 // } 2173 // 2174 // return false; 2175 // } 1995 2176 1996 2177 /*** Group Invitations *********************************************************/ … … 2212 2393 2213 2394 /* Record this in activity streams */ 2214 groups_record_activity( array( 'item_id' => $membership->group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0 ) ); 2395 $group = new BP_Groups_Group( $group_id, false, false ); 2396 2397 groups_record_activity( array( 2398 'content' => sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), 2399 'primary_link' => bp_get_group_permalink( $group ), 2400 'component_action' => 'joined_group', 2401 'item_id' => $group->id, 2402 'user_id' => $user_id 2403 ) ); 2215 2404 2216 2405 /* Send a notification to the user. */ -
trunk/bp-groups/bp-groups-cssjs.php
r1599 r1621 1 1 <?php 2 /**************************************************************************3 groups_add_js()4 5 Inserts the Javascript needed for managing groups.6 **************************************************************************/7 2 8 3 function groups_add_js() { -
trunk/bp-groups/bp-groups-templatetags.php
r1599 r1621 594 594 } 595 595 596 function bp_group_is_admin() { 597 global $bp; 598 599 return $bp->is_item_admin; 600 } 601 602 function bp_group_is_mod() { 603 global $bp; 604 605 return $bp->is_item_mod; 606 } 607 596 608 function bp_group_list_admins( $full_list = true, $group = false ) { 597 609 global $groups_template; … … 689 701 if ( $forum_id && $forum_id != '' ) { 690 702 if ( function_exists( 'bp_forums_setup' ) ) { 691 $latest_topics = bp_forums_get_ topics( $forum_id, $total_topics, 1);703 $latest_topics = bp_forums_get_forum_topics( $forum_id ); 692 704 693 705 if ( $latest_topics ) { ?> … … 1632 1644 function bp_get_new_group_name() { 1633 1645 global $bp; 1634 return apply_filters( 'bp_get_new_group_name', $bp->groups-> new_group->name );1646 return apply_filters( 'bp_get_new_group_name', $bp->groups->current_group->name ); 1635 1647 } 1636 1648 … … 1640 1652 function bp_get_new_group_description() { 1641 1653 global $bp; 1642 return apply_filters( 'bp_get_new_group_description', $bp->groups-> new_group->name );1654 return apply_filters( 'bp_get_new_group_description', $bp->groups->current_group->name ); 1643 1655 } 1644 1656 … … 1648 1660 function bp_get_new_group_news() { 1649 1661 global $bp; 1650 return apply_filters( 'bp_get_new_group_news', $bp->groups-> new_group->name );1662 return apply_filters( 'bp_get_new_group_news', $bp->groups->current_group->name ); 1651 1663 } 1652 1664 … … 1656 1668 function bp_get_new_group_enable_wire() { 1657 1669 global $bp; 1658 return (int) apply_filters( 'bp_get_new_group_enable_wire', $bp->groups-> new_group->enable_wire );1670 return (int) apply_filters( 'bp_get_new_group_enable_wire', $bp->groups->current_group->enable_wire ); 1659 1671 } 1660 1672 … … 1664 1676 function bp_get_new_group_enable_forum() { 1665 1677 global $bp; 1666 return (int) apply_filters( 'bp_get_new_group_enable_forum', $bp->groups-> new_group->enable_forum );1678 return (int) apply_filters( 'bp_get_new_group_enable_forum', $bp->groups->current_group->enable_forum ); 1667 1679 } 1668 1680 … … 1672 1684 function bp_get_new_group_status() { 1673 1685 global $bp; 1674 return apply_filters( 'bp_get_new_group_status', $bp->groups-> new_group->status );1686 return apply_filters( 'bp_get_new_group_status', $bp->groups->current_group->status ); 1675 1687 } 1676 1688 … … 1680 1692 function bp_get_new_group_avatar_thumb() { 1681 1693 global $bp; 1682 return apply_filters( 'bp_get_new_group_avatar_thumb', $bp->groups-> new_group->avatar_thumb );1694 return apply_filters( 'bp_get_new_group_avatar_thumb', $bp->groups->current_group->avatar_thumb ); 1683 1695 } 1684 1696 … … 1688 1700 function bp_get_new_group_avatar_full() { 1689 1701 global $bp; 1690 return apply_filters( 'bp_get_new_group_avatar_full', $bp->groups-> new_group->avatar_full );1702 return apply_filters( 'bp_get_new_group_avatar_full', $bp->groups->current_group->avatar_full ); 1691 1703 } 1692 1704 … … 1775 1787 } 1776 1788 1777 return implode( "\n", $items );1789 return implode( "\n", (array)$items ); 1778 1790 } 1779 1791 … … 2572 2584 return false; 2573 2585 2574 $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $bp->groups-> new_group->id );2586 $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $bp->groups->current_group->id ); 2575 2587 2576 2588 if ( $friends ) { 2577 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $bp->groups-> new_group->id );2589 $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $bp->groups->current_group->id ); 2578 2590 2579 2591 ?> … … 2630 2642 case 'group-details': ?> 2631 2643 <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label> 2632 <input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups-> new_group->name : $_POST['group-name'] ); ?>" />2644 <input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups->current_group->name : $_POST['group-name'] ); ?>" /> 2633 2645 2634 2646 <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label> 2635 <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups-> new_group->description : $_POST['group-desc'] ); ?></textarea>2647 <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea> 2636 2648 2637 2649 <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label> 2638 <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups-> new_group->news : $_POST['group-news'] ); ?></textarea>2650 <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea> 2639 2651 2640 2652 <?php do_action( 'groups_custom_group_fields_editable' ) ?> … … 2648 2660 <?php if ( function_exists('bp_wire_install') ) : ?> 2649 2661 <div class="checkbox"> 2650 <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $bp->groups-> new_group->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>2662 <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( $bp->groups->current_group->enable_wire ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label> 2651 2663 </div> 2652 2664 <?php endif; ?> … … 2655 2667 <?php if ( bp_forums_is_installed_correctly() ) { ?> 2656 2668 <div class="checkbox"> 2657 <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( $bp->groups-> new_group->enable_forum ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label>2669 <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( $bp->groups->current_group->enable_forum ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label> 2658 2670 </div> 2659 2671 <?php } else { … … 2670 2682 <?php if ( function_exists('bp_albums_install') ) : ?> 2671 2683 <div class="checkbox with-suboptions"> 2672 <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $bp->groups-> new_group->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label>2673 <div class="sub-options"<?php if ( !$bp->groups-> new_group->enable_photos ) { ?> style="display: none;"<?php } ?>>2674 <label><input type="radio" name="group-photos-status" value="all"<?php if ( !$bp->groups-> new_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('All members can upload photos', 'buddypress') ?></label>2675 <label><input type="radio" name="group-photos-status" value="admins"<?php if ( $bp->groups-> new_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('Only group admins can upload photos', 'buddypress') ?></label>2684 <label><input type="checkbox" name="group-show-photos" id="group-show-photos" value="1"<?php if ( $bp->groups->current_group->enable_photos ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable photo gallery', 'buddypress') ?></label> 2685 <div class="sub-options"<?php if ( !$bp->groups->current_group->enable_photos ) { ?> style="display: none;"<?php } ?>> 2686 <label><input type="radio" name="group-photos-status" value="all"<?php if ( !$bp->groups->current_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('All members can upload photos', 'buddypress') ?></label> 2687 <label><input type="radio" name="group-photos-status" value="admins"<?php if ( $bp->groups->current_group->photos_admin_only ) { ?> checked="checked"<?php } ?> /> <?php _e('Only group admins can upload photos', 'buddypress') ?></label> 2676 2688 </div> 2677 2689 </div> … … 2681 2693 2682 2694 <div class="radio"> 2683 <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups-> new_group->status ) { ?> checked="checked"<?php } ?> />2695 <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 2684 2696 <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong> 2685 2697 <ul> … … 2690 2702 </label> 2691 2703 2692 <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups-> new_group->status ) { ?> checked="checked"<?php } ?> />2704 <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 2693 2705 <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong> 2694 2706 <ul> … … 2699 2711 </label> 2700 2712 2701 <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups-> new_group->status ) { ?> checked="checked"<?php } ?> />2713 <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 2702 2714 <strong><?php _e('This is a hidden group', 'buddypress') ?></strong> 2703 2715 <ul> -
trunk/bp-status/bp-status-filters.php
r1567 r1621 1 1 <?php 2 2 3 add_filter( 'bp_get_the_status', 'wp_filter_kses', 1 ); 3 add_filter( 'bp_get_the_status', 'bp_status_filter_tags' ); 4 add_filter( 'bp_get_the_status', 'force_balance_tags' ); 4 5 add_filter( 'bp_get_the_status', 'wptexturize' ); 5 6 add_filter( 'bp_get_the_status', 'convert_smilies' ); … … 8 9 add_filter( 'bp_get_the_status', 'stripslashes_deep' ); 9 10 11 function bp_status_filter_tags( $status ) { 12 return apply_filters( 'bp_status_filter_tags', strip_tags( $status, '<a>' ) ); 13 } 14 10 15 ?> -
trunk/bp-wire.php
r1599 r1621 98 98 */ 99 99 100 function bp_wire_new_post( $item_id, $message, $component_name, $ private_post= false, $table_name = null ) {100 function bp_wire_new_post( $item_id, $message, $component_name, $deprecated = false, $table_name = null ) { 101 101 global $bp; 102 102 … … 119 119 if ( !$wire_post->save() ) 120 120 return false; 121 122 if ( !$private_post ) {123 // Record in the activity streams124 bp_wire_record_activity( array( 'item_id' => $wire_post->id, 'component_name' => $component_name, 'component_action' => 'new_wire_post', 'is_private' => 0 ) );125 }126 121 127 122 do_action( 'bp_wire_post_posted', $wire_post->id, $wire_post->item_id, $wire_post->user_id ); … … 151 146 return false; 152 147 153 // Delete activity stream items154 bp_wire_delete_activity( array( 'user_id' => $wire_post->user_id, 'item_id' => $wire_post->id, 'component_name' => $component_name, 'component_action' => 'new_wire_post' ) );155 156 148 do_action( 'bp_wire_post_deleted', $wire_post->id, $wire_post->item_id, $wire_post->user_id ); 157 149
Note: See TracChangeset
for help on using the changeset viewer.