function bp_activity_template($type, $user_id, $per_page, $max, $timeframe) { global $bp; $this->pag_page = isset($_REQUEST['acpage']) ? intval($_REQUEST['acpage']) : 1; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; $this->filter_content = false; $this->activity_type = $type; if ($type == 'sitewide') { $this->activities = bp_activity_get_sitewide_activity($max, $this->pag_num, $this->pag_page); } if ($type == 'personal') { $this->activities = bp_activity_get_user_activity($user_id, $timeframe, $this->page_num, $this->pag_page); } if ($type == 'friends' && (bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id)) { $this->activities = bp_activity_get_friends_activity($user_id, $timeframe, $this->pag_num, $this->pag_page); } if (!$max) { $this->total_activity_count = (int) $this->activities['total']; } else { $this->total_activity_count = (int) $max; } $this->activities = $this->activities['activities']; if ($max) { if ($max >= count($this->activities)) { $this->activity_count = count($this->activities); } else { $this->activity_count = (int) $max; } } else { $this->activity_count = count($this->activities); } $this->full_name = $bp->displayed_user->fullname; $this->pag_links = paginate_links(array('base' => add_query_arg('acpage', '%#%'), 'format' => '', 'total' => ceil((int) $this->total_activity_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1)); }
function bp_has_icons() { global $bp; if (!bp_is_home()) { echo ' class="icons"'; } }
/** * xprofile_record_wire_post_notification() * * Records a notification for a new profile wire post to the database and sends out a notification * email if the user has this setting enabled. * * @package BuddyPress XProfile * @param $wire_post_id The ID of the wire post * @param $user_id The id of the user that the wire post was sent to * @param $poster_id The id of the user who wrote the wire post * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() * @global $current_user WordPress global variable containing current logged in user information * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user * @uses get_usermeta() Get a user meta value based on meta key from wp_usermeta * @uses BP_Wire_Post Class Creates a new wire post object based on ID. * @uses site_url Returns the site URL * @uses wp_mail Sends an email */ function xprofile_record_wire_post_notification($wire_post_id, $user_id, $poster_id) { global $bp, $current_user; if ($bp->current_component == $bp->wire->slug && !bp_is_home()) { bp_core_add_notification($poster_id, $user_id, 'xprofile', 'new_wire_post'); if (!get_usermeta($bp->loggedin_user->id, 'notification_profile_wire_post') || 'yes' == get_usermeta($bp->loggedin_user->id, 'notification_profile_wire_post')) { $poster_name = bp_fetch_user_fullname($poster_id, false); $wire_post = new BP_Wire_Post($bp->profile->table_name_wire, $wire_post_id, true); $ud = get_userdata($user_id); $wire_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/wire'; $settings_link = site_url() . '/' . BP_MEMBERS_SLUG . '/' . $ud->user_login . '/settings/notifications'; // Set up and send the message $to = $ud->user_email; $subject = '[' . get_blog_option(1, 'blogname') . '] ' . sprintf(__('%s posted on your wire.', 'buddypress'), stripslashes($poster_name)); $message = sprintf(__('%s posted on your wire: "%s" To view your wire: %s --------------------- ', 'buddypress'), $poster_name, stripslashes($wire_post->content), $wire_link); $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link); // Send it wp_mail($to, $subject, $message); } } }
function bp_wire_posts_template($item_id, $component_slug, $can_post, $per_page, $max) { global $bp; if ($bp->current_component == $bp->wire->slug) { $this->table_name = $bp->profile->table_name_wire; // If the user is viewing their own wire, delete the notifications. if ('all-posts' == $bp->current_action && bp_is_home()) { bp_core_delete_notifications_for_user_by_type($bp->loggedin_user->id, 'xprofile', 'new_wire_post'); } } else { $this->table_name = $bp->{$component_slug}->table_name_wire; } $this->pag_page = isset($_REQUEST['wpage']) ? intval($_REQUEST['wpage']) : 1; $this->pag_num = isset($_REQUEST['num']) ? intval($_REQUEST['num']) : $per_page; $this->wire_posts = BP_Wire_Post::get_all_for_item($item_id, $this->table_name, $this->pag_page, $this->pag_num); $this->total_wire_post_count = (int) $this->wire_posts['count']; $this->wire_posts = $this->wire_posts['wire_posts']; $this->wire_post_count = count($this->wire_posts); if ((int) get_site_option('non-friend-wire-posting') && ($bp->current_component == $bp->profile->slug || $bp->current_component == $bp->wire->slug)) { $this->can_post = 1; } else { $this->can_post = $can_post; } $this->pag_links = paginate_links(array('base' => add_query_arg('wpage', '%#%', $bp->displayed_user->domain), 'format' => '', 'total' => ceil($this->total_wire_post_count / $this->pag_num), 'current' => $this->pag_page, 'prev_text' => '«', 'next_text' => '»', 'mid_size' => 1)); }
function bp_core_add_settings_nav() { global $bp; /* Add the settings navigation item */ bp_core_add_nav_item(__('Settings', 'buddypress'), 'settings', false, false); bp_core_add_nav_default('settings', 'bp_core_screen_general_settings', 'general', false); bp_core_add_subnav_item('settings', 'general', __('General', 'buddypress'), $bp->loggedin_user->domain . 'settings/', 'bp_core_screen_general_settings', false, bp_is_home()); bp_core_add_subnav_item('settings', 'notifications', __('Notifications', 'buddypress'), $bp->loggedin_user->domain . 'settings/', 'bp_core_screen_notification_settings', false, bp_is_home()); bp_core_add_subnav_item('settings', 'delete-account', __('Delete Account', 'buddypress'), $bp->loggedin_user->domain . 'settings/', 'bp_core_screen_delete_account', false, bp_is_home()); }
/** * bp_media_galleries_setup_nav() * * Sets up the user profile navigation items for the component. This adds the top level nav * item and all the sub level nav items to the navigation array. This is then * rendered in the template. */ function bp_media_galleries_setup_nav() { global $bp; /* Add 'Example' to the main user profile navigation */ bp_core_new_nav_item(array('name' => __('Media Galleries', 'bp-media-galleries'), 'slug' => $bp->media_galleries->slug, 'position' => 80, 'screen_function' => 'bp_media_galleries_view', 'default_subnav_slug' => 'view')); $media_galleries_link = $bp->loggedin_user->domain . $bp->media_galleries->slug . '/'; bp_core_new_subnav_item(array('name' => __('Create Gallery', 'bp-media-galleries'), 'slug' => 'create', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_create', 'position' => 10, 'user_has_access' => bp_is_home())); bp_core_new_subnav_item(array('name' => __('Upload Audio', 'bp-media-galleries'), 'slug' => 'upload-audio', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_upload_audio', 'position' => 20, 'user_has_access' => bp_is_home())); bp_core_new_subnav_item(array('name' => __('Upload Images', 'bp-media-galleries'), 'slug' => 'upload-images', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_upload_images', 'position' => 30, 'user_has_access' => bp_is_home())); bp_core_new_subnav_item(array('name' => __('Upload Videos', 'bp-media-galleries'), 'slug' => 'upload-video', 'parent_slug' => $bp->media_galleries->slug, 'parent_url' => $media_galleries_link, 'screen_function' => 'bp_media_galleries_upload_video', 'position' => 40, 'user_has_access' => bp_is_home())); /* Add a nav item for this component under the settings nav item. See bp_example_screen_settings_menu() for more info */ bp_core_new_subnav_item(array('name' => __('Media Galleries', 'bp-media-galleries'), 'slug' => 'media-galleries-admin', 'parent_slug' => $bp->settings->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/', 'screen_function' => 'bp_media_galleries_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile())); }
function bp_wire_setup_nav() { global $bp; /* Add 'Wire' to the main navigation */ //bp_core_add_nav_item( __('Wire', 'buddypress'), $bp->wire->slug ); //bp_core_add_nav_default( $bp->wire->slug, 'bp_wire_screen_latest', 'all-posts' ); /* Add the subnav items to the wire nav */ //bp_core_add_subnav_item( $bp->wire->slug, 'all-posts', __('All Posts', 'buddypress'), $bp->loggedin_user->domain . $bp->wire->slug . '/', 'bp_wire_screen_latest' ); if ($bp->current_component == $bp->wire->slug) { if (bp_is_home()) { $bp->bp_options_title = __('My Wire', 'buddypress'); } else { $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1); $bp->bp_options_title = $bp->displayed_user->fullname; } } }
function friends_setup_nav() { global $bp; /* Add 'Friends' to the main navigation */ bp_core_add_nav_item(__('Friends', 'buddypress'), $bp->friends->slug); bp_core_add_nav_default($bp->friends->slug, 'friends_screen_my_friends', 'my-friends'); $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/'; /* Add the subnav items to the friends nav item */ bp_core_add_subnav_item($bp->friends->slug, 'my-friends', __('My Friends', 'buddypress'), $friends_link, 'friends_screen_my_friends', 'friends-my-friends'); bp_core_add_subnav_item($bp->friends->slug, 'requests', __('Requests', 'buddypress'), $friends_link, 'friends_screen_requests', false, bp_is_home()); if ($bp->current_component == $bp->friends->slug) { if (bp_is_home()) { $bp->bp_options_title = __('My Friends', 'buddypress'); } else { $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1); $bp->bp_options_title = $bp->displayed_user->fullname; } } }
} else { ?> <?php if (bp_group_show_no_groups_message()) { ?> <div id="message" class="info"> <p><?php bp_word_or_name(__("You haven't joined any groups yet.", 'buddypress'), __("%s hasn't joined any groups yet.", 'buddypress')); ?> </p> </div> <?php if (bp_is_home()) { ?> <h3><?php _e('Why not join a few of these groups?', 'buddypress'); ?> </h3> <?php bp_groups_random_selection(); ?> <?php } ?> <?php
function messages_setup_nav() { global $bp; if ($bp->current_component == $bp->messages->slug) { $inbox_count = messages_get_unread_count(); $inbox_display = $inbox_count ? ' style="display:inline;"' : ' style="display:none;"'; $count_indicator = ' <span' . $inbox_display . ' class="unread-count inbox-count">' . $inbox_count . '</span>'; } /* Add 'Profile' to the main navigation */ bp_core_add_nav_item(__('Messages', 'buddypress'), $bp->messages->slug, false, false); bp_core_add_nav_default($bp->messages->slug, 'messages_screen_inbox', 'inbox', bp_is_home()); $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/'; /* Add the subnav items to the profile */ bp_core_add_subnav_item($bp->messages->slug, 'inbox', __('Inbox', 'buddypress') . $count_indicator, $messages_link, 'messages_screen_inbox', false, bp_is_home()); bp_core_add_subnav_item($bp->messages->slug, 'sentbox', __('Sent Messages', 'buddypress'), $messages_link, 'messages_screen_sentbox', false, bp_is_home()); bp_core_add_subnav_item($bp->messages->slug, 'compose', __('Compose', 'buddypress'), $messages_link, 'messages_screen_compose', false, bp_is_home()); bp_core_add_subnav_item($bp->messages->slug, 'notices', __('Notices', 'buddypress'), $messages_link, 'messages_screen_notices', false, true, true); if ($bp->current_component == $bp->messages->slug) { if (bp_is_home()) { $bp->bp_options_title = __('My Messages', 'buddypress'); } else { $bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1); $bp->bp_options_title = $bp->displayed_user->fullname; } } }
<div class="item-list-tabs no-ajax" id="subnav"> <ul> <?php //bp_get_options_nav() ?> <?php bp_user_gallery_admin_tabs();?> </ul> <?php $gallery=bp_get_single_gallery();?> </div> <div class="gnav"><?php bp_gallery_bcomb();?> </div> <?php //do_action( 'bp_before_gallery_content' ) ?> <div id="galleries"> <?php if(bp_has_galleries()):?> <?php while(bp_galleries()):bp_the_gallery() ;?> <?php if(user_can_view_gallery(bp_get_gallery_id())):?> <?php if ( bp_is_home()): ?> <div class="gallery-actions"><a href="<?php bp_gallery_edit_link();?>"> <?php _e("Edit This gallery","bp-gallery");?></a>|<?php bp_gallery_add_media_button($gallery);//depending on whether upload/add from web showuld be here ?><br /></div> <?php endif;?> <?php locate_template( array( '/gallery/single/media/'.$gallery->gallery_type.'-loop.php','/gallery/single/media/media-loop.php' ), true );?> <br class="clear" /> <?php //include the form for commenting on the gallery ?> <div class="activity single-media"> <?php // include( locate_template( array( 'gallery/single/activity.php' ), false ) )/*un comment this line if you want all the activities of a gallery listed here*/ ?> </div> <?php else:?> <p><?php printf(__("This is a %s Gallery and You don't have adequate permissions to view them.","bp-gallery"),bp_get_gallery_status());?></p>
/** * xprofile_action_new_wire_post() * * Posts a new wire post to the users profile wire. * * @package BuddyPress XProfile * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() * @uses bp_wire_new_post() Adds a new wire post to a specific wire using the ID of the item passed and the table name. * @uses bp_core_add_message() Adds an error/success message to the session to be displayed on the next page load. * @uses bp_core_redirect() Safe redirects to a new page using the wp_redirect() function */ function xprofile_action_new_wire_post() { global $bp; if ($bp->current_component != $bp->wire->slug) { return false; } if ('post' != $bp->current_action) { return false; } /* Check the nonce */ if (!check_admin_referer('bp_wire_post')) { return false; } if (!($wire_post_id = bp_wire_new_post($bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->slug, false, $bp->profile->table_name_wire))) { bp_core_add_message(__('Wire message could not be posted. Please try again.', 'buddypress'), 'error'); } else { bp_core_add_message(__('Wire message successfully posted.', 'buddypress')); if (!bp_is_home()) { /* Record the notification for the user */ bp_core_add_notification($bp->loggedin_user->id, $bp->displayed_user->id, 'profile', 'new_wire_post'); } do_action('xprofile_new_wire_post', $wire_post_id); } if (!strpos($_SERVER['HTTP_REFERER'], $bp->wire->slug)) { bp_core_redirect($bp->displayed_user->domain); } else { bp_core_redirect($bp->displayed_user->domain . $bp->wire->slug); } }
/** * bp_zoneideas_screen_one() * * Sets up and displays the screen output for the sub nav item "zoneideas/screen-one" */ function bp_zoneideas_screen_one() { global $bp; /** * There are three global variables that you should know about and you will * find yourself using often. * * $bp->current_component (string) * This will tell you the current component the user is viewing. * * Example: If the user was on the page http://example.org/members/andy/groups/my-groups * $bp->current_component would equal 'groups'. * * $bp->current_action (string) * This will tell you the current action the user is carrying out within a component. * * Example: If the user was on the page: http://example.org/members/andy/groups/leave/34 * $bp->current_action would equal 'leave'. * * $bp->action_variables (array) * This will tell you which action variables are set for a specific action * * Example: If the user was on the page: http://example.org/members/andy/groups/join/34 * $bp->action_variables would equal array( '34' ); */ /** * On this screen, as a quick example, users can send you a "High Five", by clicking a link. * When a user sends you a high five, you receive a new notification in your * notifications menu, and you will also be notified via email. */ /** * We need to run a check to see if the current user has clicked on the 'send high five' link. * If they have, then let's send the five, and redirect back with a nice error/success message. */ if ($bp->current_component == $bp->zoneideas->slug && 'screen-one' == $bp->current_action && 'send-h5' == $bp->action_variables[0]) { /* The logged in user has clicked on the 'send high five' link */ if (bp_is_home()) { /* Don't let users high five themselves */ bp_core_add_message(__('No self-fives! :)', 'bp-zoneideas'), 'error'); } else { if (bp_zoneideas_send_highfive($bp->displayed_user->id, $bp->loggedin_user->id)) { bp_core_add_message(__('High-five sent!', 'bp-zoneideas')); } else { bp_core_add_message(__('High-five could not be sent.', 'bp-zoneideas'), 'error'); } } bp_core_redirect($bp->displayed_user->domain . $bp->zoneideas->slug . '/screen-one'); } /* Add a do action here, so your component can be extended by others. */ do_action('bp_zoneideas_screen_one'); /** * Finally, load the template file. In this example it would load: * "wp-content/member-themes/[active-member-theme]/example/screen-one.php" */ bp_core_load_template('zoneideas/screen-one'); /* ---- OR ----- */ /** * However, by loading a template the above way you will need to bundle template files with your component. * This is fine for a more complex component, but if your component is simple, you may want to * rely on the "plugin-template.php" file bundled with every member theme. */ /** * To get content into the template file without editing it, we use actions. * There are three actions in the template file, the first is for header text where you can * place nav items if needed. The second is the page title, and the third is the body content * of the page. */ add_action('bp_template_content_header', 'bp_zoneideas_screen_one_header'); add_action('bp_template_title', 'bp_zoneideas_screen_one_title'); add_action('bp_template_content', 'bp_zoneideas_screen_one_content'); /* Finally load the plugin template file. */ bp_core_load_template('plugin-template'); }
/** * bp_blogs_setup_nav() * * Adds "Blog" to the navigation arrays for the current and logged in user. * * @package BuddyPress Blogs * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user */ function bp_blogs_setup_nav() { global $bp; /* Add 'Blogs' to the main navigation */ bp_core_add_nav_item(__('Blogs', 'buddypress'), $bp->blogs->slug); if ($bp->displayed_user->id) { bp_core_add_nav_default($bp->blogs->slug, 'bp_blogs_screen_my_blogs', 'my-blogs'); } $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/'; /* Add the subnav items to the blogs nav item */ bp_core_add_subnav_item($bp->blogs->slug, 'my-blogs', __('My Blogs', 'buddypress'), $blogs_link, 'bp_blogs_screen_my_blogs', 'my-blogs-list'); bp_core_add_subnav_item($bp->blogs->slug, 'recent-posts', __('Recent Posts', 'buddypress'), $blogs_link, 'bp_blogs_screen_recent_posts'); bp_core_add_subnav_item($bp->blogs->slug, 'recent-comments', __('Recent Comments', 'buddypress'), $blogs_link, 'bp_blogs_screen_recent_comments'); bp_core_add_subnav_item($bp->blogs->slug, 'create-a-blog', __('Create a Blog', 'buddypress'), $blogs_link, 'bp_blogs_screen_create_a_blog'); /* Set up the component options navigation for Blog */ if ('blogs' == $bp->current_component) { if (bp_is_home()) { if (function_exists('xprofile_setup_nav')) { $bp->bp_options_title = __('My Blogs', 'buddypress'); } } else { /* If we are not viewing the logged in user, set up the current users avatar and name */ $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1); $bp->bp_options_title = $bp->displayed_user->fullname; } } }
function get_comments_for_user($user_id = null) { global $bp, $wpdb; if (!$bp->blogs) { bp_blogs_setup_globals(); } if (!$user_id) { $user_id = $bp->displayed_user->id; } // Show the logged in user their comments on hidden blogs, but not to anyone else. if (!bp_is_home()) { $comment_ids = $wpdb->get_results($wpdb->prepare("SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id)); $total_comment_count = $wpdb->get_var($wpdb->prepare("SELECT count(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id)); } else { $comment_ids = $wpdb->get_results($wpdb->prepare("SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id)); $total_comment_count = $wpdb->get_var($wpdb->prepare("SELECT count(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id)); } for ($i = 0; $i < count($comment_ids); $i++) { $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]); } return array('comments' => $comments, 'count' => $total_comment_count); }
<?php global $bp; $user_id=$bp->displayed_user->id?$bp->displayed_user->id:$bp->loggedin_user->id; if(bp_is_home()|| gf_is_my_topics()) $name=__("You","gf"); else $name=bp_core_get_user_displayname ($user_id); if ( gf_has_forum_topics( "type=my-topics&user_id=".$user_id ) ) : ?> <?php do_action( 'bp_before_directory_forums_list' ) ?> <div id="topics-list"> <h3><?php printf(__("Topics Started by %s","gf"),$name);?></h3> <ul> <?php while ( gf_forum_topics() ) : gf_the_forum_topic(); ?> <li class="<?php gf_the_topic_css_class() ?>"> <a class="topic-title" href="<?php gf_the_topic_permalink() ?>" title="<?php gf_the_topic_title() ?> - <?php _e( 'Permalink', 'gf' ) ?>"><?php gf_the_topic_title() ?></a> -<?php printf(__("%s replies","gf"),gf_get_the_topic_total_posts()) ?> -<?php printf(__("Last reply- %s ago","gf"), gf_get_the_topic_time_since_last_post()); ?> <div class="clear"></div> </li> <?php endwhile; ?> </ul> <div class="nav"> <div class="clear"></div> <div id="post-count" class="pag-count"> <?php gf_forum_pagination_count() ?> </div>
function bp_profile_wire_can_post() { global $bp; if (bp_is_home()) { return true; } if (function_exists('friends_install')) { if (friends_check_friendship($bp->loggedin_user->id, $bp->displayed_user->id)) { return true; } else { return false; } } return true; }
function groups_setup_nav() { global $bp, $current_blog; global $group_obj; if ($group_id = BP_Groups_Group::group_exists($bp->current_action)) { /* This is a single group page. */ $bp->is_single_item = true; $group_obj = new BP_Groups_Group($group_id); /* Using "item" not "group" for generic support in other components. */ if (is_site_admin()) { $bp->is_item_admin = 1; } else { $bp->is_item_admin = groups_is_user_admin($bp->loggedin_user->id, $group_obj->id); } /* If the user is not an admin, check if they are a moderator */ if (!$bp->is_item_admin) { $bp->is_item_mod = groups_is_user_mod($bp->loggedin_user->id, $group_obj->id); } /* Is the logged in user a member of the group? */ $is_member = groups_is_user_member($bp->loggedin_user->id, $group_obj->id) ? true : false; /* Should this group be visible to the logged in user? */ $is_visible = 'public' == $group_obj->status || $is_member ? true : false; } /* Add 'Groups' to the main navigation */ bp_core_add_nav_item(__('Groups', 'buddypress'), $bp->groups->slug); if ($bp->displayed_user->id) { bp_core_add_nav_default($bp->groups->slug, 'groups_screen_my_groups', 'my-groups'); } $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/'; /* Add the subnav items to the groups nav item */ bp_core_add_subnav_item($bp->groups->slug, 'my-groups', __('My Groups', 'buddypress'), $groups_link, 'groups_screen_my_groups', 'my-groups-list'); bp_core_add_subnav_item($bp->groups->slug, 'create', __('Create a Group', 'buddypress'), $groups_link, 'groups_screen_create_group', false, bp_is_home()); bp_core_add_subnav_item($bp->groups->slug, 'invites', __('Invites', 'buddypress'), $groups_link, 'groups_screen_group_invites', false, bp_is_home()); if ($bp->current_component == $bp->groups->slug) { if (bp_is_home() && !$bp->is_single_item) { $bp->bp_options_title = __('My Groups', 'buddypress'); } else { if (!bp_is_home() && !$bp->is_single_item) { $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1); $bp->bp_options_title = $bp->displayed_user->fullname; } else { if ($bp->is_single_item) { // We are viewing a single group, so set up the // group navigation menu using the $group_obj global. /* When in a single group, the first action is bumped down one because of the group name, so we need to adjust this and set the group name to current_item. */ $bp->current_item = $bp->current_action; $bp->current_action = $bp->action_variables[0]; array_shift($bp->action_variables); $bp->bp_options_title = $group_obj->name; $bp->bp_options_avatar = '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />'; $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $group_obj->slug . '/'; // If this is a private or hidden group, does the user have access? if ('private' == $group_obj->status || 'hidden' == $group_obj->status) { if (groups_is_user_member($bp->loggedin_user->id, $group_obj->id) && is_user_logged_in()) { $has_access = true; } else { $has_access = false; } } else { $has_access = true; } // Reset the existing subnav items bp_core_reset_subnav_items($bp->groups->slug); bp_core_add_nav_default($bp->groups->slug, 'groups_screen_group_home', 'home'); bp_core_add_subnav_item($bp->groups->slug, 'home', __('Home', 'buddypress'), $group_link, 'groups_screen_group_home', 'group-home'); // If the user is a group mod or more, then show the group admin nav item */ if ($bp->is_item_mod || $bp->is_item_admin) { bp_core_add_subnav_item($bp->groups->slug, 'admin', __('Admin', 'buddypress'), $group_link, 'groups_screen_group_admin', 'group-admin', $bp->is_item_admin + (int) $bp->is_item_mod); } // If this is a private group, and the user is not a member, show a "Request Membership" nav item. if (!$has_access && !groups_check_for_membership_request($bp->loggedin_user->id, $group_obj->id) && $group_obj->status == 'private') { bp_core_add_subnav_item($bp->groups->slug, 'request-membership', __('Request Membership', 'buddypress'), $group_link, 'groups_screen_group_request_membership', 'request-membership'); } if ($has_access && $group_obj->enable_forum && function_exists('bp_forums_setup')) { bp_core_add_subnav_item($bp->groups->slug, 'forum', __('Forum', 'buddypress'), $group_link, 'groups_screen_group_forum', 'group-forum', $is_visible); } if ($has_access && $group_obj->enable_wire && function_exists('bp_wire_install')) { bp_core_add_subnav_item($bp->groups->slug, 'wire', __('Wire', 'buddypress'), $group_link, 'groups_screen_group_wire', 'group-wire', $is_visible); } if ($has_access && $group_obj->enable_photos && function_exists('bp_gallery_install')) { bp_core_add_subnav_item($bp->groups->slug, 'photos', __('Photos', 'buddypress'), $group_link, 'groups_screen_group_photos', 'group-photos', $is_visible); } if ($has_access) { bp_core_add_subnav_item($bp->groups->slug, 'members', __('Members', 'buddypress'), $group_link, 'groups_screen_group_members', 'group-members', $is_visible); } if (is_user_logged_in() && groups_is_user_member($bp->loggedin_user->id, $group_obj->id)) { if (function_exists('friends_install')) { bp_core_add_subnav_item($bp->groups->slug, 'send-invites', __('Send Invites', 'buddypress'), $group_link, 'groups_screen_group_invite', 'group-invite', $is_member); } bp_core_add_subnav_item($bp->groups->slug, 'leave-group', __('Leave Group', 'buddypress'), $group_link, 'groups_screen_group_leave', 'group-leave', $is_member); } } } } } }
/** * bp_core_add_nav_default() * * Set a default action for a nav item, when a sub nav item has not yet been selected. * * @package BuddyPress Core * @param $parent_id The id of the parent navigation item. * @param $function The function to run when this sub nav item is selected. * @param $slug The slug of the sub nav item to highlight. * @uses is_site_admin() returns true if the current user is a site admin, false if not * @uses bp_is_home() Returns true if the current user being viewed is equal the logged in user * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() */ function bp_core_add_nav_default($parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false) { global $bp; if (!$user_has_access && !bp_is_home()) { return false; } if ($admin_only && !is_site_admin()) { return false; } if ($bp->current_component == $parent_id && !$bp->current_action) { if (function_exists($function)) { add_action('wp', $function, 3); } if ($slug) { $bp->current_action = $slug; } } }
function bp_activity_setup_nav() { global $bp; /* Add 'Activity' to the main navigation */ // bp_core_add_nav_item( __('Actividad', 'buddypress'), $bp->activity->slug ); // bp_core_add_nav_default( $bp->activity->slug, 'bp_activity_screen_my_activity', 'just-me' ); $activity_link = $bp->loggedin_user->domain . $bp->activity->slug . '/'; /* Add the subnav items to the activity nav item */ // bp_core_add_subnav_item( $bp->activity->slug, 'just-me', __('Propia', 'buddypress'), $activity_link, 'bp_activity_screen_my_activity' ); // bp_core_add_subnav_item( $bp->activity->slug, 'my-friends', __('De amigos', 'buddypress'), $activity_link, 'bp_activity_screen_friends_activity', 'activity-my-friends', bp_is_home() ); if ($bp->current_component == $bp->activity->slug) { if (bp_is_home()) { $bp->bp_options_title = __('Mi actividad', 'buddypress'); } else { $bp->bp_options_avatar = bp_core_get_avatar($bp->displayed_user->id, 1); $bp->bp_options_title = $bp->displayed_user->fullname; } } }
function get_activity_for_user($user_id, $max_items, $since, $limit, $page) { global $wpdb, $bp; $since = strtotime($since); if ($limit && $page) { $pag_sql = $wpdb->prepare("LIMIT %d, %d", intval(($page - 1) * $limit), intval($limit)); } if ($max) { $max_sql = $wpdb->prepare("LIMIT %d", $max); } if (!bp_is_home()) { $privacy_sql = " AND is_private = 0"; } if ($limit && $page && $max) { $activities = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND date_recorded >= FROM_UNIXTIME(%d) {$privacy_sql} ORDER BY date_recorded DESC {$pag_sql}", $user_id, $since)); } else { $activities = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND date_recorded >= FROM_UNIXTIME(%d) {$privacy_sql} ORDER BY date_recorded DESC {$pag_sql} {$max_sql}", $user_id, $since)); } $total_activities = $wpdb->get_var($wpdb->prepare("SELECT count(id) FROM {$bp->activity->table_name_user_activity_cached} WHERE user_id = %d AND date_recorded >= FROM_UNIXTIME(%d) {$privacy_sql} ORDER BY date_recorded DESC {$max_sql}", $user_id, $since)); for ($i = 0; $i < count($activities); $i++) { if (!$activities[$i]->is_private) { $activities_formatted[$i]['content'] = $activities[$i]->content; $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link; $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded; $activities_formatted[$i]['component_name'] = $activities[$i]->component_name; $activities_formatted[$i]['component_action'] = $activities[$i]->component_action; $activities_formatted[$i]['is_private'] = $activities[$i]->is_private; } } return array('activities' => $activities_formatted, 'total' => (int) $total_activities); }
function bp_blogs_blog_tabs() { global $bp, $groups_template; // Don't show these tabs on a user's own profile if (bp_is_home()) { return false; } $current_tab = $bp->current_action; ?> <ul class="content-header-nav"> <li<?php if ('my-blogs' == $current_tab || empty($current_tab)) { ?> class="current"<?php } ?> ><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug; ?> /my-blogs"><?php printf(__("%s's Blogs", 'buddypress'), $bp->displayed_user->fullname); ?> </a></li> <li<?php if ('recent-posts' == $current_tab) { ?> class="current"<?php } ?> ><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug; ?> /recent-posts"><?php printf(__("%s's Recent Posts", 'buddypress'), $bp->displayed_user->fullname); ?> </a></li> <li<?php if ('recent-comments' == $current_tab) { ?> class="current"<?php } ?> ><a href="<?php echo $bp->displayed_user->domain . $bp->blogs->slug; ?> /recent-comments"><?php printf(__("%s's Recent Comments", 'buddypress'), $bp->displayed_user->fullname); ?> </a></li> </ul> <?php do_action('bp_blogs_blog_tabs', $current_tab); }
function bp_send_message_button() { global $bp; if (bp_is_home() || !is_user_logged_in()) { return false; } $ud = get_userdata($bp->displayed_user->id); ?> <div class="generic-button"> <a class="send-message" title="<?php _e('Send Message', 'buddypress'); ?> " href="<?php echo $bp->loggedin_user->domain . $bp->messages->slug; ?> /compose/?r=<?php echo $ud->user_login; ?> "><?php _e('Send Message', 'buddypress'); ?> </a> </div> <?php }
<div id="message"> <p>You need to <a href="<?php echo site_url('wp-login.php'); ?> ">log in</a> <?php if (bp_get_signup_allowed()) { ?> or <?php printf(__(' <a class="create-account" href="%s" title="Create an account">create an account</a>', 'buddypress'), site_url(BP_REGISTER_SLUG . '/')); } ?> to post to this user's Wall.</p> </div> <?php } elseif (!bp_is_home() && (!is_super_admin() && !buddyboss_is_admin()) && (bp_is_user() && (BUDDY_BOSS_WALL_ENABLED && !$buddy_boss_wall->is_friend($bp->displayed_user->id)))) { ?> <div id="message" class="info"> <p><?php printf(__("You and %s are not friends. Request friendship to post to their Wall.", 'buddypress'), bp_get_displayed_user_fullname()); ?> </p> </div> <?php } else { ?> <?php if (is_user_logged_in()) {
function get_random_groups($user_id, $total_groups = 5) { global $wpdb, $bp; // If the user is logged in and viewing their random groups, we can show hidden and private groups if (bp_is_home()) { return $wpdb->get_col($wpdb->prepare("SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT {$total_groups}", $user_id)); } else { return $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.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() LIMIT {$total_groups}", $user_id)); } }
</div> <?php } else { ?> <div id="message" class="info"> <p><?php bp_word_or_name(__("Your friends list is currently empty", 'buddypress'), __("%s's friends list is currently empty", 'buddypress')); ?> </p> </div> <?php } ?> <?php if (bp_is_home() && !bp_friends_is_filtered()) { ?> <h3><?php _e('Why not make friends with some of these members?', 'buddypress'); ?> </h3> <?php bp_friends_random_members(); ?> <?php } ?> <?php } ?>
/** * REMOVE TABS FROM PROFILE HEADER * * @since BuddyBoss 1.5 */ function bbg_remove_activity_friends_subnav() { global $bp; // For now we hack the $bp global to remove a nav item without // removing the funcitonality. This is a bug in Buddypress if (isset($bp->bp_options_nav) && isset($bp->bp_options_nav['activity'])) { if (isset($bp->bp_options_nav['activity']['friends'])) { unset($bp->bp_options_nav['activity']['friends']); } if (isset($bp->bp_options_nav['activity']['mentions'])) { unset($bp->bp_options_nav['activity']['mentions']); } if (isset($bp->bp_options_nav['activity']['groups'])) { unset($bp->bp_options_nav['activity']['groups']); } if (!bp_is_home() && isset($bp->bp_options_nav['activity']['favorites'])) { unset($bp->bp_options_nav['activity']['favorites']); } } /** * This code won't work until a bugfix in Buddypress is applied. * bp_core_remove_subnav_item( 'activity', 'friends' ); bp_core_remove_subnav_item( 'activity', 'mentions' ); bp_core_remove_subnav_item( 'activity', 'groups' ); if ( !bp_is_home() ) bp_core_remove_subnav_item( 'activity', 'favorites' ); */ }
/** * bp_chat_setup_nav() * * Sets up the navigation items for the component. This adds the top level nav * item and all the sub level nav items to the navigation array. This is then * rendered in the template. */ function bp_chat_setup_nav() { global $bp, $current_blog, $group_object; #$chat_link = $bp->loggedin_user->domain . $bp->chat->slug . '/'; $chat_link = get_bloginfo('wpurl') . $bp->chat->slug . '/'; if (function_exists('anygig_orig_check_supporter')) { if (false == anygig_orig_check_supporter('Chat', 'bp-chat', $bp->chat->slug, 80, $bp->chat->id, $chat_link)) { return; } } if (function_exists('bp_core_new_nav_item')) { bp_core_new_nav_item(array('name' => __('Chat', 'bp-chat'), 'slug' => $bp->chat->slug, 'screen_function' => 'bp_chat_screen_one', 'default_subnav_slug' => 'chat', 'user_has_access' => bp_is_home())); } else { /* Add 'Chat' to the main navigation */ bp_core_add_nav_item(__('Chat', 'bp-chat'), $bp->chat->slug); /* Set a specific sub nav item as the default when the top level item is clicked */ bp_core_add_nav_default($bp->chat->slug, 'bp_chat_screen_one', 'chat-one'); } if (class_exists('BP_Groups_Group')) { if ($group_id = BP_Groups_Group::group_exists($bp->current_action)) { /* This is a single group page. */ $bp->is_single_item = true; $bp->groups->current_group =& new BP_Groups_Group($group_id); } $groups_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/'; /* Add the subnav item only to the single group nav item*/ if ($bp->is_single_item) { bp_core_new_subnav_item(array('name' => __('Chat', 'bp-chat'), 'slug' => $bp->chat->slug, 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'bp_chat_screen_one', 'position' => 35, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'bp-chat')); } do_action('bp_group_documents_nav_setup'); } #print "<pre>"; #print_r ($bp->groups); #print "</pre>"; /* Only execute the following code if we are actually viewing this component (e.g. http://chat.org/chat) */ if ($bp->current_component == $bp->chat->slug) { if (bp_is_home()) { /* If the user is viewing their own profile area set the title to "My Chat" */ $bp->bp_options_title = __('My Chat', 'bp-chat'); } else { /* If the user is viewing someone elses profile area, set the title to "[user fullname]" */ //$bp->bp_options_avatar = bp_core_get_avatar( $bp->displayed_user->id, 1 ); $bp->bp_options_title = $bp->displayed_user->fullname; } } }