Skip to:
Content

BuddyPress.org

Changeset 580


Ignore:
Timestamp:
11/26/2008 10:49:51 PM (13 years ago)
Author:
apeatling
Message:
  • Added group directory to browse newest groups, groups by letter and search all groups. Also shows featured groups in the sidebar.
  • Changed buttons from images to background images and text to provide better translation options
  • Modified member theme to re-use get_header() and get_footer() - custom themes will need to be updated
  • Fixed bug with wp_redirect() and bp_core_do_catch_uri() clashing
Location:
trunk
Files:
10 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r561 r580  
    167167    /* Add the subnav items to the activity nav item */
    168168    bp_core_add_subnav_item( $bp['activity']['slug'], 'just-me', __('Just Me', 'buddypress'), $activity_link, 'bp_activity_screen_my_activity' );
    169     bp_core_add_subnav_item( $bp['activity']['slug'], 'my-friends', __('My Friends', 'buddypress'), $activity_link, 'bp_activity_screen_friends_activity' );
     169    bp_core_add_subnav_item( $bp['activity']['slug'], 'my-friends', __('My Friends', 'buddypress'), $activity_link, 'bp_activity_screen_friends_activity', false, bp_is_home() );
    170170   
    171171    if ( $bp['current_component'] == $bp['activity']['slug'] ) {
  • trunk/bp-blogs.php

    r528 r580  
    533533        $blog_id = bp_blogs_get_random_blog();
    534534
    535         wp_redirect( get_blog_option( $blog_id, 'siteurl') );
     535        bp_core_redirect( get_blog_option( $blog_id, 'siteurl') );
    536536    }
    537537}
  • trunk/bp-core.php

    r577 r580  
    479479
    480480        $ud = get_userdata( $user_id );
    481         wp_redirect( $bp['root_domain'] . '/' . MEMBERS_SLUG . '/' . $ud->user_login );
     481        bp_core_redirect( $bp['root_domain'] . '/' . MEMBERS_SLUG . '/' . $ud->user_login );
    482482    }
    483483}
     
    981981   
    982982    return $wpdb->get_var( $wpdb->prepare( "SELECT path FROM {$wpdb->base_prefix}site WHERE id = 1") );
     983}
     984
     985
     986function bp_core_redirect( $location, $status = 302 ) {
     987    global $bp_no_status_set;
     988   
     989    // Make sure we don't call status_header() in bp_core_do_catch_uri()
     990    // as this conflicts with wp_redirect()
     991    $bp_no_status_set = true;
     992   
     993    wp_redirect( $location, $status );
    983994}
    984995
  • trunk/bp-core/bp-core-avatars.php

    r531 r580  
    4141            return $url;
    4242        else
    43             return '<img src="' . $url . '" alt="" class="avatar" width="' . $width . '" height="' . $height . '" />';
     43            return '<img src="' . $url . '" alt="" class="avatar photo" width="' . $width . '" height="' . $height . '" />';
    4444    } else {
    4545        $identicon = 'http://www.gravatar.com/avatar/' . md5( $user . '@buddypress.org') . '?d=wavatar&amp;s=';
  • trunk/bp-core/bp-core-catchuri.php

    r571 r580  
    171171    global $bp_path, $bp, $wpdb;
    172172    global $current_blog, $bp_skip_blog_check;
    173 
     173    global $bp_no_status_set;
     174   
    174175    $pages = $bp_path;
    175176   
     
    180181    }
    181182   
    182     if ( !file_exists( TEMPLATEPATH . "/header.php" ) || !file_exists( TEMPLATEPATH . "/footer.php" ) )
    183         wp_redirect( $bp['root_domain'] );
    184 
    185183    /* Make sure this is not reported as a 404 */
    186     // This is causing too many problems right now.
    187     header( "Status: 200 OK", true, 200 );
    188        
    189     do_action( 'get_header' );
    190     load_template( TEMPLATEPATH . "/header.php" );
    191 
     184    if ( !$bp_no_status_set ) {
     185        status_header( 200 );
     186    }
     187   
    192188    if ( is_array( $pages ) ) {
    193189        foreach( $pages as $page ) {
     
    201197        } else {
    202198            if ( file_exists( TEMPLATEPATH . "/404.php" ) ) {
     199                status_header( 404 );
    203200                load_template( TEMPLATEPATH . "/404.php" );
    204201            } else if ( file_exists( TEMPLATEPATH . "/home.php" ) ) {
     
    206203            } else {
    207204                load_template( TEMPLATEPATH . "/index.php" );
    208             }   
    209         }
    210     }
    211 
    212     do_action( 'get_footer' );
    213     load_template( TEMPLATEPATH . "/footer.php" );
     205            }
     206        }
     207    }
    214208    die;
    215209}
  • trunk/bp-core/bp-core-notifications.php

    r502 r580  
    1414    $notification->date_notified = $date_notified;
    1515    $notification->is_new = 1;
    16    
     16
    1717    if ( $secondary_item_id )
    1818        $notification->secondary_item_id = $secondary_item_id;
  • trunk/bp-core/bp-core-widgets.php

    r574 r580  
    109109        <ul id="members-list" class="item-list">
    110110            <?php foreach ( (array) $users['users'] as $user ) : ?>
    111                 <li>
     111                <li class="vcard">
    112112                    <div class="item-avatar">
    113113                        <?php echo bp_core_get_avatar( $user->user_id, 1 ) ?>
     
    115115
    116116                    <div class="item">
    117                         <div class="item-title"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
     117                        <div class="item-title fn"><?php echo bp_core_get_userlink( $user->user_id ) ?></div>
    118118                        <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( $user->user_registered, __('registered %s ago', 'buddypress') ) ?></span></div>
    119119                    </div>
  • trunk/bp-core/css/directory-members.css

    r574 r580  
    7575        }
    7676   
    77     ul#members-list li a.add, ul#members-list li a.remove, ul#members-list li div.pending {
    78         background: url(../images/add_friend_button.gif) top left no-repeat;
    79         text-indent: -999em;
    80         display: block;
    81         overflow: hidden;
    82         width: 102px;
    83         text-align: left;
    84     }
    85    
    86     ul#members-list li a.remove {
    87         background: url(../images/remove_friend_button.gif) top left no-repeat;
    88         width: 121px;
    89     }
    90 
    91     ul#members-list li div.pending {
    92         background: url(../images/requested_friend_button.gif) top left no-repeat;
    93         width: 136px;
    94     }
    95    
    9677/* Search Form */
    9778
     
    140121}
    141122
     123/* Buttons */
     124
     125.friendship-button {
     126    background: url(../../bp-core/images/button_back.gif) top left no-repeat;
     127    display: inline-block;
     128    margin-bottom: 10px;
     129}
     130
     131.friendship-button a {
     132    display: block;
     133    height: 19px;
     134    color: #777;
     135    font-size: 11px;
     136    padding: 0 33px 0 11px;
     137    margin-right: -7px;
     138    text-shadow: 0 1px 0 #fff;
     139    text-decoration: none;
     140}
     141    .friendship-button a:hover {
     142        color: #555;
     143    }
     144
     145    .friendship-button a.add {
     146        background: url(../../bp-core/images/add_button_side.gif) top right no-repeat;
     147    }
     148
     149    .friendship-button a.remove {
     150        background: url(../../bp-core/images/remove_button_side.gif) top right no-repeat;
     151    }
     152
     153    .friendship-button a.requested {
     154        background: url(../../bp-core/images/check_button_side.gif) top right no-repeat;
     155    }
    142156   
    143157   
  • trunk/bp-core/css/structure.css

    r561 r580  
    243243    }
    244244
    245    
     245/* Buttons */
     246
     247.friendship-button {
     248    background: url(../../bp-core/images/button_back.gif) top left no-repeat;
     249    display: inline-block;
     250    margin-bottom: 10px;
     251}
     252
     253.friendship-button a {
     254    display: block;
     255    height: 19px;
     256    color: #777;
     257    font-size: 11px;
     258    padding: 0 33px 0 11px;
     259    margin-right: -7px;
     260    text-shadow: 0 1px 0 #fff;
     261    text-decoration: none;
     262}
     263    .friendship-button a:hover {
     264        color: #555;
     265    }
     266
     267    .friendship-button a.add {
     268        background: url(../../bp-core/images/add_button_side.gif) top right no-repeat;
     269    }
     270
     271    .friendship-button a.remove {
     272        background: url(../../bp-core/images/remove_button_side.gif) top right no-repeat;
     273    }
     274
     275    .friendship-button a.requested {
     276        background: url(../../bp-core/images/check_button_side.gif) top right no-repeat;
     277    }
     278
     279   
  • trunk/bp-friends.php

    r577 r580  
    132132            bp_core_add_message( __('Friendship could not be accepted', 'buddypress'), 'error' );
    133133        }
    134         wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
     134        bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
    135135       
    136136    } else if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'reject' && is_numeric($bp['action_variables'][1]) ) {
     
    141141            bp_core_add_message( __('Friendship could not be rejected', 'buddypress'), 'error' );
    142142        }   
    143         wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
     143        bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
    144144    }
    145145   
     
    482482    do_action( 'bp_friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
    483483   
    484     return $friendship->delete();
     484    if ( $friendship->delete() ) {
     485        friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
     486        return true;
     487    } else {
     488        return false;
     489    }
    485490}
    486491
  • trunk/bp-friends/bp-friends-ajax.php

    r439 r580  
    120120            echo __("Friendship could not be canceled.", 'buddypress');
    121121        } else {
    122             friends_update_friend_totals( $bp['loggedin_userid'], $_POST['fid'], 'remove' );
    123122            echo '<a id="friend-' . $_POST['fid'] . '" class="add" rel="add" title="' . __( 'Add Friend', 'buddypress' ) . '" href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/add-friend/' . $_POST['fid'] . '">' . __( 'Add Friend', 'buddypress' ) . '</a>';
    124123        }
     
    127126            echo __("Friendship could not be requested.", 'buddypress');
    128127        } else {
    129             echo 'Friendship Requested';
     128            echo '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '" class="requested">' . __( 'Friendship Requested', 'buddypres' ) . '</a>';
    130129            //echo '<a id="friend-' . $_POST['fid'] . '" class="remove" rel="remove" title="' . __( 'Remove Friend', 'buddypress' ) . '" href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/remove-friend/' . $_POST['fid'] . '">' . __( 'Remove Friend', 'buddypress' ) . '</a>';
    131130        }
  • trunk/bp-friends/bp-friends-templatetags.php

    r463 r580  
    318318        if ( !$potential_friend_id )
    319319            $potential_friend_id = $bp['current_userid'];
    320    
     320
    321321        if ( $bp['loggedin_userid'] == $potential_friend_id )
    322322            return false;
    323    
     323
    324324        $friend_status = BP_Friends_Friendship::check_is_friend( $bp['loggedin_userid'], $potential_friend_id );
    325    
     325
    326326        echo '<div class="friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
    327327        if ( $friend_status == 'pending' ) {
    328             _e('Friendship Requested', 'buddypress');
     328            echo '<a class="requested" href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
    329329        } else if ( $friend_status == 'is_friend') {
    330330            echo '<a href="' . $bp['loggedin_domain'] . $bp['friends']['slug'] . '/remove-friend/' . $potential_friend_id . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
     
    333333        }
    334334        echo '</div>';
    335    
    336         if ( function_exists('wp_nonce_field') )
    337             wp_nonce_field('addremove_friend');
     335
     336        // This causes duplicates, so it's not feasible as is.
     337        // if ( function_exists('wp_nonce_field') )
     338        //  wp_nonce_field('addremove_friend');
    338339    }
    339340}
  • trunk/bp-friends/css/structure.css

    r561 r580  
    2020}
    2121
    22 a.join-group {
    23     padding: 1em 1.7em 1em 1em;
    24     text-align: right;
    25     display: block;
    26     margin-right: 1.1em;
    27     margin-top: -1em;
    28 }
    29 
    3022#friend-list .friendship-button {
    3123    margin-top: -1.5em;
    3224}
    3325
    34 .left-menu a.add, .left-menu a.remove, .left-menu div.pending {
    35     margin: 1.5em auto;
     26.left-menu .friendship-button {
     27    margin-top: 1em;
    3628}
  • trunk/bp-groups.php

    r577 r580  
    1212include_once( 'bp-groups/bp-groups-notifications.php' );
    1313include_once( 'bp-groups/bp-groups-admin.php' );
     14include_once( 'bp-groups/directories/bp-groups-directory-groups.php' );
    1415
    1516/**************************************************************************
     
    193194    /* Add 'Groups' to the main navigation */
    194195    bp_core_add_nav_item( __('Groups', 'buddypress'), $bp['groups']['slug'] );
    195     bp_core_add_nav_default( $bp['groups']['slug'], 'groups_screen_my_groups', 'my-groups' );
     196   
     197    if ( $bp['current_userid'] )
     198        bp_core_add_nav_default( $bp['groups']['slug'], 'groups_screen_my_groups', 'my-groups' );
    196199       
    197200    $groups_link = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/';
     
    199202    /* Add the subnav items to the groups nav item */
    200203    bp_core_add_subnav_item( $bp['groups']['slug'], 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups' );
    201     bp_core_add_subnav_item( $bp['groups']['slug'], 'group-finder', __('Group Finder', 'buddypress'), $groups_link, 'groups_screen_group_finder' );
    202     bp_core_add_subnav_item( $bp['groups']['slug'], 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group' );
    203     bp_core_add_subnav_item( $bp['groups']['slug'], 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites' );
     204    bp_core_add_subnav_item( $bp['groups']['slug'], 'group-finder', __('Group Finder', 'buddypress'), $groups_link, 'groups_screen_group_finder', false, bp_is_home() );
     205    bp_core_add_subnav_item( $bp['groups']['slug'], 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home() );
     206    bp_core_add_subnav_item( $bp['groups']['slug'], 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home() );
    204207   
    205208    if ( $bp['current_component'] == $bp['groups']['slug'] ) {
     
    299302            bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );         
    300303        }
    301         wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
     304        bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
    302305       
    303306    } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) {
     
    307310            bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );         
    308311        }
    309         wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
     312        bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/' . $bp['current_action'] );
    310313    }
    311314   
     
    350353            // We're done.
    351354            if ( $create_group_step == 4 )
    352                 wp_redirect( bp_group_permalink( $group_obj, false ) );
     355                bp_core_redirect( bp_group_permalink( $group_obj, false ) );
    353356
    354357            if ( !$group_id = groups_manage_group( $create_group_step, $_SESSION['group_obj_id'] ) ) {
    355358                bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' );
    356                 wp_redirect( $bp['loggedin_domain'] . $bp['groups']['slug'] . '/create/step/' . $create_group_step );
     359                bp_core_redirect( $bp['loggedin_domain'] . $bp['groups']['slug'] . '/create/step/' . $create_group_step );
    357360            } else {
    358361                $create_group_step++;
     
    410413           
    411414            if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) {
    412                 wp_redirect( bp_group_permalink( $group_obj, false ) );
    413             } else {
    414                 wp_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp['wire']['slug'] );
     415                bp_core_redirect( bp_group_permalink( $group_obj, false ) );
     416            } else {
     417                bp_core_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp['wire']['slug'] );
    415418            }
    416419   
     
    425428           
    426429            if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) {
    427                 wp_redirect( bp_group_permalink( $group_obj, false ) );
    428             } else {
    429                 wp_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp['wire']['slug'] );
     430                bp_core_redirect( bp_group_permalink( $group_obj, false ) );
     431            } else {
     432                bp_core_redirect( bp_group_permalink( $group_obj, false ) . '/' . $bp['wire']['slug'] );
    430433            }
    431434       
     
    467470           
    468471            bp_core_add_message( __('Group invites sent.', 'buddypress') );
    469             wp_redirect( bp_group_permalink( $group_obj, false ) );
     472            bp_core_redirect( bp_group_permalink( $group_obj, false ) );
    470473        } else {
    471474            // Show send invite page
     
    484487            if ( !groups_leave_group( $group_obj->id ) ) {
    485488                bp_core_add_message(  __('There was an error leaving the group. Please try again.', 'buddypress'), 'error' );
    486                 wp_redirect( bp_group_permalink( $group_obj, false) );
     489                bp_core_redirect( bp_group_permalink( $group_obj, false) );
    487490            } else {
    488491                bp_core_add_message( __('You left the group successfully.', 'buddypress') );
    489                 wp_redirect( $bp['loggedin_domain'] . $bp['groups']['slug'] );
     492                bp_core_redirect( $bp['loggedin_domain'] . $bp['groups']['slug'] );
    490493            }
    491494        } else if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'no' ) {
    492             wp_redirect( bp_group_permalink( $group_obj, false) );
     495            bp_core_redirect( bp_group_permalink( $group_obj, false) );
    493496        } else {
    494497            // Show leave group page
     
    512515                bp_core_add_message( __( 'Your membership request was sent to the group administrator successfully. You will be notified when the group administrator responds to your request.', 'buddypress' ) );
    513516            }
    514             wp_redirect( bp_group_permalink( $group_obj, false ) );
     517            bp_core_redirect( bp_group_permalink( $group_obj, false ) );
    515518        }
    516519        bp_catch_uri( 'groups/request-membership' );
     
    539542                    bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
    540543                }
    541                 wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/edit-details' );
     544                bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/edit-details' );
    542545            }
    543546
     
    572575            }
    573576           
    574             wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/group-settings' );
     577            bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/group-settings' );
    575578        }
    576579       
     
    600603            do_action( 'bp_groups_promoted_member', $user_id, $group_obj->id );
    601604           
    602             wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
     605            bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
    603606        }
    604607       
     
    615618            do_action( 'bp_groups_demoted_member', $user_id, $group_obj->id );
    616619           
    617             wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
     620            bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
    618621        }
    619622       
     
    630633            do_action( 'bp_groups_banned_member', $user_id, $group_obj->id );
    631634           
    632             wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
     635            bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
    633636        }
    634637       
     
    645648            do_action( 'bp_groups_unbanned_member', $user_id, $group_obj->id );
    646649           
    647             wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
     650            bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/manage-members' );
    648651        }
    649652       
     
    684687                }   
    685688            }
    686             wp_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/membership-requests' );
     689            bp_core_redirect( site_url() . '/' . $bp['current_component'] . '/' . $bp['current_item'] . '/admin/membership-requests' );
    687690        }
    688691       
     
    706709            } else {
    707710                bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
    708                 wp_redirect( site_url() . '/' . $bp['groups']['slug'] . '/' );
     711                bp_core_redirect( site_url() . '/' . $bp['groups']['slug'] . '/' );
    709712            }
    710             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
     713            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
    711714        } else {
    712715            bp_catch_uri( 'groups/admin/delete-group' );
     
    779782            bp_core_add_message( __('You joined the group!', 'buddypress') );
    780783        }
    781         wp_redirect( bp_group_permalink( $group_obj, false ) );
     784        bp_core_redirect( bp_group_permalink( $group_obj, false ) );
    782785    }
    783786
     
    965968    global $bp;
    966969   
    967     $group_ids = BP_Groups_Member::get_group_ids( $bp['current_userid'], $pag_page, $pag_num );
    968     $group_count = $group_ids['count'];
    969    
    970     for ( $i = 0; $i < count($group_ids['ids']); $i++ ) {
    971         $groups[] = new BP_Groups_Group( $group_ids['ids'][$i] );
    972     }
    973    
    974     return array( 'groups' => $groups, 'count' => $group_count );
     970    $groups = BP_Groups_Member::get_group_ids( $bp['current_userid'], $pag_page, $pag_num );
     971
     972    return array( 'groups' => $groups['ids'], 'total' => $groups['total'] );
    975973}
    976974
     
    10941092                    if ( !$group_obj->save() )
    10951093                        return false;
    1096                                        
     1094
    10971095                    // Save the creator as the group administrator
    10981096                    $admin = new BP_Groups_Member( $bp['loggedin_userid'], $group_obj->id );
     
    11101108                    /* Set groupmeta */
    11111109                    groups_update_groupmeta( $group_obj->id, 'total_member_count', 1 );
     1110                    groups_update_groupmeta( $group_obj->id, 'last_activity', time() );
    11121111                    groups_update_groupmeta( $group_obj->id, 'theme', 'buddypress' );
    11131112                    groups_update_groupmeta( $group_obj->id, 'stylesheet', 'buddypress' );
     
    11801179               
    11811180                /* regular action */
    1182                 do_action( 'groups_created_group', $group_obj->id );
    1183 
     1181                do_action( 'bp_groups_created_group', $group_obj->id );
     1182               
    11841183                return $group_obj->id;
    11851184            break;
     
    12741273    return BP_Groups_Member::get_invites( $user_id, $group_id );
    12751274}
    1276 
    12771275
    12781276function groups_send_invites( $group_obj ) {
     
    14361434       
    14371435    $member = new BP_Groups_Member( $user_id, $group_id );
     1436
     1437    add_action( 'groups_premote_member', $user_id, $group_id );
     1438   
    14381439    return $member->promote();
    14391440}
     
    14461447       
    14471448    $member = new BP_Groups_Member( $user_id, $group_id );
     1449   
     1450    add_action( 'groups_demote_member', $user_id, $group_id );
     1451
    14481452    return $member->demote();
    14491453}
     
    14561460       
    14571461    $member = new BP_Groups_Member( $user_id, $group_id );
     1462
     1463    add_action( 'groups_ban_member', $user_id, $group_id );
     1464   
    14581465    return $member->ban();
    14591466}
     
    14661473       
    14671474    $member = new BP_Groups_Member( $user_id, $group_id );
     1475   
     1476    add_action( 'bp_groups_unban_member', $user_id, $group_id );
     1477   
    14681478    return $member->unban();
    14691479}
     
    15331543        $group = groups_get_random_group();
    15341544
    1535         wp_redirect( $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group->slug );
     1545        bp_core_redirect( $bp['root_domain'] . '/' . $bp['groups']['slug'] . '/' . $group->slug );
    15361546    }
    15371547}
     
    15421552   
    15431553    // Check the user is the group admin.
    1544     if ( !groups_is_group_admin( $bp['loggedin_userid'], $group_id ) )
     1554    if ( !$bp['is_item_admin'] )
    15451555        return false;
    15461556   
     
    15511561        return false;
    15521562   
     1563    add_action( 'bp_groups_delete_group', $group_id );
     1564   
    15531565    return true;
    15541566}
     
    15581570}
    15591571
    1560 function groups_get_newest( $limit = 5 ) {
    1561     return BP_Groups_Group::get_newest($limit);
    1562 }
    1563 
    1564 function groups_get_active( $limit = 5 ) {
    1565     return BP_Groups_Group::get_active($limit);
    1566 }
    1567 
    1568 function groups_get_popular( $limit = 5 ) {
    1569     return BP_Groups_Group::get_popular($limit);
    1570 }
    1571 
    1572 function groups_get_all() {
    1573     return BP_Groups_Group::get_all();
     1572function groups_get_newest( $limit = null, $page = null ) {
     1573    return BP_Groups_Group::get_newest( $limit, $page );
     1574}
     1575
     1576function groups_get_active( $limit = null, $page = null ) {
     1577    return BP_Groups_Group::get_active( $limit, $page );
     1578}
     1579
     1580function groups_get_popular( $limit = null, $page = null ) {
     1581    return BP_Groups_Group::get_popular( $limit, $page );
     1582}
     1583
     1584function groups_get_all( $limit = null, $page = null ) {
     1585    return BP_Groups_Group::get_all( $limit, $page );
    15741586}
    15751587
  • trunk/bp-groups/bp-groups-ajax.php

    r540 r580  
    6666    switch ( $_POST['filter'] ) {
    6767        case 'newest-groups':
    68             $groups = groups_get_newest($_POST['max-groups']);
     68            $groups = groups_get_newest( $_POST['max-groups'], 1 );
    6969        break;
    7070        case 'recently-active-groups':
    71             $groups = groups_get_active($_POST['max-groups']);
     71            $groups = groups_get_active( $_POST['max-groups'], 1 );
    7272        break;
    7373        case 'popular-groups':
    74             $groups = groups_get_popular($_POST['max-groups']);
     74            $groups = groups_get_popular( $_POST['max-groups'], 1 );
    7575        break;
    7676    }
    7777
    78     if ( $groups ) {
     78    if ( $groups['groups'] ) {
    7979        echo '0[[SPLIT]]'; // return valid result.
    8080   
    81         foreach ( (array) $groups as $group ) {
     81        foreach ( (array) $groups['groups'] as $group ) {
    8282            $group = new BP_Groups_Group( $group->group_id, false );
    8383        ?>
     
    205205add_action( 'wp_ajax_get_group_members_admin', 'groups_ajax_member_admin_list' );
    206206
    207 fuction
     207function bp_core_ajax_directory_groups() {
     208    global $bp;
     209
     210    check_ajax_referer('directory_groups');
     211   
     212    $pag_page = isset( $_POST['page'] ) ? intval( $_POST['page'] ) : 1;
     213    $pag_num = isset( $_POST['num'] ) ? intval( $_POST['num'] ) : 10;
     214   
     215    if ( isset( $_POST['letter'] ) && $_POST['letter'] != '' ) {
     216        $groups = BP_Groups_Group::get_by_letter( $_POST['letter'], $pag_num, $pag_page );
     217    } else if ( isset ( $_POST['groups_search'] ) && $_POST['groups_search'] != '' ) {
     218        $groups = BP_Groups_Group::search_groups( $_POST['groups_search'], $pag_num, $pag_page );
     219    } else {
     220        $groups = BP_Groups_Group::get_active( $pag_num, $pag_page );
     221    }
     222   
     223    $pag_links = paginate_links( array(
     224        'base' => add_query_arg( 'page', '%#%' ),
     225        'format' => '',
     226        'total' => ceil( $groups['total'] / $pag_num ),
     227        'current' => $pag_page,
     228        'prev_text' => '&laquo;',
     229        'next_text' => '&raquo;',
     230        'mid_size' => 1
     231    ));
     232   
     233    $from_num = intval( ( $pag_page - 1 ) * $pag_num ) + 1;
     234    $to_num = ( $from_num + 9 > $users['total'] ) ? $groups['total'] : $from_num + 9;
     235   
     236    echo '<div id="group-dir-list">';
     237    if ( $groups['groups'] ) {
     238        echo '0[[SPLIT]]'; // return valid result.
     239       
     240        ?>
     241        <div id="group-dir-count" class="pag-count">
     242            <?php echo sprintf( __( 'Viewing group %d to %d (%d total active groups)', 'buddypress' ), $from_num, $to_num, $groups['total'] ); ?> &nbsp;
     243            <img id="ajax-loader-groups" src="<?php echo $bp['core']['image_base'] ?>/ajax-loader.gif" height="7" alt="<?php _e( "Loading", "buddypress" ) ?>" style="display: none;" />
     244        </div>
     245   
     246        <div class="pagination-links" id="group-dir-pag">
     247            <?php echo $pag_links ?>
     248        </div>
     249
     250        <ul id="groups-list" class="item-list">
     251        <?php foreach ( $groups['groups'] as $group ) : ?>
     252            <?php $group = new BP_Groups_Group( $group->group_id, false, false ); ?>
     253            <li>
     254                <div class="item-avatar">
     255                    <img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" />
     256                </div>
     257
     258                <div class="item">
     259                    <div class="item-title"><a href="<?php echo bp_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
     260                    <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __('active %s ago') ) ?></span></div>
     261                </div>
     262           
     263                <div class="action">
     264                    <?php bp_group_join_button( $group ) ?>
     265                    <div class="meta">
     266                        <?php _e( sprintf( '%d members', groups_get_groupmeta( $group->id, 'total_member_count' ) ), 'buddypress' ) ?>
     267                    </div>
     268                </div>
     269           
     270                <div class="clear"></div>
     271            </li>
     272        <?php endforeach; ?>
     273        </ul>   
     274    <?php
     275    } else {
     276        echo "-1[[SPLIT]]<div id='message' class='error'><p>" . __("No groups matched the current filter.", 'buddypress') . '</p></div>';
     277    }
     278   
     279    if ( isset( $_POST['letter'] ) ) {
     280        echo '<input type="hidden" id="selected_letter" value="' . $_POST['letter'] . '" name="selected_letter" />';
     281    }
     282   
     283    if ( isset( $_POST['groups_search'] ) ) {
     284        echo '<input type="hidden" id="search_terms" value="' . $_POST['groups_search'] . '" name="search_terms" />';
     285    }
     286   
     287    echo '</div>';
     288}
     289add_action( 'wp_ajax_directory_groups', 'bp_core_ajax_directory_groups' );
     290
     291function groups_ajax_joinleave_group() {
     292    global $bp;
     293
     294    if ( groups_is_user_banned( $bp['loggedin_userid'], $_POST['gid'] ) )
     295        return false;
     296   
     297    if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) )
     298        return false;
     299   
     300    if ( $group->status == 'hidden' )
     301        return false;
     302   
     303    if ( !groups_is_user_member( $bp['loggedin_userid'], $group->id ) ) {
     304   
     305        if ( $group->status == 'public' ) {
     306            if ( !groups_join_group( $group->id ) ) {
     307                _e( 'Error joining group', 'buddypress' );
     308            } else {
     309                echo '<a id="group-' . $group->id . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __( 'Leave Group', 'buddypress' ) . '</a>';
     310            }           
     311        } else if ( $group->status == 'private' ) {
     312            if ( !groups_send_membership_request( $bp['loggedin_userid'], $group->id ) ) {
     313                _e( 'Error requesting membership', 'buddypress' ); 
     314            } else {
     315                echo '<a id="group-' . $group->id . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_group_permalink( $group, false ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';               
     316            }       
     317        }
     318       
     319    } else {
     320        if ( !groups_leave_group( $group->id ) ) {
     321            _e( 'Error leaving group', 'buddypress' );
     322        } else {
     323            if ( $group->status == 'public' ) {
     324                echo '<a id="group-' . $group->id . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . bp_group_permalink( $group, false ) . '/join">' . __( 'Join Group', 'buddypress' ) . '</a>';               
     325            } else if ( $group->status == 'private' ) {
     326                echo '<a id="group-' . $group->id . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . bp_group_permalink( $group, false ) . '/request-membership">' . __( 'Request Membership', 'buddypress' ) . '</a>';
     327            }
     328        }
     329    }
     330}
     331add_action( 'wp_ajax_joinleave_group', 'groups_ajax_joinleave_group' );
    208332
    209333?>
  • trunk/bp-groups/bp-groups-classes.php

    r548 r580  
    8484            $this->admins = $this->get_administrators();
    8585            $this->random_members = $this->get_random_members();
    86             $this->latest_wire_posts = $this->get_latest_wire_posts();
    8786            $this->random_photos = $this->get_random_photos();
    8887        }
     
    207206        return $users;
    208207    }
    209    
    210     function get_latest_wire_posts() {
    211         global $wpdb, $bp;
    212        
    213        
    214     }
    215    
     208
    216209    function get_random_photos() {
    217210        global $wpdb, $bp;
     
    241234        for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    242235            $user = $this->user_dataset[$i];
    243 
    244             if ( $total_count = get_usermeta( $user->user_id, 'total_group_count' ) != '' ) {
     236           
     237            $total_count = get_usermeta( $user->user_id, 'total_group_count' );
     238           
     239            if ( $total_count != '' ) {
    245240                update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 );
    246241            }
     
    300295        $gids = implode( ',', $gids['ids'] );
    301296
    302         $sql = $wpdb->prepare( "SELECT id FROM " . $bp['groups']['table_name'] . " WHERE id IN ($gids) AND name LIKE '$filter%%' OR description LIKE '$filter%%'$pag_sql" );
    303         $count_sql = $wpdb->prepare( "SELECT count(id) FROM " . $bp['groups']['table_name'] . " WHERE id IN ($gids) AND name LIKE '$filter%%' OR description LIKE '$filter%%'" );
    304        
    305         $group_ids = $wpdb->get_col($sql);
    306         $total_groups = $wpdb->get_var($count_sql);
    307 
    308         for ( $i = 0; $i < count($group_ids); $i++ ) {
    309             $groups[] = new BP_Groups_Group( (int)$group_ids[$i] );
    310         }
    311 
    312         return array( 'groups' => $groups, 'count' => $total_groups );
     297        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM " . $bp['groups']['table_name'] . " WHERE id IN ({$gids}) AND name LIKE '{$filter}%%' OR description LIKE '{$filter}%%'{$pag_sql}" ) );
     298        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['groups']['table_name'] . " WHERE id IN ({$gids}) AND name LIKE '{$filter}%%' OR description LIKE '{$filter}%%'" ) );
     299       
     300        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    313301    }
    314302   
     
    327315        }
    328316       
    329         $sql = $wpdb->prepare( "SELECT id FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' AND name LIKE '%%$filter%%' OR description LIKE '%%$filter%%'{$order_sql}{$pag_sql}" );
    330         $count_sql = $wpdb->prepare( "SELECT count(id) FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' AND name LIKE '%%$filter%%' OR description LIKE '%%$filter%%'" );
    331        
    332         $group_ids = $wpdb->get_col($sql);
    333         $total_groups = $wpdb->get_var($count_sql);
    334        
    335         for ( $i = 0; $i < count($group_ids); $i++ ) {
    336             $groups[] = new BP_Groups_Group( (int)$group_ids[$i] );
    337         }
    338 
    339         return array( 'groups' => $groups, 'count' => $total_groups );
     317        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' AND name LIKE '%%$filter%%' OR description LIKE '%%$filter%%'{$order_sql}{$pag_sql}" ) );
     318        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' AND name LIKE '%%$filter%%' OR description LIKE '%%$filter%%'" ) );
     319       
     320        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    340321    }
    341322   
     
    372353        global $wpdb, $bp;
    373354       
    374         if ( $limit && $page )
    375             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    376        
    377         return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp['groups']['table_name_members'] . " WHERE group_id = %d AND is_confirmed = 0{$pag_sql}", $group_id ) );           
    378     }
    379    
    380     function get_newest( $limit = 5 ) {
    381         global $wpdb, $bp;
    382        
    383         if ( !$limit )
    384             $limit = 5;
    385 
    386         return $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' ORDER BY date_created DESC LIMIT %d", $limit ) );
    387     }
    388    
    389     function get_active( $limit = 5 ) {
    390         global $wpdb, $bp;
    391        
    392         if ( !$limit )
    393             $limit = 5;
    394 
    395         return $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " gm, " . $bp['groups']['table_name'] . " g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC LIMIT %d", $limit ) );
    396     }
    397    
    398     function get_popular( $limit = 5 ) {
    399         global $wpdb, $bp;
    400        
    401         if ( !$limit )
    402             $limit = 5;
    403 
    404         return $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM " . $bp['groups']['table_name_groupmeta'] . " gm, " . $bp['groups']['table_name'] . " g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC LIMIT %d", $limit ) );
    405     }
    406    
    407     function get_all( $only_public = true, $limit = null, $page = null, $sort_by = false, $order = false, $instantiate = false ) {
     355        if ( $limit && $page ) {
     356            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     357            $total_requests = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['groups']['table_name_members'] . " WHERE group_id = %d AND is_confirmed = 0", $group_id ) );
     358        }
     359       
     360        $paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp['groups']['table_name_members'] . " WHERE group_id = %d AND is_confirmed = 0{$pag_sql}", $group_id ) );
     361
     362        return array( 'requests' => $paged_requests, 'total' => $total_requests );
     363    }
     364   
     365    function get_newest( $limit = null, $page = null ) {
     366        global $wpdb, $bp;
     367       
     368        if ( $limit && $page ) {
     369            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     370            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' ORDER BY date_created DESC LIMIT %d", $limit ) );
     371        }
     372       
     373        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM " . $bp['groups']['table_name'] . " WHERE status != 'hidden' ORDER BY date_created DESC {$pag_sq}", $limit ) );
     374
     375        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     376    }
     377   
     378    function get_active( $limit = null, $page = null ) {
     379        global $wpdb, $bp;
     380       
     381        if ( $limit && $page ) {
     382            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     383            $total_groups = count( $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " gm, " . $bp['groups']['table_name'] . " g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC", $limit ) ) );
     384        }
     385       
     386        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " gm, " . $bp['groups']['table_name'] . " g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}", $limit ) );
     387
     388        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     389    }
     390   
     391    function get_popular( $limit = null, $page = null ) {
     392        global $wpdb, $bp;
     393       
     394        if ( $limit && $page ) {
     395            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     396            $total_groups = count( $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM " . $bp['groups']['table_name_groupmeta'] . " gm, " . $bp['groups']['table_name'] . " g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC", $limit ) ) );
     397        }
     398           
     399        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM " . $bp['groups']['table_name_groupmeta'] . " gm, " . $bp['groups']['table_name'] . " g WHERE g.id = gm.group_id AND g.status != 'hidden' AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}", $limit ) );
     400
     401        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     402    }
     403   
     404    function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false, $instantiate = false ) {
    408405        global $wpdb, $bp;
    409406       
     
    446443    }
    447444   
    448     function get_random() {
    449         global $wpdb, $bp;
    450        
    451         return $wpdb->get_row( $wpdb->prepare( "SELECT id, slug FROM " . $bp['groups']['table_name'] . " WHERE status = 'public' ORDER BY rand() LIMIT 1" ) );     
     445    function get_by_letter( $letter, $limit = null, $page = null ) {
     446        global $wpdb, $bp;
     447       
     448        if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
     449            return false;
     450       
     451        like_escape($letter);
     452               
     453        if ( $limit && $page ) {
     454            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     455            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp['groups']['table_name']} WHERE name LIKE '$letter%%' ORDER BY name ASC" ) );
     456        }
     457               
     458        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp['groups']['table_name']} WHERE name LIKE '$letter%%' ORDER BY name ASC" ) );
     459       
     460        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     461    }
     462   
     463   
     464    function get_random( $limit = null, $page = null ) {
     465        global $wpdb, $bp;
     466
     467        if ( $limit && $page ) {
     468            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     469            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT id as group_id, slug FROM " . $bp['groups']['table_name'] . " WHERE status = 'public' ORDER BY rand()" ) );
     470        }
     471       
     472        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM " . $bp['groups']['table_name'] . " WHERE status = 'public' ORDER BY rand() {$pag_sql}" ) );     
     473       
     474        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    452475    }
    453476}
     
    605628        // If the user is logged in and viewing their own groups, we can show hidden and closed groups
    606629        if ( bp_is_home() ) {
    607             $group_ids = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id ) );   
     630            $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT group_id FROM " . $bp['groups']['table_name_members'] . " WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id ) );   
    608631        } else {
    609             $group_ids = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM " . $bp['groups']['table_name_members'] . " m, " . $bp['groups']['table_name'] . " g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id ) );   
     632            $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM " . $bp['groups']['table_name_members'] . " m, " . $bp['groups']['table_name'] . " g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id ) );   
    610633        }
    611634       
  • trunk/bp-groups/bp-groups-cssjs.php

    r373 r580  
    1313}
    1414add_action( 'template_redirect', 'groups_add_js' );
     15
     16function groups_add_structure_css() {
     17    /* Enqueue the structure CSS file to give basic positional formatting for components */
     18    wp_enqueue_style( 'bp-groups-structure', site_url() . '/wp-content/mu-plugins/bp-groups/css/structure.css' );   
     19}
     20add_action( 'bp_styles', 'groups_add_structure_css' );
    1521
    1622function groups_add_cropper_js() {
  • trunk/bp-groups/bp-groups-notifications.php

    r548 r580  
    227227    $group = new BP_Groups_Group( $group_id, false, false );
    228228    $group_link = bp_group_permalink( $group, false );
    229     $invites_link = $inviter_link . '/' . $bp['groups']['slug'] . '/invites';
    230229       
    231230    for ( $i = 0; $i < count( $invited_user_ids ); $i++ ) {
     
    239238        $invited_ud = get_userdata($invited_user_id);
    240239        $settings_link = site_url() . '/' . MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications';
     240        $invited_link = site_url() . '/' . MEMBERS_SLUG . '/' . $invited_ud->user_login;
     241        $invites_link = $invited_link . '/' . $bp['groups']['slug'] . '/invites';
    241242       
    242243        // Set up and send the message
  • trunk/bp-groups/bp-groups-templatetags.php

    r570 r580  
    1414    var $total_group_count;
    1515   
     16    var $single_group = false;
     17   
    1618    var $sort_by;
    1719    var $order;
     
    2931           
    3032            $this->groups = groups_get_user_groups( $this->pag_num, $this->pag_page );
    31             $this->total_group_count = (int)$this->groups['count'];
     33            $this->total_group_count = (int)$this->groups['total'];
    3234            $this->groups = $this->groups['groups'];
    3335            $this->group_count = count($this->groups);
     
    3638
    3739            $this->groups = groups_filter_user_groups( $_REQUEST['group-filter-box'], $this->pag_num, $this->pag_page );
    38             $this->total_group_count = (int)$this->groups['count'];
     40            $this->total_group_count = (int)$this->groups['total'];
    3941            $this->groups = $this->groups['groups'];
    4042            $this->group_count = count($this->groups);
     
    4345
    4446            $this->groups = groups_search_groups( $_REQUEST['groupfinder-search-box'], $this->pag_num, $this->pag_page );
    45             $this->total_group_count = (int)$this->groups['count'];
     47            $this->total_group_count = (int)$this->groups['total'];
    4648            $this->groups = $this->groups['groups'];
    4749            $this->group_count = count($this->groups);
     
    6062            if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) {
    6163                $this->groups = groups_search_groups( $_REQUEST['s'], $this->pag_num, $this->pag_page, $this->sort_by, $this->order );
    62                 $this->total_group_count = (int)$this->groups['count'];
     64                $this->total_group_count = (int)$this->groups['total'];
    6365                $this->groups = $this->groups['groups'];
    6466                $this->group_count = count($this->groups);
    6567            } else {
    66                 $this->groups = BP_Groups_Group::get_all( false, $this->pag_num, $this->pag_page, $this->sort_by, $this->order, true );
     68                $this->groups = BP_Groups_Group::get_all( $this->pag_num, $this->pag_page, false, $this->sort_by, $this->order, true );
    6769                $this->total_group_count = count(BP_Groups_Group::get_all( false )); // TODO: not ideal
    6870                $this->group_count = count($this->groups);
     
    7072           
    7173        } else if ( $group_slug ) {
    72        
    73             $this->groups = array( new BP_Groups_Group( BP_Groups_Group::get_id_from_slug($group_slug), true ) );
     74            $this->single_group = true;
     75           
     76            $group = new stdClass();
     77            $group->group_id = BP_Groups_Group::get_id_from_slug($group_slug);
     78           
     79            $this->groups = array( $group );
    7480            $this->total_group_count = 1;
    7581            $this->group_count = 1;
     
    100106        $this->group = $this->groups[$this->current_group];
    101107       
     108        // If this is a single group then instantiate group meta when creating the object.
     109        if ( $this->single_group )
     110            $this->group = new BP_Groups_Group( $this->group->group_id, true );
     111        else
     112            $this->group = new BP_Groups_Group( $this->group->group_id, false );
     113           
    102114        return $this->group;
    103115    }
     
    212224}
    213225
    214 function bp_group_last_active() {
     226function bp_group_last_active( $echo = true ) {
    215227    global $groups_template;
    216228   
     
    220232        _e( 'not yet active', 'buddypress' );
    221233    else
    222         echo bp_core_time_since( groups_get_groupmeta( $groups_template->group->id, 'last_activity' ) );
     234        echo bp_core_time_since( $last_active );
    223235}
    224236
     
    530542    <?php } else { ?>
    531543        <div id="message" class="info">
    532             <?php _e( 'This group has no administrators', 'buddypress' ); ?>
     544            <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p>
    533545        </div>
    534546    <?php }
     
    643655}
    644656
    645 function bp_group_has_requested_membership() {
     657function bp_group_has_requested_membership( $group = false ) {
    646658    global $bp, $groups_template;
    647659   
    648     if ( groups_check_for_membership_request( $bp['loggedin_userid'], $groups_template->group->id ) )
     660    if ( !$group )
     661        $group = $groups_template->group;
     662   
     663    if ( groups_check_for_membership_request( $bp['loggedin_userid'], $group->id ) )
    649664        return true;
    650665   
     
    889904?>
    890905    <div class="left-menu">
    891         <h4>Select Friends <img id="ajax-loader" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4>
     906        <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <img id="ajax-loader" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /></h4>
    892907        <?php bp_group_list_invite_friends() ?>
    893908        <?php if ( function_exists('wp_nonce_field') )
     
    930945}
    931946
    932 function bp_group_join_button() {
     947function bp_group_join_button( $group = false ) {
    933948    global $bp, $groups_template;
    934949   
    935     if ( !is_user_logged_in() || BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $groups_template->group->id ) || groups_is_user_banned( $bp['loggedin_userid'], $groups_template->group->id ) )
     950    if ( !$group )
     951        $group =& $groups_template->group;
     952   
     953    // If they're not logged in or are banned from the group, no join button.
     954    if ( !is_user_logged_in() || groups_is_user_banned( $bp['loggedin_userid'], $group->id ) )
    936955        return false;
    937        
    938     switch ( $groups_template->group->status ) {
     956   
     957    echo '<div class="group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
     958   
     959    switch ( $group->status ) {
    939960        case 'public':
    940             echo '<a class="join-group" href="' . bp_group_permalink( false, false ) . '/join">' . __('Join Group', 'buddypress') . '</a>';                 
     961            if ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group->id ) )
     962                echo '<a class="leave-group" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __('Leave Group', 'buddypress') . '</a>';                                   
     963            else
     964                echo '<a class="join-group" href="' . bp_group_permalink( $group, false ) . '/join">' . __('Join Group', 'buddypress') . '</a>';                   
    941965        break;
    942966       
    943967        case 'private':
    944             if ( !bp_group_has_requested_membership() )
    945                 echo '<a class="request-membership" href="' . bp_group_permalink( false, false ) . '/request-membership">' . __('Request Membership', 'buddypress') . '</a>';       
    946             else
    947                 echo 'Membership Requested';
     968            if ( BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group->id ) ) {
     969                echo '<a class="leave-group" href="' . bp_group_permalink( $group, false ) . '/leave-group">' . __('Leave Group', 'buddypress') . '</a>';                                       
     970            } else {
     971                if ( !bp_group_has_requested_membership( $group ) )
     972                    echo '<a class="request-membership" href="' . bp_group_permalink( $group, false ) . '/request-membership">' . __('Request Membership', 'buddypress') . '</a>';     
     973                else
     974                    echo '<a class="membership-requested" href="' . bp_group_permalink( $group, false ) . '">' . __('Membership Requested', 'buddypress') . '</a>';             
     975            }
    948976        break;
    949977    }
     978   
     979    echo '</div>';
    950980}
    951981
  • trunk/bp-groups/bp-groups-widgets.php

    r391 r580  
    3333        . $after_title; ?>
    3434   
    35     <?php $groups = groups_get_popular( $options['max_groups'] ); ?>
     35    <?php $groups = groups_get_popular( $options['max_groups'], 1 ); ?>
    3636   
    37     <?php if ( $groups ) : ?>
     37    <?php if ( $groups['groups'] ) : ?>
    3838        <div class="item-options" id="groups-list-options">
    3939            <img id="ajax-loader-groups" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /> &nbsp;
     
    4343        </div>
    4444        <ul id="groups-list" class="item-list">
    45             <?php foreach ( $groups as $group ) : ?>
     45            <?php foreach ( $groups['groups'] as $group ) : ?>
    4646                <?php $group = new BP_Groups_Group( $group->group_id, false ) ?>
    4747                <li>
  • trunk/bp-messages.php

    r577 r580  
    281281
    282282    if ( !$thread_id || !is_numeric($thread_id) || !BP_Messages_Thread::check_access($thread_id) ) {
    283         wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
     283        bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
    284284    } else {
    285285        // delete message
    286286        if ( !BP_Messages_Thread::delete($thread_id) ) {
    287287            bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
    288             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
     288            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
    289289        } else {
    290290            bp_core_add_message( __('Message deleted.', 'buddypress') );
    291             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
     291            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
    292292        }
    293293    }
     
    310310        if ( !BP_Messages_Thread::delete( explode(',', $thread_ids ) ) ) {
    311311            bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
    312             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
     312            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
    313313        } else {
    314314            bp_core_add_message( __('Messages deleted.', 'buddypress') );
    315             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
     315            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] );
    316316        }
    317317    }
     
    367367        if ( !$from_ajax ) {   
    368368            bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' );
    369             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/compose' );
     369            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/compose' );
    370370        } else {
    371371            return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress'));
     
    374374        if ( !$from_ajax ) {
    375375            bp_core_add_message( __('Please make sure you fill in all the fields.', 'buddypress'), 'error' );
    376             wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/compose' );
     376            bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/compose' );
    377377        } else {
    378378            return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress'));
     
    405405                } else {
    406406                    bp_core_add_message( $message, $type );
    407                     wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/compose' );
     407                    bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/compose' );
    408408                }
    409409            } else {
     
    424424                } else {
    425425                    bp_core_add_message( $message );
    426                     wp_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/inbox' );
     426                    bp_core_redirect( $bp['loggedin_domain'] . $bp['current_component'] . '/inbox' );
    427427                }
    428428            }
     
    435435            } else {
    436436                bp_core_add_message( $message, $type );
    437                 wp_redirect( $bp['loggedin_domain'] . $bp['messages']['slug'] . '/compose' );
     437                bp_core_redirect( $bp['loggedin_domain'] . $bp['messages']['slug'] . '/compose' );
    438438            }
    439439        }
  • trunk/bp-wire.php

    r577 r580  
    9696   
    9797    if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) {
    98         wp_redirect( $bp['current_domain'] );
     98        bp_core_redirect( $bp['current_domain'] );
    9999    } else {
    100         wp_redirect( $bp['current_domain']. $bp['wire']['slug'] );
     100        bp_core_redirect( $bp['current_domain']. $bp['wire']['slug'] );
    101101    }
    102102}
     
    118118   
    119119    if ( !strpos( $_SERVER['HTTP_REFERER'], $bp['wire']['slug'] ) ) {
    120         wp_redirect( $bp['current_domain'] );
     120        bp_core_redirect( $bp['current_domain'] );
    121121    } else {
    122         wp_redirect( $bp['current_domain']. $bp['wire']['slug'] );
     122        bp_core_redirect( $bp['current_domain']. $bp['wire']['slug'] );
    123123    }
    124124}
  • trunk/bp-wire/bp-wire-templatetags.php

    r569 r580  
    240240    global $wire_posts_template;
    241241   
    242     echo bp_core_get_userlink( $wire_posts_template->wire_post->user_id );
     242    if ( $echo )
     243        echo bp_core_get_userlink( $wire_posts_template->wire_post->user_id );
     244    else
     245        return bp_core_get_userlink( $wire_posts_template->wire_post->user_id );
    243246}
    244247
  • trunk/bp-xprofile/admin-mods/bp-xprofile-account-tab.php

    r394 r580  
    5656    $redirect = ($is_profile_page? "admin.php?page=bp-xprofile/admin-mods/bp-xprofile-account-tab.php&" : "admin.php?page=bp-xprofile/admin-mods/bp-xprofile-settings-tab.php&user_id=$user_id&"). "updated=true";
    5757    $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
    58     wp_redirect($redirect);
     58    bp_core_redirect($redirect);
    5959    exit;
    6060}
  • trunk/bp-xprofile/bp-xprofile-signup.php

    r519 r580  
    302302        // Confirm that the nonce is valid
    303303        if ( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'slick_avatars' ) )
    304             wp_redirect( get_option('home') );
     304            bp_core_redirect( get_option('home') );
    305305       
    306306        $user_id = xprofile_get_user_by_key($_GET['key']);
     
    315315        $url = site_url() . '/members/' . $ud->user_login;
    316316       
    317         wp_redirect( $url );
     317        bp_core_redirect( $url );
    318318    }
    319319}
Note: See TracChangeset for help on using the changeset viewer.