Skip to:
Content

BuddyPress.org

Changeset 4596


Ignore:
Timestamp:
07/04/2011 02:07:08 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Introduce _has_directory() functions for forums, groups, members, and activity components. This replaces the need for enabling/disabling the forum directory, since if it is not set it does not exist.

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-functions.php

    r4590 r4596  
    99 * @subpackage Activity Core
    1010 */
     11
     12/**
     13 * Checks $bp pages global and looks for directory page
     14 *
     15 * @since 1.3
     16 *
     17 * @global object $bp Global BuddyPress settings object
     18 * @return bool True if set, False if empty
     19 */
     20function bp_activity_has_directory() {
     21    global $bp;
     22
     23    return (bool) !empty( $bp->pages->activity->id );
     24}
    1125
    1226/**
  • trunk/bp-blogs/bp-blogs-functions.php

    r4486 r4596  
    11<?php
    22
    3 /*******************************************************************************
    4  * Business functions are where all the magic happens in BuddyPress. They will
    5  * handle the actual saving or manipulation of information. Usually they will
    6  * hand off to a database class for data access, then return
    7  * true or false on success or failure.
    8  */
     3/**
     4 * Checks $bp pages global and looks for directory page
     5 *
     6 * @since 1.3
     7 *
     8 * @global object $bp Global BuddyPress settings object
     9 * @return bool True if set, False if empty
     10 */
     11function bp_blogs_has_directory() {
     12    global $bp;
     13
     14    return (bool) !empty( $bp->pages->blogs->id );
     15}
    916
    1017function bp_blogs_get_blogs( $args = '' ) {
  • trunk/bp-core/admin/bp-core-admin.php

    r4559 r4596  
    117117                        </td>
    118118                    </tr>
    119 
    120                     <?php if ( bp_is_active( 'forums' ) ) : ?>
    121 
    122                         <tr>
    123                             <th scope="row"><?php _e( 'Disable global forum directory?', 'buddypress' ) ?>:</th>
    124                             <td>
    125                                 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)bp_get_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    126                                 <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)bp_get_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    127                             </td>
    128                         </tr>
    129 
    130                     <?php endif; ?>
    131119
    132120                    <?php if ( bp_is_active( 'activity' ) ) : ?>
  • trunk/bp-core/bp-core-filters.php

    r4536 r4596  
    1919        $pages[] = $bp->pages->register->id;
    2020
    21     if ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && !bp_forums_is_installed_correctly() ) )
    22         if ( !empty( $bp->pages->forums ) )
    23             $pages[] = $bp->pages->forums->id;
     21    if ( !bp_is_active( 'forums' ) || ( bp_is_active( 'forums' ) && bp_forums_has_directory() && !bp_forums_is_installed_correctly() ) )
     22        $pages[] = $bp->pages->forums->id;
    2423
    2524    return apply_filters( 'bp_core_exclude_pages', $pages );
  • trunk/bp-core/bp-core-functions.php

    r4588 r4596  
    281281
    282282    // Add the administration tab under the "Site Admin" tab for site administrators
    283     $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '', 4 );
    284 
     283    $hooks[] = add_menu_page( __( 'BuddyPress', 'buddypress' ), __( 'BuddyPress', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup', '' );
    285284    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Components', 'buddypress' ), __( 'Components', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_component_setup'  );
    286285    $hooks[] = add_submenu_page( 'bp-general-settings', __( 'Settings',   'buddypress' ), __( 'Settings',   'buddypress' ), 'manage_options', 'bp-settings',         'bp_core_admin_settings'         );
     
    997996        'bp-disable-avatar-uploads'       => '0',
    998997        'bp-disable-account-deletion'     => '0',
    999         'bp-disable-forum-directory'      => '0',
    1000998        'bp-disable-blogforum-comments'   => '0',
    1001999        'bb-config-location'              => ABSPATH,
  • trunk/bp-core/bp-core-template.php

    r4559 r4596  
    248248        $options['blogs']   = __( 'Blogs',   'buddypress' );
    249249
    250     if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && !bp_forum_directory_is_disabled() )
     250    if ( bp_is_active( 'forums' ) && bp_forums_is_installed_correctly() && bp_forums_has_directory() )
    251251        $options['forums']  = __( 'Forums',  'buddypress' );
    252252
  • trunk/bp-forums/bp-forums-functions.php

    r4400 r4596  
    1212
    1313/**
    14  * Convenience function to determine if the forum directory has been disabled
    15  * by the site admin.
     14 * Checks $bp pages global and looks for directory page
     15 *
     16 * @since 1.3
    1617 *
    1718 * @global object $bp Global BuddyPress settings object
    18  * @return bool True if forum is disabled
    19  * @since 1.3
     19 * @return bool True if set, False if empty
    2020 */
    21 function bp_forum_directory_is_disabled() {
    22     global $bp;
    23 
    24     return !empty( $bp->site_options['bp-disable-forum-directory'] );
     21function bp_forums_has_directory() {
     22    global $bp;
     23
     24    return (bool) !empty( $bp->pages->forums->id );
    2525}
    2626
  • trunk/bp-forums/bp-forums-screens.php

    r4572 r4596  
    44
    55    if ( bp_is_forums_component() && ( !bp_current_action() || ( 'tag' == bp_current_action() && bp_action_variables() ) ) && !bp_current_item() ) {
    6         if ( bp_forum_directory_is_disabled() )
     6        if ( !bp_forums_has_directory() )
    77            return false;
    88
  • trunk/bp-groups/bp-groups-functions.php

    r4558 r4596  
    77 * true or false on success or failure.
    88 */
     9
     10/**
     11 * Checks $bp pages global and looks for directory page
     12 *
     13 * @since 1.3
     14 *
     15 * @global object $bp Global BuddyPress settings object
     16 * @return bool True if set, False if empty
     17 */
     18function bp_groups_has_directory() {
     19    global $bp;
     20
     21    return (bool) !empty( $bp->pages->groups->id );
     22}
    923
    1024function groups_get_group( $args = '' ) {
  • trunk/bp-members/bp-members-functions.php

    r4594 r4596  
    1010 */
    1111
     12/**
     13 * Checks $bp pages global and looks for directory page
     14 *
     15 * @since 1.3
     16 *
     17 * @global object $bp Global BuddyPress settings object
     18 * @return bool True if set, False if empty
     19 */
     20function bp_members_has_directory() {
     21    global $bp;
     22
     23    return (bool) !empty( $bp->pages->members->id );
     24}
    1225
    1326/**
  • trunk/bp-themes/bp-default/forums/single/edit.php

    r4322 r4596  
    1111                </li>
    1212
    13                 <?php if ( !bp_forum_directory_is_disabled() ) : ?>
     13                <?php if ( bp_forums_has_directory() ) : ?>
    1414
    1515                    <li>
  • trunk/bp-themes/bp-default/forums/single/forum.php

    r4452 r4596  
    2020                            </li>
    2121
    22                             <?php if ( !bp_forum_directory_is_disabled() ) : ?>
     22                            <?php if ( bp_forums_has_directory() ) : ?>
    2323
    2424                                <li>
  • trunk/bp-themes/bp-default/forums/single/topic.php

    r4347 r4596  
    3838                                </li>
    3939
    40                                 <?php if ( !bp_forum_directory_is_disabled() ) : ?>
     40                                <?php if ( bp_forums_has_directory() ) : ?>
    4141
    4242                                    <li>
  • trunk/bp-themes/bp-default/functions.php

    r4580 r4596  
    553553        'title_li'   => ''
    554554    );
    555 
    556     if ( ( !bp_is_active( 'forums' ) || bp_forum_directory_is_disabled() ) && !empty( $bp->pages->forums->id ) ) {
    557         if ( !empty( $pages_args['exclude'] ) )
    558                 $pages_args['exclude'] .= ',';
    559 
    560         $pages_args['exclude'] .= $bp->pages->forums->id;
    561     }
    562 
    563555    $menu = wp_page_menu( $pages_args );
    564556    $menu = str_replace( array( '<div class="menu"><ul>', '</ul></div>' ), array( '<ul id="nav">', '</ul><!-- #nav -->' ), $menu );
  • trunk/bp-themes/bp-default/groups/single/forum.php

    r4452 r4596  
    1818            </li>
    1919
    20             <?php if ( !bp_forum_directory_is_disabled() ) : ?>
     20            <?php if ( bp_forums_has_directory() ) : ?>
    2121
    2222                <li>
  • trunk/bp-themes/bp-default/groups/single/forum/edit.php

    r4322 r4596  
    1111                </li>
    1212
    13                 <?php if ( !bp_forum_directory_is_disabled() ) : ?>
     13                <?php if ( bp_forums_has_directory() ) : ?>
    1414
    1515                    <li>
  • trunk/bp-themes/bp-default/groups/single/forum/topic.php

    r4322 r4596  
    1111                </li>
    1212
    13                 <?php if ( !bp_forum_directory_is_disabled() ) : ?>
     13                <?php if ( bp_forums_has_directory() ) : ?>
    1414
    1515                    <li>
  • trunk/bp-xprofile/bp-xprofile-admin.php

    r4559 r4596  
    11<?php
     2
     3/**
     4 * Creates the administration interface menus and checks to see if the DB
     5 * tables are set up.
     6 *
     7 * @package BuddyPress XProfile
     8 * @global object $bp Global BuddyPress settings object
     9 * @global $wpdb WordPress DB access object.
     10 * @uses is_super_admin() returns true if the current user is a site admin, false if not
     11 * @uses bp_xprofile_install() runs the installation of DB tables for the xprofile component
     12 * @uses wp_enqueue_script() Adds a JS file to the JS queue ready for output
     13 * @uses add_submenu_page() Adds a submenu tab to a top level tab in the admin area
     14 * @uses xprofile_install() Runs the DB table installation function
     15 * @return
     16 */
     17function xprofile_add_admin_menu() {
     18    global $wpdb, $bp;
     19
     20    if ( !is_super_admin() )
     21        return false;
     22
     23    $hook = add_options_page( __( 'Profiles Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
     24   
     25    add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
     26}
     27add_action( bp_core_admin_hook(), 'xprofile_add_admin_menu' );
    228
    329/**
  • trunk/bp-xprofile/bp-xprofile-buddybar.php

    r4482 r4596  
    11<?php
    22
    3 /**
    4  * Creates the administration interface menus and checks to see if the DB
    5  * tables are set up.
    6  *
    7  * @package BuddyPress XProfile
    8  * @global object $bp Global BuddyPress settings object
    9  * @global $wpdb WordPress DB access object.
    10  * @uses is_super_admin() returns true if the current user is a site admin, false if not
    11  * @uses bp_xprofile_install() runs the installation of DB tables for the xprofile component
    12  * @uses wp_enqueue_script() Adds a JS file to the JS queue ready for output
    13  * @uses add_submenu_page() Adds a submenu tab to a top level tab in the admin area
    14  * @uses xprofile_install() Runs the DB table installation function
    15  * @return
    16  */
    17 function xprofile_add_admin_menu() {
    18     global $wpdb, $bp;
    19 
    20     if ( !is_super_admin() )
    21         return false;
    22 
    23     // Add the administration tab under the "Site Admin" tab for site administrators
    24     $hook = add_submenu_page( 'bp-general-settings', __( 'Profile Fields', 'buddypress' ), __( 'Profile Fields', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
    25     add_action( "admin_print_styles-$hook", 'bp_core_add_admin_menu_styles' );
    26 }
    27 add_action( bp_core_admin_hook(), 'xprofile_add_admin_menu' );
    28 
    29 /**
    30  * Adds an admin bar menu to any profile page providing site admin options
    31  * for that user.
    32  *
    33  * @package BuddyPress XProfile
    34  * @global $bp BuddyPress
    35  */
    36 function xprofile_setup_adminbar_menu() {
    37     global $bp;
    38 
    39     if ( !$bp->displayed_user->id )
    40         return false;
    41 
    42     // Don't show this menu to non site admins or if you're viewing your own profile
    43     if ( !is_super_admin() || bp_is_my_profile() )
    44         return false; ?>
    45 
    46     <li id="bp-adminbar-adminoptions-menu">
    47         <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    48 
    49         <ul>
    50             <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug; ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
    51             <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug; ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
    52 
    53             <?php if ( bp_is_active( 'settings' ) ) : ?>
    54 
    55                 <li><a href="<?php echo $bp->displayed_user->domain . $bp->settings->slug; ?>/general/"><?php printf( __( "Edit %s's Settings", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
    56 
    57             <?php endif; ?>
    58 
    59             <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
    60 
    61                 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
    62 
    63             <?php else : ?>
    64 
    65                 <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
    66 
    67             <?php endif; ?>
    68 
    69             <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
    70 
    71             <?php do_action( 'xprofile_adminbar_menu_items' ) ?>
    72 
    73         </ul>
    74     </li>
    75 
    76     <?php
    77 }
    78 //add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 );
     3// Nothing to see here
    794
    805?>
Note: See TracChangeset for help on using the changeset viewer.