Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/16/2009 09:38:39 AM (16 years ago)
Author:
apeatling
Message:

Added admin option to enable/disable activity comments on blog and forum threads. Moved the "View Thread" link into a more prominent position. Fixed some activity stream spacing issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-adminbar.php

    r2168 r2189  
    3737    global $bp;
    3838
    39     if ( !is_user_logged_in() ) {
    40         echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
    41 
    42         // Show "Sign Up" link if user registrations are allowed
    43         if ( get_site_option( 'registration' ) != 'none' && get_site_option( 'registration' ) != 'blog' ) {
    44             echo '<li class="bp-signup no-arrow"><a href="' . bp_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
    45         }
     39    if ( is_user_logged_in() )
     40        return false;
     41
     42    echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
     43
     44    // Show "Sign Up" link if user registrations are allowed
     45    if ( get_site_option( 'registration' ) != 'none' && get_site_option( 'registration' ) != 'blog' ) {
     46        echo '<li class="bp-signup no-arrow"><a href="' . bp_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
    4647    }
    4748}
     
    5152    global $bp;
    5253
    53     if ( !$bp->bp_nav )
    54         return false;
    55 
    56     if ( is_user_logged_in() ) {
    57 
    58         echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
    59 
    60         echo __( 'My Account', 'buddypress' ) . '</a>';
    61         echo '<ul>';
    62 
    63         /* Loop through each navigation item */
    64         $counter = 0;
    65         foreach( $bp->bp_nav as $nav_item ) {
    66             $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    67 
    68             echo '<li' . $alt . '>';
    69             echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
    70 
    71             if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) {
    72                 echo '<ul>';
    73                 $sub_counter = 0;
    74 
    75                 foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) {
    76                     $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    77                     echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
    78                     $sub_counter++;
    79                 }
    80                 echo '</ul>';
     54    if ( !$bp->bp_nav || !is_user_logged_in() )
     55        return false;
     56
     57    echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
     58
     59    echo __( 'My Account', 'buddypress' ) . '</a>';
     60    echo '<ul>';
     61
     62    /* Loop through each navigation item */
     63    $counter = 0;
     64    foreach( $bp->bp_nav as $nav_item ) {
     65        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
     66
     67        echo '<li' . $alt . '>';
     68        echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
     69
     70        if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) {
     71            echo '<ul>';
     72            $sub_counter = 0;
     73
     74            foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) {
     75                $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
     76                echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
     77                $sub_counter++;
    8178            }
    82 
    83             echo '</li>';
    84 
    85             $counter++;
     79            echo '</ul>';
    8680        }
    8781
    88         $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    89 
    90         if ( function_exists('wp_logout_url') ) {
    91             echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    92         } else {
    93             echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    94         }
    95 
    96         echo '</ul>';
    9782        echo '</li>';
    98     }
     83
     84        $counter++;
     85    }
     86
     87    $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
     88
     89    echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
     90    echo '</ul>';
     91    echo '</li>';
    9992}
    10093
     
    10497    // If the user is a site admin, just display admin.
    10598    if ( is_site_admin() )
    106         return __( 'Admin', 'buddypress');
     99        return __( 'Admin', 'buddypress' );
    107100
    108101    $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
     
    126119// *** "My Blogs" Menu ********
    127120function bp_adminbar_blogs_menu() {
    128     if ( is_user_logged_in() ) {
    129         global $bp;
    130 
    131         if ( function_exists('bp_blogs_install') ) {
    132 
    133             if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
    134                 $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id );
    135                 wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
     121    global $bp;
     122
     123    if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
     124        return false;
     125
     126    if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
     127        $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id );
     128        wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
     129    }
     130
     131    echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
     132
     133    _e( 'My Blogs', 'buddypress' );
     134
     135    echo '</a>';
     136    echo '<ul>';
     137
     138    if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
     139        $counter = 0;
     140        foreach ( $blogs['blogs'] as $blog ) {
     141            $role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->id );
     142
     143            $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
     144            echo '<li' . $alt . '>';
     145            echo '<a href="' . $blog->siteurl . '">' . $blog->name . ' (' . $role . ')</a>';
     146            if ( !( 'Subscriber' == $role ) ) { // then they have something to display on the flyout menu
     147                echo '<ul>';
     148                echo '<li class="alt"><a href="' . $blog->siteurl  . 'wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
     149                echo '<li><a href="' . $blog->siteurl  . 'wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
     150                echo '<li class="alt"><a href="' . $blog->siteurl  . 'wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
     151                echo '<li><a href="' . $blog->siteurl  . 'wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
     152                if ( 'Admin' == $role ) {
     153                    echo '<li class="alt"><a href="' . $blog->siteurl  . 'wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
     154                }
     155                echo '</ul>';
    136156            }
    137 
    138             echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
    139 
    140             _e( 'My Blogs', 'buddypress' );
    141 
     157            echo '</li>';
     158            $counter++;
     159        }
     160    }
     161
     162    $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
     163
     164    if ( bp_blog_signup_enabled() ) {
     165        echo '<li' . $alt . '>';
     166        echo '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog!', 'buddypress') . '</a>';
     167        echo '</li>';
     168    }
     169
     170    echo '</ul>';
     171    echo '</li>';
     172}
     173
     174// **** "Notifications" Menu *********
     175function bp_adminbar_notifications_menu() {
     176    global $bp;
     177
     178    if ( !is_user_logged_in() )
     179        return false;
     180
     181    echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
     182    _e( 'Notifications', 'buddypress' );
     183
     184    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
     185        <span><?php echo count($notifications) ?></span>
     186    <?php
     187    }
     188
     189    echo '</a>';
     190    echo '<ul>';
     191
     192    if ( $notifications ) { ?>
     193        <?php $counter = 0; ?>
     194        <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
     195            <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
     196            <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
     197            <?php $counter++; ?>
     198        <?php } ?>
     199    <?php } else { ?>
     200        <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
     201    <?php
     202    }
     203
     204    echo '</ul>';
     205    echo '</li>';
     206}
     207
     208// **** "Blog Authors" Menu (visible when not logged in) ********
     209function bp_adminbar_authors_menu() {
     210    global $bp, $current_blog;
     211
     212    if ( $current_blog->id == $bp->root_blog || !function_exists( 'bp_blogs_install' ) )
     213        return false;
     214
     215    $authors = get_users_of_blog();
     216
     217    if ( is_array( $authors ) ) {
     218        /* This is a blog, render a menu with links to all authors */
     219        echo '<li id="bp-adminbar-authors-menu"><a href="/">';
     220        _e('Blog Authors', 'buddypress');
     221        echo '</a>';
     222
     223        echo '<ul class="author-list">';
     224        foreach( $authors as $author ) {
     225            $author = new BP_Core_User( $author->user_id );
     226            echo '<li>';
     227
     228            echo '<a href="' . $author->user_url . '">';
     229            echo $author->avatar_mini;
     230            echo ' ' . $author->fullname;
     231            echo '<span class="activity">' . $author->last_active . '</span>';
    142232            echo '</a>';
    143             echo '<ul>';
    144 
    145             if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
    146                 $counter = 0;
    147                 foreach ( $blogs['blogs'] as $blog ) {
    148                     $role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->id );
    149 
    150                     $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    151                     echo '<li' . $alt . '>';
    152                     echo '<a href="' . $blog->siteurl . '">' . $blog->name . ' (' . $role . ')</a>';
    153                     if ( !( 'Subscriber' == $role ) ) { // then they have something to display on the flyout menu
    154                         echo '<ul>';
    155                         echo '<li class="alt"><a href="' . $blog->siteurl  . 'wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
    156                         echo '<li><a href="' . $blog->siteurl  . 'wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
    157                         echo '<li class="alt"><a href="' . $blog->siteurl  . 'wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
    158                         echo '<li><a href="' . $blog->siteurl  . 'wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
    159                         if ( 'Admin' == $role ) {
    160                             echo '<li class="alt"><a href="' . $blog->siteurl  . 'wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
    161                         }
    162                         echo '</ul>';
    163                     }
    164                     echo '</li>';
    165                     $counter++;
    166                 }
    167             }
    168 
    169             $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    170 
    171             if ( bp_blog_signup_enabled() ) {
    172                 echo '<li' . $alt . '>';
    173                 echo '<a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/create-a-blog">' . __('Create a Blog!', 'buddypress') . '</a>';
    174                 echo '</li>';
    175             }
    176 
    177             echo '</ul>';
     233            echo '<div class="admin-bar-clear"></div>';
    178234            echo '</li>';
    179235        }
    180     }
    181 }
    182 
    183 // **** "Notifications" Menu *********
    184 function bp_adminbar_notifications_menu() {
    185     if ( is_user_logged_in() ) {
    186         global $bp;
    187 
    188         echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
    189         _e( 'Notifications', 'buddypress' );
    190 
    191         if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    192             <span><?php echo count($notifications) ?></span>
    193         <?php
    194         }
    195 
    196         echo '</a>';
    197         echo '<ul>';
    198 
    199         if ( $notifications ) { ?>
    200             <?php $counter = 0; ?>
    201             <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
    202                 <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
    203                 <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
    204                 <?php $counter++; ?>
    205             <?php } ?>
    206         <?php } else { ?>
    207             <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
    208         <?php
    209         }
    210 
    211236        echo '</ul>';
    212237        echo '</li>';
    213     }
    214 }
    215 
    216 // **** "Blog Authors" Menu (visible when not logged in) ********
    217 function bp_adminbar_authors_menu() {
    218     global $current_blog;
    219 
    220     if ( $current_blog->blog_id > 1 ) {
    221         $authors = get_users_of_blog();
    222 
    223         if ( is_array( $authors ) ) {
    224             /* This is a blog, render a menu with links to all authors */
    225             echo '<li id="bp-adminbar-authors-menu"><a href="/">';
    226             _e('Blog Authors', 'buddypress');
    227             echo '</a>';
    228 
    229             echo '<ul class="author-list">';
    230             foreach( $authors as $author ) {
    231                 $author = new BP_Core_User( $author->user_id );
    232                 echo '<li>';
    233 
    234                 echo '<a href="' . $author->user_url . '">';
    235                 echo $author->avatar_mini;
    236                 echo ' ' . $author->fullname;
    237                 echo '<span class="activity">' . $author->last_active . '</span>';
    238                 echo '</a>';
    239                 echo '<div class="admin-bar-clear"></div>';
    240                 echo '</li>';
    241             }
    242             echo '</ul>';
    243             echo '</li>';
    244         }
    245238    }
    246239}
     
    271264}
    272265
    273 
    274266add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
    275267add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
    276268add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
    277 
    278 if ( function_exists('bp_blogs_install') )
    279     add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
    280 
     269add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
    281270add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
    282 
    283 if ( function_exists('bp_blogs_install') )
    284     add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
    285 
     271add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
    286272add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
    287273
Note: See TracChangeset for help on using the changeset viewer.