Changeset 3159
- Timestamp:
- 05/15/2011 07:12:15 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/plugin/bbp-includes/bbp-user-template.php ¶
r3127 r3159 1102 1102 function bbp_get_forums_for_current_user( $args = array() ) { 1103 1103 1104 // Setup arrays 1105 $private = $hidden = $post__not_in = array(); 1106 1107 // Private forums 1108 if ( !current_user_can( 'read_private_forums' ) ) 1109 $private = bbp_get_private_forum_ids(); 1110 1111 // Hidden forums 1112 if ( !current_user_can( 'read_hidden_forums' ) ) 1113 $hidden = bbp_get_hidden_forum_ids(); 1114 1115 // Merge private and hidden forums together 1116 $forum_ids = array_merge( $private, $hidden ); 1117 1118 // There are forums that need to be ex 1119 if ( !empty( $forum_ids ) ) 1120 $post__not_in = implode( ',', $forum_ids ); 1121 1104 1122 $defaults = array( 1105 1123 'post_type' => bbp_get_forum_post_type(), 1106 ' child_of' => '0',1124 'post_status' => 'publish', 1107 1125 'numberposts' => -1, 1108 ' post_status' => 'publish',1126 'exclude' => $post__not_in 1109 1127 ); 1110 1128 $r = wp_parse_args( $args, $defaults ); 1111 1129 1112 // Exclude forums the user cannot post to1113 $r = bbp_exclude_forum_ids( $r );1114 1115 1130 // Get the forums 1116 if ( ! ( $posts = get_posts( $r ) ) ) 1117 $posts = false; 1118 1119 return apply_filters( 'bbp_get_forums_for_current_user', $posts ); 1131 $forums = get_posts( $r ); 1132 1133 // No availabe forums 1134 if ( empty( $forums ) ) 1135 $forums = false; 1136 1137 return apply_filters( 'bbp_get_forums_for_current_user', $forums ); 1120 1138 } 1121 1139 … … 1125 1143 * @since bbPress (r3127) 1126 1144 * 1127 * @uses bbp_get_forums_for_current_user()1128 1145 * @uses bbp_is_topic_edit() 1129 1146 * @uses current_user_can() … … 1135 1152 */ 1136 1153 function bbp_current_user_can_access_create_topic_form() { 1137 if ( bbp_get_forums_for_current_user() && ( ( bbp_is_topic_edit() && current_user_can( 'edit_topic', bbp_get_topic_id() ) ) || current_user_can( 'publish_topics' ) || ( bbp_allow_anonymous() && !is_user_logged_in() ) ) ) 1154 1155 // Always allow super admins 1156 if ( is_super_admin() ) 1138 1157 return true; 1139 1158 1140 return false; 1159 // Users need to earn access 1160 $retval = false; 1161 1162 // Looking at a single forum 1163 if ( bbp_is_forum() ) { 1164 1165 // What is the visibility of this forum 1166 switch ( bbp_get_forum_visibility() ) { 1167 1168 // Public 1169 case 'publish' : 1170 1171 // User cannot publish topics 1172 if ( current_user_can( 'publish_topics' ) ) 1173 $retval = true; 1174 1175 // Anonymous posting is allowed 1176 if ( bbp_allow_anonymous() && !is_user_logged_in() ) 1177 $retval = true; 1178 1179 break; 1180 1181 // Private forums 1182 case 'private' : 1183 if ( current_user_can( 'read_private_forums' ) ) 1184 $retval = true; 1185 1186 break; 1187 1188 // Hidden forums 1189 case 'hidden' : 1190 if ( current_user_can( 'read_hidden_forums' ) ) 1191 $retval = true; 1192 1193 break; 1194 } 1195 1196 // Editing a single topic 1197 } elseif ( bbp_is_topic_edit() ) { 1198 1199 // User can edit edit this topic 1200 if ( current_user_can( 'edit_topic', bbp_get_topic_id() ) ) 1201 $retval = true; 1202 } 1203 1204 // Allow access to be filtered 1205 return apply_filters( 'bbp_current_user_can_access_create_topic_form', $retval ); 1141 1206 } 1142 1207 … … 1156 1221 */ 1157 1222 function bbp_current_user_can_create_topic_in_forum() { 1158 if ( ( !bbp_is_forum_category() && ( !bbp_is_forum_closed() || current_user_can( 'edit_forum', bbp_get_topic_forum_id() ) ) ) || bbp_is_topic_edit() ) 1223 1224 // Always allow super admins 1225 if ( is_super_admin() ) 1159 1226 return true; 1160 1227 1161 return false; 1228 // Users need to earn access 1229 $retval = false; 1230 1231 // Looking at a single forum 1232 if ( bbp_is_forum() ) { 1233 1234 // Forum is not a category 1235 if ( !bbp_is_forum_category() ) { 1236 1237 // Forum is open 1238 $retval = (bool) bbp_is_forum_open(); 1239 } 1240 1241 // Editing a single topic 1242 } elseif ( bbp_is_topic_edit() ) { 1243 1244 // If you can edit this forum, you can edit topics in this forum 1245 if ( current_user_can( 'edit_forum', bbp_get_topic_forum_id() ) ) 1246 $retval = true; 1247 } 1248 1249 // Allow access to be filtered 1250 return apply_filters( 'bbp_current_user_can_create_topic_in_forum', $retval ); 1162 1251 } 1163 1252
Note: See TracChangeset
for help on using the changeset viewer.