[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/ -> bp-groups-forums.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Groups Forums.
   4   *
   5   * Action functions are exactly the same as screen functions, however they do not
   6   * have a template screen associated with them. Usually they will send the user
   7   * back to the default screen after execution.
   8   *
   9   * Note that this file is only used for the retired version of bbPress (1.x) and
  10   * will see minimal updates as of BuddyPress 1.9.0.
  11   *
  12   * @package BuddyPress
  13   * @subpackage GroupsForums
  14   * @since 1.5.0
  15   */
  16  
  17  // Exit if accessed directly.
  18  defined( 'ABSPATH' ) || exit;
  19  
  20  /**
  21   * Creates a new forum inside a specific BuddyPress group.
  22   *
  23   * Uses the bundled version of bbPress packaged with BuddyPress.
  24   *
  25   * @since 1.0.0
  26   *
  27   * @param int    $group_id   The group ID that the new forum should be attached to.
  28   * @param string $group_name The group name.
  29   * @param string $group_desc The group description.
  30   */
  31  function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
  32  
  33      if ( empty( $group_id ) ) {
  34          $group_id = bp_get_current_group_id();
  35      }
  36  
  37      if ( empty( $group_name ) ) {
  38          $group_name = bp_get_current_group_name();
  39      }
  40  
  41      if ( empty( $group_desc ) ) {
  42          $group_desc = bp_get_current_group_description();
  43      }
  44  
  45      $forum_id = bp_forums_new_forum( array(
  46          'forum_name' => $group_name,
  47          'forum_desc' => $group_desc
  48      ) );
  49  
  50      groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
  51  
  52      /**
  53       * Fires after the creation of a new forum inside a specific BuddyPress group.
  54       *
  55       * @since 1.0.0
  56       *
  57       * @param int $forum_id ID of the newly created forum.
  58       * @param int $group_id ID of the associated group.
  59       */
  60      do_action( 'groups_new_group_forum', $forum_id, $group_id );
  61  }
  62  
  63  /**
  64   * Update group forum metadata (title, description, slug) when the group's details are edited.
  65   *
  66   * @since 1.1.0
  67   *
  68   * @param int $group_id Group id, passed from groups_details_updated.
  69   * @return false|null
  70   */
  71  function groups_update_group_forum( $group_id ) {
  72  
  73      $group = groups_get_group( $group_id );
  74  
  75      /**
  76       * Bail in the following three situations:
  77       *  1. Forums are not enabled for this group
  78       *  2. The BP Forum component is not enabled
  79       *  3. The built-in bbPress forums are not correctly installed (usually means they've been
  80       *     uninstalled)
  81       */
  82      if ( empty( $group->enable_forum ) || !bp_is_active( 'forums' ) || ( function_exists( 'bp_forums_is_installed_correctly' ) && !bp_forums_is_installed_correctly() ) ) {
  83          return false;
  84      }
  85  
  86      /**
  87       * Filters the group forum metadata value argument.
  88       *
  89       * @since 1.2.5
  90       *
  91       * @param array $value Array of metadata values to update the group forum with.
  92       */
  93      bp_forums_update_forum( apply_filters( 'groups_update_group_forum', array(
  94          'forum_id'   => groups_get_groupmeta( $group_id, 'forum_id' ),
  95          'forum_name' => $group->name,
  96          'forum_desc' => $group->description,
  97          'forum_slug' => $group->slug
  98      ) ) );
  99  }
 100  add_action( 'groups_details_updated', 'groups_update_group_forum' );
 101  
 102  /**
 103   * Create a new group forum post.
 104   *
 105   * Uses the bundled version of bbPress packaged with BuddyPress.
 106   *
 107   * @since 1.0.0
 108   *
 109   * @param string $post_text The text for the forum post.
 110   * @param int    $topic_id  The topic ID used so we can identify where the new
 111   *                          forum post should reside.
 112   * @param mixed  $page      The page number where the new forum post should reside.
 113   *                          Default: false.
 114   * @return mixed The new forum post ID on success. Boolean false on failure.
 115   */
 116  function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
 117      if ( empty( $post_text ) ) {
 118          return false;
 119      }
 120  
 121      /**
 122       * Filters the text for the forum post before save.
 123       *
 124       * @since 1.2.0
 125       *
 126       * @param string $post_text Text for the forum post.
 127       */
 128      $post_text = apply_filters( 'group_forum_post_text_before_save',     $post_text );
 129  
 130      /**
 131       * Filters the ID for the forum post before save.
 132       *
 133       * @since 1.2.0
 134       *
 135       * @param int $topic_id ID of the topic the post will be associated with.
 136       */
 137      $topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id  );
 138      $post_id   = bp_forums_insert_post( array(
 139          'post_text' => $post_text,
 140          'topic_id'  => $topic_id
 141      ) );
 142  
 143      if ( empty( $post_id ) ) {
 144          return false;
 145      }
 146  
 147      $topic            = bp_forums_get_topic_details( $topic_id );
 148      $activity_action  = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
 149      $activity_content = bp_create_excerpt( $post_text );
 150      $primary_link     = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
 151  
 152      if ( !empty( $page ) ) {
 153          $primary_link .= "?topic_page=" . $page;
 154      }
 155  
 156      /**
 157       * Filters the new groups activity forum post action.
 158       *
 159       * @since 1.2.0
 160       *
 161       * @param string $activity_action Formatted action related to group activity posting.
 162       * @param int    $post_id         ID of the newly created group forum post.
 163       * @param string $post_text       The text for the forum post.
 164       * @param object $topic           Object holding current topic details. Passed by reference.
 165       */
 166      $action = apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_id, $post_text, &$topic ) );
 167  
 168      /**
 169       * Filters the new groups activity forum post content.
 170       *
 171       * @since 1.2.0
 172       *
 173       * @param string $activity_content Excerpt-length activity content to be posted.
 174       * @param int    $post_id          ID of the newly created group forum post.
 175       * @param string $post_text        The text for the forum post.
 176       * @param object $topic            Object holding current topic details. Passed by reference.
 177       */
 178      $content = apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) );
 179  
 180      /**
 181       * Filters the new groups activity forum post primary link.
 182       *
 183       * @since 1.1.0
 184       *
 185       * @param string $value URL to the newly posted forum post.
 186       */
 187      $filtered_primary_link = apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" );
 188  
 189      groups_record_activity( array(
 190          'action'            => $action,
 191          'content'           => $content,
 192          'primary_link'      => $filtered_primary_link,
 193          'type'              => 'new_forum_post',
 194          'item_id'           => bp_get_current_group_id(),
 195          'secondary_item_id' => $post_id
 196      ) );
 197  
 198      /**
 199       * Fires after the creation of a new group forum topic post.
 200       *
 201       * @since 1.0.0
 202       *
 203       * @param int $value   ID of the current group.
 204       * @param int $post_id ID of the new created forum topic post.
 205       */
 206      do_action( 'groups_new_forum_topic_post', bp_get_current_group_id(), $post_id );
 207  
 208      return $post_id;
 209  }
 210  
 211  /**
 212   * Create a new group forum topic.
 213   *
 214   * Uses the bundled version of bbPress packaged with BuddyPress.
 215   *
 216   * @since 1.0.0
 217   *
 218   * @param string $topic_title The title for the forum topic.
 219   * @param string $topic_text  The text for the forum topic.
 220   * @param string $topic_tags  A comma-delimited string of topic tags.
 221   * @param int    $forum_id    The forum ID this forum topic resides in.
 222   * @return mixed The new topic object on success. Boolean false on failure.
 223   */
 224  function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) {
 225      if ( empty( $topic_title ) || empty( $topic_text ) )
 226          return false;
 227  
 228      /**
 229       * Filters the new groups forum topic title before saving.
 230       *
 231       * @since 1.2.0
 232       *
 233       * @param string $topic_title The title for the forum topic.
 234       */
 235      $topic_title = apply_filters( 'group_forum_topic_title_before_save',    $topic_title );
 236  
 237      /**
 238       * Filters the new groups forum topic text before saving.
 239       *
 240       * @since 1.2.0
 241       *
 242       * @param string $topic_text The text for the forum topic.
 243       */
 244      $topic_text  = apply_filters( 'group_forum_topic_text_before_save',     $topic_text  );
 245  
 246      /**
 247       * Filters the new groups forum topic tags before saving.
 248       *
 249       * @since 1.2.0
 250       *
 251       * @param string $topic_tags A comma-delimited string of topic tags.
 252       */
 253      $topic_tags  = apply_filters( 'group_forum_topic_tags_before_save',     $topic_tags  );
 254  
 255      /**
 256       * Filters the forum ID this forum topic resides in.
 257       *
 258       * @since 1.2.0
 259       *
 260       * @param string $forum_id The forum ID this forum topic resides in.
 261       */
 262      $forum_id    = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id    );
 263      $topic_id    = bp_forums_new_topic( array(
 264          'topic_title' => $topic_title,
 265          'topic_text'  => $topic_text,
 266          'topic_tags'  => $topic_tags,
 267          'forum_id'    => $forum_id
 268      ) );
 269  
 270      if ( empty( $topic_id ) ) {
 271          return false;
 272      }
 273  
 274      $topic            = bp_forums_get_topic_details( $topic_id );
 275      $activity_action  = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
 276      $activity_content = bp_create_excerpt( $topic_text );
 277  
 278      /**
 279       * Filters the new groups activity forum topic action.
 280       *
 281       * @since 1.2.0
 282       *
 283       * @param string $activity_action Formatted action related to forum topic.
 284       * @param string $topic_text      New topic text.
 285       * @param object $topic           Object holding current topic details. Passed by reference.
 286       */
 287      $action = apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &$topic ) );
 288  
 289      /**
 290       * Filters the new groups activity forum topic content.
 291       *
 292       * @since 1.2.0
 293       *
 294       * @param string $activity_content Excerpt-length activity content to be posted.
 295       * @param string $topic_text       New topic text.
 296       * @param object $topic            Object holding current topic details. Passed by reference.
 297       */
 298      $content = apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) );
 299  
 300      /**
 301       * Filters the new groups activity forum topic primary link.
 302       *
 303       * @since 1.1.0
 304       *
 305       * @param string $value Concatenated primary link.
 306       */
 307      $primary_link = apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' );
 308  
 309      groups_record_activity( array(
 310          'action'            => $action,
 311          'content'           => $content,
 312          'primary_link'      => $primary_link,
 313          'type'              => 'new_forum_topic',
 314          'item_id'           => bp_get_current_group_id(),
 315          'secondary_item_id' => $topic->topic_id
 316      ) );
 317  
 318      /**
 319       * Fires after the creation of a new group forum topic.
 320       *
 321       * @since 1.0.0
 322       *
 323       * @param int    $value ID of the current group.
 324       * @param object $topic Object holding current topic details. Passed by reference.
 325       */
 326      do_action_ref_array( 'groups_new_forum_topic', array( bp_get_current_group_id(), &$topic ) );
 327  
 328      return $topic;
 329  }
 330  
 331  /**
 332   * Update an existing group forum topic.
 333   *
 334   * Uses the bundled version of bbPress packaged with BuddyPress.
 335   *
 336   * @since 1.1.0
 337   *
 338   * @param int    $topic_id    The topic ID of the existing forum topic.
 339   * @param string $topic_title The title for the forum topic.
 340   * @param string $topic_text  The text for the forum topic.
 341   * @param mixed  $topic_tags  A comma-delimited string of topic tags. Optional.
 342   * @return mixed The topic object on success. Boolean false on failure.
 343   */
 344  function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text, $topic_tags = false ) {
 345      $bp = buddypress();
 346  
 347      /** This filter is documented in bp-groups/bp-groups-forums.php */
 348      $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
 349  
 350      /** This filter is documented in bp-groups/bp-groups-forums.php */
 351      $topic_text  = apply_filters( 'group_forum_topic_text_before_save',  $topic_text  );
 352      $topic       = bp_forums_update_topic( array(
 353          'topic_title' => $topic_title,
 354          'topic_text' => $topic_text,
 355          'topic_id' => $topic_id,
 356          'topic_tags' => $topic_tags
 357      ) );
 358  
 359      if ( empty( $topic ) ) {
 360          return false;
 361      }
 362  
 363      // Get the corresponding activity item.
 364      if ( bp_is_active( 'activity' ) ) {
 365          $id = bp_activity_get_activity_id( array(
 366              'item_id'           => bp_get_current_group_id(),
 367              'secondary_item_id' => $topic_id,
 368              'component'         => $bp->groups->id,
 369              'type'              => 'new_forum_topic'
 370          ) );
 371      }
 372  
 373      $activity_action  = sprintf( __( '%1$s edited the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
 374      $activity_content = bp_create_excerpt( $topic_text );
 375  
 376      /** This filter is documented in bp-groups/bp-groups-forums.php */
 377      $action = apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &$topic ) );
 378  
 379      /** This filter is documented in bp-groups/bp-groups-forums.php */
 380      $content = apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) );
 381  
 382      /** This filter is documented in bp-groups/bp-groups-forums.php */
 383      $primary_link = apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' );
 384  
 385      groups_record_activity( array(
 386          'id'                => $id,
 387          'action'            => $action,
 388          'content'           => $content,
 389          'primary_link'      => $primary_link,
 390          'type'              => 'new_forum_topic',
 391          'item_id'           => (int) bp_get_current_group_id(),
 392          'user_id'           => (int) $topic->topic_poster,
 393          'secondary_item_id' => $topic->topic_id,
 394          'recorded_time '    => $topic->topic_time
 395      ) );
 396  
 397      /**
 398       * Fires after the update of a group forum topic.
 399       *
 400       * @since 1.1.0
 401       *
 402       * @param object $topic Object holding current topic being updated. Passed by reference.
 403       */
 404      do_action_ref_array( 'groups_update_group_forum_topic', array( &$topic ) );
 405  
 406      return $topic;
 407  }
 408  
 409  /**
 410   * Update an existing group forum post.
 411   *
 412   * Uses the bundled version of bbPress packaged with BuddyPress.
 413   *
 414   * @since 1.1.0
 415   *
 416   * @param int    $post_id   The post ID of the existing forum post.
 417   * @param string $post_text The text for the forum post.
 418   * @param int    $topic_id  The topic ID of the existing forum topic.
 419   * @param mixed  $page      The page number where the new forum post should reside. Optional.
 420   * @return mixed The forum post ID on success. Boolean false on failure.
 421   */
 422  function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
 423      $bp = buddypress();
 424  
 425      /** This filter is documented in bp-groups/bp-groups-forums.php */
 426      $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
 427  
 428      /** This filter is documented in bp-groups/bp-groups-forums.php */
 429      $topic_id  = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
 430      $post      = bp_forums_get_post( $post_id );
 431      $post_id   = bp_forums_insert_post( array(
 432          'post_id'   => $post_id,
 433          'post_text' => $post_text,
 434          'post_time' => $post->post_time,
 435          'topic_id'  => $topic_id,
 436          'poster_id' => $post->poster_id
 437      ) );
 438  
 439      if ( empty( $post_id ) ) {
 440          return false;
 441      }
 442  
 443      $topic            = bp_forums_get_topic_details( $topic_id );
 444      $activity_action  = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
 445      $activity_content = bp_create_excerpt( $post_text );
 446      $primary_link     = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
 447  
 448      if ( !empty( $page ) ) {
 449          $primary_link .= "?topic_page=" . $page;
 450      }
 451  
 452      // Get the corresponding activity item.
 453      if ( bp_is_active( 'activity' ) ) {
 454          $id = bp_activity_get_activity_id( array(
 455              'user_id'           => $post->poster_id,
 456              'component'         => $bp->groups->id,
 457              'type'              => 'new_forum_post',
 458              'item_id'           => bp_get_current_group_id(),
 459              'secondary_item_id' => $post_id
 460           ) );
 461      }
 462  
 463      /** This filter is documented in bp-groups/bp-groups-forums.php */
 464      $action = apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_text, &$topic, &$topic ) );
 465  
 466      /** This filter is documented in bp-groups/bp-groups-forums.php */
 467      $content = apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &$topic, &$topic ) );
 468  
 469      /** This filter is documented in bp-groups/bp-groups-forums.php */
 470      $filtered_primary_link = apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id );
 471  
 472      groups_record_activity( array(
 473          'id'                => $id,
 474          'action'            => $action,
 475          'content'           => $content,
 476          'primary_link'      => $filtered_primary_link,
 477          'type'              => 'new_forum_post',
 478          'item_id'           => (int) bp_get_current_group_id(),
 479          'user_id'           => (int) $post->poster_id,
 480          'secondary_item_id' => $post_id,
 481          'recorded_time'     => $post->post_time
 482      ) );
 483  
 484      /**
 485       * Fires after the update of a group forum post.
 486       *
 487       * @since 1.1.0
 488       *
 489       * @param object $post  Object holding current post being updated.
 490       * @param object $topic Object holding current topic details. Passed by reference.
 491       */
 492      do_action_ref_array( 'groups_update_group_forum_post', array( $post, &$topic ) );
 493  
 494      return $post_id;
 495  }
 496  
 497  /**
 498   * Delete a group forum topic and also any corresponding activity items.
 499   *
 500   * Uses the bundled version of bbPress packaged with BuddyPress.
 501   *
 502   * @since 1.1.0
 503   *
 504   * @param int $topic_id The ID of the topic to be deleted.
 505   * @return bool True if the delete routine went through properly.
 506   */
 507  function groups_delete_group_forum_topic( $topic_id ) {
 508      $bp = buddypress();
 509  
 510      // Before deleting the thread, get the post ids so that their activity items can be deleted.
 511      $posts  = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) );
 512      $action = bp_forums_delete_topic( array( 'topic_id' => $topic_id ) );
 513  
 514      if ( !empty( $action ) ) {
 515  
 516          /**
 517           * Fires before the deletion of a group forum topic.
 518           *
 519           * @since 1.2.9
 520           *
 521           * @param int $topic_id ID of the topic to be deleted.
 522           */
 523          do_action( 'groups_before_delete_group_forum_topic', $topic_id );
 524  
 525          // Delete the corresponding activity stream items.
 526          if ( bp_is_active( 'activity' ) ) {
 527  
 528              // The activity item for the initial topic.
 529              bp_activity_delete( array(
 530                  'item_id'           => bp_get_current_group_id(),
 531                  'secondary_item_id' => $topic_id,
 532                  'component'         => $bp->groups->id,
 533                  'type'              => 'new_forum_topic'
 534              ) );
 535  
 536              // The activity item for each post.
 537              foreach ( (array) $posts as $post ) {
 538                  bp_activity_delete( array(
 539                      'item_id'           => bp_get_current_group_id(),
 540                      'secondary_item_id' => $post->post_id,
 541                      'component'         => $bp->groups->id,
 542                      'type'              => 'new_forum_post'
 543                  ) );
 544              }
 545          }
 546  
 547          /**
 548           * Fires after the deletion of a group forum topic.
 549           *
 550           * @since 1.1.0
 551           *
 552           * @param int $topic_id ID of the topic that was deleted.
 553           */
 554          do_action( 'groups_delete_group_forum_topic', $topic_id );
 555      }
 556  
 557      return (bool) $action;
 558  }
 559  
 560  /**
 561   * Delete a group forum post and its corresponding activity item.
 562   *
 563   * Uses the bundled version of bbPress packaged with BuddyPress.
 564   *
 565   * @since 1.1.0
 566   *
 567   * @param int      $post_id  The ID of the post you want to delete.
 568   * @param int|bool $topic_id Optional. The topic to which the post belongs. This
 569   *                           value isn't used in the function but is passed along
 570   *                           to do_action() hooks.
 571   * @return bool True on success.
 572   */
 573  function groups_delete_group_forum_post( $post_id, $topic_id = false ) {
 574  
 575      $action = bp_forums_delete_post( array( 'post_id' => $post_id ) );
 576  
 577      if ( !empty( $action ) ) {
 578  
 579          /**
 580           * Fires before the deletion of a group forum post.
 581           *
 582           * @since 1.5.0
 583           *
 584           * @param int $post_id  ID of the post to be deleted.
 585           * @param int $topic_id ID of the associated topic.
 586           */
 587          do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
 588  
 589          // Delete the corresponding activity stream item.
 590          if ( bp_is_active( 'activity' ) ) {
 591              bp_activity_delete( array(
 592                  'item_id'           => bp_get_current_group_id(),
 593                  'secondary_item_id' => $post_id,
 594                  'component'         => buddypress()->groups->id,
 595                  'type'              => 'new_forum_post'
 596              ) );
 597          }
 598  
 599          /**
 600           * Fires after the deletion of a group forum post.
 601           *
 602           * @since 1.1.0
 603           *
 604           * @param int $post_id  ID of the post that was deleted.
 605           * @param int $topic_id ID of the associated topic.
 606           */
 607          do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
 608      }
 609  
 610      return (bool) $action;
 611  }
 612  
 613  /**
 614   * Get a total count of all public topics of a given type, across groups/forums.
 615   *
 616   * @since 1.5.0
 617   *
 618   * @param string $type Either 'newest', 'popular', 'unreplied', 'tags'.
 619   *                     Default: 'newest'.
 620   * @return int The topic count.
 621   */
 622  function groups_total_public_forum_topic_count( $type = 'newest' ) {
 623  
 624      /**
 625       * Filters the total count of all public topics of a given type, across groups/forums.
 626       *
 627       * @since 1.1.0
 628       *
 629       * @param int $value Total count of all public topics.
 630       */
 631      return apply_filters( 'groups_total_public_forum_topic_count', BP_Groups_Group::get_global_forum_topic_count( $type ) );
 632  }
 633  
 634  /**
 635   * Get a total count of all topics of a given status, across groups/forums.
 636   *
 637   * @since 1.5.0
 638   *
 639   * @param string      $status       Which groups to count. 'public', 'private', 'hidden',
 640   *                                  'all'. Default: 'public'.
 641   * @param string|bool $search_terms Optional. Limit by a search term.
 642   * @return int The topic count.
 643   */
 644  function groups_total_forum_topic_count( $status = 'public', $search_terms = false ) {
 645  
 646      /**
 647       * Filters the total count of all topics of a given status, across groups/forums.
 648       *
 649       * @since 1.5.0
 650       *
 651       * @param int $value Total count of all topics.
 652       */
 653      return apply_filters( 'groups_total_forum_topic_count', BP_Groups_Group::get_global_topic_count( $status, $search_terms ) );
 654  }


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1