Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/09/2012 11:00:59 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Audit the usage of $bp->is_item_admin and $bp->is_item_mod to use the _is_ functions isntead. Also fix some $bp globals in the process. See #3989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-template.php

    r5673 r5687  
    303303        return true;
    304304
    305     if ( !$group )
     305    if ( empty( $group ) )
    306306        $group =& $groups_template->group;
    307307
     
    323323        global $groups_template;
    324324
    325         if ( !$group )
     325        if ( empty( $group ) )
    326326            $group =& $groups_template->group;
    327327
     
    335335        global $groups_template;
    336336
    337         if ( !$group )
     337        if ( empty( $group ) )
    338338            $group =& $groups_template->group;
    339339
     
    347347        global $groups_template;
    348348
    349         if ( !$group )
     349        if ( empty( $group ) )
    350350            $group =& $groups_template->group;
    351351
     
    369369        global $groups_template;
    370370
    371         if ( !$group )
     371        if ( empty( $group ) )
    372372            $group =& $groups_template->group;
    373373
     
    420420        global $groups_template;
    421421
    422         if ( !$group )
     422        if ( empty( $group ) )
    423423            $group =& $groups_template->group;
    424424
     
    441441        global $groups_template, $bp;
    442442
    443         if ( !$group )
     443        if ( empty( $group ) )
    444444            $group =& $groups_template->group;
    445445
     
    453453        global $groups_template, $bp;
    454454
    455         if ( !$group )
     455        if ( empty( $group ) )
    456456            $group =& $groups_template->group;
    457457
     
    465465        global $groups_template;
    466466
    467         if ( !$group )
     467        if ( empty( $group ) )
    468468            $group =& $groups_template->group;
    469469
     
    477477        global $groups_template;
    478478
    479         if ( !$group )
     479        if ( empty( $group ) )
    480480            $group =& $groups_template->group;
    481481
     
    489489        global $groups_template;
    490490
    491         if ( !$group )
     491        if ( empty( $group ) )
    492492            $group =& $groups_template->group;
    493493
     
    501501        global $groups_template;
    502502
    503         if ( !$group )
     503        if ( empty( $group ) )
    504504            $group =& $groups_template->group;
    505505
     
    514514        global $groups_template;
    515515
    516         if ( !$group )
     516        if ( empty( $group ) )
    517517            $group =& $groups_template->group;
    518518
     
    530530        global $groups_template;
    531531
    532         if ( !$group )
     532        if ( empty( $group ) )
    533533            $group =& $groups_template->group;
    534534
     
    542542        global $groups_template;
    543543
    544         if ( !$group )
     544        if ( empty( $group ) )
    545545            $group =& $groups_template->group;
    546546
     
    549549
    550550function bp_group_is_admin() {
    551     global $bp;
    552 
    553     return $bp->is_item_admin;
     551    return bp_is_item_admin();
    554552}
    555553
    556554function bp_group_is_mod() {
    557     global $bp;
    558 
    559     return $bp->is_item_mod;
     555    return bp_is_item_mod();
    560556}
    561557
     
    563559    global $groups_template;
    564560
    565     if ( !$group )
     561    if ( empty( $group ) )
    566562        $group =& $groups_template->group;
    567563
     
    621617    global $groups_template;
    622618
    623     if ( !$group )
     619    if ( empty( $group ) )
    624620        $group =& $groups_template->group;
    625621
     
    651647    global $groups_template;
    652648
    653     if ( !$group )
     649    if ( empty( $group ) )
    654650        $group =& $groups_template->group;
    655651
     
    674670        global $groups_template, $bp;
    675671
    676         if ( !$group )
     672        if ( empty( $group ) )
    677673            $group =& $groups_template->group;
    678674
     
    747743        global $groups_template;
    748744
    749         if ( !$group )
     745        if ( empty( $group ) )
    750746            $group =& $groups_template->group;
    751747
     
    771767        global $groups_template;
    772768
    773         if ( !$group )
     769        if ( empty( $group ) )
    774770            $group =& $groups_template->group;
    775771
     
    848844    global $groups_template;
    849845
    850     if ( !$group )
     846    if ( empty( $group ) )
    851847        $group =& $groups_template->group;
    852848
     
    868864    global $groups_template;
    869865
    870     if ( !$group )
     866    if ( empty( $group ) )
    871867        $group =& $groups_template->group;
    872868
     
    878874    global $groups_template;
    879875
    880     if ( !$group )
     876    if ( empty( $group ) )
    881877        $group =& $groups_template->group;
    882878
     
    11441140    global $group_mods, $groups_template;
    11451141
    1146     if ( !$group )
     1142    if ( empty( $group ) )
    11471143        $group =& $groups_template->group;
    11481144
     
    11951191        global $members_template, $groups_template, $bp;
    11961192
    1197         if ( !$group )
     1193        if ( empty( $group ) )
    11981194            $group =& $groups_template->group;
    11991195
     
    12151211        global $members_template, $groups_template, $bp;
    12161212
    1217         if ( !$group )
     1213        if ( empty( $group ) )
    12181214            $group =& $groups_template->group;
    12191215
     
    12351231            $user_id = $members_template->member->user_id;
    12361232
    1237         if ( !$group )
     1233        if ( empty( $group ) )
    12381234            $group =& $groups_template->group;
    12391235
     
    12531249        global $members_template, $groups_template;
    12541250
    1255         if ( !$group )
     1251        if ( empty( $group ) )
    12561252            $group =& $groups_template->group;
    12571253
     
    12621258    global $bp, $groups_template;
    12631259
    1264     if ( !$group )
     1260    if ( empty( $group ) )
    12651261        $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group;
    12661262
    12671263    $current_tab = bp_action_variable( 0 );
    1268 ?>
    1269     <?php if ( $bp->is_item_admin || $bp->is_item_mod ) { ?>
     1264
     1265    if ( bp_is_item_admin() || bp_is_item_mod() ) : ?>
     1266
    12701267        <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/edit-details' ) ?>"><?php _e( 'Details', 'buddypress' ); ?></a></li>
    1271     <?php } ?>
    1272 
    1273     <?php
    1274         if ( !$bp->is_item_admin )
    1275             return false;
    1276     ?>
     1268
     1269    <?php endif; ?>
     1270
     1271    <?php if ( ! bp_is_item_admin() )
     1272            return false; ?>
     1273
    12771274    <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
    12781275
    12791276    <?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) : ?>
     1277
    12801278        <li<?php if ( 'group-avatar'   == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/group-avatar' ) ?>"><?php _e( 'Avatar', 'buddypress' ); ?></a></li>
     1279
    12811280    <?php endif; ?>
    12821281
     
    12841283
    12851284    <?php if ( $groups_template->group->status == 'private' ) : ?>
     1285
    12861286        <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/membership-requests' ) ?>"><?php _e( 'Requests', 'buddypress' ); ?></a></li>
     1287
    12871288    <?php endif; ?>
    12881289
     
    12901291
    12911292    <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/delete-group' ) ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></li>
     1293
    12921294<?php
    12931295}
     
    13041306}
    13051307    function bp_get_group_form_action( $page, $group = false ) {
    1306         global $bp, $groups_template;
    1307 
    1308         if ( !$group )
     1308        global $groups_template;
     1309
     1310        if ( empty( $group ) )
    13091311            $group =& $groups_template->group;
    13101312
     
    13181320        global $groups_template;
    13191321
    1320         if ( !$group )
    1321             $group =& $groups_template->group;
    1322 
    1323         if ( !$page )
     1322        if ( empty( $group ) )
     1323            $group =& $groups_template->group;
     1324
     1325        if ( empty( $page ) )
    13241326            $page = bp_action_variable( 0 );
    13251327
     
    13301332    global $groups_template;
    13311333
    1332     if ( !$group )
     1334    if ( empty( $group ) )
    13331335        $group =& $groups_template->group;
    13341336
     
    13471349 * @uses apply_filters Creates bp_group_is_member filter and passes $is_member
    13481350 * @usedby groups/activity.php, groups/single/forum/edit.php, groups/single/forum/topic.php to determine template part visibility
    1349  * @global array $bp BuddyPress Master global
    13501351 * @global object $groups_template Current Group (usually in template loop)
    13511352 * @param object $group Group to check is_member
     
    13531354 */
    13541355function bp_group_is_member( $group = false ) {
    1355     global $bp, $groups_template;
     1356    global $groups_template;
    13561357
    13571358    // Site admins always have access
     
    13591360        return true;
    13601361
    1361     if ( !$group )
     1362    if ( empty( $group ) )
    13621363        $group =& $groups_template->group;
    13631364
     
    13851386        return false;
    13861387
    1387     if ( !$group ) {
     1388    if ( empty( $group ) ) {
    13881389        $group =& $groups_template->group;
    13891390
     
    14041405        global $groups_template, $bp;
    14051406
    1406         if ( !$group )
     1407        if ( empty( $group ) )
    14071408            $group =& $groups_template->group;
    14081409
     
    14161417        global $groups_template, $bp;
    14171418
    1418         if ( !$group )
     1419        if ( empty( $group ) )
    14191420            $group =& $groups_template->group;
    14201421
     
    14261427}
    14271428    function bp_get_group_leave_confirm_link( $group = false ) {
    1428         global $groups_template, $bp;
    1429 
    1430         if ( !$group )
     1429        global $groups_template;
     1430
     1431        if ( empty( $group ) )
    14311432            $group =& $groups_template->group;
    14321433
     
    14381439}
    14391440    function bp_get_group_leave_reject_link( $group = false ) {
    1440         global $groups_template, $bp;
    1441 
    1442         if ( !$group )
     1441        global $groups_template;
     1442
     1443        if ( empty( $group ) )
    14431444            $group =& $groups_template->group;
    14441445
     
    14501451}
    14511452    function bp_get_group_send_invite_form_action( $group = false ) {
    1452         global $groups_template, $bp;
    1453 
    1454         if ( !$group )
     1453        global $groups_template;
     1454
     1455        if ( empty( $group ) )
    14551456            $group =& $groups_template->group;
    14561457
     
    14591460
    14601461function bp_has_friends_to_invite( $group = false ) {
    1461     global $groups_template, $bp;
     1462    global $groups_template;
    14621463
    14631464    if ( !bp_is_active( 'friends' ) )
    14641465        return false;
    14651466
    1466     if ( !$group )
     1467    if ( empty( $group ) )
    14671468        $group =& $groups_template->group;
    14681469
     
    14741475
    14751476function bp_group_new_topic_button( $group = false ) {
    1476     echo bp_get_group_new_topic_button();
     1477    echo bp_get_group_new_topic_button( $group );
    14771478}
    14781479    function bp_get_group_new_topic_button( $group = false ) {
    14791480        global $groups_template;
    14801481
    1481         if ( !$group )
     1482        if ( empty( $group ) )
    14821483            $group =& $groups_template->group;
    14831484
     
    15061507}
    15071508    function bp_get_group_join_button( $group = false ) {
    1508         global $bp, $groups_template;
    1509 
    1510         if ( !$group )
     1509        global $groups_template;
     1510
     1511        if ( empty( $group ) )
    15111512            $group =& $groups_template->group;
    15121513
     
    16871688
    16881689    function __construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude ) {
    1689         global $bp;
    16901690
    16911691        $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;
    1692         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    1693 
    1694         $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude );
     1692        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     1693        $this->members  = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude );
    16951694
    16961695        if ( !$max || $max >= (int)$this->members['count'] )
     
    17561755
    17571756    function the_member() {
    1758         global $member;
    17591757
    17601758        $this->in_the_loop = true;
    1761         $this->member = $this->next_member();
     1759        $this->member      = $this->next_member();
    17621760
    17631761        if ( 0 == $this->current_member ) // loop has just started
     
    17671765
    17681766function bp_group_has_members( $args = '' ) {
    1769     global $bp, $members_template;
     1767    global $members_template;
    17701768
    17711769    $defaults = array(
     
    18781876}
    18791877    function bp_get_group_member_is_banned() {
    1880         global $members_template, $groups_template;
     1878        global $members_template;
    18811879
    18821880        return apply_filters( 'bp_get_group_member_is_banned', $members_template->member->is_banned );
     
    19211919}
    19221920    function bp_get_group_pag_id() {
    1923         global $bp;
    1924 
    19251921        return apply_filters( 'bp_get_group_pag_id', 'pag' );
    19261922    }
     
    22622258
    22632259function bp_directory_groups_search_form() {
    2264     global $bp;
    22652260
    22662261    $default_search_value = bp_get_search_default_text( 'groups' );
     
    22822277 */
    22832278function bp_groups_header_tabs() {
    2284     global $create_group_step, $completed_to_step;
    2285 ?>
     2279    global $bp;?>
     2280
    22862281    <li<?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $bp->displayed_user->domain . bp_get_groups_slug() . '/my-groups/recently-active' ) ?>"><?php _e( 'Recently Active', 'buddypress' ) ?></a></li>
    22872282    <li<?php if ( bp_is_action_variable( 'recently-joined', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $bp->displayed_user->domain . bp_get_groups_slug() . '/my-groups/recently-joined' ) ?>"><?php _e( 'Recently Joined', 'buddypress' ) ?></a></li>
     
    22902285    <li<?php if ( bp_is_action_variable( 'mod-of', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $bp->displayed_user->domain . bp_get_groups_slug() . '/my-groups/mod-of' ) ?>"><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
    22912286    <li<?php if ( bp_is_action_variable( 'alphabetically' ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $bp->displayed_user->domain . bp_get_groups_slug() . '/my-groups/alphabetically' ) ?>"><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
     2287
    22922288<?php
    22932289    do_action( 'groups_header_tabs' );
     
    24172413    function __construct( $group_id, $per_page, $max ) {
    24182414
    2419         global $bp;
    2420 
    24212415        $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;
    2422         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    2423 
     2416        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    24242417        $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );
    24252418
     
    24862479
    24872480    function the_request() {
    2488         global $request;
    2489 
    24902481        $this->in_the_loop = true;
    2491         $this->request = $this->next_request();
     2482        $this->request     = $this->next_request();
    24922483
    24932484        if ( 0 == $this->current_request ) // loop has just started
     
    25912582
    25922583    function __construct( $user_id, $group_id ) {
    2593 
    2594         global $bp;
    2595 
    2596         $this->invites = groups_get_invites_for_group( $user_id, $group_id );
     2584        $this->invites      = groups_get_invites_for_group( $user_id, $group_id );
    25972585        $this->invite_count = count( $this->invites );
    2598 
    25992586    }
    26002587
     
    26332620
    26342621    function the_invite() {
    2635         global $invite, $group_id;
    2636 
    2637         $this->in_the_loop = true;
    2638         $user_id = $this->next_invite();
    2639 
    2640         $this->invite = new stdClass;
    2641         $this->invite->user = new BP_Core_User( $user_id );
     2622        global $group_id;
     2623
     2624        $this->in_the_loop      = true;
     2625        $user_id                = $this->next_invite();
     2626        $this->invite           = new stdClass;
     2627        $this->invite->user     = new BP_Core_User( $user_id );
    26422628        $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites()
    26432629
Note: See TracChangeset for help on using the changeset viewer.