Skip to:
Content

bbPress.org

Changeset 3678


Ignore:
Timestamp:
01/17/2012 08:50:29 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Add forum author functions, and rename bbp_get_forum_parent() to bbp_get_forum_parent_id(). See #1669.

Location:
branches/plugin/bbp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-functions.php

    r3675 r3678  
    345345 * @uses wp_save_post_revision() To save a forum revision
    346346 * @uses bbp_update_forum_revision_log() To update the forum revision log
    347  * @uses bbp_stick_forum() To stick or super stick the forum
    348  * @uses bbp_unstick_forum() To unstick the forum
    349347 * @uses wp_update_post() To update the forum
    350348 * @uses do_action() Calls 'bbp_edit_forum' with the forum id, forum id,
     
    393391        check_admin_referer( 'bbp-edit-forum_' . $forum_id );
    394392
    395         // Check users ability to create new forum
    396         if ( !bbp_is_forum_anonymous( $forum_id ) ) {
    397 
    398             // User cannot edit this forum
    399             if ( !current_user_can( 'edit_forum', $forum_id ) ) {
    400                 bbp_add_error( 'bbp_edit_forum_permissions', __( '<strong>ERROR</strong>: You do not have permission to edit that forum.', 'bbpress' ) );
    401             }
    402 
    403         // It is an anonymous post
    404         } else {
    405 
    406             // Filter anonymous data
    407             $anonymous_data = bbp_filter_anonymous_post_data( array(), true );
     393        // User cannot edit this forum
     394        if ( !current_user_can( 'edit_forum', $forum_id ) ) {
     395            bbp_add_error( 'bbp_edit_forum_permissions', __( '<strong>ERROR</strong>: You do not have permission to edit that forum.', 'bbpress' ) );
    408396        }
    409397    }
     
    423411
    424412    // Current forum this forum is in
    425     $current_parent_forum_id = bbp_get_forum_parent( $forum_id );
     413    $current_parent_forum_id = bbp_get_forum_parent_id( $forum_id );
    426414
    427415    // Forum exists
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r3662 r3678  
    552552
    553553/**
    554  * Return ID of forum parent, if exists
    555  *
    556  * @since bbPress (r2625)
    557  *
    558  * @param int $forum_id Optional. Forum id
    559  * @uses bbp_get_forum_id() To get the forum id
    560  * @uses get_post_field() To get the forum parent
    561  * @uses apply_filters() Calls 'bbp_get_forum_parent' with the parent & forum id
    562  * @return int Forum parent
    563  */
    564 function bbp_get_forum_parent( $forum_id = 0 ) {
    565     $forum_id  = bbp_get_forum_id( $forum_id );
    566     $parent_id = get_post_field( 'post_parent', $forum_id );
    567 
    568     return (int) apply_filters( 'bbp_get_forum_parent', (int) $parent_id, $forum_id );
    569 }
     554 * Output parent ID of a forum, if exists
     555 *
     556 * @since bbPress (r3675)
     557 *
     558 * @param int $forum_id Forum ID
     559 * @uses bbp_get_forum_parent_id() To get the forum's parent ID
     560 */
     561function bbp_forum_parent_id( $forum_id = 0 ) {
     562    echo bbp_get_forum_parent_id( $forum_id );
     563}
     564    /**
     565     * Return ID of forum parent, if exists
     566     *
     567     * @since bbPress (r3675)
     568     *
     569     * @param int $forum_id Optional. Forum id
     570     * @uses bbp_get_forum_id() To get the forum id
     571     * @uses get_post_field() To get the forum parent
     572     * @uses apply_filters() Calls 'bbp_get_forum_parent' with the parent & forum id
     573     * @return int Forum parent
     574     */
     575    function bbp_get_forum_parent_id( $forum_id = 0 ) {
     576        $forum_id  = bbp_get_forum_id( $forum_id );
     577        $parent_id = get_post_field( 'post_parent', $forum_id );
     578
     579        return (int) apply_filters( 'bbp_get_forum_parent_id', (int) $parent_id, $forum_id );
     580    }
    570581
    571582/**
     
    15711582
    15721583/**
     1584 * Output the author of the forum
     1585 *
     1586 * @since bbPress (r3675)
     1587 *
     1588 * @param int $forum_id Optional. Forum id
     1589 * @uses bbp_get_forum_author() To get the forum author
     1590 */
     1591function bbp_forum_author_display_name( $forum_id = 0 ) {
     1592    echo bbp_get_forum_author_display_name( $forum_id );
     1593}
     1594    /**
     1595     * Return the author of the forum
     1596     *
     1597     * @since bbPress (r3675)
     1598     *
     1599     * @param int $forum_id Optional. Forum id
     1600     * @uses bbp_get_forum_id() To get the forum id
     1601     * @uses bbp_get_forum_author_id() To get the forum author id
     1602     * @uses get_the_author_meta() To get the display name of the author
     1603     * @uses apply_filters() Calls 'bbp_get_forum_author' with the author
     1604     *                        and forum id
     1605     * @return string Author of forum
     1606     */
     1607    function bbp_get_forum_author_display_name( $forum_id = 0 ) {
     1608        $forum_id = bbp_get_forum_id( $forum_id );
     1609        $author   = get_the_author_meta( 'display_name', bbp_get_forum_author_id( $forum_id ) );
     1610
     1611        return apply_filters( 'bbp_get_forum_author_display_name', $author, $forum_id );
     1612    }
     1613
     1614/**
     1615 * Output the author ID of the forum
     1616 *
     1617 * @since bbPress (r3675)
     1618 *
     1619 * @param int $forum_id Optional. Forum id
     1620 * @uses bbp_get_forum_author_id() To get the forum author id
     1621 */
     1622function bbp_forum_author_id( $forum_id = 0 ) {
     1623    echo bbp_get_forum_author_id( $forum_id );
     1624}
     1625    /**
     1626     * Return the author ID of the forum
     1627     *
     1628     * @since bbPress (r3675)
     1629     *
     1630     * @param int $forum_id Optional. Forum id
     1631     * @uses bbp_get_forum_id() To get the forum id
     1632     * @uses get_post_field() To get the forum author id
     1633     * @uses apply_filters() Calls 'bbp_get_forum_author_id' with the author
     1634     *                        id and forum id
     1635     * @return string Author of forum
     1636     */
     1637    function bbp_get_forum_author_id( $forum_id = 0 ) {
     1638        $forum_id  = bbp_get_forum_id( $forum_id );
     1639        $author_id = get_post_field( 'post_author', $forum_id );
     1640
     1641        return (int) apply_filters( 'bbp_get_forum_author_id', (int) $author_id, $forum_id );
     1642    }
     1643
     1644/**
    15731645 * Replace forum meta details for users that cannot view them.
    15741646 *
Note: See TracChangeset for help on using the changeset viewer.