Changeset 3806
- Timestamp:
- 01/22/2011 08:39:40 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-template.php
r3778 r3806 701 701 702 702 // Insert the permalink 703 if ( !bp_is_ activity_permalink() )703 if ( !bp_is_single_activity() ) 704 704 $content .= apply_filters( 'bp_activity_permalink', ' · <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity ); 705 705 -
trunk/bp-core/bp-core-catchuri.php
r3796 r3806 157 157 // Find the offset 158 158 $uri_offset = 0; 159 $slug = isset( $match ) ? explode( '/', $match->slug ) : '';159 $slug = explode( '/', $match->slug ); 160 160 161 161 if ( !empty( $slug ) && 1 != count( $slug ) ) { -
trunk/bp-core/bp-core-loader.php
r3790 r3806 13 13 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php' ); 14 14 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php' ); 15 require ( BP_PLUGIN_DIR . '/bp-core/bp-core-deprecated.php' ); 15 16 // Do we load deprecated functions? 17 if ( !defined( 'BP_SKIP_DEPRECATED' ) ) 18 require ( BP_PLUGIN_DIR . '/bp-core/deprecated/1.3.php' ); 16 19 17 20 // If BP_DISABLE_ADMIN_BAR is defined, do not load the global admin bar. -
trunk/bp-core/bp-core-template.php
r3796 r3806 2 2 3 3 /** 4 * bp_get_options_nav()5 * TEMPLATE TAG6 *7 4 * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component. 8 5 * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function. … … 54 51 } 55 52 56 57 /** AVATAR TEMPLATE TAGS *******************************************************/ 53 /** Avatars *******************************************************************/ 58 54 59 55 /** 60 * bp_has_options_avatar()61 * TEMPLATE TAG62 *63 56 * Check to see if there is an options avatar. An options avatar is an avatar for something 64 57 * like a group, or a friend. Basically an avatar that appears in the sub nav options bar. … … 145 138 function bp_site_name() { 146 139 echo apply_filters( 'bp_site_name', get_bloginfo( 'name', 'display' ) ); 147 }148 149 function bp_core_get_wp_profile() {150 global $bp;151 152 $ud = get_userdata( $bp->displayed_user->id );153 ?>154 155 <div class="bp-widget wp-profile">156 <h4><?php _e( 'My Profile' ) ?></h4>157 158 <table class="wp-profile-fields zebra">159 <?php if ( $ud->display_name ) { ?>160 <tr id="wp_displayname">161 <td class="label">162 <?php _e( 'Name', 'buddypress' ) ?>163 </td>164 <td class="data">165 <?php echo $ud->display_name ?>166 </td>167 </tr>168 <?php } ?>169 <?php if ( $ud->user_description ) { ?>170 <tr id="wp_desc">171 <td class="label">172 <?php _e( 'About Me', 'buddypress' ) ?>173 </td>174 <td class="data">175 <?php echo $ud->user_description ?>176 </td>177 </tr>178 <?php } ?>179 <?php if ( $ud->user_url ) { ?>180 <tr id="wp_website">181 <td class="label">182 <?php _e( 'Website', 'buddypress' ) ?>183 </td>184 <td class="data">185 <?php echo make_clickable( $ud->user_url ) ?>186 </td>187 </tr>188 <?php } ?>189 <?php if ( $ud->jabber ) { ?>190 <tr id="wp_jabber">191 <td class="label">192 <?php _e( 'Jabber', 'buddypress' ) ?>193 </td>194 <td class="data">195 <?php echo $ud->jabber ?>196 </td>197 </tr>198 <?php } ?>199 <?php if ( $ud->aim ) { ?>200 <tr id="wp_aim">201 <td class="label">202 <?php _e( 'AOL Messenger', 'buddypress' ) ?>203 </td>204 <td class="data">205 <?php echo $ud->aim ?>206 </td>207 </tr>208 <?php } ?>209 <?php if ( $ud->yim ) { ?>210 <tr id="wp_yim">211 <td class="label">212 <?php _e( 'Yahoo Messenger', 'buddypress' ) ?>213 </td>214 <td class="data">215 <?php echo $ud->yim ?>216 </td>217 </tr>218 <?php } ?>219 </table>220 </div>221 <?php222 140 } 223 141 … … 281 199 } 282 200 283 284 201 function bp_get_plugin_sidebar() { 285 202 locate_template( array( 'plugin-sidebar.php' ), true ); … … 293 210 global $bp, $post, $wp_query, $current_blog; 294 211 212 // Home 295 213 if ( is_front_page() || ( is_home() && bp_is_page( 'home' ) ) ) { 296 214 $title = __( 'Home', 'buddypress' ); 297 215 298 } else if ( bp_is_blog_page() ) { 216 // Blog 217 } elseif ( bp_is_blog_page() ) { 299 218 if ( is_single() ) { 300 219 $title = __( 'Blog | ' . $post->post_title, 'buddypress' ); … … 308 227 $title = __( 'Blog', 'buddypress' ); 309 228 310 } else if ( !empty( $bp->displayed_user->fullname ) ) { 229 // Displayed user 230 } elseif ( !empty( $bp->displayed_user->fullname ) ) { 311 231 $title = strip_tags( $bp->displayed_user->fullname . ' | ' . ucwords( $bp->current_component ) ); 312 232 313 } else if ( !empty( $bp->is_single_item ) ) { 314 $title = ucwords( $bp->current_component ) . ' | ' . $bp->bp_options_title . ' | ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name']; 315 316 } else if ( !empty( $bp->is_directory ) ) { 233 // A single item of a component 234 } elseif ( bp_is_single_item() ) { 235 $title = ucwords( $bp->current_component ) . ' | ' . $bp->bp_options_title . ' | '; // . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name']; 236 237 // An index or directory 238 } elseif ( bp_is_directory() ) { 317 239 if ( !$bp->current_component ) 318 240 $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) ); … … 320 242 $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) ); 321 243 322 } else if ( bp_is_register_page() ) { 244 // Sign up page 245 } elseif ( bp_is_register_page() ) { 323 246 $title = __( 'Create an Account', 'buddypress' ); 324 247 325 } else if ( bp_is_activation_page() ) { 248 // Activation page 249 } elseif ( bp_is_activation_page() ) { 326 250 $title = __( 'Activate your Account', 'buddypress' ); 327 251 328 } else if ( bp_is_group_create() ) { 252 // Group creation page 253 } elseif ( bp_is_group_create() ) { 329 254 $title = __( 'Create a Group', 'buddypress' ); 330 255 331 } else if ( bp_is_create_blog() ) { 256 // Blog creation page 257 } elseif ( bp_is_create_blog() ) { 332 258 $title = __( 'Create a Blog', 'buddypress' ); 333 259 } 334 260 261 // Filter the title 335 262 return apply_filters( 'bp_page_title', esc_attr( get_bloginfo( 'name', 'display' ) . ' | ' . $title ), esc_attr( $title ) ); 336 263 } … … 340 267 wp_print_styles(); 341 268 } 269 270 /** Search Form ***************************************************************/ 342 271 343 272 /** … … 692 621 } 693 622 694 /* Template is_() functions to determine the current page*/623 /** is_() functions to determine the current page *****************************/ 695 624 696 625 /** … … 746 675 } 747 676 677 function bp_is_current_action( $action = '' ) { 678 global $bp; 679 680 if ( !empty( $action ) && ( $action == $bp->current_action ) ) 681 return true; 682 683 return false; 684 } 685 686 function bp_is_single_item() { 687 global $bp; 688 689 if ( !empty( $bp->is_single_item ) ) 690 return true; 691 692 return false; 693 } 694 695 function bp_is_directory() { 696 global $bp; 697 698 if ( !empty( $bp->is_directory ) ) 699 return true; 700 701 return false; 702 } 703 748 704 /** 749 * Checks to see if a component's URL should be in the root, not under a member page: 750 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group 705 * Checks to see if a component's URL should be in the root, not under a 706 * member page: 707 * 708 * Yes: http://domain.com/groups/the-group 709 * No: http://domain.com/members/andy/groups/the-group 751 710 * 752 711 * @package BuddyPress Core … … 756 715 global $bp; 757 716 717 if ( !isset( $bp->active_components ) ) 718 return false; 719 758 720 foreach ( (array) $bp->active_components as $key => $slug ) { 759 721 if ( $key == $component_name || $slug == $component_name ) … … 765 727 766 728 /** 767 * Checks if the site's front page is set to the specified BuddyPress component page in wp-admin's Settings > Reading screen. 729 * Checks if the site's front page is set to the specified BuddyPress component 730 * page in wp-admin's Settings > Reading screen. 768 731 * 769 732 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 770 * @global $current_blog WordPress global containing information and settings for the current blog being viewed.771 * @param string $component Optional; name of the component to check for. If not specified, uses $bp->current_component.772 * @return bool True if the specified component is set to be the site's front page.733 * @global $current_blog WordPress global for the current blog 734 * @param string $component Optional; Name of the component to check for. 735 * @return bool True If the specified component is set to be the site's front page. 773 736 * @since 1.3 774 737 */ 775 function bp_is_component_front_page( $component ='' ) {738 function bp_is_component_front_page( $component = '' ) { 776 739 global $bp, $current_blog; 777 740 … … 779 742 $component = $bp->current_component; 780 743 781 if ( is_main_site() ) 782 $path = bp_core_get_site_path(); 783 else 784 $path = $current_blog->path; 744 $path = is_main_site() ? bp_core_get_site_path() : $current_blog->path; 785 745 786 746 if ( 'page' != get_option( 'show_on_front' ) || !$component || empty( $bp->pages->{$component} ) || $_SERVER['REQUEST_URI'] != $path ) … … 793 753 global $bp, $wp_query; 794 754 795 if ( $wp_query->is_home && ( !isset( $bp->is_directory ) || !$bp->is_directory ) ) 796 return true; 797 798 if ( !$bp->displayed_user->id && !$bp->is_single_item && ( !isset( $bp->is_directory ) || !$bp->is_directory ) && !bp_is_root_component( $bp->current_component ) ) 799 return true; 800 801 return false; 802 } 755 if ( $wp_query->is_home && !bp_is_directory() ) 756 return true; 757 758 if ( !bp_is_user() && !bp_is_single_item() && !bp_is_directory() && !bp_is_root_component( $bp->current_component ) ) 759 return true; 760 761 return false; 762 } 763 764 function bp_is_page( $page ) { 765 global $bp; 766 767 if ( !bp_is_user() && bp_is_current_component( $page ) ) 768 return true; 769 770 if ( 'home' == $page ) 771 return bp_is_front_page(); 772 773 return false; 774 } 775 776 /** Components ****************************************************************/ 777 778 function bp_is_active( $component ) { 779 global $bp_deactivated; 780 781 if ( !isset( $bp_deactivated[ 'bp-' . $component . '/bp-' . $component . '-loader.php' ] ) ) 782 return true; 783 784 return false; 785 } 786 787 function bp_is_profile_component() { 788 if ( bp_is_current_component( 'profile' ) ) 789 return true; 790 791 return false; 792 } 793 794 function bp_is_activity_component() { 795 if ( bp_is_current_component( 'activity' ) ) 796 return true; 797 798 return false; 799 } 800 801 function bp_is_blogs_component() { 802 if ( is_multisite() && bp_is_current_component( 'blogs' ) ) 803 return true; 804 805 return false; 806 } 807 808 function bp_is_messages_component() { 809 if ( bp_is_current_component( 'messages' ) ) 810 return true; 811 812 return false; 813 } 814 815 function bp_is_friends_component() { 816 817 if ( bp_is_current_component( 'friends' ) ) 818 return true; 819 820 return false; 821 } 822 823 function bp_is_groups_component() { 824 if ( bp_is_current_component( 'groups' ) ) 825 return true; 826 827 return false; 828 } 829 830 function bp_is_forums_component() { 831 if ( bp_is_current_component( 'forums' ) ) 832 return true; 833 834 return false; 835 } 836 837 function bp_is_settings_component() { 838 if ( bp_is_current_component( 'settings' ) ) 839 return true; 840 841 return false; 842 } 843 844 /** Activity ******************************************************************/ 845 846 function bp_is_single_activity() { 847 global $bp; 848 849 if ( bp_is_current_component( 'activity' ) && is_numeric( $bp->current_action ) ) 850 return true; 851 852 return false; 853 } 854 855 /** User **********************************************************************/ 803 856 804 857 function bp_is_my_profile() { … … 812 865 return apply_filters( 'bp_is_my_profile', $my_profile ); 813 866 } 814 function bp_is_home() { return bp_is_my_profile(); } 815 816 /** 817 * Is the user on the front page of the site? 818 * 819 * @deprecated 1.3 820 * @deprecated Use is_front_page() 821 * @return bool 822 */ 823 function bp_is_front_page() { 824 _deprecated_function( __FUNCTION__, '1.3', "is_front_page()" ); 825 return is_front_page(); 826 } 827 828 /** 829 * Is the front page of the site set to the Activity component? 830 * 831 * @deprecated 1.3 832 * @deprecated Use bp_is_component_front_page( 'activity' ) 833 * @return bool 834 */ 835 function bp_is_activity_front_page() { 836 _deprecated_function( __FUNCTION__, '1.3', "bp_is_component_front_page( 'activity' )" ); 837 return bp_is_component_front_page( 'activity' ); 838 } 839 840 function bp_is_directory() { 841 global $bp; 842 843 return ( isset( $bp->is_directory ) && $bp->is_directory ); 844 } 845 846 function bp_is_page( $page ) { 847 global $bp; 848 849 if ( !$bp->displayed_user->id && $bp->current_component == $page ) 850 return true; 851 852 if ( 'home' == $page ) 853 return bp_is_front_page(); 854 855 return false; 856 } 857 858 function bp_is_active( $component ) { 859 global $bp_deactivated; 860 861 if ( !isset( $bp_deactivated[ 'bp-' . $component . '/bp-' . $component . '-loader.php' ] ) ) 862 return true; 863 864 return false; 865 } 866 867 function bp_is_profile_component() { 867 868 function bp_is_user() { 869 global $bp; 870 871 if ( !empty( $bp->displayed_user->id ) ) 872 return true; 873 874 return false; 875 } 876 877 function bp_is_user_activity() { 878 global $bp; 879 880 if ( bp_is_current_component( 'activity' ) ) 881 return true; 882 883 return false; 884 } 885 886 function bp_is_user_friends_activity() { 887 global $bp; 888 889 if ( bp_is_current_component( 'activity' ) && bp_is_current_action( 'my-friends' ) ) 890 return true; 891 892 return false; 893 } 894 895 function bp_is_user_profile() { 896 global $bp; 897 868 898 if ( bp_is_current_component( 'profile' ) ) 869 899 return true; … … 872 902 } 873 903 874 function bp_is_activity_component() { 875 if ( bp_is_current_component( 'activity' ) ) 876 return true; 877 878 return false; 879 } 880 881 function bp_is_blogs_component() { 904 function bp_is_user_profile_edit() { 905 global $bp; 906 907 if ( bp_is_current_component( 'profile' ) && bp_is_current_action( 'edit' ) ) 908 return true; 909 910 return false; 911 } 912 913 function bp_is_user_change_avatar() { 914 global $bp; 915 916 if ( bp_is_current_component( 'profile' ) && bp_is_current_action( 'change-avatar' ) ) 917 return true; 918 919 return false; 920 } 921 922 function bp_is_user_groups() { 923 global $bp; 924 925 if ( bp_is_current_component( 'groups' ) ) 926 return true; 927 928 return false; 929 } 930 931 function bp_is_user_blogs() { 932 global $bp; 933 882 934 if ( is_multisite() && bp_is_current_component( 'blogs' ) ) 883 935 return true; … … 886 938 } 887 939 888 function bp_is_messages_component() { 940 function bp_is_user_recent_posts() { 941 global $bp; 942 943 if ( is_multisite() && bp_is_current_component( 'blogs' ) && bp_is_current_action( 'recent-posts' ) ) 944 return true; 945 946 return false; 947 } 948 949 function bp_is_user_recent_commments() { 950 global $bp; 951 952 if ( is_multisite() && bp_is_current_component( 'blogs' ) && bp_is_current_action( 'recent-comments' ) ) 953 return true; 954 955 return false; 956 } 957 958 function bp_is_user_friends() { 959 960 if ( bp_is_current_component( 'friends' ) ) 961 return true; 962 963 return false; 964 } 965 966 function bp_is_user_friend_requests() { 967 global $bp; 968 969 if ( bp_is_current_component( 'friends' ) && bp_is_current_action( 'requests' ) ) 970 return true; 971 972 return false; 973 } 974 975 /** Groups ******************************************************************/ 976 977 function bp_is_group() { 978 global $bp; 979 980 if ( bp_is_current_component( 'groups' ) && isset( $bp->groups->current_group ) && $bp->groups->current_group ) 981 return true; 982 983 return false; 984 } 985 986 function bp_is_group_home() { 987 global $bp; 988 989 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && ( !bp_is_current_action() || bp_is_current_action( 'home' ) ) ) 990 return true; 991 992 return false; 993 } 994 995 function bp_is_group_create() { 996 global $bp; 997 998 if ( bp_is_current_component( 'groups' ) && bp_is_current_action( 'create' ) ) 999 return true; 1000 1001 return false; 1002 } 1003 1004 function bp_is_group_admin_page() { 1005 global $bp; 1006 1007 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && bp_is_current_action( 'admin' ) ) 1008 return true; 1009 1010 return false; 1011 } 1012 1013 function bp_is_group_forum() { 1014 global $bp; 1015 1016 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && bp_is_current_action( 'forum' ) ) 1017 return true; 1018 1019 return false; 1020 } 1021 1022 function bp_is_group_activity() { 1023 global $bp; 1024 1025 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && bp_is_current_action( 'activity' ) ) 1026 return true; 1027 1028 return false; 1029 } 1030 1031 function bp_is_group_forum_topic() { 1032 global $bp; 1033 1034 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && bp_is_current_action( 'forum' ) && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] ) 1035 return true; 1036 1037 return false; 1038 } 1039 1040 function bp_is_group_forum_topic_edit() { 1041 global $bp; 1042 1043 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && bp_is_current_action( 'forum' ) && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] ) 1044 return true; 1045 1046 return false; 1047 } 1048 1049 function bp_is_group_members() { 1050 global $bp; 1051 1052 if ( bp_is_single_item() && bp_is_current_component( 'groups' ) && bp_is_current_action( 'members' ) ) 1053 return true; 1054 1055 return false; 1056 } 1057 1058 function bp_is_group_invites() { 1059 global $bp; 1060 1061 if ( bp_is_current_component( 'groups' ) && bp_is_current_action( 'send-invites' ) ) 1062 return true; 1063 1064 return false; 1065 } 1066 1067 function bp_is_group_membership_request() { 1068 global $bp; 1069 1070 if ( bp_is_current_component( 'groups' ) && bp_is_current_action( 'request-membership' ) ) 1071 return true; 1072 1073 return false; 1074 } 1075 1076 function bp_is_group_leave() { 1077 global $bp; 1078 1079 if ( bp_is_current_component( 'groups' ) && bp_is_single_item() && bp_is_current_action( 'leave-group' ) ) 1080 return true; 1081 1082 return false; 1083 } 1084 1085 function bp_is_group_single() { 1086 global $bp; 1087 1088 if ( bp_is_current_component( 'groups' ) && bp_is_single_item() ) 1089 return true; 1090 1091 return false; 1092 } 1093 1094 function bp_is_create_blog() { 1095 global $bp; 1096 1097 if ( is_multisite() && bp_is_current_component( 'blogs' ) && bp_is_current_action( 'create' ) ) 1098 return true; 1099 1100 return false; 1101 } 1102 1103 /** Messages ******************************************************************/ 1104 1105 function bp_is_user_messages() { 1106 889 1107 if ( bp_is_current_component( 'messages' ) ) 890 1108 return true; … … 893 1111 } 894 1112 895 function bp_is_friends_component() {896 897 if ( bp_is_current_component( 'friends' ) )898 return true;899 900 return false;901 }902 903 function bp_is_groups_component() {904 if ( bp_is_current_component( 'groups' ) )905 return true;906 907 return false;908 }909 910 function bp_is_settings_component() {911 if ( bp_is_current_component( 'settings' ) )912 return true;913 914 return false;915 }916 917 function bp_is_member() {918 global $bp;919 920 if ( !empty( $bp->displayed_user->id ) )921 return true;922 923 return false;924 }925 926 function bp_is_user_activity() {927 global $bp;928 929 if ( bp_is_current_component( 'activity' ) )930 return true;931 932 return false;933 }934 935 function bp_is_user_friends_activity() {936 global $bp;937 938 if ( bp_is_current_component( 'activity' ) && 'my-friends' == $bp->current_action )939 return true;940 941 return false;942 }943 944 function bp_is_activity_permalink() {945 global $bp;946 947 if ( bp_is_current_component( 'activity' ) && is_numeric( $bp->current_action ) )948 return true;949 950 return false;951 }952 953 function bp_is_user_profile() {954 global $bp;955 956 if ( bp_is_current_component( 'profile' ) )957 return true;958 959 return false;960 }961 962 function bp_is_profile_edit() {963 global $bp;964 965 if ( bp_is_current_component( 'profile' ) && 'edit' == $bp->current_action )966 return true;967 968 return false;969 }970 971 function bp_is_change_avatar() {972 global $bp;973 974 if ( bp_is_current_component( 'profile' ) && 'change-avatar' == $bp->current_action )975 return true;976 977 return false;978 }979 980 function bp_is_user_groups() {981 global $bp;982 983 if ( bp_is_current_component( 'groups' ) )984 return true;985 986 return false;987 }988 989 function bp_is_group() {990 global $bp;991 992 if ( bp_is_current_component( 'groups' ) && isset( $bp->groups->current_group ) && $bp->groups->current_group )993 return true;994 995 return false;996 }997 998 function bp_is_group_home() {999 global $bp;1000 1001 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )1002 return true;1003 1004 return false;1005 }1006 1007 function bp_is_group_create() {1008 global $bp;1009 1010 if ( bp_is_current_component( 'groups' ) && 'create' == $bp->current_action )1011 return true;1012 1013 return false;1014 }1015 1016 1017 function bp_is_group_admin_page() {1018 global $bp;1019 1020 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'admin' == $bp->current_action )1021 return true;1022 1023 return false;1024 }1025 1026 function bp_is_group_forum() {1027 global $bp;1028 1029 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action )1030 return true;1031 1032 return false;1033 }1034 1035 function bp_is_group_activity() {1036 global $bp;1037 1038 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'activity' == $bp->current_action )1039 return true;1040 1041 return false;1042 }1043 1044 function bp_is_group_forum_topic() {1045 global $bp;1046 1047 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] )1048 return true;1049 1050 return false;1051 }1052 1053 function bp_is_group_forum_topic_edit() {1054 global $bp;1055 1056 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'forum' == $bp->current_action && isset( $bp->action_variables[0] ) && 'topic' == $bp->action_variables[0] && isset( $bp->action_variables[2] ) && 'edit' == $bp->action_variables[2] )1057 return true;1058 1059 return false;1060 }1061 1062 function bp_is_group_members() {1063 global $bp;1064 1065 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'members' == $bp->current_action )1066 return true;1067 1068 return false;1069 }1070 1071 function bp_is_group_invites() {1072 global $bp;1073 1074 if ( bp_is_current_component( 'groups' ) && 'send-invites' == $bp->current_action )1075 return true;1076 1077 return false;1078 }1079 1080 function bp_is_group_membership_request() {1081 global $bp;1082 1083 if ( bp_is_current_component( 'groups' ) && 'request-membership' == $bp->current_action )1084 return true;1085 1086 return false;1087 }1088 1089 function bp_is_group_leave() {1090 global $bp;1091 1092 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item && 'leave-group' == $bp->current_action )1093 return true;1094 1095 return false;1096 }1097 1098 function bp_is_group_single() {1099 global $bp;1100 1101 if ( bp_is_current_component( 'groups' ) && $bp->is_single_item )1102 return true;1103 1104 return false;1105 }1106 1107 function bp_is_user_blogs() {1108 global $bp;1109 1110 if ( is_multisite() && bp_is_current_component( 'blogs' ) )1111 return true;1112 1113 return false;1114 }1115 1116 function bp_is_user_recent_posts() {1117 global $bp;1118 1119 if ( is_multisite() && bp_is_current_component( 'blogs' ) && 'recent-posts' == $bp->current_action )1120 return true;1121 1122 return false;1123 }1124 1125 function bp_is_user_recent_commments() {1126 global $bp;1127 1128 if ( is_multisite() && bp_is_current_component( 'blogs' ) && 'recent-comments' == $bp->current_action )1129 return true;1130 1131 return false;1132 }1133 1134 function bp_is_create_blog() {1135 global $bp;1136 1137 if ( is_multisite() && bp_is_current_component( 'blogs' ) && 'create' == $bp->current_action )1138 return true;1139 1140 return false;1141 }1142 1143 function bp_is_user_friends() {1144 1145 if ( bp_is_current_component( 'friends' ) )1146 return true;1147 1148 return false;1149 }1150 1151 function bp_is_friend_requests() {1152 global $bp;1153 1154 if ( bp_is_current_component( 'friends' ) && 'requests' == $bp->current_action )1155 return true;1156 1157 return false;1158 }1159 1160 function bp_is_user_messages() {1161 1162 if ( bp_is_current_component( 'messages' ) )1163 return true;1164 1165 return false;1166 }1167 1168 1113 function bp_is_messages_inbox() { 1169 1114 global $bp; 1170 1115 1171 if ( bp_is_current_component( 'messages' ) && ( ! $bp->current_action || 'inbox' == $bp->current_action) )1116 if ( bp_is_current_component( 'messages' ) && ( !bp_is_current_action() || bp_is_current_action( 'inbox' ) ) ) 1172 1117 return true; 1173 1118 … … 1178 1123 global $bp; 1179 1124 1180 if ( bp_is_current_component( 'messages' ) && 'sentbox' == $bp->current_action ) 1181 return true; 1182 1183 return false; 1184 } 1185 1125 if ( bp_is_current_component( 'messages' ) && bp_is_current_action( 'sentbox' ) ) 1126 return true; 1127 1128 return false; 1129 } 1130 1131 function bp_is_messages_compose_screen() { 1132 global $bp; 1133 1134 if ( bp_is_current_component( 'messages' ) && bp_is_current_action( 'compose' ) ) 1135 return true; 1136 1137 return false; 1138 } 1186 1139 1187 1140 function bp_is_notices() { 1188 1141 global $bp; 1189 1142 1190 if ( bp_is_current_component( 'messages' ) && 'notices' == $bp->current_action ) 1191 return true; 1192 1193 return false; 1194 } 1195 1196 1197 function bp_is_messages_compose_screen() { 1198 global $bp; 1199 1200 if ( bp_is_current_component( 'messages' ) && 'compose' == $bp->current_action ) 1201 return true; 1202 1203 return false; 1204 } 1205 1206 function bp_is_single_item() { 1207 global $bp; 1208 1209 if ( $bp->is_single_item ) 1210 return true; 1211 1212 return false; 1213 } 1143 if ( bp_is_current_component( 'messages' ) && bp_is_current_action( 'notices' ) ) 1144 return true; 1145 1146 return false; 1147 } 1148 1149 1150 function bp_is_single( $component, $callback ) { 1151 global $bp; 1152 1153 if ( bp_is_current_component( $component ) && ( true === call_user_func( $callback ) ) ) 1154 return true; 1155 1156 return false; 1157 } 1158 1159 /** Registration **************************************************************/ 1214 1160 1215 1161 function bp_is_activation_page() { … … 1227 1173 } 1228 1174 1229 /* Use the above is_() functions to output a body class for each page */ 1230 1175 /** 1176 * Use the above is_() functions to output a body class for each scenario 1177 * 1178 * @package BuddyPress 1179 * @subpackage Core Template 1180 */ 1231 1181 function bp_the_body_class() { 1232 1182 echo bp_get_the_body_class(); … … 1237 1187 $bp_classes = array(); 1238 1188 1189 /** Pages *************************************************************/ 1190 1239 1191 if ( is_front_page() ) 1240 1192 $bp_classes[] = 'home-page'; … … 1243 1195 $bp_classes[] = 'directory'; 1244 1196 1245 if ( bp_is_user_profile() && !bp_is_blog_page() ) 1246 $bp_classes[] = 'profile'; 1247 1248 if ( bp_is_activity_component() && !bp_is_blog_page() ) 1249 $bp_classes[] = 'activity'; 1250 1251 if ( bp_is_blogs_component() && !bp_is_blog_page() ) 1252 $bp_classes[] = 'blogs'; 1253 1254 if ( bp_is_messages_component() && !bp_is_blog_page() ) 1255 $bp_classes[] = 'messages'; 1256 1257 if ( bp_is_friends_component() && !bp_is_blog_page() ) 1258 $bp_classes[] = 'friends'; 1259 1260 if ( bp_is_groups_component() && !bp_is_blog_page() ) 1261 $bp_classes[] = 'groups'; 1262 1263 if ( bp_is_settings_component() && !bp_is_blog_page() ) 1264 $bp_classes[] = 'settings'; 1197 if ( bp_is_single_item() ) 1198 $bp_classes[] = 'single-item'; 1199 1200 /** Components ********************************************************/ 1201 1202 if ( !bp_is_blog_page() ) : 1203 if ( bp_is_user_profile() ) 1204 $bp_classes[] = 'profile'; 1205 1206 if ( bp_is_activity_component() ) 1207 $bp_classes[] = 'activity'; 1208 1209 if ( bp_is_blogs_component() ) 1210 $bp_classes[] = 'blogs'; 1211 1212 if ( bp_is_messages_component() ) 1213 $bp_classes[] = 'messages'; 1214 1215 if ( bp_is_friends_component() ) 1216 $bp_classes[] = 'friends'; 1217 1218 if ( bp_is_groups_component() ) 1219 $bp_classes[] = 'groups'; 1220 1221 if ( bp_is_settings_component() ) 1222 $bp_classes[] = 'settings'; 1223 endif; 1224 1225 /** User **************************************************************/ 1226 1227 if ( !bp_is_directory() ) : 1228 if ( bp_is_user_blogs() ) 1229 $bp_classes[] = 'my-blogs'; 1230 1231 if ( bp_is_user_groups() ) 1232 $bp_classes[] = 'my-groups'; 1233 1234 if ( bp_is_user_activity() ) 1235 $bp_classes[] = 'my-activity'; 1236 endif; 1237 1238 if ( bp_is_my_profile() ) 1239 $bp_classes[] = 'my-account'; 1265 1240 1266 1241 if ( bp_is_user_profile() ) 1267 1242 $bp_classes[] = 'my-profile'; 1268 1243 1269 if ( bp_is_my_profile() ) 1270 $bp_classes[] = 'my-account'; 1271 1272 if ( bp_is_single_item() ) 1273 $bp_classes[] = 'single-item'; 1244 if ( bp_is_user_friends() ) 1245 $bp_classes[] = 'my-friends'; 1246 1247 if ( bp_is_user_messages() ) 1248 $bp_classes[] = 'my-messages'; 1249 1250 if ( bp_is_user_recent_commments() ) 1251 $bp_classes[] = 'recent-comments'; 1252 1253 if ( bp_is_user_recent_posts() ) 1254 $bp_classes[] = 'recent-posts'; 1255 1256 if ( bp_is_user_change_avatar() ) 1257 $bp_classes[] = 'change-avatar'; 1258 1259 if ( bp_is_user_profile_edit() ) 1260 $bp_classes[] = 'profile-edit'; 1261 1262 if ( bp_is_user_friends_activity() ) 1263 $bp_classes[] = 'friends-activity'; 1264 1265 if ( is_user_logged_in() ) 1266 $bp_classes[] = 'logged-in'; 1267 1268 /** Messages **********************************************************/ 1274 1269 1275 1270 if ( bp_is_messages_inbox() ) … … 1285 1280 $bp_classes[] = 'notices'; 1286 1281 1287 if ( bp_is_ friend_requests() )1282 if ( bp_is_user_friend_requests() ) 1288 1283 $bp_classes[] = 'friend-requests'; 1289 1290 if ( bp_is_user_friends() )1291 $bp_classes[] = 'my-friends';1292 1293 if ( bp_is_user_messages() )1294 $bp_classes[] = 'my-messages';1295 1284 1296 1285 if ( bp_is_create_blog() ) 1297 1286 $bp_classes[] = 'create-blog'; 1298 1287 1299 if ( bp_is_user_recent_commments() ) 1300 $bp_classes[] = 'recent-comments'; 1301 1302 if ( bp_is_user_recent_posts() ) 1303 $bp_classes[] = 'recent-posts'; 1304 1305 if ( bp_is_user_blogs() && !bp_is_directory() ) 1306 $bp_classes[] = 'my-blogs'; 1307 1308 if ( bp_is_user_groups() && !bp_is_directory() ) 1309 $bp_classes[] = 'my-groups'; 1288 /** Groups ************************************************************/ 1310 1289 1311 1290 if ( bp_is_group_leave() ) … … 1336 1315 $bp_classes[] = 'group-home'; 1337 1316 1338 if ( bp_is_change_avatar() ) 1339 $bp_classes[] = 'change-avatar'; 1340 1341 if ( bp_is_profile_edit() ) 1342 $bp_classes[] = 'profile-edit'; 1343 1344 if ( bp_is_user_friends_activity() ) 1345 $bp_classes[] = 'friends-activity'; 1346 1347 if ( bp_is_user_activity() && !bp_is_directory() ) 1348 $bp_classes[] = 'my-activity'; 1349 1350 if ( bp_is_activity_permalink() ) 1317 if ( bp_is_single_activity() ) 1351 1318 $bp_classes[] = 'activity-permalink'; 1319 1320 /** Registration ******************************************************/ 1352 1321 1353 1322 if ( bp_is_register_page() ) … … 1357 1326 $bp_classes[] = 'activation'; 1358 1327 1359 if ( is_user_logged_in() ) 1360 $bp_classes[] = 'logged-in'; 1361 1362 // Add the current_component, current_action into the bp classes 1328 /** Current Component & Action ****************************************/ 1329 1363 1330 if ( !bp_is_blog_page() ) { 1364 if ( !empty( $bp->current_component ) ) 1365 $bp_classes[] = $bp->current_component; 1366 1367 if ( !empty( $bp->current_action ) ) 1368 $bp_classes[] = $bp->current_action; 1331 $bp_classes[] = bp_current_component(); 1332 $bp_classes[] = bp_current_action(); 1369 1333 } 1334 1335 /** Clean up***********************************************************/ 1370 1336 1371 1337 // We don't want WordPress blog classes to appear on non-blog pages. -
trunk/bp-forums/bp-forums-admin.php
r3471 r3806 1 1 <?php 2 2 3 function bp_forums_add_admin_menu() { 4 global $bp; 5 6 if ( !is_super_admin() ) 7 return false; 8 9 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 10 11 // Add the administration tab under the "Site Admin" tab for site administrators 12 add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" ); 13 } 14 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' ); 15 3 16 function bp_forums_bbpress_admin() { 4 global $bp; 5 ?> 17 global $bp; ?> 18 6 19 <div class="wrap"> 7 20 … … 9 22 10 23 <?php if ( isset( $_POST['submit'] ) ) : ?> 24 11 25 <div id="message" class="updated fade"> 12 26 <p><?php _e( 'Settings Saved.', 'buddypress' ) ?></p> 13 27 </div> 28 14 29 <?php endif; ?> 15 30 16 31 <?php 17 32 18 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) {33 if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) : 19 34 update_site_option( 'bb-config-location', false ); 20 35 bp_forums_bbpress_install_wizard(); 21 } else { ?> 36 else : ?> 37 22 38 <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), site_url( 'wp-admin/admin.php?page=bb-forums-setup&reinstall=1' ) ); ?> 23 39 <p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p> 24 <?php 25 }26 ?> 40 41 <?php endif; ?> 42 27 43 </div> 28 44 <?php … … 44 60 <p><?php _e( 'BuddyPress will now use its internal copy of bbPress to run the forums on your site. If you wish, you can remove your old bbPress installation files, as long as you keep the bb-config.php file in the same location.', 'buddypress' ) ?></p><?php 45 61 } 46 } else { 47 ?> 62 } else { ?> 63 48 64 <form action="" method="post"> 49 65 <h3><?php _e( 'Existing bbPress Installation', 'buddypress' ) ?></h3> … … 55 71 <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?> 56 72 </form> 73 57 74 <?php 58 75 } … … 73 90 break; 74 91 } 75 } else { 76 ?> 92 } else { ?> 93 77 94 <h3><?php _e( 'New bbPress Installation', 'buddypress' ) ?></h3> 78 95 <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 79 96 process. When you're ready, hit the link below.", 'buddypress' ) ?></p> 80 97 <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> 81 <?php 98 99 <?php 82 100 } 83 101 break; … … 85 103 default: 86 104 if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?> 105 87 106 <div id="message" class="error"> 88 107 <p><?php printf( __( 'bbPress files were not found. To install the forums component you must download a copy of bbPress and make sure it is in the folder: "%s"', 'buddypress' ), 'wp-content/plugins/buddypress/bp-forums/bbpress/' ) ?></p> 89 108 </div> 109 90 110 <?php } else { ?> 91 111 … … 105 125 check_admin_referer( 'bp_forums_existing_install_init' ); 106 126 107 / * Sanitize $_REQUEST['bbconfigloc'] */127 // Sanitize $_REQUEST['bbconfigloc'] 108 128 $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] ); 109 129 … … 128 148 check_admin_referer( 'bp_forums_new_install_init' ); 129 149 130 / * Create the bb-config.php file */150 // Create the bb-config.php file 131 151 $initial_write = bp_forums_bbpress_write( 132 152 BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-config-sample.php', 133 153 ABSPATH . 'bb-config.php', 134 154 array( 135 "define( 'BBDB_NAME'," 136 "define( 'BBDB_USER'," 137 "define( 'BBDB_PASSWO" 138 "define( 'BBDB_HOST'," 139 "define( 'BBDB_CHARSE" 140 "define( 'BBDB_COLLAT" 141 "define( 'BB_AUTH_KEY" 142 "define( 'BB_SECURE_A" 143 "define( 'BB_LOGGED_I" 144 "define( 'BB_NONCE_KE" 145 "\$bb_table_prefix = '" 146 "define( 'BB_LANG', '" 155 "define( 'BBDB_NAME'," => array( "'bbpress'", "'" . DB_NAME . "'" ), 156 "define( 'BBDB_USER'," => array( "'username'", "'" . DB_USER . "'" ), 157 "define( 'BBDB_PASSWO" => array( "'password'", "'" . DB_PASSWORD . "'" ), 158 "define( 'BBDB_HOST'," => array( "'localhost'", "'" . DB_HOST . "'" ), 159 "define( 'BBDB_CHARSE" => array( "'utf8'", "'" . DB_CHARSET . "'" ), 160 "define( 'BBDB_COLLAT" => array( "''", "'" . DB_COLLATE . "'" ), 161 "define( 'BB_AUTH_KEY" => array( "'put your unique phrase here'", "'" . addslashes( AUTH_KEY ) . "'" ), 162 "define( 'BB_SECURE_A" => array( "'put your unique phrase here'", "'" . addslashes( SECURE_AUTH_KEY ) . "'" ), 163 "define( 'BB_LOGGED_I" => array( "'put your unique phrase here'", "'" . addslashes( LOGGED_IN_KEY ) . "'" ), 164 "define( 'BB_NONCE_KE" => array( "'put your unique phrase here'", "'" . addslashes( NONCE_KEY ) . "'" ), 165 "\$bb_table_prefix = '" => array( "'bb_'", "'" . $bp->table_prefix . "bb_'" ), 166 "define( 'BB_LANG', '" => array( "''", "'" . WPLANG . "'" ) 147 167 ) 148 168 ); 149 169 150 / * Add the custom user and usermeta entries to the config file */151 if ( $initial_write == 1 ) {170 // Add the custom user and usermeta entries to the config file 171 if ( $initial_write == 1 ) 152 172 $file = file_get_contents( ABSPATH . 'bb-config.php' ); 153 } else {173 else 154 174 $file = &$initial_write; 155 }156 175 157 176 $file = substr( $file, 0, -2 ); … … 189 208 190 209 function bp_forums_bbpress_write( $file_source, $file_target, $alterations ) { 191 if ( !$file_source || !file_exists( $file_source ) || !is_file( $file_source ) ) { 210 211 if ( !$file_source || !file_exists( $file_source ) || !is_file( $file_source ) ) 192 212 return -1; 193 } 194 195 if ( !$file_target ) { 213 214 if ( !$file_target ) 196 215 $file_target = $file_source; 197 } 198 199 if ( !$alterations || !is_array( $alterations ) ) { 216 217 if ( !$alterations || !is_array( $alterations ) ) 200 218 return -2; 201 }202 219 203 220 // Get the existing lines in the file … … 234 251 } 235 252 236 if ( !$writable)253 if ( empty( $writable ) ) 237 254 return trim( join( null, $modified_lines ) ); 238 255 … … 258 275 return 1; 259 276 } 277 260 278 ?> -
trunk/bp-forums/bp-forums-loader.php
r3790 r3806 1 1 <?php 2 2 3 // Define the parent forum ID 4 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 5 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 3 /** 4 * BuddyPress Forums Streams Loader 5 * 6 * An forums stream component, for users, groups, and blog tracking. 7 * 8 * @package BuddyPress 9 * @subpackage Forums Core 10 */ 6 11 7 // Support for bbPress stand-alone 8 if ( !defined( 'BB_PATH' ) ) 9 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress-sa.php' ); 12 class BP_Forums_Component extends BP_Component { 10 13 11 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php' ); 12 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-template.php' ); 14 /** 15 * Start the forums component creation process 16 * 17 * @since BuddyPress {unknown} 18 */ 19 function BP_Forums_Component() { 20 parent::start( 'forums', __( 'Discussion Forums', 'buddypress' ) ); 21 } 13 22 14 /** 15 * Puts important forums component data into the $bp global for later use. 16 * 17 * @package BuddyPress Forums 18 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 19 */ 20 function bp_forums_setup() { 21 global $bp; 23 /** 24 * Setup globals 25 * 26 * The BP_FORUMS_SLUG constant is deprecated, and only used here for 27 * backwards compatibility. 28 * 29 * @since BuddyPress {unknown} 30 * @global obj $bp 31 */ 32 function _setup_globals() { 33 global $bp; 22 34 23 if ( !defined( 'BP_FORUMS_SLUG' ) ) 24 define ( 'BP_FORUMS_SLUG', bp_core_component_slug_from_root_slug( $bp->pages->forums->slug ) ); 35 // Define the parent forum ID 36 if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) ) 37 define( 'BP_FORUMS_PARENT_FORUM_ID', 1 ); 25 38 26 // For internal identification 27 $bp->forums->id = 'forums'; 39 // Define a slug, if necessary 40 if ( !defined( 'BP_FORUMS_SLUG' ) ) 41 define( 'BP_FORUMS_SLUG', $this->id ); 28 42 29 // Slugs30 $bp->forums->slug = BP_FORUMS_SLUG;31 $bp->forums->root_slug = $bp->pages->forums->slug;43 // Do some slug checks 44 $this->slug = BP_FORUMS_SLUG; 45 $this->root_slug = isset( $bp->pages->forums->slug ) ? $bp->pages->forums->slug : $this->slug; 32 46 33 // Images 34 $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images'; 47 // The location of the bbPress stand-alone config file 48 if ( isset( $bp->site_options['bb-config-location'] ) ) 49 $this->bbconfig = $bp->site_options['bb-config-location']; 35 50 36 if ( isset( $bp->site_options['bb-config-location'] ) )37 $bp-> forums->bbconfig = $bp->site_options['bb-config-location'];51 // Register this in the active components array 52 $bp->active_components[$this->id] = $this->id; 38 53 39 // Register this in the active components array 40 $bp->active_components[$bp->forums->slug] = $bp->forums->id; 54 // The default text for the blogs directory search box 55 $bp->default_search_strings[$this->id] = __( 'Search Forums...', 'buddypress' ); 56 } 41 57 42 // The default text for the forums directory search box 43 $bp->default_search_strings[$bp->forums->slug] = __( 'Search Forum Topics...', 'buddypress' ); 58 /** 59 * Include files 60 */ 61 function _includes() { 62 // Support for bbPress stand-alone 63 if ( !defined( 'BB_PATH' ) ) 64 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress-sa.php' ); 44 65 45 do_action( 'bp_forums_setup' ); 46 } 47 add_action( 'bp_setup_globals', 'bp_forums_setup' ); 66 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-actions.php' ); 67 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-screens.php' ); 68 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-filters.php' ); 69 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-template.php' ); 70 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-functions.php' ); 71 } 48 72 49 function bp_forums_is_installed_correctly() { 50 global $bp; 73 /** 74 * Setup BuddyBar navigation 75 * 76 * @global obj $bp 77 */ 78 function _setup_nav() { 79 global $bp; 51 80 52 if ( isset( $bp->forums->bbconfig ) && file_exists( $bp->forums->bbconfig ) ) 53 return true; 81 // Add 'Forums' to the main navigation 82 bp_core_new_nav_item( array( 83 'name' => __( 'Forums', 'buddypress' ), 84 'slug' => $this->slug, 85 'position' => 80, 86 'screen_function' => 'bp_forums_screen_topics', 87 'default_subnav_slug' => 'topics', 88 'item_css_id' => $this->id ) 89 ); 54 90 55 return false; 56 } 91 // Stop if there is no user displayed or logged in 92 if ( !is_user_logged_in() && !isset( $bp->displayed_user->id ) ) 93 return; 57 94 58 /** 59 * Convenience function to determine if the forum directory has been disabled 60 * by the site admin. 61 * 62 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() 63 * @return bool True if forum is disabled 64 * @since 1.3 65 */ 66 function bp_forum_directory_is_disabled() { 67 global $bp; 68 69 return !empty( $bp->site_options['bp-disable-forum-directory'] ); 70 } 71 72 function bp_forums_directory_forums_setup() { 73 global $bp; 74 75 if ( $bp->current_component == $bp->forums->slug ) { 76 if ( bp_forum_directory_is_disabled() || !bp_is_active( 'groups' ) ) 77 return false; 78 79 if ( !bp_forums_is_installed_correctly() ) { 80 bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' ); 81 bp_core_redirect( $bp->root_domain ); 95 // Determine user to use 96 if ( isset( $bp->displayed_user->domain ) ) { 97 $user_domain = $bp->displayed_user->domain; 98 $user_login = $bp->displayed_user->userdata->user_login; 99 } elseif ( isset( $bp->loggedin_user->domain ) ) { 100 $user_domain = $bp->loggedin_user->domain; 101 $user_login = $bp->loggedin_user->userdata->user_login; 102 } else { 103 return; 82 104 } 83 105 84 $bp->is_directory = true; 106 // User link 107 $forums_link = trailingslashit( $user_domain . $this->slug ); 85 108 86 do_action( 'bbpress_init' ); 109 // Additional menu if friends is active 110 bp_core_new_subnav_item( array( 111 'name' => __( 'Topics Started', 'buddypress' ), 112 'slug' => 'topics', 113 'parent_url' => $forums_link, 114 'parent_slug' => $this->slug, 115 'screen_function' => 'bp_forums_screen_topics', 116 'position' => 20, 117 'item_css_id' => 'forums-friends' 118 ) ); 87 119 88 // Check to see if the user has posted a new topic from the forums page. 89 if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic' ) ) { 90 check_admin_referer( 'bp_forums_new_topic' ); 120 // Additional menu if friends is active 121 bp_core_new_subnav_item( array( 122 'name' => __( 'Replies', 'buddypress' ), 123 'slug' => 'replies', 124 'parent_url' => $forums_link, 125 'parent_slug' => $this->slug, 126 'screen_function' => 'bp_forums_screen_topics', 127 'position' => 40, 128 'item_css_id' => 'forums-friends' 129 ) ); 91 130 92 if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) { 93 // Auto join this user if they are not yet a member of this group 94 if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 95 groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id ); 131 // Favorite forums items 132 bp_core_new_subnav_item( array( 133 'name' => __( 'Favorite Topics', 'buddypress' ), 134 'slug' => 'favorites', 135 'parent_url' => $forums_link, 136 'parent_slug' => $this->slug, 137 'screen_function' => 'bp_forums_screen_favorites', 138 'position' => 60, 139 'item_css_id' => 'forums-favs' 140 ) ); 96 141 97 $error_message = ''; 98 if ( $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) ) { 99 if ( empty( $_POST['topic_title'] ) ) 100 $error_message = __( 'Please provide a title for your forum topic.', 'buddypress' ); 101 else if ( empty( $_POST['topic_text'] ) ) 102 $error_message = __( 'Forum posts cannot be empty. Please enter some text.', 'buddypress' ); 103 104 if ( $error_message ) { 105 bp_core_add_message( $error_message, 'error' ); 106 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum'; 107 } else { 108 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) { 109 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' ); 110 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum'; 111 } else { 112 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') ); 113 $redirect = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/'; 114 } 115 } 116 117 bp_core_redirect( $redirect ); 118 119 } else { 120 bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' ); 121 } 122 } 123 } 124 125 do_action( 'bp_forums_directory_forums_setup' ); 126 127 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'forums/index' ) ); 128 } 129 } 130 add_action( 'wp', 'bp_forums_directory_forums_setup', 2 ); 131 132 function bp_forums_add_admin_menu() { 133 global $bp; 134 135 if ( !is_super_admin() ) 136 return false; 137 138 require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' ); 139 140 // Add the administration tab under the "Site Admin" tab for site administrators 141 add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" ); 142 } 143 add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', 'bp_forums_add_admin_menu' ); 144 145 /** Forum Functions ***********************************************************/ 146 147 function bp_forums_get_forum( $forum_id ) { 148 do_action( 'bbpress_init' ); 149 return bb_get_forum( $forum_id ); 150 } 151 152 function bp_forums_new_forum( $args = '' ) { 153 do_action( 'bbpress_init' ); 154 155 $defaults = array( 156 'forum_name' => '', 157 'forum_desc' => '', 158 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 159 'forum_order' => false, 160 'forum_is_category' => 0 161 ); 162 163 $r = wp_parse_args( $args, $defaults ); 164 extract( $r, EXTR_SKIP ); 165 166 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 ) ); 167 } 168 169 function bp_forums_update_forum( $args = '' ) { 170 do_action( 'bbpress_init' ); 171 172 $defaults = array( 173 'forum_id' => '', 174 'forum_name' => '', 175 'forum_desc' => '', 176 'forum_slug' => '', 177 'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 178 'forum_order' => false, 179 'forum_is_category' => 0 180 ); 181 182 $r = wp_parse_args( $args, $defaults ); 183 extract( $r, EXTR_SKIP ); 184 185 return bb_update_forum( array( 'forum_id' => (int)$forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) ); 186 } 187 188 /** Topic Functions ***********************************************************/ 189 190 function bp_forums_get_forum_topics( $args = '' ) { 191 global $bp; 192 193 do_action( 'bbpress_init' ); 194 195 $defaults = array( 196 'type' => 'newest', 197 'forum_id' => false, 198 'user_id' => false, 199 'page' => 1, 200 'per_page' => 15, 201 'exclude' => false, 202 'show_stickies' => 'all', 203 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on. 204 ); 205 206 $r = wp_parse_args( $args, $defaults ); 207 extract( $r, EXTR_SKIP ); 208 209 if ( class_exists( 'BB_Query' ) ) { 210 switch ( $type ) { 211 case 'newest': 212 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' ); 213 $topics =& $query->results; 214 break; 215 216 case 'popular': 217 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 218 $topics =& $query->results; 219 break; 220 221 case 'unreplied': 222 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 223 $topics =& $query->results; 224 break; 225 226 case 'tags': 227 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) ); 228 $topics =& $query->results; 229 break; 230 } 231 } else { 232 $topics = array(); 233 } 234 235 return apply_filters( 'bp_forums_get_forum_topics', $topics, &$r ); 236 } 237 238 function bp_forums_get_topic_details( $topic_id ) { 239 do_action( 'bbpress_init' ); 240 241 $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); 242 243 return $query->results[0]; 244 } 245 246 function bp_forums_get_topic_id_from_slug( $topic_slug ) { 247 do_action( 'bbpress_init' ); 248 return bb_get_id_from_slug( 'topic', $topic_slug ); 249 } 250 251 function bp_forums_new_topic( $args = '' ) { 252 global $bp; 253 254 do_action( 'bbpress_init' ); 255 256 $defaults = array( 257 'topic_title' => '', 258 'topic_slug' => '', 259 'topic_text' => '', 260 'topic_poster' => $bp->loggedin_user->id, // accepts ids 261 'topic_poster_name' => $bp->loggedin_user->fullname, // accept names 262 'topic_last_poster' => $bp->loggedin_user->id, // accepts ids 263 'topic_last_poster_name' => $bp->loggedin_user->fullname, // accept names 264 'topic_start_time' => bp_core_current_time(), 265 'topic_time' => bp_core_current_time(), 266 'topic_open' => 1, 267 'topic_tags' => false, // accepts array or comma delim 268 'forum_id' => 0 // accepts ids or slugs 269 ); 270 271 $r = wp_parse_args( $args, $defaults ); 272 extract( $r, EXTR_SKIP ); 273 274 $topic_title = strip_tags( $topic_title ); 275 276 if ( empty( $topic_title ) || !strlen( trim( $topic_title ) ) ) 277 return false; 278 279 if ( empty( $topic_slug ) ) 280 $topic_slug = sanitize_title( $topic_title ); 281 282 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, 'tags' => $topic_tags ) ) ) 283 return false; 284 285 // Now insert the first post. 286 if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) ) 287 return false; 288 289 do_action( 'bp_forums_new_topic', $topic_id ); 290 291 return $topic_id; 292 } 293 294 function bp_forums_update_topic( $args = '' ) { 295 global $bp; 296 297 do_action( 'bbpress_init' ); 298 299 $defaults = array( 300 'topic_id' => false, 301 'topic_title' => '', 302 'topic_text' => '' 303 ); 304 305 $r = wp_parse_args( $args, $defaults ); 306 extract( $r, EXTR_SKIP ); 307 308 if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) ) 309 return false; 310 311 if ( !$post = bb_get_first_post( $topic_id ) ) 312 return false; 313 314 // Update the first post 315 if ( !$post = bp_forums_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 ) ) ) 316 return false; 317 318 return bp_forums_get_topic_details( $topic_id ); 319 } 320 321 function bp_forums_sticky_topic( $args = '' ) { 322 global $bp; 323 324 do_action( 'bbpress_init' ); 325 326 $defaults = array( 327 'topic_id' => false, 328 'mode' => 'stick' // stick/unstick 329 ); 330 331 $r = wp_parse_args( $args, $defaults ); 332 extract( $r, EXTR_SKIP ); 333 334 if ( 'stick' == $mode ) 335 return bb_stick_topic( $topic_id ); 336 else if ( 'unstick' == $mode ) 337 return bb_unstick_topic( $topic_id ); 338 339 return false; 340 } 341 342 function bp_forums_openclose_topic( $args = '' ) { 343 global $bp; 344 345 do_action( 'bbpress_init' ); 346 347 $defaults = array( 348 'topic_id' => false, 349 'mode' => 'close' // stick/unstick 350 ); 351 352 $r = wp_parse_args( $args, $defaults ); 353 extract( $r, EXTR_SKIP ); 354 355 if ( 'close' == $mode ) 356 return bb_close_topic( $topic_id ); 357 else if ( 'open' == $mode ) 358 return bb_open_topic( $topic_id ); 359 360 return false; 361 } 362 363 function bp_forums_delete_topic( $args = '' ) { 364 global $bp; 365 366 do_action( 'bbpress_init' ); 367 368 $defaults = array( 369 'topic_id' => false 370 ); 371 372 $r = wp_parse_args( $args, $defaults ); 373 extract( $r, EXTR_SKIP ); 374 375 return bb_delete_topic( $topic_id, 1 ); 376 } 377 378 function bp_forums_total_topic_count() { 379 global $bbdb; 380 381 do_action( 'bbpress_init' ); 382 383 if ( isset( $bbdb ) ) 384 $count = $bbdb->get_results( $bbdb->prepare( "SELECT t.topic_id FROM {$bbdb->topics} AS t". groups_add_forum_tables_sql( '' ) . " WHERE " . groups_add_forum_where_sql( "t.topic_status = 0" ) ) ); 385 else 386 $count = 0; 387 388 return apply_filters( 'bp_forums_total_topic_count', count( (array)$count ) ); 389 } 390 391 function bp_forums_total_topic_count_for_user( $user_id = 0 ) { 392 global $bp; 393 394 do_action( 'bbpress_init' ); 395 396 if ( !$user_id ) 397 $user_id = ( $bp->displayed_user->id ) ? $bp->displayed_user->id : $bp->loggedin_user->id; 398 399 if ( class_exists( 'BB_Query' ) ) { 400 $query = new BB_Query( 'topic', array( 'topic_author_id' => $user_id, 'page' => 1, 'per_page' => -1, 'count' => true ) ); 401 $count = $query->count; 402 $query = null; 403 } else { 404 $count = 0; 405 } 406 407 return $count; 408 } 409 410 function bp_forums_get_topic_extras( $topics ) { 411 global $bp, $wpdb, $bbdb; 412 413 if ( empty( $topics ) ) 414 return $topics; 415 416 // Get the topic ids 417 foreach ( (array)$topics as $topic ) $topic_ids[] = $topic->topic_id; 418 $topic_ids = $wpdb->escape( join( ',', (array)$topic_ids ) ); 419 420 // Fetch the topic's last poster details 421 $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, t.topic_last_poster, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u, {$bbdb->topics} t WHERE u.ID = t.topic_last_poster AND t.topic_id IN ( {$topic_ids} )" ) ); 422 for ( $i = 0; $i < count( $topics ); $i++ ) { 423 foreach ( (array)$poster_details as $poster ) { 424 if ( $poster->topic_id == $topics[$i]->topic_id ) { 425 $topics[$i]->topic_last_poster_email = $poster->user_email; 426 $topics[$i]->topic_last_poster_nicename = $poster->user_nicename; 427 $topics[$i]->topic_last_poster_login = $poster->user_login; 428 $topics[$i]->topic_last_poster_displayname = $poster->display_name; 142 // Adjust title based on view 143 if ( bp_is_forums_component() ) { 144 if ( bp_is_my_profile() ) { 145 $bp->bp_options_title = __( 'My Forums', 'buddypress' ); 146 } else { 147 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 148 'item_id' => $bp->displayed_user->id, 149 'type' => 'thumb' 150 ) ); 151 $bp->bp_options_title = $bp->displayed_user->fullname; 429 152 } 430 153 } 431 154 } 432 433 // Fetch fullname for the topic's last poster434 if ( bp_is_active( 'profile' ) ) {435 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) );436 for ( $i = 0; $i < count( $topics ); $i++ ) {437 foreach ( (array)$poster_names as $name ) {438 if ( $name->topic_id == $topics[$i]->topic_id )439 $topics[$i]->topic_last_poster_displayname = $name->value;440 }441 }442 }443 444 return $topics;445 155 } 446 447 /** Post Functions ************************************************************/ 448 449 function bp_forums_get_topic_posts( $args = '' ) { 450 do_action( 'bbpress_init' ); 451 452 $defaults = array( 453 'topic_id' => false, 454 'page' => 1, 455 'per_page' => 15, 456 'order' => 'ASC' 457 ); 458 459 $args = wp_parse_args( $args, $defaults ); 460 $query = new BB_Query( 'post', $args, 'get_thread' ); 461 462 return bp_forums_get_post_extras( $query->results ); 463 } 464 465 function bp_forums_get_post( $post_id ) { 466 do_action( 'bbpress_init' ); 467 return bb_get_post( $post_id ); 468 } 469 470 function bp_forums_delete_post( $args = '' ) { 471 global $bp; 472 473 do_action( 'bbpress_init' ); 474 475 $defaults = array( 476 'post_id' => false 477 ); 478 479 $r = wp_parse_args( $args, $defaults ); 480 extract( $r, EXTR_SKIP ); 481 482 return bb_delete_post( $post_id, 1 ); 483 } 484 485 function bp_forums_insert_post( $args = '' ) { 486 global $bp; 487 488 do_action( 'bbpress_init' ); 489 490 $defaults = array( 491 'post_id' => false, 492 'topic_id' => false, 493 'post_text' => '', 494 'post_time' => bp_core_current_time(), 495 'poster_id' => $bp->loggedin_user->id, // accepts ids or names 496 'poster_ip' => $_SERVER['REMOTE_ADDR'], 497 'post_status' => 0, // use bb_delete_post() instead 498 'post_position' => false 499 ); 500 501 $r = wp_parse_args( $args, $defaults ); 502 extract( $r, EXTR_SKIP ); 503 504 if ( !$post = bp_forums_get_post( $post_id ) ) 505 $post_id = false; 506 507 if ( !isset( $topic_id ) ) 508 $topic_id = $post->topic_id; 509 510 if ( empty( $post_text ) ) 511 $post_text = $post->post_text; 512 513 if ( !isset( $post_time ) ) 514 $post_time = $post->post_time; 515 516 if ( !isset( $post_position ) ) 517 $post_position = $post->post_position; 518 519 $post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) ); 520 521 if ( !empty( $post_id ) ) 522 do_action( 'bp_forums_new_post', $post_id ); 523 524 return $post_id; 525 } 526 527 function bp_forums_get_post_extras( $posts ) { 528 global $bp, $wpdb; 529 530 if ( empty( $posts ) ) 531 return $posts; 532 533 // Get the user ids 534 foreach ( (array)$posts as $post ) $user_ids[] = $post->poster_id; 535 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) ); 536 537 // Fetch the poster's user_email, user_nicename and user_login 538 $poster_details = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_nicename, u.user_email, u.display_name FROM {$wpdb->users} u WHERE u.ID IN ( {$user_ids} )" ) ); 539 540 for ( $i = 0; $i < count( $posts ); $i++ ) { 541 foreach ( (array)$poster_details as $poster ) { 542 if ( $poster->user_id == $posts[$i]->poster_id ) { 543 $posts[$i]->poster_email = $poster->user_email; 544 $posts[$i]->poster_login = $poster->user_nicename; 545 $posts[$i]->poster_nicename = $poster->user_login; 546 $posts[$i]->poster_name = $poster->display_name; 547 } 548 } 549 } 550 551 // Fetch fullname for each poster. 552 if ( bp_is_active( 'profile' ) ) { 553 $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) ); 554 for ( $i = 0; $i < count( $posts ); $i++ ) { 555 foreach ( (array)$poster_names as $name ) { 556 if ( isset( $topics[$i] ) && $name->user_id == $topics[$i]->user_id ) 557 $posts[$i]->poster_name = $poster->value; 558 } 559 } 560 } 561 562 return $posts; 563 } 564 565 function bp_forums_get_forum_topicpost_count( $forum_id ) { 566 global $wpdb, $bbdb; 567 568 do_action( 'bbpress_init' ); 569 570 // Need to find a bbPress function that does this 571 return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) ); 572 } 573 574 function bp_forums_filter_caps( $allcaps ) { 575 global $bp, $wp_roles, $bb_table_prefix; 576 577 if ( !isset( $bp->loggedin_user->id ) ) 578 return $allcaps; 579 580 $bb_cap = get_user_meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities', true ); 581 582 if ( empty( $bb_cap ) ) 583 return $allcaps; 584 585 $bb_cap = array_keys($bb_cap); 586 $bb_cap = $wp_roles->get_role( $bb_cap[0] ); 587 $bb_cap = $bb_cap->capabilities; 588 589 return array_merge( (array) $allcaps, (array) $bb_cap ); 590 } 591 add_filter( 'user_has_cap', 'bp_forums_filter_caps' ); 592 593 594 /******************************************************************************** 595 * Caching 596 * 597 * Caching functions handle the clearing of cached objects and pages on specific 598 * actions throughout BuddyPress. 599 */ 600 601 // List actions to clear super cached pages on, if super cache is installed 602 add_action( 'bp_forums_new_forum', 'bp_core_clear_cache' ); 603 add_action( 'bp_forums_new_topic', 'bp_core_clear_cache' ); 604 add_action( 'bp_forums_new_post', 'bp_core_clear_cache' ); 156 // Create the forums component 157 $bp->forums = new BP_Forums_Component(); 605 158 606 159 ?> -
trunk/bp-groups/bp-groups-loader.php
r3796 r3806 139 139 140 140 // Add a new default subnav item for when the groups nav is selected. 141 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups-> root_slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );141 bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) ); 142 142 143 143 // Add the "Home" subnav item, as this will always be present … … 175 175 global $bp; 176 176 177 if ( bp_is_current_component( $bp->groups->id) && empty( $bp->current_action ) && empty( $bp->current_item ) ) {177 if ( bp_is_current_component( 'groups' ) && empty( $bp->current_action ) && empty( $bp->current_item ) ) { 178 178 $bp->is_directory = true; 179 179 … … 632 632 global $bp; 633 633 634 if ( bp_is_current_component( $bp->groups->slug) && 'edit-details' == $bp->action_variables[0] ) {634 if ( bp_is_current_component( 'groups' ) && isset( $bp->action_variables[0] ) && 'edit-details' == $bp->action_variables[0] ) { 635 635 636 636 if ( $bp->is_item_admin || $bp->is_item_mod ) { … … 664 664 global $bp; 665 665 666 if ( bp_is_current_component( $bp->groups->slug) && 'group-settings' == $bp->action_variables[0] ) {666 if ( bp_is_current_component( 'groups' ) && isset( $bp->action_variables[0] ) && 'group-settings' == $bp->action_variables[0] ) { 667 667 668 668 if ( !$bp->is_item_admin ) … … 701 701 global $bp; 702 702 703 if ( bp_is_current_component( $bp->groups->slug) && 'group-avatar' == $bp->action_variables[0] ) {703 if ( bp_is_current_component( 'groups' ) && isset( $bp->action_variables[0] ) && 'group-avatar' == $bp->action_variables[0] ) { 704 704 705 705 if ( !$bp->is_item_admin ) … … 759 759 global $bp; 760 760 761 if ( bp_is_current_component( $bp->groups->slug) && 'manage-members' == $bp->action_variables[0] ) {761 if ( bp_is_current_component( 'groups' ) && isset( $bp->action_variables[0] ) && 'manage-members' == $bp->action_variables[0] ) { 762 762 763 763 if ( !$bp->is_item_admin ) … … 865 865 global $bp; 866 866 867 if ( bp_is_current_component( $bp->groups->slug) && 'membership-requests' == $bp->action_variables[0] ) {867 if ( bp_is_current_component( 'groups' ) && isset( $bp->action_variables[0] ) && 'membership-requests' == $bp->action_variables[0] ) { 868 868 869 869 // Ask for a login if the user is coming here via an email notification … … 923 923 global $bp; 924 924 925 if ( bp_is_current_component( $bp->groups->slug) && 'delete-group' == $bp->action_variables[0] ) {925 if ( bp_is_current_component( 'groups' ) && isset( $bp->action_variables[0] ) && 'delete-group' == $bp->action_variables[0] ) { 926 926 927 927 if ( !$bp->is_item_admin && !is_super_admin() ) -
trunk/bp-themes/bp-default/members/single/profile.php
r3771 r3806 22 22 locate_template( array( 'members/single/profile/change-avatar.php' ), true ); 23 23 24 elseif ( bp_is_active( 'profile' ) ) : 25 locate_template( array( 'members/single/profile/profile-loop.php' ), true ); 26 24 27 else : 25 locate_template( array( 'members/single/profile/profile- loop.php' ), true );28 locate_template( array( 'members/single/profile/profile-wp.php' ), true ); 26 29 27 30 endif; -
trunk/bp-themes/bp-default/members/single/profile/profile-loop.php
r3790 r3806 1 1 <?php do_action( 'bp_before_profile_loop_content' ) ?> 2 2 3 <?php if ( bp_ is_active( 'profile') ) : ?>3 <?php if ( bp_has_profile() ) : ?> 4 4 5 <?php if ( bp_has_profile() ) :?>5 <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?> 6 6 7 <?php while ( bp_profile_groups() ) : bp_the_profile_group();?>7 <?php if ( bp_profile_group_has_fields() ) : ?> 8 8 9 <?php if ( bp_profile_group_has_fields() ) :?>9 <?php do_action( 'bp_before_profile_field_content' ) ?> 10 10 11 <?php do_action( 'bp_before_profile_field_content' ) ?> 11 <div class="bp-widget <?php bp_the_profile_group_slug() ?>"> 12 <?php if ( 1 != bp_get_the_profile_group_id() ) : ?> 13 <h4><?php bp_the_profile_group_name() ?></h4> 14 <?php endif; ?> 12 15 13 <div class="bp-widget <?php bp_the_profile_group_slug() ?>"> 14 <?php if ( 1 != bp_get_the_profile_group_id() ) : ?> 15 <h4><?php bp_the_profile_group_name() ?></h4> 16 <?php endif; ?> 16 <table class="profile-fields zebra"> 17 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?> 17 18 18 <table class="profile-fields zebra">19 <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>19 <?php if ( bp_field_has_data() ) : ?> 20 <tr<?php bp_field_css_class() ?>> 20 21 21 <?php if ( bp_field_has_data() ) : ?> 22 <tr<?php bp_field_css_class() ?>> 22 <td class="label"> 23 <?php bp_the_profile_field_name() ?> 24 </td> 23 25 24 <td class="label">25 <?php bp_the_profile_field_name() ?>26 26 <td class="data"> 27 <?php bp_the_profile_field_value() ?> 28 </td> 27 29 28 <td class="data"> 29 <?php bp_the_profile_field_value() ?> 30 </td> 30 </tr> 31 <?php endif; ?> 31 32 32 </tr> 33 <?php endif; ?> 33 <?php do_action( 'bp_profile_field_item' ) ?> 34 34 35 <?php do_action( 'bp_profile_field_item' ) ?> 35 <?php endwhile; ?> 36 </table> 37 </div> 36 38 37 <?php endwhile; ?> 38 </table> 39 </div> 39 <?php do_action( 'bp_after_profile_field_content' ) ?> 40 40 41 <?php do_action( 'bp_after_profile_field_content' )?>41 <?php endif; ?> 42 42 43 <?php endif; ?>43 <?php endwhile; ?> 44 44 45 <?php endwhile; ?> 46 47 <?php do_action( 'bp_profile_field_buttons' ) ?> 48 49 <?php endif; ?> 50 51 <?php else : ?> 52 53 <?php /* Just load the standard WP profile information, if BP extended profiles are not loaded. */ ?> 54 <?php bp_core_get_wp_profile() ?> 45 <?php do_action( 'bp_profile_field_buttons' ) ?> 55 46 56 47 <?php endif; ?> 57 48 58 49 <?php do_action( 'bp_after_profile_loop_content' ) ?> 59 -
trunk/bp-users/bp-users-template.php
r3796 r3806 675 675 } 676 676 677 /* @todo Deprecate incorrectly named function? */678 function bp_loggedinuser_link() {679 global $bp;680 681 if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) )682 echo apply_filters( 'bp_loggedin_user_link', $link );683 }684 685 677 function bp_displayed_user_link() { 686 678 echo bp_get_displayed_user_link(); … … 938 930 */ 939 931 function bp_users_activity_feed() { 940 if ( !bp_is_active( 'activity' ) || !bp_is_ member() )932 if ( !bp_is_active( 'activity' ) || !bp_is_user() ) 941 933 return; ?> 942 934
Note: See TracChangeset
for help on using the changeset viewer.