BP_Groups_Component::setup_globals( array $args = array() )
Set up component global data.
Description
The BP_GROUPS_SLUG constant is deprecated, and only used here for backwards compatibility.
See also
- BP_Component::setup_globals(): for a description of arguments.
Parameters
- $args
-
(Optional) See BP_Component::setup_globals() for a description.
Default value: array()
Source
File: bp-groups/classes/class-bp-groups-component.php
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | public function setup_globals( $args = array () ) { $bp = buddypress(); // Define a slug, if necessary. if ( ! defined( 'BP_GROUPS_SLUG' ) ) { define( 'BP_GROUPS_SLUG' , $this ->id ); } // Global tables for groups component. $global_tables = array ( 'table_name' => $bp ->table_prefix . 'bp_groups' , 'table_name_members' => $bp ->table_prefix . 'bp_groups_members' , 'table_name_groupmeta' => $bp ->table_prefix . 'bp_groups_groupmeta' ); // Metadata tables for groups component. $meta_tables = array ( 'group' => $bp ->table_prefix . 'bp_groups_groupmeta' , ); // Fetch the default directory title. $default_directory_titles = bp_core_get_directory_page_default_titles(); $default_directory_title = $default_directory_titles [ $this ->id]; // All globals for groups component. // Note that global_tables is included in this array. $args = array ( 'slug' => BP_GROUPS_SLUG, 'root_slug' => isset( $bp ->pages->groups->slug ) ? $bp ->pages->groups->slug : BP_GROUPS_SLUG, 'has_directory' => true, 'directory_title' => isset( $bp ->pages->groups->title ) ? $bp ->pages->groups->title : $default_directory_title , 'notification_callback' => 'groups_format_notifications' , 'search_string' => __( 'Search Groups…' , 'buddyboss' ), 'global_tables' => $global_tables , 'meta_tables' => $meta_tables , ); parent::setup_globals( $args ); /* Single Group Globals **********************************************/ // Are we viewing a single group? if ( bp_is_groups_component() && ( ( $group_id = BP_Groups_Group::group_exists( bp_current_action() ) ) || ( $group_id = BP_Groups_Group::get_id_by_previous_slug( bp_current_action() ) ) ) ) { $bp ->is_single_item = true; /** * Filters the current PHP Class being used. * * @since BuddyPress 1.5.0 * * @param string $value Name of the class being used. */ $current_group_class = apply_filters( 'bp_groups_current_group_class' , 'BP_Groups_Group' ); if ( $current_group_class == 'BP_Groups_Group' ) { $this ->current_group = groups_get_group( $group_id ); } else { /** * Filters the current group object being instantiated from previous filter. * * @since BuddyPress 1.5.0 * * @param object $value Newly instantiated object for the group. */ $this ->current_group = apply_filters( 'bp_groups_current_group_object' , new $current_group_class ( $group_id ) ); } // When in a single group, the first action is bumped down one because of the // group name, so we need to adjust this and set the group name to current_item. $bp ->current_item = bp_current_action(); $bp ->current_action = bp_action_variable( 0 ); array_shift ( $bp ->action_variables ); // Using "item" not "group" for generic support in other components. if ( bp_current_user_can( 'bp_moderate' ) ) { bp_update_is_item_admin( true, 'groups' ); } else { bp_update_is_item_admin( groups_is_user_admin( bp_loggedin_user_id(), $this ->current_group->id ), 'groups' ); } // If the user is not an admin, check if they are a moderator. if ( ! bp_is_item_admin() ) { bp_update_is_item_mod ( groups_is_user_mod ( bp_loggedin_user_id(), $this ->current_group->id ), 'groups' ); } // Check once if the current group has a custom front template. $this ->current_group->front_template = bp_groups_get_front_template( $this ->current_group ); // Initialize the nav for the groups component. $this ->nav = new BP_Core_Nav( $this ->current_group->id ); // Set current_group to 0 to prevent debug errors. } else { $this ->current_group = 0; } // Set group type if available. if ( bp_is_groups_directory() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_action_variable() ) { $matched_types = bp_groups_get_group_types( array ( 'has_directory' => true, 'directory_slug' => bp_action_variable(), ) ); // Set 404 if we do not have a valid group type. if ( empty ( $matched_types ) ) { bp_do_404(); return ; } // Set our directory type marker. $this ->current_directory_type = reset( $matched_types ); } // Set up variables specific to the group creation process. if ( bp_is_groups_component() && bp_is_current_action( 'create' ) && bp_user_can_create_groups() && isset( $_COOKIE [ 'bp_new_group_id' ] ) ) { $bp ->groups->new_group_id = (int) $_COOKIE [ 'bp_new_group_id' ]; } /** * Filters the list of illegal groups names/slugs. * * @since BuddyPress 1.0.0 * * @param array $value Array of illegal group names/slugs. */ $this ->forbidden_names = apply_filters( 'groups_forbidden_names' , array ( 'my-groups' , 'create' , 'invites' , 'send-invites' , 'forum' , 'delete' , 'add' , 'admin' , 'request-membership' , 'members' , 'settings' , 'avatar' , $this ->slug, $this ->root_slug, ) ); // If the user was attempting to access a group, but no group by that name was found, 404. if ( bp_is_groups_component() && empty ( $this ->current_group ) && empty ( $this ->current_directory_type ) && bp_current_action() && ! in_array( bp_current_action(), $this ->forbidden_names ) ) { bp_do_404(); return ; } /** * Filters the preconfigured groups creation steps. * * @since BuddyPress 1.1.0 * * @param array $value Array of preconfigured group creation steps. */ $this ->group_creation_steps = apply_filters( 'groups_create_group_steps' , array ( 'group-details' => array ( 'name' => __( 'Details' , 'buddyboss' ), 'position' => 0 ), 'group-settings' => array ( 'name' => __( 'Settings' , 'buddyboss' ), 'position' => 10 ) ) ); // If avatar uploads are not disabled, add avatar option. $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads(); if ( ! $disabled_avatar_uploads && $bp ->avatar->show_avatars ) { $this ->group_creation_steps[ 'group-avatar' ] = array ( 'name' => __( 'Photo' , 'buddyboss' ), 'position' => 20 ); } if ( bp_group_use_cover_image_header() ) { $this ->group_creation_steps[ 'group-cover-image' ] = array ( 'name' => __( 'Cover Photo' , 'buddyboss' ), 'position' => 25 ); } // If friends component is active, add invitations. if ( bp_is_active( 'friends' ) ) { $this ->group_creation_steps[ 'group-invites' ] = array ( 'name' => __( 'Invites' , 'buddyboss' ), 'position' => 30 ); } /** * Filters the list of valid groups statuses. * * @since BuddyPress 1.1.0 * * @param array $value Array of valid group statuses. */ $this ->valid_status = apply_filters( 'groups_valid_status' , array ( 'public' , 'private' , 'hidden' ) ); // Auto Group Membership Approval when non group member performs group activity. $this ->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) && BP_DISABLE_AUTO_GROUP_JOIN ? false : true; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.